96 DEBUGCOUT(
"Entering DataManager::AssJac()" << std::endl);
109 DEBUGCOUT(
"Entering DataManager::AssJac()" << std::endl);
120 Joint *pJ = Cast<Joint>(j->second);
123 JacHdl += j->second->AssJac(WorkMat, *
pXCurr);
130 silent_cerr(
"DataManager::AssConstrJac(" << pIDS->
GetProblemType() <<
") not implemented yet" << std::endl);
143 Joint *pJ = Cast<Joint>(j->second,
true);
146 pJ = Cast<Joint>(j->second,
false);
156 for (
int iCnt = 1; iCnt <= iNumDof; iCnt++) {
157 JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) = 1.;
178 ASSERT(n->second->iGetNumDof() == 6);
179 integer iFirstIndex = n->second->iGetFirstIndex();
181 for (
integer iCnt = 1; iCnt <= 6; iCnt++) {
182 JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) += 1.;
194 ASSERT(n->second->iGetNumDof() == 6);
195 integer iFirstIndex = n->second->iGetFirstIndex();
197 for (
integer iCnt = 1; iCnt <= 6; iCnt++) {
198 JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) += dw1;
206 #ifdef TORQUE_OPTIMIZATION
211 #endif // TORQUE_OPTIMIZATION
213 for (ElemContainerType::const_iterator b =
ElemData[
Elem::BODY].ElemContainer.begin();
216 if (!b->second->bIsErgonomy()) {
220 const Body *pBody(Cast<Body>(b->second));
228 for (
int iRow = 1; iRow <= 3; iRow++) {
229 JacHdl(iFirstIndex + iRow, iFirstIndex + iRow) += dm;
231 for (
int iCol = 1; iCol <= 3; iCol++) {
232 JacHdl(iFirstIndex + 3 + iRow, iFirstIndex + 3 + iCol) += J(iRow, iCol);
236 JacHdl(iFirstIndex + 3 + 1, iFirstIndex + 2) = -S(3);
237 JacHdl(iFirstIndex + 3 + 1, iFirstIndex + 3) = S(2);
238 JacHdl(iFirstIndex + 3 + 2, iFirstIndex + 3) = -S(1);
239 JacHdl(iFirstIndex + 3 + 2, iFirstIndex + 1) = S(3);
240 JacHdl(iFirstIndex + 3 + 3, iFirstIndex + 1) = -S(2);
241 JacHdl(iFirstIndex + 3 + 3, iFirstIndex + 2) = S(1);
243 JacHdl(iFirstIndex + 2, iFirstIndex + 3 + 1) = -S(3);
244 JacHdl(iFirstIndex + 3, iFirstIndex + 3 + 1) = S(2);
245 JacHdl(iFirstIndex + 3, iFirstIndex + 3 + 2) = -S(1);
246 JacHdl(iFirstIndex + 1, iFirstIndex + 3 + 2) = S(3);
247 JacHdl(iFirstIndex + 1, iFirstIndex + 3 + 3) = -S(2);
248 JacHdl(iFirstIndex + 2, iFirstIndex + 3 + 3) = S(1);
256 Joint *pJ = Cast<Joint>(j->second,
true);
259 pJ = Cast<Joint>(j->second,
false);
272 for (
int iCnt = 1; iCnt <= iNumDof; iCnt++) {
273 JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) = 1.;
282 Beam2 *pB = Cast<Beam2>(j->second,
true);
285 pB = Cast<Beam2>(j->second,
false);
305 DEBUGCOUT(
"Entering AssRes()" << std::endl);
316 DEBUGCOUT(
"Entering AssRes()" << std::endl);
320 bool ChangedEqStructure(
false);
328 Joint *pJ = Cast<Joint>(j->second);
337 ChangedEqStructure =
true;
345 silent_cerr(
"DataManager::AssConstrRes(" << pIDS->
GetProblemType() <<
") not implemented yet" << std::endl);
366 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
367 ResHdl(iFirstIndex + iCnt) += dw1*DX(iCnt);
372 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
373 ResHdl(iFirstIndex + 3 + iCnt) += dw1*DTheta(iCnt);
379 #ifdef TORQUE_OPTIMIZATION
381 for (ElemContainerType::const_iterator b =
ElemData[
Elem::BODY].ElemContainer.begin();
384 if (!b->second->bIsRightHandSide()) {
388 const Body *pBody(Cast<Body>(b->second));
403 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
404 ResHdl(iFirstIndex + iCnt) -= XRes(iCnt);
407 Vec3 ThetaRes(S.Cross(DXPP) + J*DWP + DW.Cross(J*DW));
408 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
409 ResHdl(iFirstIndex + 3 + iCnt) -= ThetaRes(iCnt);
412 #else // !TORQUE_OPTIMIZATION
413 for (ElemContainerType::const_iterator b =
ElemData[
Elem::BODY].ElemContainer.begin();
416 if (!b->second->bIsErgonomy()) {
420 const Body *pBody(Cast<Body>(b->second));
432 Vec3 XRes(DX*dm - S.Cross(DTheta));
433 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
434 ResHdl(iFirstIndex + iCnt) += XRes(iCnt);
437 Vec3 ThetaRes(S.Cross(DX) + J*DTheta);
438 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
439 ResHdl(iFirstIndex + 3 + iCnt) += ThetaRes(iCnt);
442 #endif // !TORQUE_OPTIMIZATION
466 #define USE_X 1 // 1st order, l-stable (implicit Euler), less accurate (alpha == 1.)
470 Vec3 VRef((XCurr - XPrev)*(2./h) - VPrev);
472 Vec3 VRef((XCurr - XPrev)*(2./3./h) + VPrev/3.);
473 #elif defined(USE_alphaX_betaV)
474 Vec3 VRef((XCurr - XPrev)*(USE_alphaX_betaV/h) + VPrev*(1 - USE_alphaX_betaV));
476 Vec3 VRef((XCurr - XPrev)/h);
478 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
479 ResHdl(iFirstIndex + iCnt) += dw1*VRef(iCnt);
490 #elif defined(USE_alphaX_betaV)
491 Vec3 WRef(
RotManip::VecRot(RCurr.MulMT(RPrev))*(USE_alphaX_betaV/h) + WPrev*(1 - USE_alphaX_betaV));
495 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
496 ResHdl(iFirstIndex + 3 + iCnt) += dw1*WRef(iCnt);
502 for (ElemContainerType::const_iterator b =
ElemData[
Elem::BODY].ElemContainer.begin();
505 if (!b->second->bIsErgonomy()) {
509 const Body *pBody(Cast<Body>(b->second));
518 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
519 ResHdl(iFirstIndex + iCnt) += BPrev(iCnt);
523 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
524 ResHdl(iFirstIndex + 3 + iCnt) += GPrev(iCnt);
550 Vec3 XPPRef((VCurr - VPrev)*(2./h) - XPPPrev);
552 Vec3 XPPRef((VCurr - VPrev)*(2./3./h) + XPPPrev/3.);
553 #elif defined(USE_alphaX_betaV)
554 Vec3 XPPRef((VCurr - VPrev)*(USE_alphaX_betaV/h) + XPPPrev*(1 - USE_alphaX_betaV));
556 Vec3 XPPRef((VCurr - VPrev)/h);
562 Vec3 XPPRef(XPPPrev + (VCurr + VPrev)*(6./h) - (XCurr - XPrev)*(12./h/h));
564 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
565 ResHdl(iFirstIndex + iCnt) += dw1*XPPRef(iCnt);
573 Vec3 WPRef((WCurr - WPrev)*(2./h) - WPPrev);
575 Vec3 WPRef((WCurr - WPrev)*(2./3./h) + WPPrev/3.);
576 #elif defined(USE_alphaX_betaV)
577 Vec3 WPRef((WCurr - WPrev)*(USE_alphaX_betaV/h) + WPPrev*(1 - USE_alphaX_betaV));
579 Vec3 WPRef((WCurr - WPrev)/h);
587 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
588 ResHdl(iFirstIndex + 3 + iCnt) += dw1*WPRef(iCnt);
594 for (ElemContainerType::const_iterator b =
ElemData[
Elem::BODY].ElemContainer.begin();
597 if (!b->second->bIsErgonomy()) {
601 const Body *pBody(Cast<Body>(b->second));
610 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
611 ResHdl(iFirstIndex + iCnt) += BPPrev(iCnt);
615 for (
integer iCnt = 1; iCnt <= 3; iCnt++) {
616 ResHdl(iFirstIndex + 3 + iCnt) += GPPrev(iCnt);
630 Joint *pJ = Cast<Joint>(j->second,
true);
633 pJ = Cast<Joint>(j->second,
false);
640 ResHdl += j->second->AssRes(WorkVec, *
pXCurr,
645 ChangedEqStructure =
true;
652 for (
int iCnt = 1; iCnt <= iNumDof; iCnt++) {
653 ResHdl(iFirstIndex + iCnt) = -(*pXCurr)(iFirstIndex + iCnt);
657 for (
int iCnt = 1; iCnt <= iNumDof; iCnt++) {
658 ResHdl(iFirstIndex + iCnt) = 0.;
668 Beam2 *pB = Cast<Beam2>(j->second,
true);
671 pB = Cast<Beam2>(j->second,
false);
677 ResHdl += j->second->AssRes(WorkVec, *
pXCurr,
682 ChangedEqStructure =
true;
694 if (ChangedEqStructure) {
703 DEBUGCOUT(
"Entering AssRes()" << std::endl);
710 Inertia *pI = Cast<Inertia>(j->second,
true);
713 pI = Cast<Inertia>(j->second,
false);
729 DEBUGCOUT(
"Entering AssRes()" << std::endl);
742 bool ChangedEqStructure(
false);
745 for (ElemContainerType::iterator j =
ElemData[ElemType[et]].ElemContainer.begin();
748 if (!j->second->bIsRightHandSide()) {
753 ResHdl += j->second->AssRes(WorkVec, *
pXCurr,
759 ChangedEqStructure =
true;
768 Joint *pJ = Cast<Joint>(j->second,
true);
771 pJ = Cast<Joint>(j->second,
false);
782 ChangedEqStructure =
true;
787 if (ChangedEqStructure) {
828 for (NodeVecType::const_iterator i =
Nodes.begin(); i !=
Nodes.end(); ++i) {
829 (*i)->Update(*pV, iOrder);
839 for (NodeVecType::const_iterator i =
Nodes.begin(); i !=
Nodes.end(); ++i) {
857 for (NodeVecType::const_iterator i =
Nodes.begin(); i !=
Nodes.end(); ++i) {
878 for (ElemContainerType::const_iterator p =
ElemData[iCnt].ElemContainer.begin();
884 <<
"(" << pEWD->
GetLabel() <<
")" << std::endl);
898 silent_cerr(
"DataManager::IDDofInit: no dof owners are defined" << std::endl);
930 unsigned iNumDofs = pDO->
iNumDofs = i->second->iGetNumDof();
933 iNodeIndex += iNumDofs;
934 iRealTotDofs += iNumDofs;
939 DEBUGCERR(
"warning, Structural(" << i->second->GetLabel() <<
") "
940 "(DofOwner #" << (iDOm1 + 1) <<
") has 0 dofs" << std::endl);
952 dynamic_cast<StructNode *
>(n->second)->OutputAccelerations(
true);
963 integer iPrescribedMotionJointIndex;
965 switch (dynamic_cast<InverseSolver *>(
pSolver)->GetProblemType()) {
975 iPrescribedMotionJointIndex = 0;
976 iTorqueJointIndex = 0;
981 iJointIndex = iNodeIndex;
982 iPrescribedMotionJointIndex = iNodeIndex;
983 iTorqueJointIndex = iNodeIndex;
994 Joint *pJ = Cast<Joint>(j->second);
1003 iRealTotDofs += iNumDofs;
1004 iJointIndex += iNumDofs;
1006 iPrescribedMotionJointIndex += iNumDofs;
1009 iTorqueJointIndex += iNumDofs;
1014 DEBUGCERR(
"warning, Joint(" << j->second->GetLabel() <<
") "
1015 "has 0 dofs" << std::endl);
1018 const char *sTorque = pJ->
bIsTorque() ?
"T" :
"_";
1020 const char *sErgonomy = pJ->
bIsErgonomy() ?
"E" :
"_";
1023 silent_cout(
"Joint(" << pJ->
GetLabel() <<
"): " << sTorque << sPrescribedMotion << sErgonomy << sRightHandSide << std::endl);
1029 Beam2 *pB = Cast<Beam2>(j->second);
1032 const char *sTorque =
"_";
1033 const char *sPrescribedMotion =
"_";
1034 const char *sErgonomy = pB->
bIsErgonomy() ?
"E" :
"_";
1037 silent_cout(
"Beam2(" << pB->
GetLabel() <<
"): " << sTorque << sPrescribedMotion << sErgonomy << sRightHandSide << std::endl);
1040 switch (dynamic_cast<InverseSolver *>(
pSolver)->GetProblemType()) {
1065 silent_cerr(
"DataManager::IDDofInit: no dofs defined" << std::endl);
1069 Dofs.resize(iRealTotDofs);
1073 for (
integer idx = 0; idx < iRealTotDofs; idx++) {
1074 Dofs[idx].iIndex = iIndex++;
1094 switch (dynamic_cast<InverseSolver *>(
pSolver)->GetProblemType()) {
1113 integer iFirstIndex = std::numeric_limits<integer>::max();
1116 for (NodeVecType::const_iterator n =
Nodes.begin(); n !=
Nodes.end(); ++n) {
1117 integer iIndex = (*n)->iGetFirstIndex();
1118 integer iNumDofs = (*n)->iGetNumDof();
1120 if (iFirstIndex > iIndex) {
1121 iFirstIndex = iIndex;
1124 if (iLastIndex < iIndex + iNumDofs) {
1125 iLastIndex = iIndex + iNumDofs;
1129 silent_cout(
"DataManager::IDSetTest(): SolTest range=[" << iFirstIndex + 1 <<
":" << iLastIndex <<
"]" << std::endl);
1131 pSolTest->
SetRange(iFirstIndex + 1, iLastIndex);
1133 iFirstIndex = std::numeric_limits<integer>::max();
1139 const Joint *pJ = Cast<Joint>(j->second);
1144 const ElemWithDofs* pEWD = Cast<ElemWithDofs>(j->second);
1149 if (iFirstIndex > iIndex) {
1150 iFirstIndex = iIndex;
1153 if (iLastIndex < iIndex + iNumDofs) {
1154 iLastIndex = iIndex + iNumDofs;
1164 silent_cout(
"DataManager::IDSetTest(): ResTest range=[" << iFirstIndex + 1 <<
":" << iLastIndex <<
"]" << std::endl);
1166 pResTest->
SetRange(iFirstIndex + 1, iLastIndex);
virtual const Vec3 & GetWPrev(void) const
virtual void IDSetTest(NonlinearSolverTestRange *pResTest, NonlinearSolverTestRange *pSolTest, bool bFullResTest)
ElemContainerType ElemContainer
Vec3 Cross(const Vec3 &v) const
#define MBDYN_EXCEPT_ARGS
DofOwner::Type DofOwnerType
bool bGetNext(T &TReturn) const
#define DEBUGCOUTFNAME(fname)
virtual const Mat3x3 & GetRCurr(void) const
bool bIsErgonomy(void) const
virtual const Vec3 & GetXPrev(void) const
bool bIsRightHandSide(void) const
MySubVectorHandler * pWorkVec
const StructNode * pGetNode(void) const
MatrixHandler & AddToT(MatrixHandler &MH) const
virtual void AssRes(VectorHandler &ResHdl, doublereal dCoef)
virtual Elem::Type GetElemType(void) const =0
std::vector< DofOwner > DofOwners
InverseDynamics::Type GetProblemType(void) const
NodeContainerType NodeContainer
Vec3 VecRot(const Mat3x3 &Phi)
virtual void Reset(void)=0
bool bIsPrescribedMotion(void) const
virtual void IDAfterConvergence(void) const
virtual const DofOwner * pGetDofOwner(void) const
void SetRange(integer iFirstIndex, integer iLastIndex)
VectorHandler * pXPrimePrimeCurr
void LinkToSolution(VectorHandler &XCurr, VectorHandler &XPrimeCurr)
virtual StepIntegrator * pGetStepIntegrator(void) const
InverseDynamics::Order GetOrder(void) const
int iIDGetJointTotNumDofs(void) const
virtual const Mat3x3 & GetRPrev(void) const
doublereal dGetTimeStep(void) const
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
virtual const Vec3 & GetVPrev(void) const
int iIDGetNodeTotNumDofs(void) const
VectorHandler * pXPrimeCurr
virtual const Vec3 & GetWCurr(void) const
doublereal dGetM(void) const
#define ASSERT(expression)
VecIter< Elem * > ElemIter
VectorHandler * pLambdaCurr
virtual void AssConstrJac(MatrixHandler &JacHdl)
virtual const Vec3 & GetXCurr(void) const
virtual unsigned int iGetNumDof(void) const
virtual unsigned int iGetNumDof(void) const =0
void LinkToSolution(const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
bool bIsTorque(void) const
const char * psElemNames[]
virtual void AfterConvergence(const VectorHandler &X, const VectorHandler &XP)
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
virtual const Vec3 & GetVCurr(void) const
virtual void Update(void) const
bool bGetFirst(T &TReturn) const
Mat3x3 MulMT(const Mat3x3 &m) const
virtual const Vec3 & GetWPPrev(void) const
virtual const Vec3 & GetXPPPrev(void) const
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
virtual void AssConstrRes(VectorHandler &ResHdl, InverseDynamics::Order iOrder)
virtual integer iGetFirstIndex(void) const
void GetWeight(InverseDynamics::Order iOrder, doublereal &dw1, doublereal &dw2) const
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
unsigned int GetLabel(void) const
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
#define DEBUGLCOUT(level, msg)
VariableSubMatrixHandler * pWorkMat
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
int iIDGetTotNumDofs(void) const