54 pNode1(pN1), pNode2(pN2), f1(f1), f2(f2),
97 <<
" " << d << std::endl;
107 for (
unsigned i = 0; i < ph->size(); i++) {
123 }
else if (dynamic_cast<Joint::ReactionsHint *>(pjh)) {
132 pedantic_cout(
"DriveDisplacementJoint(" <<
uLabel <<
"): "
133 "creating drive from hint[" << i <<
"]..." << std::endl);
137 silent_cerr(
"DriveDisplacementJoint(" <<
uLabel <<
"): "
138 "unable to create drive "
139 "after hint #" << i << std::endl);
153 if (strncasecmp(s,
"offset{" ,
STRLENOF(
"offset{" )) == 0)
157 if (strcmp(&s[1],
"}") != 0) {
176 const char *prefix,
bool bInitial)
const
181 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
182 "reaction forces [fx,fy,fz]" << std::endl;
187 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
188 "reaction force derivatives [fPx,fPy,fPz]" << std::endl;
194 static const char xyz[] =
"xyz";
195 static const char *
dof[] = {
"reaction force f",
"reaction force derivative fP" };
196 static const char *
eq[] = {
"displacement constraint P",
"displacement constraint derivative v" };
200 bool bInitial,
int i)
const
213 std::ostringstream os;
214 os <<
"DriveDisplacementJoint(" <<
GetLabel() <<
")";
217 std::string name = os.str();
218 for (i = 0; i < iend; i++) {
220 os.seekp(0, std::ios_base::end);
221 os <<
": " <<
dof[i/3] <<
xyz[i%3];
227 os <<
": " <<
dof[i/3] <<
xyz[i%3];
234 const char *prefix,
bool bInitial)
const
239 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
240 "position constraints [px1=px2,py1=py2,pz1=pz2]" << std::endl;
245 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
246 "velocity constraints [vx1=vx2,vy1=vy2,vz1=vz2]" << std::endl;
255 bool bInitial,
int i)
const
268 std::ostringstream os;
269 os <<
"DriveDisplacementJoint(" <<
GetLabel() <<
")";
272 std::string name = os.str();
273 for (i = 0; i < iend; i++) {
275 os.seekp(0, std::ios_base::end);
276 os <<
": " <<
eq[i/3] <<
xyz[i%3];
282 os <<
": " <<
eq[i/3] <<
xyz[i%3];
304 unsigned int idx = 0;
356 DEBUGCOUT(
"Entering DriveDisplacementJoint::AssJac()" << std::endl);
374 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
377 WM.
PutRowIndex(6 + iCnt, iNode2FirstMomIndex + iCnt);
378 WM.
PutColIndex(6 + iCnt, iNode2FirstPosIndex + iCnt);
380 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
381 WM.
PutRowIndex(12 + iCnt, iFirstReactionIndex + iCnt);
382 WM.
PutColIndex(12 + iCnt, iFirstReactionIndex + iCnt);
404 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
406 WM.
DecCoef(iCnt, 12 + iCnt, 1.);
408 WM.
IncCoef(6 + iCnt, 12 + iCnt, 1.);
411 WM.
DecCoef(12 + iCnt, iCnt, 1.);
413 WM.
IncCoef(12 + iCnt, 6 + iCnt, 1.);
419 WM.
Sub(3 + 1, 12 + 1, MTmp);
421 WM.
Add(12 + 1, 3 + 1, MTmp);
425 WM.
Add(9 + 1, 12 + 1, MTmp);
427 WM.
Sub(12 + 1, 9 + 1, MTmp);
431 WM.
Sub(3 + 1, 3 + 1, MTmp);
435 WM.
Add(9 + 1, 9 + 1, MTmp);
446 DEBUGCOUT(
"Entering DriveDisplacementJoint::AssRes()" << std::endl);
460 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
461 WorkVec.
PutRowIndex(iCnt, iNode1FirstMomIndex + iCnt);
462 WorkVec.
PutRowIndex(6 + iCnt, iNode2FirstMomIndex + iCnt);
465 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
466 WorkVec.
PutRowIndex(12 + iCnt, iFirstReactionIndex + iCnt);
469 F =
Vec3(XCurr, iFirstReactionIndex + 1);
487 WorkVec.
Sub(6 + 1,
F);
488 WorkVec.
Sub(9 + 1, f2Tmp.Cross(
F));
500 DEBUGCOUT(
"Entering DriveDisplacementJoint::InitialAssJac()" << std::endl);
514 integer iNode1FirstVelIndex = iNode1FirstPosIndex + 6;
515 integer iNode2FirstVelIndex = iNode2FirstPosIndex + 6;
516 integer iFirstReactionPrimeIndex = iFirstReactionIndex + 3;
519 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
522 WM.
PutRowIndex(6 + iCnt, iNode1FirstVelIndex + iCnt);
523 WM.
PutColIndex(6 + iCnt, iNode1FirstVelIndex + iCnt);
524 WM.
PutRowIndex(12 + iCnt, iNode2FirstPosIndex + iCnt);
525 WM.
PutColIndex(12 + iCnt, iNode2FirstPosIndex + iCnt);
526 WM.
PutRowIndex(18 + iCnt, iNode2FirstVelIndex + iCnt);
527 WM.
PutColIndex(18 + iCnt, iNode2FirstVelIndex + iCnt);
528 WM.
PutRowIndex(24 + iCnt, iFirstReactionIndex + iCnt);
529 WM.
PutColIndex(24 + iCnt, iFirstReactionIndex + iCnt);
532 Vec3 FPrime =
Vec3(XCurr, iFirstReactionPrimeIndex + 1);
534 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
536 WM.
DecCoef(iCnt, 24 + iCnt, 1.);
538 WM.
IncCoef(12 + iCnt, 24 + iCnt, 1.);
541 WM.
DecCoef(6 + iCnt, 27 + iCnt, 1.);
543 WM.
IncCoef(18 + iCnt, 27 + iCnt, 1.);
546 WM.
DecCoef(24 + iCnt, iCnt, 1.);
548 WM.
IncCoef(24 + iCnt, 12 + iCnt, 1.);
551 WM.
DecCoef(27 + iCnt, 6 + iCnt, 1.);
553 WM.
IncCoef(27 + iCnt, 18 + iCnt, 1.);
559 WM.
Sub(3 + 1, 24 + 1, MTmp);
561 WM.
Sub(9 + 1, 27 + 1, MTmp);
563 WM.
Add(24 + 1, 3 + 1, MTmp);
565 WM.
Add(27 + 1, 9 + 1, MTmp);
574 WM.
Add(15 + 1, 24 + 1, MTmp);
576 WM.
Add(21 + 1, 27 + 1, MTmp);
578 WM.
Sub(24 + 1, 15 + 1, MTmp);
580 WM.
Sub(27 + 1, 21 + 1, MTmp);
584 WM.
Sub(3 + 1, 3 + 1, MTmp);
588 WM.
Sub(9 + 1, 9 + 1, MTmp);
592 WM.
Add(15 + 1, 15 + 1, MTmp);
596 WM.
Add(21 + 1, 21 + 1, MTmp);
600 WM.
Sub(27 + 1, 3 + 1, MTmp);
604 WM.
Add(27 + 1, 15 + 1, MTmp);
615 DEBUGCOUT(
"Entering DriveDisplacementJoint::InitialAssRes()" << std::endl);
627 integer iNode1FirstVelIndex = iNode1FirstPosIndex + 6;
628 integer iNode2FirstVelIndex = iNode2FirstPosIndex + 6;
629 integer iReactionPrimeIndex = iFirstReactionIndex + 3;
632 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
633 WorkVec.
PutRowIndex(iCnt, iNode1FirstPosIndex + iCnt);
634 WorkVec.
PutRowIndex(6 + iCnt, iNode1FirstVelIndex + iCnt);
635 WorkVec.
PutRowIndex(12 + iCnt, iNode2FirstPosIndex + iCnt);
636 WorkVec.
PutRowIndex(18 + iCnt, iNode2FirstVelIndex + iCnt);
637 WorkVec.
PutRowIndex(24 + iCnt, iFirstReactionIndex + iCnt);
640 F =
Vec3(XCurr, iFirstReactionIndex + 1);
641 Vec3 FPrime =
Vec3(XCurr, iReactionPrimeIndex + 1);
648 WorkVec.
Add(6 + 1, FPrime);
651 WorkVec.
Sub(12 + 1,
F);
653 WorkVec.
Sub(18 + 1, FPrime);
664 WorkVec.
Add(27 + 1, PhiPrime);
682 Joint(uL, pDO, fOut),
684 pNode(pN), f(f), x(x),
707 f.
Write(out,
", ") <<
", ",
708 x.
Write(out,
", ") <<
", ",
721 <<
" " << d << std::endl;
731 for (
unsigned i = 0; i < ph->size(); i++) {
745 }
else if (dynamic_cast<Joint::ReactionsHint *>(pjh)) {
754 pedantic_cout(
"DriveDisplacementPinJoint(" <<
uLabel <<
"): "
755 "creating drive from hint[" << i <<
"]..." << std::endl);
759 silent_cerr(
"DriveDisplacementPinJoint(" <<
uLabel <<
"): "
760 "unable to create drive "
761 "after hint #" << i << std::endl);
775 if (strncasecmp(s,
"offset{" ,
STRLENOF(
"offset{" )) == 0)
779 if (strcmp(&s[1],
"}") != 0) {
798 const char *prefix,
bool bInitial)
const
803 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
804 "reaction forces [fx,fy,fz]" << std::endl;
809 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
810 "reaction force derivatives [fPx,fPy,fPz]" << std::endl;
818 bool bInitial,
int i)
const
831 std::ostringstream os;
832 os <<
"DriveDisplacementPinJoint(" <<
GetLabel() <<
")";
835 std::string name = os.str();
836 for (i = 0; i < iend; i++) {
838 os.seekp(0, std::ios_base::end);
839 os <<
": " <<
dof[i/3] <<
xyz[i%3];
845 os <<
": " <<
dof[i/3] <<
xyz[i%3];
852 const char *prefix,
bool bInitial)
const
857 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
858 "position constraints [px1=px2,py1=py2,pz1=pz2]" << std::endl;
863 << prefix << iIndex + 1 <<
"->" << iIndex + 3 <<
": "
864 "velocity constraints [vx1=vx2,vy1=vy2,vz1=vz2]" << std::endl;
873 bool bInitial,
int i)
const
886 std::ostringstream os;
887 os <<
"DriveDisplacementPinJoint(" <<
GetLabel() <<
")";
890 std::string name = os.str();
891 for (i = 0; i < iend; i++) {
893 os.seekp(0, std::ios_base::end);
894 os <<
": " <<
eq[i/3] <<
xyz[i%3];
900 os <<
": " <<
eq[i/3] <<
xyz[i%3];
922 unsigned int idx = 0;
974 DEBUGCOUT(
"Entering DriveDisplacementPinJoint::AssJac()" << std::endl);
990 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
994 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
995 WM.
PutRowIndex(6 + iCnt, iFirstReactionIndex + iCnt);
996 WM.
PutColIndex(6 + iCnt, iFirstReactionIndex + iCnt);
1018 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
1020 WM.
IncCoef(iCnt, 6 + iCnt, 1.);
1023 WM.
IncCoef(6 + iCnt, iCnt, 1.);
1029 WM.
Add(3 + 1, 6 + 1, MTmp);
1032 WM.
Sub(6 + 1, 3 + 1, MTmp);
1037 WM.
Add(3 + 1, 3 + 1, MTmp);
1048 DEBUGCOUT(
"Entering DriveDisplacementPinJoint::AssRes()" << std::endl);
1061 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
1062 WorkVec.
PutRowIndex(iCnt, iNodeFirstMomIndex + iCnt);
1065 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
1066 WorkVec.
PutRowIndex(6 + iCnt, iFirstReactionIndex + iCnt);
1069 F =
Vec3(XCurr, iFirstReactionIndex + 1);
1096 DEBUGCOUT(
"Entering DriveDisplacementPinJoint::InitialAssJac()" << std::endl);
1109 integer iNodeFirstVelIndex = iNodeFirstPosIndex + 6;
1110 integer iReactionPrimeIndex = iFirstReactionIndex + 3;
1113 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
1116 WM.
PutRowIndex(6 + iCnt, iNodeFirstVelIndex + iCnt);
1117 WM.
PutColIndex(6 + iCnt, iNodeFirstVelIndex + iCnt);
1118 WM.
PutRowIndex(12 + iCnt, iFirstReactionIndex + iCnt);
1119 WM.
PutColIndex(12 + iCnt, iFirstReactionIndex + iCnt);
1122 Vec3 FPrime =
Vec3(XCurr, iReactionPrimeIndex + 1);
1124 for (
int iCnt = 1; iCnt <= 3; iCnt++) {
1126 WM.
IncCoef(iCnt, 12 + iCnt, 1.);
1129 WM.
IncCoef(6 + iCnt, 15 + iCnt, 1.);
1132 WM.
IncCoef(12 + iCnt, iCnt, 1.);
1135 WM.
IncCoef(15 + iCnt, 6 + iCnt, 1.);
1140 WM.
Add(3 + 1, 12 + 1, MTmp);
1142 WM.
Add(9 + 1, 15 + 1, MTmp);
1144 WM.
Sub(12 + 1, 3 + 1, MTmp);
1146 WM.
Sub(15 + 1, 9 + 1, MTmp);
1150 WM.
Add(3 + 1, 3 + 1, MTmp);
1154 WM.
Add(9 + 1, 9 + 1, MTmp);
1158 WM.
Add(15 + 1, 3 + 1, MTmp);
1169 DEBUGCOUT(
"Entering DriveDisplacementPinJoint::InitialAssRes()" << std::endl);
1180 integer iNodeFirstVelIndex = iNodeFirstPosIndex + 6;
1181 integer iFirstReactionPrimeIndex = iFirstReactionIndex + 3;
1184 for (
int iCnt = 1; iCnt <= 6; iCnt++) {
1185 WorkVec.
PutRowIndex(iCnt, iNodeFirstPosIndex + iCnt);
1186 WorkVec.
PutRowIndex(6 + iCnt, iNodeFirstVelIndex + iCnt);
1187 WorkVec.
PutRowIndex(12 + iCnt, iFirstReactionIndex + iCnt);
1190 F =
Vec3(XCurr, iFirstReactionIndex + 1);
1191 Vec3 FPrime =
Vec3(XCurr, iFirstReactionPrimeIndex + 1);
1198 WorkVec.
Sub(6 + 1, FPrime);
1208 WorkVec.
Sub(15 + 1, PhiPrime);
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
void PutColIndex(integer iSubCol, integer iCol)
virtual ~DriveDisplacementJoint(void)
void AssVec(SubVectorHandler &WorkVec, doublereal dCoef)
const Vec3 Zero3(0., 0., 0.)
Vec3 Cross(const Vec3 &v) const
std::ostream & Write(std::ostream &out, const char *sFill=" ") const
virtual const Mat3x3 & GetRRef(void) const
DriveDisplacementJoint(unsigned int uL, const DofOwner *pDO, const TplDriveCaller< Vec3 > *pDC, const StructNode *pN1, const StructNode *pN2, const Vec3 &f1, const Vec3 &f2, flag fOut)
virtual bool bToBeOutput(void) const
virtual bool bIsDifferentiable(void) const
#define MBDYN_EXCEPT_ARGS
virtual void ResizeReset(integer)
const MatCross_Manip MatCross
FullSubMatrixHandler & SetFull(void)
virtual const Mat3x3 & GetRCurr(void) const
virtual Node::Type GetNodeType(void) const
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
unsigned int iGetPrivDataIdx(const char *s) const
void Add(integer iRow, integer iCol, const Vec3 &v)
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const
void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
virtual Hint * ParseHint(DataManager *pDM, const char *s) const
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
virtual void Sub(integer iRow, const Vec3 &v)
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
virtual void AfterPredict(VectorHandler &X, VectorHandler &XP)
void AssMat(FullSubMatrixHandler &WM, doublereal dCoef)
virtual const Vec3 & GetWRef(void) const
virtual Hint * ParseHint(DataManager *pDM, const char *s) const
std::vector< Hint * > Hints
virtual doublereal dGetPrivData(unsigned int i=0) const
void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
DriveDisplacementPinJoint(unsigned int uL, const DofOwner *pDO, const TplDriveCaller< Vec3 > *pDC, const StructNode *pN, const Vec3 &f, const Vec3 &x, flag fOut)
void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
void Set(const TplDriveCaller< T > *pDC)
virtual std::ostream & Restart(std::ostream &out) const
virtual unsigned int iGetNumPrivData(void) const
virtual std::ostream & Restart(std::ostream &out) const
virtual Hint * ParseHint(DataManager *pDM, const char *s) const
void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
virtual VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
virtual Vec3 GetP(void) const
virtual SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
virtual void Output(OutputHandler &OH) const
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
virtual unsigned int iGetNumPrivData(void) const
TplDriveCaller< Vec3 > * pGetDriveCaller(void) const
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
static const char * dof[]
const doublereal & dGet(unsigned short int iRow) const
virtual std::ostream & DescribeEq(std::ostream &out, const char *prefix="", bool bInitial=false) const
virtual std::ostream & DescribeDof(std::ostream &out, const char *prefix="", bool bInitial=false) const
virtual std::ostream & DescribeDof(std::ostream &out, const char *prefix="", bool bInitial=false) const
const StructNode * pNode1
virtual std::ostream & DescribeEq(std::ostream &out, const char *prefix="", bool bInitial=false) const
virtual integer iGetFirstMomentumIndex(void) const =0
virtual integer iGetFirstPositionIndex(void) const
virtual const Vec3 & GetWCurr(void) const
virtual std::ostream & Restart(std::ostream &out) const
std::ostream & Joints(void) const
virtual std::ostream & Restart(std::ostream &out) const =0
TplDriveCaller< T > * pCreateDrive(DataManager *pDM) const
#define ASSERT(expression)
virtual const Vec3 & GetXCurr(void) const
virtual void Add(integer iRow, const Vec3 &v)
virtual ~DriveDisplacementPinJoint(void)
virtual void ResizeReset(integer, integer)
virtual void Output(OutputHandler &OH) const
virtual void AfterPredict(VectorHandler &X, VectorHandler &XP)
const StructNode * pNode2
Mat3x3 Transpose(void) const
const MatCrossCross_Manip MatCrossCross
void PutRowIndex(integer iSubRow, integer iRow)
virtual VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
unsigned int iGetPrivDataIdx(const char *s) const
virtual const Vec3 & GetVCurr(void) const
void Sub(integer iRow, integer iCol, const Vec3 &v)
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
virtual SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
virtual integer iGetFirstIndex(void) const
void AssMat(FullSubMatrixHandler &WM, doublereal dCoef)
std::ostream & Output(std::ostream &out, const char *sJointName, unsigned int uLabel, const Vec3 &FLocal, const Vec3 &MLocal, const Vec3 &FGlobal, const Vec3 &MGlobal) const
unsigned int GetLabel(void) const
virtual doublereal dGetPrivData(unsigned int i=0) const
void AssVec(SubVectorHandler &WorkVec, doublereal dCoef)