38 #ifdef MBDYN_X_DISTANCE_JOINT 
   53 pNode1(pN1), pNode2(pN2), Vec(
Zero3), dAlpha(0.)
 
   65 DistanceJoint::Abort(
void)
 
   67         silent_cerr(
"DistanceJoint(" << 
GetLabel() << 
"): distance is null" 
   78                 for (
unsigned i = 0; i < ph->size(); i++) {
 
   82                                 pedantic_cout(
"DistanceJoint(" << 
uLabel << 
"): " 
   83                                         "creating drive from hint[" << i << 
"]..." << std::endl);
 
   87                                         silent_cerr(
"DistanceJoint(" << 
uLabel << 
"): " 
   88                                                 "unable to create drive after hint " 
   89                                                 "#" << i << std::endl);
 
  103         if (
fabs(dDistance) <= std::numeric_limits<doublereal>::epsilon()) {
 
  111         if (d <= std::numeric_limits<doublereal>::epsilon()) {
 
  112                 silent_cerr(
"DistanceJoint(" << 
uLabel << 
") " 
  115                         "nodes are coincident;" << std::endl
 
  116                         << 
"initial joint assembly is recommended" 
  134         if (strcmp(s, 
"d") == 0) {
 
  176         DEBUGCOUT(
"Entering DistanceJoint::AssMat()" << std::endl);
 
  180         for (
int iCnt = 1; iCnt <= 3; iCnt++) {
 
  186                 WorkMatB.
DecCoef(6 + 1, 0 + iCnt, d/dv);
 
  189                 WorkMatB.
IncCoef(6 + 1, 3 + iCnt, d/dv);
 
  194                 WorkMatB.
DecCoef(0 + iCnt, 6 + 1, d);
 
  197                 WorkMatB.
IncCoef(3 + iCnt, 6 + 1, d);
 
  200                 WorkMatA.
IncCoef(0 + iCnt, 0 + iCnt, d*dd);
 
  203                 WorkMatA.
DecCoef(0 + iCnt, 3 + iCnt, d*dd);
 
  206                 WorkMatA.
DecCoef(3 + iCnt, 0 + iCnt, d*dd);
 
  209                 WorkMatA.
IncCoef(3 + iCnt, 3 + iCnt, d*dd);
 
  221         DEBUGCOUT(
"Entering DistanceJoint::AssJac()" << std::endl);
 
  232         for (
int iCnt = 1; iCnt <= 3; iCnt++) {
 
  233                 WM.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  234                 WM.
PutColIndex(0 + iCnt, iNode1FirstPosIndex + iCnt);
 
  235                 WM.
PutRowIndex(3 + iCnt, iNode2FirstMomIndex + iCnt);
 
  236                 WM.
PutColIndex(3 + iCnt, iNode2FirstPosIndex + iCnt);
 
  241         AssMat(WM, WM, dCoef, XCurr, XPrimeCurr);
 
  254         DEBUGCOUT(
"Entering DistanceJoint::AssMats()" << std::endl);
 
  268         for (
int iCnt = 1; iCnt <= 3; iCnt++) {
 
  269                 WMA.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  270                 WMA.
PutColIndex(0 + iCnt, iNode1FirstPosIndex + iCnt);
 
  271                 WMA.
PutRowIndex(3 + iCnt, iNode2FirstMomIndex + iCnt);
 
  272                 WMA.
PutColIndex(3 + iCnt, iNode2FirstPosIndex + iCnt);
 
  274                 WMB.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  275                 WMB.
PutColIndex(0 + iCnt, iNode1FirstPosIndex + iCnt);
 
  276                 WMB.
PutRowIndex(3 + iCnt, iNode2FirstMomIndex + iCnt);
 
  277                 WMB.
PutColIndex(3 + iCnt, iNode2FirstPosIndex + iCnt);
 
  285         AssMat(WMA, WMB, 1., XCurr, XPrimeCurr);
 
  296         DEBUGCOUT(
"Entering DistanceJoint::AssRes()" << std::endl);
 
  308         for (
int iCnt = 1; iCnt <= 3; iCnt++) {
 
  310                 WorkVec.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  313                 WorkVec.
PutRowIndex(3 + iCnt, iNode2FirstMomIndex + iCnt);
 
  317         WorkVec.
PutRowIndex(6 + 1, iFirstReactionIndex + 1);
 
  322         dAlpha = XCurr(iFirstReactionIndex + 1);
 
  327         if (
fabs(dDistance) <= std::numeric_limits<doublereal>::epsilon()) {
 
  331         WorkVec.
IncCoef(6 + 1, (dDistance - Vec.Norm())/dCoef);
 
  334         WorkVec.
Add(0 + 1, Tmp);
 
  335         WorkVec.
Sub(3 + 1, Tmp);
 
  346                         << 
" " << Vec/dDistance << 
" " << dDistance
 
  358         DEBUGCOUT(
"Entering DistanceJoint::InitialAssJac()" << std::endl);
 
  371         DEBUGCOUT(
"Entering DistanceJoint::InitialAssRes()" << std::endl);
 
  413                 << 
", reference, node, ",
 
  416                 << 
", reference, node, ",
 
  427                 for (
unsigned i = 0; i < ph->size(); i++) {
 
  428                         pedantic_cout(
"DistanceJointWithOffset(" << 
uLabel << 
"): " 
  429                                 "creating drive from hint..." << std::endl);
 
  436                                         silent_cerr(
"DistanceJointWithOffset(" << 
uLabel << 
"): " 
  437                                                 "unable to create drive after hint " 
  438                                                 "#" << i << std::endl);
 
  452         if (
fabs(dDistance) <= std::numeric_limits<doublereal>::epsilon()) {
 
  459         if (d <= std::numeric_limits<doublereal>::epsilon()) {
 
  460                 silent_cerr(
"DistanceJoint(" << 
GetLabel() << 
") " 
  463                         "nodes are coincident;" << std::endl
 
  464                         << 
"this is no longer supported" << std::endl);
 
  477         DEBUGCOUT(
"Entering DistanceJointWithOffset::AssMat()" << std::endl);
 
  479         Vec3 f1Tmp(dynamic_cast<const StructNode *>(
pNode1)->GetRRef()*
f1);
 
  480         Vec3 f2Tmp(dynamic_cast<const StructNode *>(
pNode2)->GetRRef()*
f2);
 
  482         Vec3 f1u(f1Tmp.Cross(Vec));
 
  483         Vec3 f2u(f2Tmp.Cross(Vec));
 
  487         for (
int iCnt = 1; iCnt <= 3; iCnt++) {
 
  493                 WorkMatB.
DecCoef(12 + 1, 0 + iCnt, d/dv);
 
  496                 WorkMatB.
IncCoef(12 + 1, 6 + iCnt, d/dv);
 
  501                 WorkMatB.
DecCoef(0 + iCnt, 12 + 1, d);
 
  504                 WorkMatB.
IncCoef(6 + iCnt, 12 + 1, d);
 
  507                 WorkMatA.
IncCoef(0 + iCnt, 0 + iCnt, dd);
 
  510                 WorkMatA.
DecCoef(0 + iCnt, 6 + iCnt, dd);
 
  513                 WorkMatA.
DecCoef(6 + iCnt, 0 + iCnt, dd);
 
  516                 WorkMatA.
IncCoef(6 + iCnt, 6 + iCnt, dd);
 
  521                 WorkMatB.
DecCoef(12 + 1, 3 + iCnt, d/dv);
 
  524                 WorkMatB.
DecCoef(3 + iCnt, 12 + 1, d);
 
  529                 WorkMatB.
IncCoef(12 + 1, 9 + iCnt, d/dv);
 
  532                 WorkMatB.
IncCoef(9 + iCnt, 12 + 1, d);
 
  540         WorkMatA.
Sub(0 + 1, 3 + 1, Tmp);
 
  543         WorkMatA.
Add(6 + 1, 3 + 1, Tmp);
 
  546         WorkMatA.
Add(3 + 1, 0 + 1, Tmp);
 
  549         WorkMatA.
Sub(3 + 1, 6 + 1, Tmp);
 
  554         WorkMatA.
Add(0 + 1, 9 + 1, Tmp);
 
  557         WorkMatA.
Sub(6 + 1, 9 + 1, Tmp);
 
  560         WorkMatA.
Sub(9 + 1, 0 + 1, Tmp);
 
  563         WorkMatA.
Add(9 + 1, 6 + 1, Tmp);
 
  568         WorkMatA.
Add(3 + 1, 9 + 1, Tmp);
 
  573         WorkMatA.
Add(9 + 1, 3 + 1, Tmp);
 
  578         WorkMatA.
Sub(3 + 1, 3 + 1, Tmp);
 
  583         WorkMatA.
Add(9 + 1, 9 + 1, Tmp);
 
  593         DEBUGCOUT(
"Entering DistanceJointWithOffset::AssJac()" << std::endl);
 
  604         for (
int iCnt = 1; iCnt <= 6; iCnt++) {
 
  605                 WM.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  606                 WM.
PutColIndex(0 + iCnt, iNode1FirstPosIndex + iCnt);
 
  607                 WM.
PutRowIndex(6 + iCnt, iNode2FirstMomIndex + iCnt);
 
  608                 WM.
PutColIndex(6 + iCnt, iNode2FirstPosIndex + iCnt);
 
  613         AssMat(WM, WM, dCoef, XCurr, XPrimeCurr);
 
  625         DEBUGCOUT(
"Entering DistanceJointWithOffset::AssMats()" << std::endl);
 
  639         for (
int iCnt = 1; iCnt <= 6; iCnt++) {
 
  640                 WMA.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  641                 WMA.
PutColIndex(0 + iCnt, iNode1FirstPosIndex + iCnt);
 
  642                 WMA.
PutRowIndex(6 + iCnt, iNode2FirstMomIndex + iCnt);
 
  643                 WMA.
PutColIndex(6 + iCnt, iNode2FirstPosIndex + iCnt);
 
  645                 WMB.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  646                 WMB.
PutColIndex(0 + iCnt, iNode1FirstPosIndex + iCnt);
 
  647                 WMB.
PutRowIndex(6 + iCnt, iNode2FirstMomIndex + iCnt);
 
  648                 WMB.
PutColIndex(6 + iCnt, iNode2FirstPosIndex + iCnt);
 
  656         AssMat(WMA, WMB, 1., XCurr, XPrimeCurr);
 
  666         DEBUGCOUT(
"Entering DistanceJointWithOffset::AssRes()" << std::endl);
 
  678         for (
int iCnt = 1; iCnt <= 6; iCnt++) {
 
  680                 WorkVec.
PutRowIndex(0 + iCnt, iNode1FirstMomIndex + iCnt);
 
  683                 WorkVec.
PutRowIndex(6 + iCnt, iNode2FirstMomIndex + iCnt);
 
  687         WorkVec.
PutRowIndex(12 + 1, iFirstReactionIndex + 1);
 
  689         Vec3 f1Tmp(dynamic_cast<const StructNode *>(
pNode1)->GetRCurr()*
f1);
 
  690         Vec3 f2Tmp(dynamic_cast<const StructNode *>(
pNode2)->GetRCurr()*
f2);
 
  697         dAlpha = XCurr(iFirstReactionIndex + 1);
 
  702         if (
fabs(dDistance) <= std::numeric_limits<doublereal>::epsilon()) {
 
  706         WorkVec.
IncCoef(12 + 1, (dDistance - Vec.Norm())/dCoef);
 
  709         WorkVec.
Add(0 + 1, Tmp);
 
  710         WorkVec.
Add(3 + 1, f1Tmp.Cross(Tmp));
 
  711         WorkVec.
Sub(6 + 1, Tmp);
 
  712         WorkVec.
Sub(9 + 1, f2Tmp.Cross(Tmp));
 
  723         DEBUGCOUT(
"Entering DistanceJointWithOffset::InitialAssJac()" 
  737         DEBUGCOUT(
"Entering DistanceJointWithOffset::InitialAssRes()" 
VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
void PutColIndex(integer iSubCol, integer iCol)
 
virtual void Output(OutputHandler &OH) const 
 
SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
 
const Vec3 Zero3(0., 0., 0.)
 
std::ostream & Write(std::ostream &out, const char *sFill=" ") const 
 
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bToBeOutput(void) const 
 
virtual std::ostream & Restart(std::ostream &out) const 
 
#define MBDYN_EXCEPT_ARGS
 
virtual doublereal dGetPrivData(unsigned int i) const 
 
virtual void ResizeReset(integer)
 
virtual unsigned int iGetPrivDataIdx(const char *s) const 
 
const MatCross_Manip MatCross
 
FullSubMatrixHandler & SetFull(void)
 
virtual std::ostream & Restart(std::ostream &out) const 
 
doublereal Dot(const Vec3 &v) const 
 
void Add(integer iRow, integer iCol, const Vec3 &v)
 
virtual void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
 
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const 
 
virtual void Sub(integer iRow, const Vec3 &v)
 
doublereal dGet(void) const 
 
virtual void IncCoef(integer iRow, const doublereal &dCoef)=0
 
std::vector< Hint * > Hints
 
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
 
void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
 
virtual std::ostream & Restart(std::ostream &out) const =0
 
void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
 
const StructNode * pNode1
 
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
 
DistanceJointWithOffset(unsigned int uL, const DofOwner *pDO, const StructNode *pN1, const StructNode *pN2, const Vec3 &f1Tmp, const Vec3 &f2Tmp, const DriveCaller *pDC, flag fOut)
 
const StructDispNode * pNode1
 
const StructNode * pNode2
 
SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
 
virtual void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
 
virtual integer iGetFirstMomentumIndex(void) const =0
 
virtual integer iGetFirstPositionIndex(void) const 
 
VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual std::ostream & Restart(std::ostream &out) const 
 
std::ostream & Joints(void) const 
 
DriveCaller * pCreateDrive(DataManager *pDM) const 
 
~DistanceJointWithOffset(void)
 
#define ASSERT(expression)
 
DistanceJoint(unsigned int uL, const DofOwner *pDO, const StructDispNode *pN1, const StructDispNode *pN2, const DriveCaller *pDC, flag fOut)
 
DriveCaller * pGetDriveCaller(void) const 
 
virtual const Vec3 & GetXCurr(void) const 
 
virtual void Add(integer iRow, const Vec3 &v)
 
virtual void ResizeReset(integer, integer)
 
virtual doublereal dGet(const doublereal &dVar) const =0
 
const MatCrossCross_Manip MatCrossCross
 
const StructDispNode * pNode2
 
VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const 
 
void PutRowIndex(integer iSubRow, integer iRow)
 
void Set(const DriveCaller *pDC)
 
virtual void AssMats(VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
void Sub(integer iRow, integer iCol, const Vec3 &v)
 
virtual integer iGetFirstIndex(void) const 
 
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 
 
VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Resize(integer iNewSize)=0
 
virtual unsigned int iGetNumPrivData(void) const