MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
DataManager Class Reference

#include <dataman.h>

Inheritance diagram for DataManager:
Collaboration diagram for DataManager:

Classes

struct  ElemDataStructure
 
struct  ElemRead
 
struct  NodeDataStructure
 
struct  NodeRead
 

Public Types

enum  eRestart {
  NEVER, ATEND, ITERATIONS, TIME,
  TIMES
}
 
enum  ResType { RES_NONE = 0x00, RES_TEXT = 0x01, RES_NETCDF = 0x02 }
 
enum  ModuleInsertMode { MIM_FAIL, MIM_REPLACE, MIM_IGNORE }
 
enum  DerivationTable {
  ELEM = 0x0U, DOFOWNER = 0x1U, GRAVITYOWNER = 0x2U, AIRPROPOWNER = 0x4U,
  INITIALASSEMBLY = 0x8U
}
 
enum  DataFlags {
  NONE = 0x00U, ISUNIQUE = 0x01U, TOBEUSEDINASSEMBLY = 0x02U, GENERATESINERTIAFORCES = 0x04U,
  USESAIRPROPERTIES = 0x08U, DEFAULTOUT = 0x10U
}
 
typedef std::map< std::string,
DataManager::ElemRead
*, ltstrcase
ElemReadType
 
typedef std::pair< unsigned,
Elem * > 
KeyElemPair
 
typedef std::list< KeyElemPairElemContainerType
 
typedef std::map< unsigned,
ElemContainerType::iterator > 
ElemMapToListType
 
typedef std::map< std::string,
DataManager::NodeRead
*, ltstrcase
NodeReadType
 
typedef std::pair< unsigned,
Node * > 
KeyNodePair
 
typedef std::list< KeyNodePairNodeContainerType
 
typedef std::map< unsigned,
NodeContainerType::iterator > 
NodeMapToListType
 
typedef std::vector< DofDofVecType
 
typedef DofVecType::const_iterator DofIterator_const
 
typedef DofVecType::iterator DofIterator
 

Public Member Functions

bool bOutput (ResType t) const
 
template<class T >
flag fReadOutput (MBDynParser &HP, const T &t) const
 
doublereal dReadScale (MBDynParser &HP, enum DofOwner::Type t) const
 
bool bOutputAccelerations (void) const
 
bool bOutputDriveCallers (void) const
 
const doublerealdGetInitialPositionStiffness (void) const
 
const doublerealdGetInitialVelocityStiffness (void) const
 
bool bDoesOmegaRotate (void) const
 
void IncElemCount (Elem::Type type)
 
virtual clock_t GetCPUTime (void) const
 
 DataManager (MBDynParser &HP, unsigned OF, Solver *pS, doublereal dInitialTime, const char *sOutputFileName, const char *sInputFileName, bool bAbortAfterInput)
 
virtual ~DataManager (void)
 
int Cleanup (void)
 
int ReadScalarAlgebraicNode (MBDynParser &HP, unsigned int uLabel, Node::Type type, doublereal &dX) const
 
int ReadScalarDifferentialNode (MBDynParser &HP, unsigned int uLabel, Node::Type type, doublereal &dX, doublereal &dXP) const
 
NodeReadNode (MBDynParser &HP, Node::Type type) const
 
ElemReadElem (MBDynParser &HP, Elem::Type type) const
 
template<class Tbase , Node::Type type>
Tbase * ReadNode (MBDynParser &HP) const
 
template<class Tder , class Tbase , Node::Type type>
Tder * ReadNode (MBDynParser &HP) const
 
template<class Tbase , Elem::Type type>
Tbase * ReadElem (MBDynParser &HP) const
 
template<class Tder , class Tbase , Elem::Type type>
Tder * ReadElem (MBDynParser &HP) const
 
void SetTime (const doublereal &dTime, const doublereal &dTimeStep=-1., const integer &iStep=-1, bool bServePending=true)
 
doublereal dGetTime (void) const
 
NamedValueInsertSym (const char *const s, const Real &v, int redefine=0)
 
NamedValueInsertSym (const char *const s, const Int &v, int redefine=0)
 
void LinkToSolution (VectorHandler &XCurr, VectorHandler &XPrimeCurr)
 
void LinkToSolution (VectorHandler &XCurr, VectorHandler &XPrimeCurr, VectorHandler &XPrimePrimeCurr, VectorHandler &LambdaCurr)
 
std::ostream & GetOutFile (void) const
 
std::ostream & GetLogFile (void) const
 
const OutputHandlerpGetOutHdl (void) const
 
void SetOrientationDescription (OrientationDescription)
 
OrientationDescription GetOrientationDescription (void) const
 
void SetOutput (Elem::Type t, unsigned, OrientationDescription)
 
void GetOutput (Elem::Type t, unsigned &, OrientationDescription &) const
 
const DriveHandlerpGetDrvHdl (void) const
 
MathParserGetMathParser (void) const
 
MBDynParserGetMBDynParser (void) const
 
const SolverGetSolver (void) const
 
bool PushCurrData (const std::string &name, const TypedValue &value)
 
bool PopCurrData (const std::string &name)
 
virtual void AssJac (MatrixHandler &JacHdl, doublereal dCoef)
 
virtual void AssMats (MatrixHandler &A_Hdl, MatrixHandler &B_Hdl)
 
virtual void AssRes (VectorHandler &ResHdl, doublereal dCoef)
 
virtual void AssConstrRes (VectorHandler &ResHdl, InverseDynamics::Order iOrder)
 
virtual void AssRes (VectorHandler &ResHdl)
 
virtual void AssConstrJac (MatrixHandler &JacHdl)
 
unsigned ConvergedRegister (void)
 
void ConvergedSet (unsigned idx, Converged::State s)
 
bool IsConverged (void) const
 
bool EndOfSimulation (void) const
 
virtual void OutputPrepare (void)
 
virtual void OutputEigPrepare (const integer iNumAnalyses, const integer iSize)
 
virtual bool Output (long lStep, const doublereal &dTime, const doublereal &dTimeStep, bool force=false) const
 
virtual void Output (const VectorHandler &X, const VectorHandler &XP) const
 
void OutputOpen (const OutputHandler::OutFiles out)
 
void OutputEigOpen (const std::string &postfix)
 
void OutputEigParams (const doublereal &dTime, const doublereal &dCoef, const unsigned uCurrEigSol, const int iResultsPrecision)
 
void OutputEigFullMatrices (const MatrixHandler *pmMatA, const MatrixHandler *pmMatB, const unsigned uCurrEigSol, const int iMatrixPrecision)
 
void OutputEigSparseMatrices (const MatrixHandler *pmMatA, const MatrixHandler *pmMatB, const unsigned uCurrEigSol, const int iMatrixPrecision)
 
void OutputEigNaiveMatrices (const MatrixHandler *pmMatA, const MatrixHandler *pmMatB, const unsigned uCurrEigSol, const int iMatrixPrecision)
 
void OutputEigenvectors (const VectorHandler *pBeta, const VectorHandler &R, const VectorHandler &I, const doublereal &dShiftR, const MatrixHandler *pVL, const MatrixHandler &VR, const std::vector< bool > &vOut, const unsigned uCurrEigSol, const int iResultsPrecision)
 
void OutputEigGeometry (const unsigned uCurrSol, const int iResultsPrecision)
 
bool OutputEigClose (void)
 
void SetValue (VectorHandler &X, VectorHandler &XP)
 
virtual void MakeRestart (void)
 
virtual void DerivativesUpdate (void) const
 
virtual void BeforePredict (VectorHandler &X, VectorHandler &XP, VectorHandler &XPrev, VectorHandler &XPPrev) const
 
virtual void AfterPredict (void) const
 
virtual void Update (void) const
 
virtual void AfterConvergence (void) const
 
virtual void Update (InverseDynamics::Order iOrder) const
 
virtual void IDAfterConvergence (void) const
 
virtual void IDSetTest (NonlinearSolverTestRange *pResTest, NonlinearSolverTestRange *pSolTest, bool bFullResTest)
 
void bSetStaticModel (bool b)
 
bool bIsStaticModel (void) const
 
const RigidBodyKinematicspGetRBK (void) const
 
void bSetInverseDynamics (bool b)
 
bool bIsInverseDynamics (void) const
 
const LoadableCallsGetLoadableElemModule (std::string) const
 
void SetLoadableElemModule (std::string, const LoadableCalls *, ModuleInsertMode=MIM_FAIL)
 
DrivepFindDrive (Drive::Type Typ, unsigned int uL) const
 
ElempFindElem (Elem::Type Typ, unsigned int uElem=unsigned(-1)) const
 
template<class Tbase , Elem::Type type>
Tbase * pFindElem (unsigned int uElem=unsigned(-1)) const
 
template<class Tder , class Tbase , Elem::Type type>
Tder * pFindElem (unsigned int uElem=unsigned(-1)) const
 
const
DataManager::ElemDataStructure
GetElemDataStructure (Elem::Type Typ) const
 
std::vector< doublereal > & GetBufIn (unsigned uL)
 
const std::vector< doublereal > & GetBufOut (unsigned uL) const
 
doublerealGetBufInRaw (unsigned uL)
 
void SetBufInRaw (unsigned uL, integer n, const doublereal *p)
 
const doublerealGetBufOutRaw (unsigned uL) const
 
void SetBufOutRaw (unsigned uL, integer n, const doublereal *p)
 
void ElemManager (void)
 
void ElemManagerDestructor (void)
 
void ElemDataInit (void)
 
void ElemAssInit (void)
 
void ElemOutputPrepare (OutputHandler &OH)
 
void ElemOutput (OutputHandler &OH) const
 
void ElemOutput (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
void DriveOutput (OutputHandler &OH) const
 
void DriveTrace (OutputHandler &OH) const
 
DataManager::ElemContainerType::const_iterator begin (Elem::Type t) const
 
DataManager::ElemContainerType::const_iterator end (Elem::Type t) const
 
Node ** ppFindNode (Node::Type Typ, unsigned int uNode) const
 
NodepFindNode (Node::Type Typ, unsigned int uNode) const
 
template<class Tbase , Node::Type type>
Tbase * pFindNode (unsigned int uNode) const
 
template<class Tder , class Tbase , Node::Type type>
Tder * pFindNode (unsigned int uNode) const
 
void NodeManager (void)
 
void NodeManagerDestructor (void)
 
void NodeDataInit (void)
 
DataManager::NodeContainerType::const_iterator begin (Node::Type t) const
 
DataManager::NodeContainerType::const_iterator end (Node::Type t) const
 
void NodeOutputPrepare (OutputHandler &OH)
 
void NodeOutput (OutputHandler &OH) const
 
void NodeOutput (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
const DofVecTypeGetDofs (void) const
 
integer iGetNumDofs (void) const
 
void DofManager (void)
 
void DofManagerDestructor (void)
 
void DofDataInit (void)
 
void DofInit (void)
 
void IDDofInit (void)
 
int iIDGetNodeTotNumDofs (void) const
 
int iIDGetJointTotNumDofs (void) const
 
int iIDGetTotNumDofs (void) const
 
void SetScale (VectorHandler &XScale) const
 
const VectorHandlerGetpXCurr (void) const
 
const VectorHandlerGetpXPCurr (void) const
 
virtual void PrintResidual (const VectorHandler &Res, integer iIterCnt) const
 
virtual void PrintSolution (const VectorHandler &Sol, integer iIterCnt) const
 
virtual const std::string & GetDofDescription (int i) const
 
virtual const std::string & GetEqDescription (int i) const
 
virtual DofOrder::Order GetDofType (int i) const
 
virtual DofOrder::Order GetEqType (int i) const
 
- Public Member Functions inherited from SolutionDataManager
virtual ~SolutionDataManager (void)
 
- Public Member Functions inherited from SolverDiagnostics
 SolverDiagnostics (unsigned OF=OUTPUT_DEFAULT, DriveCaller *pOM=0)
 
virtual ~SolverDiagnostics (void)
 
void SetNoOutput (void)
 
void SetOutputMeter (DriveCaller *pOM)
 
void SetOutputDriveHandler (const DriveHandler *pDH)
 
void SetOutputFlags (unsigned OF)
 
void AddOutputFlags (unsigned OF)
 
void DelOutputFlags (unsigned OF)
 
MatrixHandler::Norm_t GetCondMatNorm (void) const
 
bool outputMeter (void) const
 
bool outputIters (void) const
 
bool outputRes (void) const
 
bool outputSol (void) const
 
bool outputJac (void) const
 
bool outputStep (void) const
 
bool outputBailout (void) const
 
bool outputCounter (void) const
 
bool outputMatrixConditionNumber (void) const
 
bool outputSolverConditionNumber (void) const
 
bool outputSolverConditionStat (void) const
 
bool outputCPUTime (void) const
 
bool outputMsg (void) const
 

Protected Types

enum  PrintFlags {
  PRINT_NONE = 0x00U, PRINT_DOF_STATS = 0x01U, PRINT_DOF_DESCRIPTION = 0x02U, PRINT_EQ_DESCRIPTION = 0x04U,
  PRINT_DESCRIPTION = (PRINT_DOF_DESCRIPTION|PRINT_EQ_DESCRIPTION), PRINT_NODE_CONNECTION = 0x10U, PRINT_EL_CONNECTION = 0x20U, PRINT_CONNECTION = (PRINT_NODE_CONNECTION|PRINT_EL_CONNECTION),
  PRINT_TO_FILE = 0x1000U
}
 
typedef std::vector
< Converged::State
Converged_t
 
typedef std::vector< Elem * > ElemVecType
 
typedef std::vector< Node * > NodeVecType
 
- Protected Types inherited from SolverDiagnostics
enum  {
  OUTPUT_NONE = 0x0000, OUTPUT_ITERS = 0x0001, OUTPUT_RES = 0x0002, OUTPUT_SOL = 0x0004,
  OUTPUT_JAC = 0x0008, OUTPUT_BAILOUT = 0x0010, OUTPUT_MSG = 0x0020, OUTPUT_COUNTER = 0x0040,
  OUTPUT_MAT_COND_NUM_1 = 0x0080, OUTPUT_MAT_COND_NUM_INF = 0x0100, OUTPUT_SOLVER_COND_NUM = 0x0200, OUTPUT_SOLVER_COND_STAT = 0x400,
  OUTPUT_CPU_TIME = 0x800, OUTPUT_MAT_COND_NUM = OUTPUT_MAT_COND_NUM_1 | OUTPUT_MAT_COND_NUM_INF, OUTPUT_DEFAULT = OUTPUT_MSG, OUTPUT_STEP = (OUTPUT_ITERS | OUTPUT_RES | OUTPUT_SOL | OUTPUT_JAC | OUTPUT_MAT_COND_NUM | OUTPUT_SOLVER_COND_NUM),
  OUTPUT_MASK = 0x07FF
}
 

Protected Member Functions

void ReadControl (MBDynParser &HP, const char *sInputFileName)
 
void ReadNodes (MBDynParser &HP)
 
void ReadDrivers (MBDynParser &HP)
 
void ReadElems (MBDynParser &HP)
 
template<class T >
T * Cast (Elem *pEl, bool bActive=false)
 
void InitialJointAssembly (void)
 
void DofOwnerSet (void)
 
void DofOwnerInit (void)
 
void IDDofOwnerSet (void)
 
virtual void AssJac (MatrixHandler &JacHdl, doublereal dCoef, VecIter< Elem * > &Iter, VariableSubMatrixHandler &WorkMat)
 
virtual void AssMats (MatrixHandler &A_Hdl, MatrixHandler &B_Hdl, VecIter< Elem * > &Iter, VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB)
 
virtual void AssRes (VectorHandler &ResHdl, doublereal dCoef, VecIter< Elem * > &Iter, SubVectorHandler &WorkVec)
 
void AssConstrJac (MatrixHandler &JacHdl, VecIter< Elem * > &Iter, VariableSubMatrixHandler &WorkMat)
 
void AssConstrRes (VectorHandler &ResHdl, VecIter< Elem * > &Iter, SubVectorHandler &WorkVec, InverseDynamics::Order iOrder)
 
void AssRes (VectorHandler &ResHdl, VecIter< Elem * > &Iter, SubVectorHandler &WorkVec)
 
Elem ** InsertElem (ElemDataStructure &eldata, unsigned int uLabel, Elem *pE)
 
ElempFindElem (Elem::Type Typ, unsigned int uElem, unsigned int iDeriv) const
 
ElempChooseElem (Elem *p, unsigned int iDeriv) const
 
Elem ** ppFindElem (Elem::Type Typ, unsigned int uElem) const
 
flag fGetDefaultOutputFlag (const Elem::Type &t) const
 
Elem ** ReadOneElem (MBDynParser &HP, unsigned int uLabel, const std::string &sName, int CurrType)
 
Node ** InsertNode (NodeDataStructure &nodedata, unsigned int uLabel, Node *pN)
 
flag fGetDefaultOutputFlag (const Node::Type &t) const
 
doublereal dGetDefaultScale (DofOwner::Type t) const
 

Protected Attributes

void ** ppCleanupData
 
MBDynParserMBPar
 
MathParserMathPar
 
SolverpSolver
 
std::map< std::string, const
LoadableCalls * > 
MapOfLoadableElemHandlers
 
DriveHandler DrvHdl
 
OutputHandler OutHdl
 
VectorHandlerpXCurr
 
VectorHandlerpXPrimeCurr
 
VectorHandlerpXPrimePrimeCurr
 
VectorHandlerpLambdaCurr
 
bool bInitialJointAssemblyToBeDone
 
bool bSkipInitialJointAssembly
 
bool bOutputFrames
 
bool bOutputAccels
 
bool bOutputDriveCaller
 
doublereal dInitialPositionStiffness
 
doublereal dInitialVelocityStiffness
 
bool bOmegaRotates
 
doublereal dInitialAssemblyTol
 
integer iMaxInitialIterations
 
doublereal dEpsilon
 
LinSol CurrSolver
 
RigidBodyKinematicspRBK
 
bool bStaticModel
 
bool bInverseDynamics
 
int iIDNodeTotNumDofs
 
int iIDJointTotNumDofs
 
unsigned uPrintFlags
 
char * sSimulationTitle
 
eRestart RestartEvery
 
integer iRestartIterations
 
doublereal dRestartTime
 
doublerealpdRestartTimes
 
integer iNumRestartTimes
 
integer iCurrRestartTime
 
integer iCurrRestartIter
 
doublereal dLastRestartTime
 
bool saveXSol
 
char * solArrFileName
 
DriveCallerpOutputMeter
 
integer iOutputCount
 
int ResMode
 
OrientationDescription od
 
Converged_t m_IsConverged
 
struct
DataManager::ElemDataStructure 
ElemData [Elem::LASTELEMTYPE]
 
ElemVecType Elems
 
VecIter< Elem * > ElemIter
 
struct {
   Drive **   ppFirstDrive
 
   unsigned int   iNum
 
DriveData [Drive::LASTDRIVETYPE]
 
Drive ** ppDrive
 
unsigned int iTotDrive
 
integer iMaxWorkNumRowsRes
 
integer iMaxWorkNumRowsJac
 
integer iMaxWorkNumColsJac
 
integer iMaxWorkNumItemsJac
 
VariableSubMatrixHandlerpWorkMatA
 
VariableSubMatrixHandlerpWorkMatB
 
VariableSubMatrixHandlerpWorkMat
 
MySubVectorHandlerpWorkVec
 
struct
DataManager::NodeDataStructure 
NodeData [Node::LASTNODETYPE]
 
NodeVecType Nodes
 
unsigned int iTotNodes
 
struct {
   DofOwner *   pFirstDofOwner
 
   integer   iNum
 
   integer   iSize
 
   doublereal   dDefScale
 
DofData [DofOwner::LASTDOFTYPE]
 
integer iTotDofOwners
 
std::vector< DofOwnerDofOwners
 
integer iTotDofs
 
DofVecType Dofs
 
DofOwner DummyDofOwner
 
- Protected Attributes inherited from SolverDiagnostics
unsigned OutputFlags
 
DriveCallerpOutputMeter
 

Friends

class InitialAssemblyIterator
 

Detailed Description

Definition at line 85 of file dataman.h.

Member Typedef Documentation

Definition at line 398 of file dataman.h.

typedef DofVecType::iterator DataManager::DofIterator

Definition at line 803 of file dataman.h.

typedef DofVecType::const_iterator DataManager::DofIterator_const

Definition at line 802 of file dataman.h.

Definition at line 801 of file dataman.h.

Definition at line 554 of file dataman.h.

typedef std::map<unsigned, ElemContainerType::iterator> DataManager::ElemMapToListType

Definition at line 555 of file dataman.h.

typedef std::map<std::string, DataManager::ElemRead *, ltstrcase> DataManager::ElemReadType

Definition at line 552 of file dataman.h.

Definition at line 599 of file dataman.h.

typedef std::pair<unsigned, Elem*> DataManager::KeyElemPair

Definition at line 553 of file dataman.h.

typedef std::pair<unsigned, Node*> DataManager::KeyNodePair

Definition at line 708 of file dataman.h.

Definition at line 709 of file dataman.h.

typedef std::map<unsigned, NodeContainerType::iterator> DataManager::NodeMapToListType

Definition at line 710 of file dataman.h.

typedef std::map<std::string, DataManager::NodeRead *, ltstrcase> DataManager::NodeReadType

Definition at line 707 of file dataman.h.

Definition at line 739 of file dataman.h.

Member Enumeration Documentation

Enumerator
NONE 
ISUNIQUE 
TOBEUSEDINASSEMBLY 
GENERATESINERTIAFORCES 
USESAIRPROPERTIES 
DEFAULTOUT 

Definition at line 535 of file dataman.h.

Enumerator
ELEM 
DOFOWNER 
GRAVITYOWNER 
AIRPROPOWNER 
INITIALASSEMBLY 

Definition at line 526 of file dataman.h.

526  {
527  ELEM = 0x0U, // pleonastico
528  DOFOWNER = 0x1U,
529  GRAVITYOWNER = 0x2U,
530  AIRPROPOWNER = 0x4U,
531  INITIALASSEMBLY = 0x8U
532  };
Enumerator
NEVER 
ATEND 
ITERATIONS 
TIME 
TIMES 

Definition at line 161 of file dataman.h.

Enumerator
MIM_FAIL 
MIM_REPLACE 
MIM_IGNORE 

Definition at line 513 of file dataman.h.

enum DataManager::PrintFlags
protected
Enumerator
PRINT_NONE 
PRINT_DOF_STATS 
PRINT_DOF_DESCRIPTION 
PRINT_EQ_DESCRIPTION 
PRINT_DESCRIPTION 
PRINT_NODE_CONNECTION 
PRINT_EL_CONNECTION 
PRINT_CONNECTION 
PRINT_TO_FILE 

Definition at line 141 of file dataman.h.

Enumerator
RES_NONE 
RES_TEXT 
RES_NETCDF 

Definition at line 192 of file dataman.h.

192  {
193  RES_NONE = 0x00,
194  RES_TEXT = 0x01,
195  RES_NETCDF = 0x02,
196  };

Constructor & Destructor Documentation

DataManager::DataManager ( MBDynParser HP,
unsigned  OF,
Solver pS,
doublereal  dInitialTime,
const char *  sOutputFileName,
const char *  sInputFileName,
bool  bAbortAfterInput 
)

Definition at line 90 of file dataman.cc.

References bInitialJointAssemblyToBeDone, bInverseDynamics, bOutputFrames, bSkipInitialJointAssembly, datamanager_cleanup(), DEBUG_LEVEL_MATCH, DEBUGCERR, DEBUGCOUTFNAME, DEBUGLCOUT, dof_plugin(), DofData, DofDataInit(), DofInit(), DofManager(), DofOwnerInit(), DofOwners, DofOwnerSet(), Dofs, OutputHandler::DRIVECALLERS, DriveData, elem_priv_plugin(), ElemAssInit(), DataManager::ElemDataStructure::ElemContainer, ElemData, ElemDataInit(), ELEMENTS, ElemManager(), Elems, HighParser::GetDescription(), MBDynParser::GetDriveCallerContainer(), IncludeParser::GetLineData(), HighParser::GetMathParser(), MathParser::GetSymbolTable(), HighParser::GetWord(), IDDofInit(), IDDofOwnerSet(), InitDriveData(), InitGustData(), InitialJointAssembly(), InitUDE(), iTotDofs, iTotDrive, iTotNodes, DofOwner::LASTDOFTYPE, Drive::LASTDRIVETYPE, Elem::LASTELEMTYPE, LASTKEYWORD, Node::LASTNODETYPE, MathPar, mbdyn_cleanup_register(), MBDYN_EXCEPT_ARGS, MBPar, MYDEBUG_INIT, NO_OP, node_priv_plugin(), DataManager::NodeDataStructure::NodeContainer, NodeData, NodeDataInit(), NodeManager(), OutputHandler::Open(), OutHdl, OUTPUT, MBDynParser::OutputFrames(), ppCleanupData, psDofOwnerNames, psDriveNames, psElemNames, psNodeNames, ReadControl(), ReadDrivers(), ReadElems(), ReadNodes(), OutputHandler::REFERENCEFRAMES, OutputHandler::ReferenceFrames(), MathParser::RegisterNameSpace(), MathParser::RegisterPlugIn(), OutputHandler::SetExceptions(), SetTime(), OutputHandler::TRACES, and OutputHandler::UNKNOWN.

97 :
99 #ifdef USE_MULTITHREAD
100 nThreads(0),
101 #endif /* USE_MULTITHREAD */
102 MBPar(HP),
103 MathPar(HP.GetMathParser()),
104 pSolver(pS),
105 DrvHdl(HP.GetMathParser()),
106 OutHdl(sOutputFileName, 0),
107 pXCurr(0), pXPrimeCurr(0),
108 /* Inverse Dynamics: */
110 pLambdaCurr(0),
113 bOutputFrames(false),
114 bOutputAccels(false),
115 bOutputDriveCaller(false),
121 dEpsilon(1.),
123 pRBK(0),
124 bStaticModel(false),
125 /* auto-detect if running inverse dynamics */
126 bInverseDynamics(dynamic_cast<InverseSolver *>(pS) != 0),
129 #if defined(USE_RUNTIME_LOADING)
130 moduleInitialized(false),
131 #endif // USE_RUNTIME_LOADING
132 uPrintFlags(PRINT_NONE), /* Morandini, 2003-11-17 */
136 dRestartTime(0.),
137 pdRestartTimes(0),
141 dLastRestartTime(dInitialTime),
142 saveXSol(false),
143 solArrFileName(0),
144 pOutputMeter(0),
145 iOutputCount(0),
146 #ifdef MBDYN_FDJAC
147 pFDJacMeter(0),
148 #endif // MBDYN_FDJAC
150 #ifdef USE_NETCDF
151 // NetCDF stuff
152 bNetCDFsync(false),
153 bNetCDFnoText(false),
154 Var_Step(0),
155 Var_Time(0),
156 Var_TimeStep(0),
157 Var_Eig_lStep(0),
158 Var_Eig_dTime(0),
159 Var_Eig_dCoef(0),
160 Var_Eig_dAplus(0),
161 Var_Eig_dAminus(0),
162 Var_Eig_dAlpha(0),
163 Var_Eig_Idx(0),
164 Var_Eig_dVR(0),
165 Var_Eig_dVL(0),
166 #endif // USE_NETCDF
167 od(EULER_123),
168 
169 #ifdef USE_SOCKET
170 SocketUsersTimeout(0),
171 #endif // USE_SOCKET
172 
173 /* ElemManager */
174 ElemIter(),
175 ppDrive(0),
176 iTotDrive(0),
177 iMaxWorkNumRowsRes(1), // Allocating a work space size >= 1 will be safe in any case
181 pWorkMatA(0),
182 pWorkMatB(0),
183 pWorkMat(0),
184 pWorkVec(0),
185 
186 /* NodeManager */
187 iTotNodes(0),
188 
189 /* DofManager */
190 iTotDofOwners(0),
191 DofOwners(),
192 iTotDofs(0),
193 Dofs()
194 {
195  DEBUGCOUTFNAME("DataManager::DataManager");
196 
198  *ppCleanupData = (void *)this;
199 
200  OutHdl.SetExceptions(std::ios::badbit); // terminate if disk is full
201 
202  /* pseudocostruttori */
203  ElemManager();
204  NodeManager();
205  DofManager();
206 
207  InitDriveData();
208  InitUDE();
209  InitGustData();
210 
211  /* registra il plugin per i dofs */
212  HP.GetMathParser().RegisterPlugIn("dof", dof_plugin, this);
213 
214  /* registra il plugin per i dati privati dei nodi */
215  HP.GetMathParser().RegisterPlugIn("node", node_priv_plugin, this);
216 
217  /* registra il plugin per i dati privati degli elementi */
218  HP.GetMathParser().RegisterPlugIn("element", elem_priv_plugin, this);
219 
220  /* registra il namespace del modello */
221 
223 
224  /* Setta il tempo al valore iniziale */
225  SetTime(dInitialTime, 0., 0, false);
226 
227  DEBUGLCOUT(MYDEBUG_INIT, "Global symbol table:"
228  << MathPar.GetSymbolTable() << std::endl);
229 
230  /*
231  * Possiede MathParser, con relativa SymbolTable.
232  * Crea ExternKeyTable, MBDynParser,
233  * e legge i dati esterni. Quindi, quando trova
234  * i dati di controllo, chiama la relativa
235  * funzione di lettura (distinta per comodita')
236  */
237 
238  /* parole chiave */
239  const char* sKeyWords[] = {
240  "begin",
241  "control" "data",
242  "scalar" "function",
243  "nodes",
244  "elements",
245  "drivers",
246  "output",
247  0
248  };
249 
250  /* enum delle parole chiave */
251  enum KeyWords {
252  BEGIN = 0,
253  CONTROLDATA,
254  SCALARFUNCTION,
255  NODES,
256  ELEMENTS,
257  DRIVERS,
258  OUTPUT,
260  };
261 
262  /* tabella delle parole chiave */
263  KeyTable K(HP, sKeyWords);
264 
265  KeyWords CurrDesc = KeyWords(HP.GetDescription());
266  /* legge i dati di controllo */
267  if (CurrDesc != BEGIN) {
268  DEBUGCERR("");
269  silent_cerr("<begin> expected at line "
270  << HP.GetLineData() << std::endl);
271 
273  }
274 
275  if (KeyWords(HP.GetWord()) != CONTROLDATA) {
276  DEBUGCERR("");
277  silent_cerr("<begin: control data;> expected at line "
278  << HP.GetLineData() << std::endl);
279 
281  }
282 
283  ReadControl(HP, sInputFileName);
284  try {
285  CurrDesc = KeyWords(HP.GetDescription());
286  } catch (EndOfFile) {
287  NO_OP;
288  }
289 
290  /* fine lettura dati di controllo */
291 
292 
293 
294  /*
295  * a questo punto ElemManager contiene i numeri totali di elementi;
296  * NodeManager contiene i numeri totali di nodi;
297  * DofManager contiene i numeri totali di potenziali possessori di gradi
298  * di liberta'; quindi si puo' cominciare ad allocare matrici
299  */
300 
301 
302 
303  /* Costruzione struttura DofData e creazione array DofOwner */
304  DofDataInit();
305 
306  /* Costruzione struttura NodeData e creazione array Node* */
307  NodeDataInit();
308 
309  /*
310  * legge i nodi, crea gli item della struttura ppNodes
311  * e contemporaneamente aggiorna i dof
312  */
313  if (iTotNodes > 0) {
314  if (CurrDesc != BEGIN) {
315  DEBUGCERR("");
316  silent_cerr("<begin> expected at line "
317  << HP.GetLineData() << std::endl);
318 
320  }
321 
322  if (KeyWords(HP.GetWord()) != NODES) {
323  DEBUGCERR("");
324  silent_cerr("<begin: nodes;> expected at line "
325  << HP.GetLineData() << std::endl);
326 
328  }
329 
330  ReadNodes(HP);
331  try {
332  CurrDesc = KeyWords(HP.GetDescription());
333  } catch (EndOfFile) {}
334  } else {
335  DEBUGCERR("");
336  silent_cerr("warning, no nodes are defined" << std::endl);
337  }
338  /* fine lettura nodi */
339 
340  /*
341  * Costruzione struttura ElemData, DriveData
342  * e creazione array Elem* e Drive*
343  */
344  ElemDataInit();
345 
346  /* legge i drivers, crea la struttura ppDrive */
347  bool bGotDrivers = false;
348  if (iTotDrive > 0) {
349  if (CurrDesc != BEGIN) {
350  DEBUGCERR("");
351  silent_cerr("\"begin\" expected at line "
352  << HP.GetLineData() << std::endl);
353 
355  }
356 
357  if (KeyWords(HP.GetWord()) != DRIVERS) {
358  DEBUGCERR("");
359  silent_cerr("\"begin: drivers;\" expected at line "
360  << HP.GetLineData() << std::endl);
361 
363  }
364 
365  bGotDrivers = true;
366 
367  ReadDrivers(HP);
368  try {
369  CurrDesc = KeyWords(HP.GetDescription());
370  } catch (EndOfFile) {}
371 
372  } else {
373  DEBUGCERR("warning, no drivers are defined" << std::endl);
374  }
375 
376  /* fine lettura drivers */
377 
378 
379  /*
380  * legge gli elementi, crea la struttura ppElems
381  * e contemporaneamente aggiorna i dof
382  */
383  if (!Elems.empty()) {
384  if (CurrDesc != BEGIN) {
385  DEBUGCERR("");
386  silent_cerr("\"begin\" expected at line "
387  << HP.GetLineData() << std::endl);
388 
390  }
391 
392  switch (KeyWords(HP.GetWord())) {
393  case ELEMENTS:
394  break;
395 
396  case DRIVERS:
397  if (!bGotDrivers) {
398  silent_cerr("got unexpected \"begin: drivers;\" "
399  "at line " << HP.GetLineData() << std::endl
400  << "(hint: define \"file drivers\" in \"control data\" block)"
401  << std::endl);
402  }
403  // fallthru
404 
405  default:
406  DEBUGCERR("");
407  silent_cerr("\"begin: elements;\" expected at line "
408  << HP.GetLineData() << std::endl);
409 
411  }
412 
413  ReadElems(HP);
414 #if 0
415  /* FIXME: we don't check extra statements after "end: elements;"
416  * because there might be more... */
417  try {
418  CurrDesc = KeyWords(HP.GetDescription());
419  } catch (EndOfFile) {}
420 #endif
421  } else {
422  DEBUGCERR("");
423  silent_cerr("warning, no elements are defined" << std::endl);
424  }
425 
426  if (bOutputFrames) {
429  }
430 
431  /* fine lettura elementi */
432 
433  // if output is defined and at least one node wants to output,
434  // open file
435  for (int i = 0; i < Node::LASTNODETYPE; i++) {
436  if (NodeData[i].OutFile != OutputHandler::UNKNOWN)
437  {
438  for (NodeContainerType::const_iterator n = NodeData[i].NodeContainer.begin();
439  n != NodeData[i].NodeContainer.end(); ++n)
440  {
441  if (n->second->bToBeOutput()) {
442  OutHdl.Open(NodeData[i].OutFile);
443  break;
444  }
445  }
446  }
447  }
448 
449  // if output is defined and at least one element wants to output,
450  // open file
451  for (int i = 0; i < Elem::LASTELEMTYPE; i++) {
452  if (ElemData[i].OutFile != OutputHandler::UNKNOWN)
453  {
454  for (ElemContainerType::const_iterator e = ElemData[i].ElemContainer.begin();
455  e != ElemData[i].ElemContainer.end(); ++e)
456  {
457  if (e->second->bToBeOutput()) {
458  OutHdl.Open(ElemData[i].OutFile);
459  break;
460  }
461  }
462  }
463  }
464 
465  // open drive output & trave files only if needed
467  for (MBDynParser::DCType::const_iterator i = DC.begin(); i != DC.end(); ++i) {
468  if (i->second->fToBeTraced()) {
470  break;
471  }
472  }
473 
474  for (MBDynParser::DCType::const_iterator i = DC.begin(); i != DC.end(); ++i) {
475  if (i->second->bToBeOutput()) {
477  break;
478  }
479  }
480 
481  /* Verifica dei dati di controllo */
482 #ifdef DEBUG
484  /* mostra in modo succinto il numero di DofOwner per tipo */
485  for (int i = 0; i < DofOwner::LASTDOFTYPE; i++) {
486  std::cout << "DofType " << i << " "
487  "(" << psDofOwnerNames[i] << "), "
488  "n. of owners: " << DofData[i].iNum
489  << std::endl;
490  }
491 
492  /* mostra in modo succinto il numero di nodi per tipo */
493  for (int i = 0; i < Node::LASTNODETYPE; i++) {
494  std::cout << "NodeType " << i << " "
495  "(" << psNodeNames[i] << "), "
496  "n. of nodes: " << NodeData[i].NodeContainer.size()
497  << std::endl;
498  }
499 
500  /* mostra in modo succinto il numero di elementi per tipo */
501  for (int i = 0; i < Elem::LASTELEMTYPE; i++) {
502  std::cout << "Element Type " << i << " "
503  "(" << psElemNames[i] << "), "
504  "n. of elems: " << ElemData[i].ElemContainer.size()
505  << std::endl;
506  }
507 
508  /* mostra in modo succinto il numero di drivers per tipo */
509  for (int i = 0; i < Drive::LASTDRIVETYPE; i++) {
510  std::cout << "DriveType " << i << " "
511  "(" << psDriveNames[i] << "), "
512  "n. of drivers: " << DriveData[i].iNum
513  << std::endl;
514  }
515  }
516 #endif /* DEBUG */
517 
518  if (bAbortAfterInput) {
519  silent_cout("Only input is required" << std::endl);
520  return;
521  }
522 
523 #ifdef USE_SOCKET
524  /* waits for all pending sockets to connect */
525  WaitSocketUsers();
526 #endif // USE_SOCKET
527 
528  /* Qui intercetto la struttura dei Dof prima che venga costruita e modifico
529  * in modo che sia adatta all'assemblaggio dei vincoli; quindi la resetto
530  * e la lascio generare correttamente.
531  * L'assemblaggio iniziale viene gestito dal DataManager perche'
532  * concettualmente la consistenza dei dati deve essere assicurata da lui,
533  * che conosce gli aspetti fisici del problema
534  */
535 
537  for (int i = 0; i < Elem::LASTELEMTYPE; ++i) {
538  if (ElemData[i].bToBeUsedInAssembly() && !ElemData[i].ElemContainer.empty()) {
540  break;
541  }
542  }
543  }
544 
548 
549  } else {
550  silent_cout("Skipping initial joints assembly" << std::endl);
551  }
552 
553  } else {
554  silent_cout("No initial assembly is required since no joints are defined"
555  << std::endl);
556  }
557 
558  /* Costruzione dei dati dei Dof definitivi da usare nella simulazione */
559 
560  /* Aggiornamento DofOwner degli elementi (e dei nodi) */
561  if (bInverseDynamics) {
562  IDDofOwnerSet();
563  } else {
564  DofOwnerSet();
565  }
566 
567  /* Verifica dei dati di controllo */
568 #ifdef DEBUG
570  /* mostra in modo succinto i DofOwners */
571  int k = 0;
572  for (int i = 0; i < DofOwner::LASTDOFTYPE; i++) {
573  std::cout << "DofType " << i << ':' << std::endl;
574  for (int j = 0; j < DofData[i].iNum; j++) {
575  std::cout << "DofOwner " << j << ", n. of dofs: "
576  << DofOwners[k++].iNumDofs << std::endl;
577  }
578  }
579  }
580 #endif /* DEBUG */
581 
582  /* a questo punto i dof sono completamente scritti in quanto a numero.
583  * Rimane da sistemare il vettore con gli indici "interni" ed il tipo */
584 
585  /* Costruzione array DofOwner e Dof */
586  if(bInverseDynamics) {
587  IDDofInit();
588  } else {
589  DofInit();
590  }
591 
592  /* Aggiornamento Dof di proprieta' degli elementi e dei nodi */
593 // if(bInverseDynamics) {
594 // InverseDofOwnerInit();
595 // } else {
596  DofOwnerInit();
597 // }
598 
599  /* Creazione strutture di lavoro per assemblaggio e residuo */
600  ElemAssInit();
601 
602 #ifdef DEBUG
604  for (int iCnt = 0; iCnt < iTotDofs; iCnt++) {
605  std::cout << "Dof " << std::setw(4) << iCnt+1 << ": order "
606  << Dofs[iCnt].Order << std::endl;
607  }
608  }
609 #endif /* DEBUG */
610 
611 
612 } /* End of DataManager::DataManager() */
integer iTotDofOwners
Definition: dataman.h:795
std::ostream & ReferenceFrames(void) const
Definition: output.h:534
eRestart RestartEvery
Definition: dataman.h:164
integer iMaxWorkNumItemsJac
Definition: dataman.h:628
#define DEBUG_LEVEL_MATCH(level)
Definition: myassert.h:241
ElemVecType Elems
Definition: dataman.h:609
MathParser::PlugIn * node_priv_plugin(MathParser &mp, void *arg)
Definition: privpgin.cc:299
ElemContainerType ElemContainer
Definition: dataman.h:591
const bool bDefaultSkipInitialJointAssembly(false)
doublereal dEpsilon
Definition: dataman.h:126
VariableSubMatrixHandler * pWorkMatA
Definition: dataman.h:630
char * sSimulationTitle
Definition: dataman.h:158
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
MathParser & MathPar
Definition: dataman.h:98
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
int mbdyn_cleanup_register(mbdyn_cleanup_f handler, void ***datapp)
Definition: cleanup.cc:62
const DCType & GetDriveCallerContainer(void) const
Definition: mbpar.cc:854
DofVecType Dofs
Definition: dataman.h:813
integer iMaxWorkNumRowsRes
Definition: dataman.h:625
int iIDNodeTotNumDofs
Definition: dataman.h:134
struct DataManager::@29 DriveData[Drive::LASTDRIVETYPE]
void ElemManager(void)
Definition: elman.cc:51
void ReadControl(MBDynParser &HP, const char *sInputFileName)
Definition: dataman3.cc:68
int RegisterNameSpace(NameSpace *ns)
Definition: mathp.cc:4602
doublereal dInitialPositionStiffness
Definition: dataman.h:121
bool bOmegaRotates
Definition: dataman.h:123
integer iCurrRestartTime
Definition: dataman.h:170
OutputHandler OutHdl
Definition: dataman.h:105
unsigned int iTotNodes
Definition: dataman.h:748
MySubVectorHandler * pWorkVec
Definition: dataman.h:633
void ReadNodes(MBDynParser &HP)
Definition: dataman3.cc:1557
void DofOwnerSet(void)
Definition: dataman2.cc:1368
VariableSubMatrixHandler * pWorkMatB
Definition: dataman.h:631
void NodeDataInit(void)
Definition: nodeman.cc:98
#define DEBUGCERR(msg)
Definition: myassert.h:235
unsigned int iTotDrive
Definition: dataman.h:622
#define NO_OP
Definition: myassert.h:74
integer iMaxInitialIterations
Definition: dataman.h:125
int iIDJointTotNumDofs
Definition: dataman.h:135
std::vector< DofOwner > DofOwners
Definition: dataman.h:796
virtual const LinSol & GetLinearSolver(void) const
Definition: solver.h:401
void DofOwnerInit(void)
Definition: dataman2.cc:182
void InitialJointAssembly(void)
Definition: dataman2.cc:679
bool bInverseDynamics
Definition: dataman.h:133
NodeContainerType NodeContainer
Definition: dataman.h:731
void DofDataInit(void)
Definition: dofman.cc:69
integer iTotDofs
Definition: dataman.h:809
bool Open(const OutputHandler::OutFiles out)
Definition: output.cc:298
bool bSkipInitialJointAssembly
Definition: dataman.h:117
bool saveXSol
Definition: dataman.h:175
void ReadDrivers(MBDynParser &HP)
Definition: dataman3.cc:2187
VectorHandler * pXPrimePrimeCurr
Definition: dataman.h:112
void IDDofOwnerSet(void)
Definition: invdataman.cc:852
void DofInit(void)
Definition: dofman.cc:111
const bool bDefaultInitialJointAssemblyToBeMade(false)
doublereal dRestartTime
Definition: dataman.h:166
std::map< unsigned, const DriveCaller * > DCType
Definition: mbpar.h:207
void ** ppCleanupData
Definition: dataman.h:89
integer iMaxWorkNumRowsJac
Definition: dataman.h:626
void IDDofInit(void)
Definition: invdataman.cc:895
Solver * pSolver
Definition: dataman.h:99
int ResMode
Definition: dataman.h:201
DriveCaller * pOutputMeter
Definition: dataman.h:179
doublereal dLastRestartTime
Definition: dataman.h:173
RigidBodyKinematics * pRBK
Definition: dataman.h:129
SolverDiagnostics(unsigned OF=OUTPUT_DEFAULT, DriveCaller *pOM=0)
int GetDescription(void)
Definition: parser.cc:730
void NodeManager(void)
Definition: nodeman.cc:44
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
void SetExceptions(std::ios::iostate flags)
Definition: output.cc:678
const char * psDofOwnerNames[]
Definition: enums.cc:423
integer iMaxWorkNumColsJac
Definition: dataman.h:627
void ReadElems(MBDynParser &HP)
Definition: dataman4.cc:157
int datamanager_cleanup(void *data)
Definition: dataman.cc:914
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
bool bOutputFrames
Definition: dataman.h:118
virtual MathParser & GetMathParser(void)
Definition: parser.cc:668
doublereal dInitialAssemblyTol
Definition: dataman.h:124
integer iRestartIterations
Definition: dataman.h:165
VecIter< Elem * > ElemIter
Definition: dataman.h:612
OrientationDescription od
Definition: dataman.h:229
bool bInitialJointAssemblyToBeDone
Definition: dataman.h:116
KeyWords
Definition: dataman4.cc:94
VectorHandler * pLambdaCurr
Definition: dataman.h:113
doublereal dInitialVelocityStiffness
Definition: dataman.h:122
const doublereal dDefaultInitialStiffness
Definition: dataman.cc:80
integer iOutputCount
Definition: dataman.h:180
const bool bDefaultOmegaRotates(false)
void SetTime(const doublereal &dTime, const doublereal &dTimeStep=-1., const integer &iStep=-1, bool bServePending=true)
Definition: dataman2.cc:139
const integer iDefaultMaxInitialIterations
Definition: dataman.cc:83
bool bOutputDriveCaller
Definition: dataman.h:120
integer iCurrRestartIter
Definition: dataman.h:172
char * solArrFileName
Definition: dataman.h:176
Drive ** ppDrive
Definition: dataman.h:621
const char * psNodeNames[]
Definition: enums.cc:372
void DofManager(void)
Definition: dofman.cc:40
MathParser::PlugIn * elem_priv_plugin(MathParser &mp, void *arg)
Definition: privpgin.cc:308
doublereal * pdRestartTimes
Definition: dataman.h:168
const char * psElemNames[]
Definition: enums.cc:39
virtual int GetWord(void)
Definition: parser.cc:1083
MathParser::PlugIn * dof_plugin(MathParser &mp, void *arg)
Definition: dofpgin.cc:278
bool bStaticModel
Definition: dataman.h:130
MBDynParser & MBPar
Definition: dataman.h:97
LinSol CurrSolver
Definition: dataman.h:127
void InitUDE(void)
Definition: userelem.cc:107
integer iNumRestartTimes
Definition: dataman.h:169
void InitDriveData(void)
Definition: drive_.cc:3002
const doublereal dDefaultInitialAssemblyTol
Definition: dataman.cc:82
DriveHandler DrvHdl
Definition: dataman.h:104
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
int RegisterPlugIn(const char *name, MathParser::PlugIn *(*)(MathParser &, void *), void *arg)
Definition: mathp.cc:4584
void ElemDataInit(void)
Definition: elman.cc:248
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
Table & GetSymbolTable(void) const
Definition: mathp.cc:1931
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
unsigned uPrintFlags
Definition: dataman.h:156
VariableSubMatrixHandler * pWorkMat
Definition: dataman.h:632
void OutputFrames(std::ostream &out) const
Definition: mbpar.cc:1323
void InitGustData(void)
Definition: gust.cc:212
bool bOutputAccels
Definition: dataman.h:119
VectorHandler * pXCurr
Definition: dataman.h:108
void ElemAssInit(void)
Definition: elman.cc:318
const char * psDriveNames[]
Definition: enums.cc:351

Here is the call graph for this function:

DataManager::~DataManager ( void  )
virtual

Definition at line 618 of file dataman.cc.

References ATEND, DestroyDriveData(), DestroyGustData(), DestroyUDE(), DofManagerDestructor(), ElemManagerDestructor(), MakeRestart(), module_finalize(), NodeManagerDestructor(), pOutputMeter, ppCleanupData, pRBK, RestartEvery, SAFEDELETE, SAFEDELETEARR, and sSimulationTitle.

619 {
620  *ppCleanupData = 0;
621 
622  /* Se e' richiesto il file di restart, il distruttore del DataManager
623  * crea il file e forza gli oggetti a scrivere il loro contributo nel modo
624  * opportuno
625  */
626  if (RestartEvery == ATEND) {
627  MakeRestart();
628  }
629 
630  if (sSimulationTitle != 0) {
632  sSimulationTitle = 0;
633  }
634 
635  if (pOutputMeter) {
637  pOutputMeter = 0;
638  }
639 
640 #ifdef MBDYN_FDJAC
641  if (pFDJacMeter) {
642  SAFEDELETE(pFDJacMeter);
643  pFDJacMeter = 0;
644  }
645 #endif // MBDYN_FDJAC
646 
647  if (pRBK) {
648  SAFEDELETE(pRBK);
649  pRBK = 0;
650  }
651 
655 
657  DestroyUDE();
658  DestroyGustData();
659 
660 #if defined(USE_RUNTIME_LOADING)
661  if (moduleInitialized) {
662  module_finalize();
663  }
664 #endif // USE_RUNTIME_LOADING
665 } /* End of DataManager::DataManager() */
eRestart RestartEvery
Definition: dataman.h:164
char * sSimulationTitle
Definition: dataman.h:158
void module_finalize(void)
Definition: modules.cc:67
void DofManagerDestructor(void)
Definition: dofman.cc:56
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
void ** ppCleanupData
Definition: dataman.h:89
void ElemManagerDestructor(void)
Definition: elman.cc:196
DriveCaller * pOutputMeter
Definition: dataman.h:179
void NodeManagerDestructor(void)
Definition: nodeman.cc:84
virtual void MakeRestart(void)
Definition: dataman.cc:699
RigidBodyKinematics * pRBK
Definition: dataman.h:129
void DestroyGustData(void)
Definition: gust.cc:233
void DestroyDriveData(void)
Definition: drive_.cc:3028
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710
void DestroyUDE(void)
Definition: userelem.cc:134

Here is the call graph for this function:

Member Function Documentation

void DataManager::AfterConvergence ( void  ) const
virtual

Reimplemented in SchurDataManager.

Definition at line 2527 of file dataman2.cc.

References SimulationEntity::AfterConvergence(), ASSERT, VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), Solver::dGetInitialTimeStep(), DriveHandler::dGetTime(), dLastRestartTime, dRestartTime, DrvHdl, ElemIter, iCurrRestartIter, iCurrRestartTime, iNumRestartTimes, iRestartIterations, ITERATIONS, MakeRestart(), NEVER, Nodes, pdRestartTimes, pSolver, pXCurr, pXPrimeCurr, RestartEvery, TIME, and TIMES.

Referenced by DerivativeSolver::Advance(), Step1Integrator::Advance(), and Step2Integrator::Advance().

2528 {
2529  for (NodeVecType::const_iterator i = Nodes.begin(); i != Nodes.end(); ++i) {
2530  (*i)->AfterConvergence(*pXCurr, *pXPrimeCurr);
2531  }
2532 
2533  /* Versione con iteratore: */
2534  Elem* pEl = NULL;
2535  if (ElemIter.bGetFirst(pEl)) {
2536  do {
2537  pEl->AfterConvergence(*pXCurr,
2538  *pXPrimeCurr);
2539  } while (ElemIter.bGetNext(pEl));
2540  }
2541 
2542  /* Restart condizionato */
2543  switch (RestartEvery) {
2544  case NEVER:
2545  break;
2546 
2547  case ITERATIONS:
2549  iCurrRestartIter = 0;
2550  const_cast<DataManager *>(this)->MakeRestart();
2551  }
2552  break;
2553 
2554  case TIME: {
2555  doublereal dT = DrvHdl.dGetTime();
2556  if (dT - dLastRestartTime >= dRestartTime) {
2557  dLastRestartTime = dT;
2558  const_cast<DataManager *>(this)->MakeRestart();
2559  }
2560  break;
2561  }
2562 
2563  case TIMES: {
2564  doublereal dT = DrvHdl.dGetTime()
2565  + pSolver->dGetInitialTimeStep()/100.;
2567  break;
2568  }
2569 
2571 
2572  if (dT >= pdRestartTimes[iCurrRestartTime]) {
2573  iCurrRestartTime++;
2574  const_cast<DataManager *>(this)->MakeRestart();
2575  }
2576  break;
2577  }
2578 
2579  default:
2580  ASSERT(0);
2581  break;
2582  }
2583 }
eRestart RestartEvery
Definition: dataman.h:164
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
NodeVecType Nodes
Definition: dataman.h:743
integer iCurrRestartTime
Definition: dataman.h:170
doublereal dRestartTime
Definition: dataman.h:166
Solver * pSolver
Definition: dataman.h:99
virtual void MakeRestart(void)
Definition: dataman.cc:699
doublereal dLastRestartTime
Definition: dataman.h:173
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
integer iRestartIterations
Definition: dataman.h:165
#define ASSERT(expression)
Definition: colamd.c:977
VecIter< Elem * > ElemIter
Definition: dataman.h:612
integer iCurrRestartIter
Definition: dataman.h:172
Definition: elem.h:75
doublereal * pdRestartTimes
Definition: dataman.h:168
virtual void AfterConvergence(const VectorHandler &X, const VectorHandler &XP)
Definition: simentity.cc:120
doublereal dGetTime(void) const
Definition: drive.h:386
integer iNumRestartTimes
Definition: dataman.h:169
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
DriveHandler DrvHdl
Definition: dataman.h:104
double doublereal
Definition: colamd.c:52
virtual doublereal dGetInitialTimeStep(void) const
Definition: solver.h:417
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AfterPredict ( void  ) const
virtual

Reimplemented in SchurDataManager.

Definition at line 2472 of file dataman2.cc.

References SimulationEntity::AfterPredict(), VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), ElemIter, Elem::GetElemType(), WithLabel::GetLabel(), m_IsConverged, Nodes, Converged::NOT_CONVERGED, psElemNames, psNodeNames, pXCurr, and pXPrimeCurr.

Referenced by DerivativeSolver::Advance(), Step1Integrator::Advance(), Step2Integrator::Advance(), and ThirdOrderIntegrator::Predict().

2473 {
2474  /* reset any external convergence requirement before starting
2475  * a new step */
2476  for (Converged_t::iterator i = m_IsConverged.begin();
2477  i != m_IsConverged.end(); ++i)
2478  {
2480  }
2481 
2482  for (NodeVecType::const_iterator i = Nodes.begin(); i != Nodes.end(); ++i) {
2483  try {
2484  (*i)->AfterPredict(*pXCurr, *pXPrimeCurr);
2485  }
2486  catch (Elem::ChangedEquationStructure& e) {
2487  // ignore by now
2488  silent_cerr("DataManager::AfterPredict: "
2489  "warning, caught Elem::ChangedEquationStructure while processing "
2490  << psNodeNames[(*i)->GetNodeType()] << "(" << (*i)->GetLabel() << ")" << std::endl);
2491  }
2492  }
2493 
2494  Elem* pEl = 0;
2495  if (ElemIter.bGetFirst(pEl)) {
2496  do {
2497  try {
2498  pEl->AfterPredict(*pXCurr, *pXPrimeCurr);
2499  }
2501  // ignore by now
2502  silent_cerr("DataManager::AfterPredict: "
2503  "warning, caught Elem::ChangedEquationStructure while processing "
2504  << psElemNames[pEl->GetElemType()] << "(" << pEl->GetLabel() << ")" << std::endl);
2505  }
2506  } while (ElemIter.bGetNext(pEl));
2507  }
2508 }
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
NodeVecType Nodes
Definition: dataman.h:743
Converged_t m_IsConverged
Definition: dataman.h:399
virtual Elem::Type GetElemType(void) const =0
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
VecIter< Elem * > ElemIter
Definition: dataman.h:612
const char * psNodeNames[]
Definition: enums.cc:372
Definition: elem.h:75
const char * psElemNames[]
Definition: enums.cc:39
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
virtual void AfterPredict(VectorHandler &X, VectorHandler &XP)
Definition: simentity.cc:91
unsigned int GetLabel(void) const
Definition: withlab.cc:62
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssConstrJac ( MatrixHandler JacHdl)
virtual

Definition at line 94 of file invdataman.cc.

References ASSERT, DEBUGCOUT, ElemIter, Elems, and pWorkMat.

Referenced by InverseDynamicsStepSolver::Jacobian().

95 {
96  DEBUGCOUT("Entering DataManager::AssJac()" << std::endl);
97 
98  ASSERT(pWorkMat != NULL);
99  ASSERT(Elems.begin() != Elems.end());
100 
101  AssConstrJac(JacHdl, ElemIter, *pWorkMat);
102 }
ElemVecType Elems
Definition: dataman.h:609
#define DEBUGCOUT(msg)
Definition: myassert.h:232
#define ASSERT(expression)
Definition: colamd.c:977
VecIter< Elem * > ElemIter
Definition: dataman.h:612
virtual void AssConstrJac(MatrixHandler &JacHdl)
Definition: invdataman.cc:94
VariableSubMatrixHandler * pWorkMat
Definition: dataman.h:632
void DataManager::AssConstrJac ( MatrixHandler JacHdl,
VecIter< Elem * > &  Iter,
VariableSubMatrixHandler WorkMat 
)
protected

Definition at line 105 of file invdataman.cc.

References VariableSubMatrixHandler::AddToT(), ASSERT, Elem::AssJac(), Beam2::AssJac(), Elem::BEAM, Elem::bIsErgonomy(), Joint::bIsPrescribedMotion(), Joint::bIsTorque(), Elem::BODY, DEBUGCOUT, Body::dGetM(), DriveHandler::dGetTimeStep(), DrvHdl, DataManager::ElemDataStructure::ElemContainer, ElemData, InverseDynamics::FULLY_ACTUATED_COLLOCATED, InverseDynamics::FULLY_ACTUATED_NON_COLLOCATED, Body::GetJ(), InverseDynamicsStepSolver::GetOrder(), InverseSolver::GetProblemType(), Body::GetS(), InverseSolver::GetWeight(), DofOwnerOwner::iGetFirstIndex(), SimulationEntity::iGetNumDof(), Elem::iGetNumDof(), InverseDynamics::INVERSE_DYNAMICS, Elem::JOINT, Elem::JOINT_REGULARIZATION, MBDYN_EXCEPT_ARGS, DataManager::NodeDataStructure::NodeContainer, NodeData, Body::pGetNode(), Solver::pGetStepIntegrator(), InverseDynamics::POSITION, pSolver, pXCurr, MatrixHandler::Reset(), Node::STRUCTURAL, InverseDynamics::UNDERDETERMINED_FULLY_ACTUATED, and InverseDynamics::UNDERDETERMINED_UNDERACTUATED_COLLOCATED.

108 {
109  DEBUGCOUT("Entering DataManager::AssJac()" << std::endl);
110 
111  JacHdl.Reset();
112 
113  InverseSolver *pIDS = dynamic_cast<InverseSolver *>(pSolver);
114 
115  switch (pIDS->GetProblemType()) {
117  for (ElemContainerType::iterator j = ElemData[Elem::JOINT].ElemContainer.begin();
118  j != ElemData[Elem::JOINT].ElemContainer.end(); ++j)
119  {
120  Joint *pJ = Cast<Joint>(j->second);
121  if (pJ->bIsPrescribedMotion()) {
122  ASSERT(pJ->bIsTorque());
123  JacHdl += j->second->AssJac(WorkMat, *pXCurr);
124  }
125  }
126  break;
127 
130  silent_cerr("DataManager::AssConstrJac(" << pIDS->GetProblemType() << ") not implemented yet" << std::endl);
132 
134  // NOTE: in this case, the name of the function is misleading,
135  // since it assembles the entire problem's Jacobian matrix
136  // and not only the Jacobian matrix of the constraints
139  for (ElemContainerType::iterator j = ElemData[Elem::JOINT].ElemContainer.begin();
140  j != ElemData[Elem::JOINT].ElemContainer.end(); ++j)
141  {
142  bool bActive(true);
143  Joint *pJ = Cast<Joint>(j->second, true);
144  if (pJ == 0) {
145  bActive = false;
146  pJ = Cast<Joint>(j->second, false);
147  }
148 
149  if (pJ->bIsTorque() && bActive) {
150  JacHdl += pJ->AssJac(WorkMat, *pXCurr);
151  WorkMat.AddToT(JacHdl);
152 
153  } else if (pJ->bIsPrescribedMotion() || (pJ->bIsTorque() && !bActive)) {
154  integer iNumDof = pJ->iGetNumDof();
155  integer iFirstIndex = pJ->iGetFirstIndex();
156  for (int iCnt = 1; iCnt <= iNumDof; iCnt++) {
157  JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) = 1.;
158  }
159  }
160  }
161 
162  // FIXME: regularization could be needed also in other phases
163  // may need to be related to the state of the regularized joint
164  for (ElemContainerType::iterator j = ElemData[Elem::JOINT_REGULARIZATION].ElemContainer.begin();
166  {
167  JointRegularization *pJ = Cast<JointRegularization>(j->second, true);
168  if (pJ) {
169  JacHdl += pJ->AssJac(WorkMat, *pXCurr);
170  }
171  }
172 
173 #if 0
174  // this _should_ be harmless...
175  for (NodeContainerType::const_iterator n = NodeData[Node::STRUCTURAL].NodeContainer.begin();
176  n != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++n)
177  {
178  ASSERT(n->second->iGetNumDof() == 6);
179  integer iFirstIndex = n->second->iGetFirstIndex();
180 
181  for (integer iCnt = 1; iCnt <= 6; iCnt++) {
182  JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) += 1.;
183  }
184  }
185 #endif
186 
187  } else {
188  doublereal dw1, dw2;
189  pIDS->GetWeight(pIDSS->GetOrder(), dw1, dw2);
190  if (dw1 > 0.) {
191  for (NodeContainerType::const_iterator n = NodeData[Node::STRUCTURAL].NodeContainer.begin();
192  n != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++n)
193  {
194  ASSERT(n->second->iGetNumDof() == 6);
195  integer iFirstIndex = n->second->iGetFirstIndex();
196 
197  for (integer iCnt = 1; iCnt <= 6; iCnt++) {
198  JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) += dw1;
199  }
200  }
201  }
202 
203  if (dw2 > 0.) {
204 // DO NOT ENABLE, BROKEN
205 //#define TORQUE_OPTIMIZATION
206 #ifdef TORQUE_OPTIMIZATION
207  if (pIDSS->GetOrder() == InverseDynamics::POSITION) {
209  dw2 /= h*h;
210  }
211 #endif // TORQUE_OPTIMIZATION
212 
213  for (ElemContainerType::const_iterator b = ElemData[Elem::BODY].ElemContainer.begin();
214  b != ElemData[Elem::BODY].ElemContainer.end(); ++b)
215  {
216  if (!b->second->bIsErgonomy()) {
217  continue;
218  }
219 
220  const Body *pBody(Cast<Body>(b->second));
221  doublereal dm(pBody->dGetM()*dw2);
222  Vec3 S(pBody->GetS()*dw2);
223  Mat3x3 J = (pBody->GetJ()*dw2);
224  const StructNode *pNode = pBody->pGetNode();
225  ASSERT(pNode->iGetNumDof() == 6);
226  integer iFirstIndex = pNode->iGetFirstIndex();
227 
228  for (int iRow = 1; iRow <= 3; iRow++) {
229  JacHdl(iFirstIndex + iRow, iFirstIndex + iRow) += dm;
230 
231  for (int iCol = 1; iCol <= 3; iCol++) {
232  JacHdl(iFirstIndex + 3 + iRow, iFirstIndex + 3 + iCol) += J(iRow, iCol);
233  }
234  }
235 
236  JacHdl(iFirstIndex + 3 + 1, iFirstIndex + 2) = -S(3); // 1, 2
237  JacHdl(iFirstIndex + 3 + 1, iFirstIndex + 3) = S(2); // 1, 3
238  JacHdl(iFirstIndex + 3 + 2, iFirstIndex + 3) = -S(1); // 2, 3
239  JacHdl(iFirstIndex + 3 + 2, iFirstIndex + 1) = S(3); // 2, 1
240  JacHdl(iFirstIndex + 3 + 3, iFirstIndex + 1) = -S(2); // 3, 1
241  JacHdl(iFirstIndex + 3 + 3, iFirstIndex + 2) = S(1); // 3, 2
242 
243  JacHdl(iFirstIndex + 2, iFirstIndex + 3 + 1) = -S(3); // 2, 1
244  JacHdl(iFirstIndex + 3, iFirstIndex + 3 + 1) = S(2); // 3, 1
245  JacHdl(iFirstIndex + 3, iFirstIndex + 3 + 2) = -S(1); // 3, 2
246  JacHdl(iFirstIndex + 1, iFirstIndex + 3 + 2) = S(3); // 1, 2
247  JacHdl(iFirstIndex + 1, iFirstIndex + 3 + 3) = -S(2); // 1, 3
248  JacHdl(iFirstIndex + 2, iFirstIndex + 3 + 3) = S(1); // 2, 3
249  }
250  }
251 
252  for (ElemContainerType::iterator j = ElemData[Elem::JOINT].ElemContainer.begin();
253  j != ElemData[Elem::JOINT].ElemContainer.end(); ++j)
254  {
255  bool bActive(true);
256  Joint *pJ = Cast<Joint>(j->second, true);
257  if (pJ == 0) {
258  bActive = false;
259  pJ = Cast<Joint>(j->second, false);
260  }
261 
262  if (pJ->bIsPrescribedMotion() && bActive) {
263  JacHdl += pJ->AssJac(WorkMat, *pXCurr);
264  WorkMat.AddToT(JacHdl);
265 
266  } else if (pJ->bIsErgonomy() && bActive && pIDSS->GetOrder() == InverseDynamics::POSITION) {
267  JacHdl += pJ->AssJac(WorkMat, *pXCurr);
268 
269  } else if (pJ->bIsTorque() || (pJ->bIsPrescribedMotion() && !bActive)) {
270  integer iNumDof = pJ->iGetNumDof();
271  integer iFirstIndex = pJ->iGetFirstIndex();
272  for (int iCnt = 1; iCnt <= iNumDof; iCnt++) {
273  JacHdl(iFirstIndex + iCnt, iFirstIndex + iCnt) = 1.;
274  }
275  }
276  }
277 
278  for (ElemContainerType::iterator j = ElemData[Elem::BEAM].ElemContainer.begin();
279  j != ElemData[Elem::BEAM].ElemContainer.end(); ++j)
280  {
281  bool bActive(true);
282  Beam2 *pB = Cast<Beam2>(j->second, true);
283  if (pB == 0) {
284  bActive = false;
285  pB = Cast<Beam2>(j->second, false);
286  }
287 
288  if (pB && pB->bIsErgonomy() && bActive && pIDSS->GetOrder() == InverseDynamics::POSITION) {
289  JacHdl += pB->AssJac(WorkMat, *pXCurr);
290  }
291  }
292  }
293  } break;
294 
295  default:
296  ASSERT(0);
298  }
299 }
ElemContainerType ElemContainer
Definition: dataman.h:591
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: body.h:270
Definition: matvec3.h:98
bool bIsErgonomy(void) const
Definition: elem.cc:83
Definition: beam2.h:50
MatrixHandler & AddToT(MatrixHandler &MH) const
Definition: submat.h:1277
InverseDynamics::Type GetProblemType(void) const
Definition: invsolver.cc:889
NodeContainerType NodeContainer
Definition: dataman.h:731
virtual void Reset(void)=0
bool bIsPrescribedMotion(void) const
Definition: joint.cc:170
virtual StepIntegrator * pGetStepIntegrator(void) const
Definition: solver.h:407
InverseDynamics::Order GetOrder(void) const
Definition: stepsol.cc:1516
Solver * pSolver
Definition: dataman.h:99
doublereal dGetTimeStep(void) const
Definition: drive.h:393
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
#define DEBUGCOUT(msg)
Definition: myassert.h:232
#define ASSERT(expression)
Definition: colamd.c:977
virtual unsigned int iGetNumDof(void) const
Definition: elem.cc:118
virtual unsigned int iGetNumDof(void) const =0
bool bIsTorque(void) const
Definition: joint.cc:176
Definition: joint.h:50
DriveHandler DrvHdl
Definition: dataman.h:104
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
void GetWeight(InverseDynamics::Order iOrder, doublereal &dw1, doublereal &dw2) const
Definition: invsolver.cc:895
long int integer
Definition: colamd.c:51
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: beam2.cc:485
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssConstrRes ( VectorHandler ResHdl,
InverseDynamics::Order  iOrder 
)
virtual

Definition at line 303 of file invdataman.cc.

References DEBUGCOUT, ElemIter, and pWorkVec.

Referenced by InverseDynamicsStepSolver::Residual().

304 {
305  DEBUGCOUT("Entering AssRes()" << std::endl);
306 
307  AssConstrRes(ResHdl, ElemIter, *pWorkVec, iOrder);
308 }
MySubVectorHandler * pWorkVec
Definition: dataman.h:633
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VecIter< Elem * > ElemIter
Definition: dataman.h:612
virtual void AssConstrRes(VectorHandler &ResHdl, InverseDynamics::Order iOrder)
Definition: invdataman.cc:303
void DataManager::AssConstrRes ( VectorHandler ResHdl,
VecIter< Elem * > &  Iter,
SubVectorHandler WorkVec,
InverseDynamics::Order  iOrder 
)
protected

Definition at line 311 of file invdataman.cc.

References InverseDynamics::ACCELERATION, ASSERT, Elem::AssRes(), Elem::BEAM, Elem::bIsErgonomy(), Joint::bIsPrescribedMotion(), Joint::bIsTorque(), Elem::BODY, Vec3::Cross(), DEBUGCOUT, Body::dGetM(), DriveHandler::dGetTimeStep(), DrvHdl, DataManager::ElemDataStructure::ElemContainer, ElemData, InverseDynamics::FULLY_ACTUATED_COLLOCATED, InverseDynamics::FULLY_ACTUATED_NON_COLLOCATED, Body::GetJ(), InverseSolver::GetProblemType(), StructNode::GetRCurr(), StructNode::GetRPrev(), Body::GetS(), StructDispNode::GetVCurr(), StructDispNode::GetVPrev(), StructNode::GetWCurr(), InverseSolver::GetWeight(), StructNode::GetWPPrev(), StructNode::GetWPrev(), StructDispNode::GetXCurr(), StructDispNode::GetXPPPrev(), StructDispNode::GetXPrev(), DofOwnerOwner::iGetFirstIndex(), SimulationEntity::iGetNumDof(), Elem::iGetNumDof(), Elem::JOINT, MBDYN_EXCEPT_ARGS, Mat3x3::MulMT(), DataManager::NodeDataStructure::NodeContainer, NodeData, Body::pGetNode(), InverseDynamics::POSITION, pSolver, pXCurr, pXPrimeCurr, pXPrimePrimeCurr, Node::STRUCTURAL, InverseDynamics::UNDERDETERMINED_FULLY_ACTUATED, InverseDynamics::UNDERDETERMINED_UNDERACTUATED_COLLOCATED, RotManip::VecRot(), and InverseDynamics::VELOCITY.

315 {
316  DEBUGCOUT("Entering AssRes()" << std::endl);
317 
318  // TODO
319 
320  bool ChangedEqStructure(false);
321  InverseSolver *pIDS = dynamic_cast<InverseSolver *>(pSolver);
322 
323  switch (pIDS->GetProblemType()) {
325  for (ElemContainerType::iterator j = ElemData[Elem::JOINT].ElemContainer.begin();
326  j != ElemData[Elem::JOINT].ElemContainer.end(); ++j)
327  {
328  Joint *pJ = Cast<Joint>(j->second);
329  if (pJ->bIsPrescribedMotion()) {
330  ASSERT(pJ->bIsTorque());
331  try {
332  ResHdl += pJ->AssRes(WorkVec, *pXCurr,
333  *pXPrimeCurr, *pXPrimePrimeCurr, iOrder);
334  }
336  ResHdl += WorkVec;
337  ChangedEqStructure = true;
338  }
339  }
340  }
341  break;
342 
345  silent_cerr("DataManager::AssConstrRes(" << pIDS->GetProblemType() << ") not implemented yet" << std::endl);
347 
349  // NOTE: in this case, the name of the function is misleading,
350  // since it assembles the entire problem's residual
351  // and not only the residual of the constraints
352  doublereal dw1, dw2;
353  pIDS->GetWeight(iOrder, dw1, dw2);
354  switch (iOrder) {
356  if (dw1 > 0.) {
357  for (NodeContainerType::const_iterator n = NodeData[Node::STRUCTURAL].NodeContainer.begin();
358  n != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++n)
359  {
360  const StructNode *pNode = dynamic_cast<const StructNode *>(n->second);
361 
362  ASSERT(pNode->iGetNumDof() == 6);
363  integer iFirstIndex = pNode->iGetFirstIndex();
364 
365  Vec3 DX(pNode->GetXPrev() - pNode->GetXCurr());
366  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
367  ResHdl(iFirstIndex + iCnt) += dw1*DX(iCnt);
368  }
369 
370  // VecRot(Rp*Rc^T) = -VecRot(Rc*Rp^T)
371  Vec3 DTheta(RotManip::VecRot(pNode->GetRPrev().MulMT(pNode->GetRCurr())));
372  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
373  ResHdl(iFirstIndex + 3 + iCnt) += dw1*DTheta(iCnt);
374  }
375  }
376  }
377 
378  if (dw2 > 0.) {
379 #ifdef TORQUE_OPTIMIZATION
381  for (ElemContainerType::const_iterator b = ElemData[Elem::BODY].ElemContainer.begin();
382  b != ElemData[Elem::BODY].ElemContainer.end(); ++b)
383  {
384  if (!b->second->bIsRightHandSide()) {
385  continue;
386  }
387 
388  const Body *pBody(Cast<Body>(b->second));
389  doublereal dm(pBody->dGetM()*dw2);
390  Vec3 S(pBody->GetS()*dw2);
391  Mat3x3 J = (pBody->GetJ()*dw2);
392  const StructNode *pNode = pBody->pGetNode();
393  ASSERT(pNode->iGetNumDof() == 6);
394  integer iFirstIndex = pNode->iGetFirstIndex();
395 
396  Vec3 DXP((pNode->GetXCurr() - pNode->GetXPrev())/h);
397  Vec3 DXPP((DXP - pNode->GetVPrev())/h);
398  // VecRot(Rp*Rc^T) = -VecRot(Rc*Rp^T)
399  Vec3 DW(RotManip::VecRot(pNode->GetRCurr().MulMT(pNode->GetRPrev()))/h);
400  Vec3 DWP((DW - pNode->GetWPrev())/h);
401 
402  Vec3 XRes(DXPP*dm + DWP.Cross(S) + DW.Cross(DW.Cross(S)));
403  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
404  ResHdl(iFirstIndex + iCnt) -= XRes(iCnt);
405  }
406 
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);
410  }
411  }
412 #else // !TORQUE_OPTIMIZATION
413  for (ElemContainerType::const_iterator b = ElemData[Elem::BODY].ElemContainer.begin();
414  b != ElemData[Elem::BODY].ElemContainer.end(); ++b)
415  {
416  if (!b->second->bIsErgonomy()) {
417  continue;
418  }
419 
420  const Body *pBody(Cast<Body>(b->second));
421  doublereal dm(pBody->dGetM()*dw2);
422  Vec3 S(pBody->GetS()*dw2);
423  Mat3x3 J = (pBody->GetJ()*dw2);
424  const StructNode *pNode = pBody->pGetNode();
425  ASSERT(pNode->iGetNumDof() == 6);
426  integer iFirstIndex = pNode->iGetFirstIndex();
427 
428  Vec3 DX(pNode->GetXPrev() - pNode->GetXCurr());
429  // VecRot(Rp*Rc^T) = -VecRot(Rc*Rp^T)
430  Vec3 DTheta(RotManip::VecRot(pNode->GetRPrev().MulMT(pNode->GetRCurr())));
431 
432  Vec3 XRes(DX*dm - S.Cross(DTheta));
433  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
434  ResHdl(iFirstIndex + iCnt) += XRes(iCnt);
435  }
436 
437  Vec3 ThetaRes(S.Cross(DX) + J*DTheta);
438  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
439  ResHdl(iFirstIndex + 3 + iCnt) += ThetaRes(iCnt);
440  }
441  }
442 #endif // !TORQUE_OPTIMIZATION
443  }
444  break;
445 
447  if (dw1 > 0.) {
449 
450  // xp_k = xp_km1/3 + 2/3*(x_k - x_km1)/h
451  // xp_k = 2*(x_k - x_km1)/h - xp_km1
452  for (NodeContainerType::const_iterator n = NodeData[Node::STRUCTURAL].NodeContainer.begin();
453  n != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++n)
454  {
455  const StructNode *pNode = dynamic_cast<const StructNode *>(n->second);
456 
457  ASSERT(pNode->iGetNumDof() == 6);
458  integer iFirstIndex = pNode->iGetFirstIndex();
459 
460  const Vec3& VPrev(pNode->GetVPrev());
461  const Vec3& XPrev(pNode->GetXPrev());
462  const Vec3& XCurr(pNode->GetXCurr());
463 
464 // #define USE_2XmV 1 // 2nd order, a-stable, oscillations
465 // #define USE_2XpVd3 1 // 1st order, a/l-stable, more accurate
466 #define USE_X 1 // 1st order, l-stable (implicit Euler), less accurate (alpha == 1.)
467 // #define USE_alphaX_betaV (1.0) // alpha = 1. + |rho|; beta = (1 - alpha) for 1st order accuracy
468 
469 #if USE_2XmV
470  Vec3 VRef((XCurr - XPrev)*(2./h) - VPrev);
471 #elif USE_2XpVd3
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));
475 #elif USE_X
476  Vec3 VRef((XCurr - XPrev)/h);
477 #endif
478  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
479  ResHdl(iFirstIndex + iCnt) += dw1*VRef(iCnt);
480  }
481 
482  const Vec3& WPrev(pNode->GetWPrev());
483  const Mat3x3& RPrev(pNode->GetRPrev());
484  const Mat3x3& RCurr(pNode->GetRCurr());
485 
486 #if USE_2XmV
487  Vec3 WRef(RotManip::VecRot(RCurr.MulMT(RPrev))*(2./h) - WPrev);
488 #elif USE_2XpVd3
489  Vec3 WRef(RotManip::VecRot(RCurr.MulMT(RPrev))*(2./3./h) + WPrev/3.);
490 #elif defined(USE_alphaX_betaV)
491  Vec3 WRef(RotManip::VecRot(RCurr.MulMT(RPrev))*(USE_alphaX_betaV/h) + WPrev*(1 - USE_alphaX_betaV));
492 #elif USE_X
493  Vec3 WRef(RotManip::VecRot(RCurr.MulMT(RPrev))/h);
494 #endif
495  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
496  ResHdl(iFirstIndex + 3 + iCnt) += dw1*WRef(iCnt);
497  }
498  }
499  }
500 
501  if (dw2 > 0.) {
502  for (ElemContainerType::const_iterator b = ElemData[Elem::BODY].ElemContainer.begin();
503  b != ElemData[Elem::BODY].ElemContainer.end(); ++b)
504  {
505  if (!b->second->bIsErgonomy()) {
506  continue;
507  }
508 
509  const Body *pBody(Cast<Body>(b->second));
510  doublereal dm(pBody->dGetM()*dw2);
511  Vec3 S(pBody->GetS()*dw2);
512  Mat3x3 J = (pBody->GetJ()*dw2);
513  const StructNode *pNode = pBody->pGetNode();
514  ASSERT(pNode->iGetNumDof() == 6);
515  integer iFirstIndex = pNode->iGetFirstIndex();
516 
517  Vec3 BPrev(pNode->GetVPrev()*dm - S.Cross(pNode->GetWPrev()));
518  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
519  ResHdl(iFirstIndex + iCnt) += BPrev(iCnt);
520  }
521 
522  Vec3 GPrev(S.Cross(pNode->GetVPrev()) + J*pNode->GetWPrev());
523  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
524  ResHdl(iFirstIndex + 3 + iCnt) += GPrev(iCnt);
525  }
526  }
527  }
528  break;
529 
531  if (dw1 > 0.) {
533 
534  // xpp_k = xpp_km1/3 + 2/3*(xp_k - xp_km1)/h
535  // xpp_k = 2*(xp_k - xp_km1)/h - xpp_km1
536  // xpp_k = xpp_km1 + 6*(xp_k + xp_km1)/h - 12*(x_k - x_km1)/h^2
537  for (NodeContainerType::const_iterator n = NodeData[Node::STRUCTURAL].NodeContainer.begin();
538  n != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++n)
539  {
540  const StructNode *pNode = dynamic_cast<const StructNode *>(n->second);
541 
542  ASSERT(pNode->iGetNumDof() == 6);
543  integer iFirstIndex = pNode->iGetFirstIndex();
544 
545  const Vec3& XPPPrev(pNode->GetXPPPrev());
546  const Vec3& VPrev(pNode->GetVPrev());
547  const Vec3& VCurr(pNode->GetVCurr());
548 
549 #if USE_2XmV
550  Vec3 XPPRef((VCurr - VPrev)*(2./h) - XPPPrev);
551 #elif USE_2XpVd3
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));
555 #elif USE_X
556  Vec3 XPPRef((VCurr - VPrev)/h);
557 #endif
558 #if 0
559  const Vec3& XPrev(pNode->GetXPrev());
560  const Vec3& XCurr(pNode->GetXCurr());
561 
562  Vec3 XPPRef(XPPPrev + (VCurr + VPrev)*(6./h) - (XCurr - XPrev)*(12./h/h));
563 #endif
564  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
565  ResHdl(iFirstIndex + iCnt) += dw1*XPPRef(iCnt);
566  }
567 
568  const Vec3& WPPrev(pNode->GetWPPrev());
569  const Vec3& WPrev(pNode->GetWPrev());
570  const Vec3& WCurr(pNode->GetWCurr());
571 
572 #if USE_2XmV
573  Vec3 WPRef((WCurr - WPrev)*(2./h) - WPPrev);
574 #elif USE_2XpVd3
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));
578 #elif USE_X
579  Vec3 WPRef((WCurr - WPrev)/h);
580 #endif
581 #if 0
582  const Mat3x3& RPrev(pNode->GetRPrev());
583  const Mat3x3& RCurr(pNode->GetRCurr());
584 
585  Vec3 WPRef(WPPrev + (WCurr + WPrev)*(6./h) - RotManip::VecRot(RCurr.MulMT(RPrev))*(12./h/h));
586 #endif
587  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
588  ResHdl(iFirstIndex + 3 + iCnt) += dw1*WPRef(iCnt);
589  }
590  }
591  }
592 
593  if (dw2 > 0.) {
594  for (ElemContainerType::const_iterator b = ElemData[Elem::BODY].ElemContainer.begin();
595  b != ElemData[Elem::BODY].ElemContainer.end(); ++b)
596  {
597  if (!b->second->bIsErgonomy()) {
598  continue;
599  }
600 
601  const Body *pBody(Cast<Body>(b->second));
602  doublereal dm(pBody->dGetM()*dw2);
603  Vec3 S(pBody->GetS()*dw2);
604  Mat3x3 J = (pBody->GetJ()*dw2);
605  const StructNode *pNode = pBody->pGetNode();
606  ASSERT(pNode->iGetNumDof() == 6);
607  integer iFirstIndex = pNode->iGetFirstIndex();
608 
609  Vec3 BPPrev(pNode->GetXPPPrev()*dm - S.Cross(pNode->GetWPPrev()));
610  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
611  ResHdl(iFirstIndex + iCnt) += BPPrev(iCnt);
612  }
613 
614  Vec3 GPPrev(S.Cross(pNode->GetXPPPrev()) + J*pNode->GetWPPrev());
615  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
616  ResHdl(iFirstIndex + 3 + iCnt) += GPPrev(iCnt);
617  }
618  }
619  }
620  break;
621 
622  default:
623  ASSERT(0);
624  }
625 
626  for (ElemContainerType::iterator j = ElemData[Elem::JOINT].ElemContainer.begin();
627  j != ElemData[Elem::JOINT].ElemContainer.end(); ++j)
628  {
629  bool bActive(true);
630  Joint *pJ = Cast<Joint>(j->second, true);
631  if (pJ == 0) {
632  bActive = false;
633  pJ = Cast<Joint>(j->second, false);
634  }
635 
636  if ((pJ->bIsPrescribedMotion()
637  || (iOrder == InverseDynamics::POSITION && pJ->bIsErgonomy())) && bActive)
638  {
639  try {
640  ResHdl += j->second->AssRes(WorkVec, *pXCurr,
641  *pXPrimeCurr, *pXPrimePrimeCurr, iOrder);
642  }
644  ResHdl += WorkVec;
645  ChangedEqStructure = true;
646  }
647 
648  } else if (pJ->bIsTorque() || (pJ->bIsPrescribedMotion() && !bActive)) {
649  integer iNumDof = pJ->iGetNumDof();
650  integer iFirstIndex = pJ->iGetFirstIndex();
651  if (iOrder == InverseDynamics::POSITION) {
652  for (int iCnt = 1; iCnt <= iNumDof; iCnt++) {
653  ResHdl(iFirstIndex + iCnt) = -(*pXCurr)(iFirstIndex + iCnt);
654  }
655 
656  } else {
657  for (int iCnt = 1; iCnt <= iNumDof; iCnt++) {
658  ResHdl(iFirstIndex + iCnt) = 0.;
659  }
660  }
661  }
662  }
663 
664  for (ElemContainerType::iterator j = ElemData[Elem::BEAM].ElemContainer.begin();
665  j != ElemData[Elem::BEAM].ElemContainer.end(); ++j)
666  {
667  bool bActive(true);
668  Beam2 *pB = Cast<Beam2>(j->second, true);
669  if (pB == 0) {
670  bActive = false;
671  pB = Cast<Beam2>(j->second, false);
672  }
673 
674  if (pB && (iOrder == InverseDynamics::POSITION && pB->bIsErgonomy()) && bActive)
675  {
676  try {
677  ResHdl += j->second->AssRes(WorkVec, *pXCurr,
678  *pXPrimeCurr, *pXPrimePrimeCurr, iOrder);
679  }
681  ResHdl += WorkVec;
682  ChangedEqStructure = true;
683  }
684  }
685  }
686 
687  } break;
688 
689  default:
690  ASSERT(0);
692  }
693 
694  if (ChangedEqStructure) {
695  throw ChangedEquationStructure(MBDYN_EXCEPT_ARGS);
696  }
697 }
virtual const Vec3 & GetWPrev(void) const
Definition: strnode.h:1018
ElemContainerType ElemContainer
Definition: dataman.h:591
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: body.h:270
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
bool bIsErgonomy(void) const
Definition: elem.cc:83
Definition: beam2.h:50
virtual const Vec3 & GetXPrev(void) const
Definition: strnode.h:304
InverseDynamics::Type GetProblemType(void) const
Definition: invsolver.cc:889
NodeContainerType NodeContainer
Definition: dataman.h:731
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
bool bIsPrescribedMotion(void) const
Definition: joint.cc:170
VectorHandler * pXPrimePrimeCurr
Definition: dataman.h:112
Solver * pSolver
Definition: dataman.h:99
virtual const Mat3x3 & GetRPrev(void) const
Definition: strnode.h:1000
doublereal dGetTimeStep(void) const
Definition: drive.h:393
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
virtual const Vec3 & GetVPrev(void) const
Definition: strnode.h:316
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
#define ASSERT(expression)
Definition: colamd.c:977
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
virtual unsigned int iGetNumDof(void) const
Definition: elem.cc:118
virtual unsigned int iGetNumDof(void) const =0
bool bIsTorque(void) const
Definition: joint.cc:176
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
Definition: joint.h:50
Mat3x3 MulMT(const Mat3x3 &m) const
Definition: matvec3.cc:444
virtual const Vec3 & GetWPPrev(void) const
Definition: strnode.h:1036
DriveHandler DrvHdl
Definition: dataman.h:104
virtual const Vec3 & GetXPPPrev(void) const
Definition: strnode.h:328
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
void GetWeight(InverseDynamics::Order iOrder, doublereal &dw1, doublereal &dw2) const
Definition: invsolver.cc:895
long int integer
Definition: colamd.c:51
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssJac ( MatrixHandler JacHdl,
doublereal  dCoef 
)
virtual

Reimplemented in SchurDataManager.

Definition at line 392 of file elman.cc.

References ASSERT, DEBUGCOUT, ElemIter, Elems, and pWorkMat.

Referenced by Solver::Eig(), ThirdOrderIntegrator::Jacobian(), DerivativeSolver::Jacobian(), and StepNIntegrator::Jacobian().

393 {
394  DEBUGCOUT("Entering DataManager::AssJac()" << std::endl);
395 
396  ASSERT(pWorkMat != NULL);
397  ASSERT(Elems.begin() != Elems.end());
398 
399  AssJac(JacHdl, dCoef, ElemIter, *pWorkMat);
400 }
ElemVecType Elems
Definition: dataman.h:609
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual void AssJac(MatrixHandler &JacHdl, doublereal dCoef)
Definition: elman.cc:392
#define ASSERT(expression)
Definition: colamd.c:977
VecIter< Elem * > ElemIter
Definition: dataman.h:612
VariableSubMatrixHandler * pWorkMat
Definition: dataman.h:632
void DataManager::AssJac ( MatrixHandler JacHdl,
doublereal  dCoef,
VecIter< Elem * > &  Iter,
VariableSubMatrixHandler WorkMat 
)
protectedvirtual

Definition at line 403 of file elman.cc.

References Elem::AssJac(), VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), c, DEBUGCOUT, Elem::GetElemType(), WithLabel::GetLabel(), MatrixHandler::iGetNumCols(), MatrixHandler::iGetNumRows(), MBDYN_EXCEPT_ARGS, psElemNames, pXCurr, pXPrimeCurr, and MatrixHandler::Reset().

406 {
407  DEBUGCOUT("Entering DataManager::AssJac()" << std::endl);
408 
409  JacHdl.Reset();
410 
411 #if 0
412  for (int r = 1; r <= JacHdl.iGetNumRows(); r++) {
413  for (int c = 1; c <= JacHdl.iGetNumCols(); c++) {
414  if (JacHdl(r, c) != 0.) {
415  silent_cerr("JacHdl(" << r << "," << c << ")="
416  << JacHdl(r, c) << std::endl);
417  }
418  JacHdl(r, c) = std::numeric_limits<doublereal>::epsilon();
419  }
420  }
421 #endif
422 
423  Elem* pTmpEl = NULL;
424  if (Iter.bGetFirst(pTmpEl)) {
425  do {
426  try {
427  JacHdl += pTmpEl->AssJac(WorkMat, dCoef,
428  *pXCurr, *pXPrimeCurr);
429  }
430  catch (ErrDivideByZero) {
431  silent_cerr("AssJac: divide by zero "
432  "in " << psElemNames[pTmpEl->GetElemType()]
433  << "(" << pTmpEl->GetLabel() << ")"
434  << std::endl);
436  }
437 
438 #if 0
439  silent_cerr("### " << psElemNames[pTmpEl->GetElemType()] << "(" << pTmpEl->GetLabel() <<"):" << std::endl);
440  silent_cerr(JacHdl << std::endl);
441 #endif
442  } while (Iter.bGetNext(pTmpEl));
443  }
444 }
virtual integer iGetNumCols(void) const =0
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
virtual Elem::Type GetElemType(void) const =0
virtual void Reset(void)=0
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
static std::stack< cleanup * > c
Definition: cleanup.cc:59
Definition: elem.h:75
const char * psElemNames[]
Definition: enums.cc:39
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
unsigned int GetLabel(void) const
Definition: withlab.cc:62
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
virtual integer iGetNumRows(void) const =0
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssMats ( MatrixHandler A_Hdl,
MatrixHandler B_Hdl 
)
virtual

Definition at line 447 of file elman.cc.

References ASSERT, DEBUGCOUT, ElemIter, Elems, pWorkMatA, and pWorkMatB.

448 {
449  DEBUGCOUT("Entering DataManager::AssMats()" << std::endl);
450 
451  ASSERT(pWorkMatA != NULL);
452  ASSERT(pWorkMatB != NULL);
453  ASSERT(Elems.begin() != Elems.end());
454 
455  AssMats(A_Hdl, B_Hdl, ElemIter, *pWorkMatA, *pWorkMatB);
456 }
ElemVecType Elems
Definition: dataman.h:609
VariableSubMatrixHandler * pWorkMatA
Definition: dataman.h:630
VariableSubMatrixHandler * pWorkMatB
Definition: dataman.h:631
#define DEBUGCOUT(msg)
Definition: myassert.h:232
#define ASSERT(expression)
Definition: colamd.c:977
VecIter< Elem * > ElemIter
Definition: dataman.h:612
virtual void AssMats(MatrixHandler &A_Hdl, MatrixHandler &B_Hdl)
Definition: elman.cc:447
void DataManager::AssMats ( MatrixHandler A_Hdl,
MatrixHandler B_Hdl,
VecIter< Elem * > &  Iter,
VariableSubMatrixHandler WorkMatA,
VariableSubMatrixHandler WorkMatB 
)
protectedvirtual

Definition at line 459 of file elman.cc.

References Elem::AssMats(), VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), DEBUGCOUT, pXCurr, and pXPrimeCurr.

463 {
464  DEBUGCOUT("Entering DataManager::AssMats()" << std::endl);
465 
466  /* Versione con iteratore: */
467  Elem* pTmpEl = NULL;
468  if (Iter.bGetFirst(pTmpEl)) {
469  /* Nuova versione, piu' compatta.
470  * La funzione propria AssJac, comune a tutti gli elementi,
471  * scrive nella WorkMat (passata come reference) il contributo
472  * dell'elemento allo jacobiano e restituisce un reference
473  * alla workmat stessa, che viene quindi sommata allo jacobiano.
474  * Ogni elemento deve provvedere al resizing della WorkMat e al
475  * suo reset ove occorra */
476 
477  /* il SubMatrixHandler e' stato modificato in modo da essere
478  * in grado di trasformarsi agevolmente da Full a Sparse
479  * e quindi viene gestito in modo automatico, e del tutto
480  * trasparente, il passaggio da un modo all'altro.
481  * L'elemento switcha la matrice nel modo che ritiene
482  * opportuno; l'operatore += capisce di quale matrice
483  * si sta occupando ed agisce di conseguenza.
484  */
485 
486  /* Con VariableSubMatrixHandler */
487  do {
488  pTmpEl->AssMats(WorkMatA, WorkMatB,
489  *pXCurr, *pXPrimeCurr);
490  A_Hdl += WorkMatA;
491  B_Hdl += WorkMatB;
492  } while (Iter.bGetNext(pTmpEl));
493  }
494 }
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
Definition: elem.h:75
virtual void AssMats(VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: elem.cc:55
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssRes ( VectorHandler ResHdl,
doublereal  dCoef 
)
virtual

Implements SolutionDataManager.

Reimplemented in SchurDataManager.

Definition at line 498 of file elman.cc.

References DEBUGCOUT, ElemIter, and pWorkVec.

Referenced by AssRes(), ThirdOrderIntegrator::Jacobian(), StepNIntegrator::Jacobian(), ThirdOrderIntegrator::Residual(), DerivativeSolver::Residual(), StepNIntegrator::Residual(), and InverseDynamicsStepSolver::Residual().

499 {
500  DEBUGCOUT("Entering AssRes()" << std::endl);
501 
502  AssRes(ResHdl, dCoef, ElemIter, *pWorkVec);
503 }
MySubVectorHandler * pWorkVec
Definition: dataman.h:633
virtual void AssRes(VectorHandler &ResHdl, doublereal dCoef)
Definition: elman.cc:498
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VecIter< Elem * > ElemIter
Definition: dataman.h:612
void DataManager::AssRes ( VectorHandler ResHdl)
virtual

Definition at line 701 of file invdataman.cc.

References AssRes(), DEBUGCOUT, DataManager::ElemDataStructure::ElemContainer, ElemData, ElemIter, Elem::INERTIA, InverseDynamics::INVERSE_DYNAMICS, pWorkVec, pXCurr, pXPrimeCurr, and pXPrimePrimeCurr.

702 {
703  DEBUGCOUT("Entering AssRes()" << std::endl);
704  AssRes(ResHdl, ElemIter, *pWorkVec);
705 
706  for (ElemContainerType::iterator j = ElemData[Elem::INERTIA].ElemContainer.begin();
707  j != ElemData[Elem::INERTIA].ElemContainer.end(); ++j)
708  {
709  bool bActive(true);
710  Inertia *pI = Cast<Inertia>(j->second, true);
711  if (pI == 0) {
712  bActive = false;
713  pI = Cast<Inertia>(j->second, false);
714  }
715  if (pI && bActive)
716  {
717  ResHdl += j->second->AssRes(*pWorkVec, *pXCurr,
720  }
721  }
722 }
ElemContainerType ElemContainer
Definition: dataman.h:591
MySubVectorHandler * pWorkVec
Definition: dataman.h:633
virtual void AssRes(VectorHandler &ResHdl, doublereal dCoef)
Definition: elman.cc:498
VectorHandler * pXPrimePrimeCurr
Definition: dataman.h:112
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
VecIter< Elem * > ElemIter
Definition: dataman.h:612
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssRes ( VectorHandler ResHdl,
doublereal  dCoef,
VecIter< Elem * > &  Iter,
SubVectorHandler WorkVec 
)
protectedvirtual

Definition at line 506 of file elman.cc.

References Elem::AssRes(), VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), DEBUGCOUT, Elem::GetElemType(), WithLabel::GetLabel(), MBDYN_EXCEPT_ARGS, PrintResidual(), psElemNames, pXCurr, and pXPrimeCurr.

509 {
510  DEBUGCOUT("Entering AssRes()" << std::endl);
511 
512  Elem* pTmpEl = NULL;
513  bool ChangedEqStructure(false);
514  if (Iter.bGetFirst(pTmpEl)) {
515  do {
516  try {
517  ResHdl += pTmpEl->AssRes(WorkVec, dCoef,
518  *pXCurr, *pXPrimeCurr);
519  }
521  ResHdl += WorkVec;
522  ChangedEqStructure = true;
523  }
524  catch (ErrDivideByZero) {
525  silent_cerr("AssRes: divide by zero "
526  "in " << psElemNames[pTmpEl->GetElemType()]
527  << "(" << pTmpEl->GetLabel() << ")"
528  << std::endl);
530  }
531 
532 #if 0
533  silent_cerr("### " << psElemNames[pTmpEl->GetElemType()] << "(" << pTmpEl->GetLabel() <<"):" << std::endl);
534  PrintResidual(ResHdl, -1);
535 #endif
536 
537  } while (Iter.bGetNext(pTmpEl));
538  }
539  if (ChangedEqStructure) {
540  throw ChangedEquationStructure(MBDYN_EXCEPT_ARGS);
541  }
542 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
virtual Elem::Type GetElemType(void) const =0
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
virtual void PrintResidual(const VectorHandler &Res, integer iIterCnt) const
Definition: dataman2.cc:2603
Definition: elem.h:75
const char * psElemNames[]
Definition: enums.cc:39
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
unsigned int GetLabel(void) const
Definition: withlab.cc:62
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

void DataManager::AssRes ( VectorHandler ResHdl,
VecIter< Elem * > &  Iter,
SubVectorHandler WorkVec 
)
protected

Definition at line 725 of file invdataman.cc.

References Elem::AssRes(), Elem::BEAM, Elem::bIsRightHandSide(), Elem::BODY, DEBUGCOUT, DataManager::ElemDataStructure::ElemContainer, ElemData, Elem::FORCE, InverseDynamics::INVERSE_DYNAMICS, Elem::JOINT, Elem::LASTELEMTYPE, MBDYN_EXCEPT_ARGS, pXCurr, pXPrimeCurr, and pXPrimePrimeCurr.

728 {
729  DEBUGCOUT("Entering AssRes()" << std::endl);
730 
731  // TODO
732  // FIXME: could be as the rest?
733 
734  const Elem::Type ElemType[] = {
735  Elem::BODY,
736  Elem::BEAM,
737  Elem::FORCE,
738 
740  };
741 
742  bool ChangedEqStructure(false);
743 
744  for (int et = 0; ElemType[et] != Elem::LASTELEMTYPE; et++) {
745  for (ElemContainerType::iterator j = ElemData[ElemType[et]].ElemContainer.begin();
746  j != ElemData[ElemType[et]].ElemContainer.end(); ++j)
747  {
748  if (!j->second->bIsRightHandSide()) {
749  continue;
750  }
751 
752  try {
753  ResHdl += j->second->AssRes(WorkVec, *pXCurr,
756  }
758  ResHdl += WorkVec;
759  ChangedEqStructure = true;
760  }
761  }
762  }
763 
764  for (ElemContainerType::iterator j = ElemData[Elem::JOINT].ElemContainer.begin();
765  j != ElemData[Elem::JOINT].ElemContainer.end(); ++j)
766  {
767  bool bActive(true);
768  Joint *pJ = Cast<Joint>(j->second, true);
769  if (pJ == 0) {
770  bActive = false;
771  pJ = Cast<Joint>(j->second, false);
772  }
773 
774  if (bActive && pJ->bIsRightHandSide()) {
775  try {
776  ResHdl += pJ->AssRes(WorkVec, *pXCurr,
779  }
781  ResHdl += WorkVec;
782  ChangedEqStructure = true;
783  }
784  }
785  }
786 
787  if (ChangedEqStructure) {
788  throw ChangedEquationStructure(MBDYN_EXCEPT_ARGS);
789  }
790 }
ElemContainerType ElemContainer
Definition: dataman.h:591
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
bool bIsRightHandSide(void) const
Definition: elem.cc:89
VectorHandler * pXPrimePrimeCurr
Definition: dataman.h:112
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
Type
Definition: elem.h:91
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
Definition: joint.h:50
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

bool DataManager::bDoesOmegaRotate ( void  ) const

Definition at line 123 of file dataman2.cc.

References bOmegaRotates.

Referenced by ReadStructNode().

124 {
125  return bOmegaRotates;
126 }
bool bOmegaRotates
Definition: dataman.h:123
void DataManager::BeforePredict ( VectorHandler X,
VectorHandler XP,
VectorHandler XPrev,
VectorHandler XPPrev 
) const
virtual

Reimplemented in SchurDataManager.

Definition at line 2454 of file dataman2.cc.

References SimulationEntity::BeforePredict(), VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), ElemIter, and Nodes.

Referenced by Solver::Advance(), Solver::Prepare(), and Solver::Start().

2457 {
2458  for (NodeVecType::const_iterator i = Nodes.begin(); i != Nodes.end(); ++i) {
2459  (*i)->BeforePredict(X, XP, XPrev, XPPrev);
2460  }
2461 
2462  /* Versione con iteratore: */
2463  Elem* pEl = NULL;
2464  if (ElemIter.bGetFirst(pEl)) {
2465  do {
2466  pEl->BeforePredict(X, XP, XPrev, XPPrev);
2467  } while (ElemIter.bGetNext(pEl));
2468  }
2469 }
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
NodeVecType Nodes
Definition: dataman.h:743
VecIter< Elem * > ElemIter
Definition: dataman.h:612
virtual void BeforePredict(VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
Definition: simentity.cc:82
Definition: elem.h:75
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88

Here is the call graph for this function:

DataManager::ElemContainerType::const_iterator DataManager::begin ( Elem::Type  t) const

Definition at line 902 of file dataman.cc.

References DataManager::ElemDataStructure::ElemContainer, and ElemData.

Referenced by DofOwnerInit(), LoadIncNorm::LoadIncNorm(), and TimeStep::TimeStep().

903 {
904  return ElemData[t].ElemContainer.begin();
905 }
ElemContainerType ElemContainer
Definition: dataman.h:591
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
DataManager::NodeContainerType::const_iterator DataManager::begin ( Node::Type  t) const

Definition at line 890 of file dataman.cc.

References DataManager::NodeDataStructure::NodeContainer, and NodeData.

891 {
892  return NodeData[t].NodeContainer.begin();
893 }
NodeContainerType NodeContainer
Definition: dataman.h:731
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
bool DataManager::bIsInverseDynamics ( void  ) const
inline

Definition at line 493 of file dataman.h.

References bInverseDynamics.

Referenced by ReadBeam2(), ReadBody(), and ReadVariableBody().

493  {
494  return bInverseDynamics;
495  };
bool bInverseDynamics
Definition: dataman.h:133
bool DataManager::bIsStaticModel ( void  ) const
inline

Definition at line 482 of file dataman.h.

References bStaticModel.

Referenced by ReadBody(), ReadStructNode(), and ReadVariableBody().

482  {
483  return bStaticModel;
484  };
bool bStaticModel
Definition: dataman.h:130
bool DataManager::bOutput ( ResType  t) const

Definition at line 694 of file dataman.cc.

References ResMode.

Referenced by ReadControl().

695 {
696  return (ResMode & t) ? true : false;
697 }
int ResMode
Definition: dataman.h:201
bool DataManager::bOutputAccelerations ( void  ) const

Definition at line 878 of file dataman.cc.

References bOutputAccels.

Referenced by ReadStructNode().

879 {
880  return bOutputAccels;
881 }
bool bOutputAccels
Definition: dataman.h:119
bool DataManager::bOutputDriveCallers ( void  ) const

Definition at line 884 of file dataman.cc.

References bOutputDriveCaller.

Referenced by DriveCallerRead::ReadOutput().

885 {
886  return bOutputDriveCaller;
887 }
bool bOutputDriveCaller
Definition: dataman.h:120
void DataManager::bSetInverseDynamics ( bool  b)
inline

Definition at line 490 of file dataman.h.

References bInverseDynamics.

490  {
491  bInverseDynamics = b;
492  };
bool bInverseDynamics
Definition: dataman.h:133
void DataManager::bSetStaticModel ( bool  b)
inline

Definition at line 479 of file dataman.h.

References bStaticModel.

479  {
480  bStaticModel = b;
481  };
bool bStaticModel
Definition: dataman.h:130
template<class T >
T * DataManager::Cast ( Elem pEl,
bool  bActive = false 
)
protected

Definition at line 875 of file dataman.h.

References ASSERT, DrivenElem::bIsActive(), Elem::GetElemType(), WithLabel::GetLabel(), MBDYN_EXCEPT_ARGS, NestedElem::pGetElem(), and psElemNames.

876 {
877  ASSERT(pEl != NULL);
878 
879  T *pT = dynamic_cast<T *>(pEl);
880 
881  if (pT == 0) {
882  DrivenElem *pDE = dynamic_cast<DrivenElem *>(pEl);
883  if (pDE == 0) {
884  silent_cerr("unable to cast "
885  << psElemNames[pEl->GetElemType()]
886  << "(" << pEl->GetLabel() << ") as \"" << mbdyn_demangle<T>() << "\" (not driven)" << std::endl);
888  }
889 
890  if (bActive && !pDE->bIsActive()) {
891  pedantic_cerr("unable to cast "
892  << psElemNames[pEl->GetElemType()]
893  << "(" << pEl->GetLabel() << ") as \"" << mbdyn_demangle<T>() << "\""
894  " (driven but currently inactive)" << std::endl);
895  return 0;
896  }
897 
898  pT = dynamic_cast<T *>(pDE->pGetElem());
899  if (pT == 0) {
900  pedantic_cerr("unable to cast "
901  << psElemNames[pEl->GetElemType()]
902  << "(" << pEl->GetLabel() << ") as \"" << mbdyn_demangle<T>() << "\""
903  " (driven but cast failed)" << std::endl);
904  }
905  }
906 
907  return pT;
908 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual Elem::Type GetElemType(void) const =0
#define ASSERT(expression)
Definition: colamd.c:977
const char * psElemNames[]
Definition: enums.cc:39
virtual Elem * pGetElem(void) const
Definition: nestedelem.cc:60
unsigned int GetLabel(void) const
Definition: withlab.cc:62
virtual bool bIsActive(void) const
Definition: driven.cc:74

Here is the call graph for this function:

int DataManager::Cleanup ( void  )

Definition at line 668 of file dataman.cc.

Referenced by datamanager_cleanup().

669 {
670 #ifdef USE_SOCKET
671  DeleteSocketUsers();
672 #endif // USE_SOCKET
673  return 0;
674 }
unsigned DataManager::ConvergedRegister ( void  )

Definition at line 2675 of file dataman2.cc.

References Converged::CONVERGED, and m_IsConverged.

Referenced by Converged::Register().

2676 {
2677  unsigned idx = m_IsConverged.size();
2678  m_IsConverged.resize(idx + 1);
2680  return idx;
2681 }
Converged_t m_IsConverged
Definition: dataman.h:399
void DataManager::ConvergedSet ( unsigned  idx,
Converged::State  s 
)

Definition at line 2684 of file dataman2.cc.

References ASSERT, and m_IsConverged.

Referenced by Converged::Set().

2685 {
2686  ASSERT(idx < m_IsConverged.size());
2687 
2688  m_IsConverged[idx] = s;
2689 }
Converged_t m_IsConverged
Definition: dataman.h:399
#define ASSERT(expression)
Definition: colamd.c:977
void DataManager::DerivativesUpdate ( void  ) const
virtual

Reimplemented in SchurDataManager.

Definition at line 2587 of file dataman2.cc.

References VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), SimulationEntity::DerivativesUpdate(), ElemIter, Nodes, pXCurr, and pXPrimeCurr.

Referenced by DerivativeSolver::Update().

2588 {
2589  for (NodeVecType::const_iterator i = Nodes.begin(); i != Nodes.end(); ++i) {
2590  (*i)->DerivativesUpdate(*pXCurr, *pXPrimeCurr);
2591  }
2592 
2593  /* Versione con iteratore: */
2594  Elem* pEl = NULL;
2595  if (ElemIter.bGetFirst(pEl)) {
2596  do {
2598  } while (ElemIter.bGetNext(pEl));
2599  }
2600 }
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
NodeVecType Nodes
Definition: dataman.h:743
VectorHandler * pXPrimeCurr
Definition: dataman.h:109
VecIter< Elem * > ElemIter
Definition: dataman.h:612
Definition: elem.h:75
virtual void DerivativesUpdate(const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: simentity.cc:105
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
VectorHandler * pXCurr
Definition: dataman.h:108

Here is the call graph for this function:

doublereal DataManager::dGetDefaultScale ( DofOwner::Type  t) const
protected

Definition at line 64 of file dofman.cc.

References DofData.

Referenced by DofDataInit(), and dReadScale().

65 {
66  return DofData[t].dDefScale;
67 }
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
const doublereal & DataManager::dGetInitialPositionStiffness ( void  ) const

Definition at line 111 of file dataman2.cc.

References dInitialPositionStiffness.

Referenced by ReadStructNode().

112 {
114 }
doublereal dInitialPositionStiffness
Definition: dataman.h:121
const doublereal & DataManager::dGetInitialVelocityStiffness ( void  ) const

Definition at line 117 of file dataman2.cc.

References dInitialVelocityStiffness.

Referenced by ReadStructNode().

118 {
120 }
doublereal dInitialVelocityStiffness
Definition: dataman.h:122
doublereal DataManager::dGetTime ( void  ) const

Definition at line 165 of file dataman2.cc.

References DriveHandler::dGetTime(), and DrvHdl.

Referenced by DerivativeSolver::Advance(), Step1Integrator::Advance(), Step2Integrator::Advance(), ModuleFMU::AssRes(), ThirdOrderIntegrator::Jacobian(), LineSearchSolver::LineSearch(), ModuleFMU::ModuleFMU(), ThirdOrderIntegrator::Residual(), InverseSolver::Restart(), Solver::Restart(), and LineSearchSolver::Solve().

166 {
167  return DrvHdl.dGetTime();
168 } /* End of DataManager::dGetTime() */
doublereal dGetTime(void) const
Definition: drive.h:386
DriveHandler DrvHdl
Definition: dataman.h:104

Here is the call graph for this function:

void DataManager::DofDataInit ( void  )

Definition at line 69 of file dofman.cc.

References DEBUGLCOUT, dGetDefaultScale(), DofData, DofOwners, iTotDofOwners, DofOwner::LASTDOFTYPE, MBDYN_EXCEPT_ARGS, and MYDEBUG_INIT.

Referenced by DataManager().

70 {
71  /* struttura dei DofOwner */
72 
73  /* Calcola il numero totale di DofOwner */
74  for (int iCnt = 0; iCnt < DofOwner::LASTDOFTYPE; iCnt++) {
75  iTotDofOwners += DofData[iCnt].iNum;
76  }
77 
78  DEBUGLCOUT(MYDEBUG_INIT, "iTotDofOwners = " << iTotDofOwners << std::endl);
79 
80  /* Crea la struttura dinamica dei DofOwner */
81  if (iTotDofOwners > 0) {
82  DofOwners.resize(iTotDofOwners);
83 
84  /* Resetta la struttura dinamica dei DofOwner */
85  for (int iCnt = 0; iCnt < iTotDofOwners; iCnt++) {
86  DofOwners[iCnt].iFirstIndex = 0;
87  DofOwners[iCnt].iNumDofs = 0;
88  }
89 
90  /* Inizializza la struttura dinamica dei DofOwner
91  * con il numero di Dof di ognuno */
92  DofData[0].pFirstDofOwner = &DofOwners[0];
93  for (int iType = 0; iType < DofOwner::LASTDOFTYPE - 1; iType++) {
94  DofData[iType + 1].pFirstDofOwner =
95  DofData[iType].pFirstDofOwner+
96  DofData[iType].iNum;
97 
98  for (int iDof = 0; iDof < DofData[iType].iNum; iDof++) {
99  DofData[iType].pFirstDofOwner[iDof].SetScale(dGetDefaultScale(DofOwner::Type(iType)));
100  }
101  }
102 
103  } else {
104  /* Se non sono definiti DofOwners, la simulazione non ha senso,
105  * quindi il programma termina */
106  silent_cerr("warning, no dof owners are defined" << std::endl);
107  throw NoErr(MBDYN_EXCEPT_ARGS);
108  }
109 }
integer iTotDofOwners
Definition: dataman.h:795
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal dGetDefaultScale(DofOwner::Type t) const
Definition: dofman.cc:64
std::vector< DofOwner > DofOwners
Definition: dataman.h:796
Definition: except.h:79
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244

Here is the call graph for this function:

void DataManager::DofInit ( void  )

Definition at line 111 of file dofman.cc.

References DEBUGCERR, DEBUGLCOUT, DofOrder::DIFFERENTIAL, DofOwners, Dofs, iTotDofOwners, iTotDofs, MBDYN_EXCEPT_ARGS, and MYDEBUG_INIT.

Referenced by DataManager().

112 {
113  if (iTotDofOwners > 0) {
114 
115  /* Di ogni DofOwner setta il primo indice
116  * e calcola il numero totale di Dof */
117  integer iIndex = 0; /* contatore dei Dof */
118  integer iNumDofs = 0; /* numero di dof di un owner */
119 
120  for (int iCnt = 0; iCnt < iTotDofOwners; iCnt++) {
121  iNumDofs = DofOwners[iCnt].iNumDofs;
122  if (iNumDofs > 0) {
123  DofOwners[iCnt].iFirstIndex = iIndex;
124  iIndex += iNumDofs;
125  } else {
126  DofOwners[iCnt].iFirstIndex = -1;
127  DEBUGCERR("warning, item " << (iCnt + 1) << " has 0 dofs" << std::endl);
128  }
129  }
130 
131  iTotDofs = iIndex;
132 
133  DEBUGLCOUT(MYDEBUG_INIT, "iTotDofs = " << iTotDofs << std::endl);
134  } else {
135  DEBUGCERR("");
136  silent_cerr("no dof owners are defined" << std::endl);
137 
139  }
140 
141 
142  /* Crea la struttura dinamica dei Dof */
143  if(iTotDofs > 0) {
144  Dofs.resize(iTotDofs);
145  integer iIndex = DofOwners[0].iFirstIndex;
146  for (DofIterator i = Dofs.begin(); i != Dofs.end(); ++i) {
147  i->iIndex = iIndex++;
148  i->Order = DofOrder::DIFFERENTIAL;
149  }
150  } else {
151  DEBUGCERR("");
152  silent_cerr("no dofs are defined" << std::endl);
153 
155  }
156 }
integer iTotDofOwners
Definition: dataman.h:795
DofVecType::iterator DofIterator
Definition: dataman.h:803
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
DofVecType Dofs
Definition: dataman.h:813
#define DEBUGCERR(msg)
Definition: myassert.h:235
std::vector< DofOwner > DofOwners
Definition: dataman.h:796
integer iTotDofs
Definition: dataman.h:809
long int integer
Definition: colamd.c:51
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
void DataManager::DofManager ( void  )

Definition at line 40 of file dofman.cc.

References DofData, DummyDofOwner, DofOwner::iFirstIndex, DofOwner::iNumDofs, and DofOwner::LASTDOFTYPE.

Referenced by DataManager().

41 {
44 
45  /* Resetta la struttura statica */
46  for(int i = 0; i < DofOwner::LASTDOFTYPE; i++) {
47  DofData[i].pFirstDofOwner = NULL;
48  DofData[i].iNum = 0;
49  DofData[i].iSize = 0;
50  DofData[i].dDefScale = 1.;
51  }
52 }
unsigned int iNumDofs
Definition: dofown.h:95
DofOwner DummyDofOwner
Definition: dataman.h:815
integer iFirstIndex
Definition: dofown.h:94
struct DataManager::@30 DofData[DofOwner::LASTDOFTYPE]
void DataManager::DofManagerDestructor ( void  )

Definition at line 56 of file dofman.cc.

References DEBUGCOUTFNAME.

Referenced by ~DataManager().

57 {
58  DEBUGCOUTFNAME("DataManager::DofManagerDestructor");
59 
60  // TODO: remove?
61 }
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
void DataManager::DofOwnerInit ( void  )
protected

Definition at line 182 of file dataman2.cc.

References ASSERT, begin(), VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), DEBUG_LEVEL_MATCH, DEBUGCOUTFNAME, DEBUGLCOUT, Elem::DescribeDof(), Elem::DescribeEq(), Dofs, OutputHandler::DOFSTATS, OutputHandler::DofStats(), StructNode::DUMMY, ElemIter, Elem::GetConnectedNodes(), Elem::GetDofType(), Elem::GetElemType(), SimulationEntity::GetEqType(), WithLabel::GetLabel(), Node::GetNode(), Node::GetNodeType(), StructDispNode::GetStructDispNodeType(), StructNode::GetStructNodeType(), DofOwnerOwner::iGetFirstIndex(), StructDispNode::iGetFirstMomentumIndex(), StructDispNode::iGetFirstPositionIndex(), Elem::iGetNumDof(), Node::LASTNODETYPE, OutputHandler::Log(), MYDEBUG_ASSEMBLY, MYDEBUG_INIT, DataManager::NodeDataStructure::NodeContainer, NodeData, Nodes, OutputHandler::Open(), OutHdl, PRINT_DOF_DESCRIPTION, PRINT_DOF_STATS, PRINT_EL_CONNECTION, PRINT_EQ_DESCRIPTION, PRINT_NODE_CONNECTION, PRINT_TO_FILE, psElemNames, psNodeNames, StructDispNode::STATIC, StructNode::STATIC, Node::STRUCTURAL, and uPrintFlags.

Referenced by DataManager().

183 {
184  DEBUGCOUTFNAME("DataManager::DofOwnerInit");
185  ASSERT(!Dofs.empty());
186  ASSERT(!Nodes.empty());
187 
188  if ( uPrintFlags & PRINT_TO_FILE ) {
190  }
191 
192  std::ostream& out_ds = (uPrintFlags & PRINT_TO_FILE)
193  ? OutHdl.DofStats()
194  : std::cout;
195 
196  bool pds =
197 #ifdef DEBUG
199 #endif /* DEBUG */
200  (!silent_output && (uPrintFlags & PRINT_DOF_STATS));
201 
202  /* NOTE: further direct use of std::cout instead
203  * of silent_cout() macro because silent_cout is
204  * tested in "pds".
205  */
206  if (pds) {
207  out_ds << "Regular steps dof stats" << std::endl;
208  }
209 
210  /* per ogni nodo strutturale */
211  if (!NodeData[Node::STRUCTURAL].NodeContainer.empty()) {
212 
213  /*
214  * used by POD stuff: if any, output
215  * the list of the first dof (minus 1)
216  * of each structural node, so it's easy
217  * to get the struct node values
218  * in MATLAB: given a vector "X" with all
219  * the states, and a vector
220  * "v" with the first dof of each
221  * structural node, then the x coordinate
222  * is X(v+1) and so forth
223  */
224 
225  OutHdl.Log() << "struct node dofs:";
226  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
227  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
228  {
229  const StructNode *pNode = dynamic_cast<const StructNode *>(i->second);
230  if (pNode) {
231  if (pNode->GetStructNodeType() == StructNode::DUMMY) {
232  continue;
233  }
234  OutHdl.Log() << " " << pNode->iGetFirstPositionIndex();
235  }
236  }
237  OutHdl.Log() << std::endl;
238 
239  OutHdl.Log() << "struct node eqs:";
240  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
241  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
242  {
243  const StructNode *pNode = dynamic_cast<const StructNode *>(i->second);
244  if (pNode) {
245  if (pNode->GetStructNodeType() == StructNode::DUMMY) {
246  continue;
247  }
248  OutHdl.Log() << " " << pNode->iGetFirstMomentumIndex();
249  }
250  }
251  OutHdl.Log() << std::endl;
252 
253  OutHdl.Log() << "struct node momentum dofs:";
254  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
255  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
256  {
257  const StructNode *pNode = dynamic_cast<const StructNode *>(i->second);
258  if (pNode) {
259  switch (pNode->GetStructNodeType()) {
260  case StructNode::STATIC:
261  case StructNode::DUMMY:
262  continue;
263 
264  default:
265  break;
266  }
267  OutHdl.Log() << " " << pNode->iGetFirstMomentumIndex();
268  }
269  }
270  OutHdl.Log() << std::endl;
271 
272  OutHdl.Log() << "struct node momentum eqs:";
273  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
274  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
275  {
276  const StructNode *pNode = dynamic_cast<const StructNode *>(i->second);
277  if (pNode) {
278  switch (pNode->GetStructNodeType()) {
279  case StructNode::STATIC:
280  case StructNode::DUMMY:
281  continue;
282 
283  default:
284  break;
285  }
286  OutHdl.Log() << " " << pNode->iGetFirstIndex();
287  }
288  }
289  OutHdl.Log() << std::endl;
290 
291  OutHdl.Log() << "struct displacement node dofs:";
292  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
293  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
294  {
295  const StructDispNode *pDispNode = dynamic_cast<const StructDispNode *>(i->second);
296  if (pDispNode) {
297  const StructNode* pNode = dynamic_cast<const StructNode*>(pDispNode);
298  if (pNode && pNode->GetStructNodeType() == StructNode::DUMMY) {
299  continue;
300  }
301  OutHdl.Log() << " " << pDispNode->iGetFirstPositionIndex();
302  }
303  }
304  OutHdl.Log() << std::endl;
305 
306  OutHdl.Log() << "struct displacement node eqs:";
307  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
308  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
309  {
310  const StructDispNode *pDispNode = dynamic_cast<const StructDispNode *>(i->second);
311  if (pDispNode) {
312  const StructNode* pNode = dynamic_cast<const StructNode*>(pDispNode);
313  if (pNode && pNode->GetStructNodeType() == StructNode::DUMMY) {
314  continue;
315  }
316  OutHdl.Log() << " " << pDispNode->iGetFirstMomentumIndex();
317  }
318  }
319  OutHdl.Log() << std::endl;
320 
321  OutHdl.Log() << "struct displacement node momentum dofs:";
322  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
323  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
324  {
325  const StructDispNode *pDispNode = dynamic_cast<const StructDispNode *>(i->second);
326  if (pDispNode) {
327  const StructNode* pNode = dynamic_cast<const StructNode*>(pDispNode);
328  if (pNode && pNode->GetStructNodeType() == StructNode::DUMMY) {
329  continue;
330  }
331  switch (pDispNode->GetStructDispNodeType()) {
333  continue;
334 
335  default:
336  break;
337  }
338  OutHdl.Log() << " " << pDispNode->iGetFirstMomentumIndex();
339  }
340  }
341  OutHdl.Log() << std::endl;
342 
343  OutHdl.Log() << "struct displacement node momentum eqs:";
344  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
345  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
346  {
347  const StructDispNode *pDispNode = dynamic_cast<const StructDispNode *>(i->second);
348  if (pDispNode) {
349  const StructNode* pNode = dynamic_cast<const StructNode*>(pDispNode);
350  if (pNode && pNode->GetStructNodeType() == StructNode::DUMMY) {
351  continue;
352  }
353  switch (pDispNode->GetStructDispNodeType()) {
354  case StructNode::STATIC:
355  continue;
356 
357  default:
358  break;
359  }
360  OutHdl.Log() << " " << pDispNode->iGetFirstIndex();
361  }
362  }
363  OutHdl.Log() << std::endl;
364 
365  OutHdl.Log() << "struct node labels:";
366  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
367  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
368  {
369  const StructNode *pNode = dynamic_cast<const StructNode *>(i->second);
370  if (pNode) {
371  if (pNode->GetStructNodeType() == StructNode::DUMMY) {
372  continue;
373  }
374  OutHdl.Log() << " " << pNode->GetLabel();
375  }
376  }
377  OutHdl.Log() << std::endl;
378 
379  OutHdl.Log() << "struct displacement node labels:";
380  for (NodeContainerType::const_iterator i = NodeData[Node::STRUCTURAL].NodeContainer.begin();
381  i != NodeData[Node::STRUCTURAL].NodeContainer.end(); ++i)
382  {
383  const StructDispNode *pDispNode = dynamic_cast<const StructDispNode *>(i->second);
384  if (pDispNode) {
385  const StructNode* pNode = dynamic_cast<const StructNode*>(pDispNode);
386  if (pNode && pNode->GetStructNodeType() == StructNode::DUMMY) {
387  continue;
388  }
389  OutHdl.Log() << " " << pDispNode->GetLabel();
390  }
391  }
392  OutHdl.Log() << std::endl;
393  }
394 
395  /* per ogni nodo */
396  for (NodeVecType::const_iterator i = Nodes.begin(); i != Nodes.end(); ++i) {
398  psNodeNames[(*i)->GetNodeType()]
399  << "(" << (*i)->GetLabel() << ")"
400  << std::endl);
401 
402  /* chiede al nodo quanti dof possiede */
403  unsigned int iNumDof = (*i)->iGetNumDof();
404  if (iNumDof > 0) {
405  ASSERT((*i)->iGetFirstIndex() >= 0);
406 
407  /* si fa passare il primo Dof */
408  Dof* pDf = &Dofs[(*i)->iGetFirstIndex()];
409 
410 #ifdef DEBUG
412  psNodeNames[(*i)->GetNodeType()]
413  << "(" << (*i)->GetLabel() << "): "
414  "first dof = " << pDf->iIndex + 1
415  << std::endl);
416 #endif /* DEBUG */
417 
418  if (pds) {
419  unsigned int nd = (*i)->iGetNumDof();
420  integer fd = pDf->iIndex;
421 
422  out_ds << psNodeNames[(*i)->GetNodeType()]
423  << "(" << (*i)->GetLabel() << "): "
424  << nd << " " << fd + 1;
425  if (nd > 1) {
426  out_ds << "->" << fd + nd;
427  }
428  out_ds << std::endl;
430  (*i)->DescribeDof(out_ds,
431  " ");
432  }
433 
435  (*i)->DescribeEq(out_ds,
436  " ");
437  }
438  }
439 
440  /* per ogni Dof, chiede al nodo di che tipo e' e lo
441  * setta nel DofOwner */
442  std::vector<std::string> DofDesc;
443  (*i)->DescribeDof(DofDesc);
444  if (DofDesc.size() == iNumDof) {
445  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
446  pDf[iCnt].Description = DofDesc[iCnt];
447  }
448 
449  } else {
450  std::ostringstream os;
451  os << psNodeNames[(*i)->GetNodeType()]
452  << "(" << (*i)->GetLabel() << ")";
453  std::string name(os.str());
454 
455  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
456  os.str(name);
457  os.seekp(0, std::ios_base::end);
458  os << ": dof(" << iCnt + 1 << ")";
459  pDf[iCnt].Description = os.str();
460  }
461  }
462 
463  std::vector<std::string> EqDesc;
464  (*i)->DescribeEq(EqDesc);
465  if (EqDesc.size() == iNumDof) {
466  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
467  pDf[iCnt].EqDescription = EqDesc[iCnt];
468  }
469 
470  } else {
471  std::ostringstream os;
472  os << psNodeNames[(*i)->GetNodeType()]
473  << "(" << (*i)->GetLabel() << ")";
474  std::string name(os.str());
475 
476  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
477  os.str(name);
478  os.seekp(0, std::ios_base::end);
479  os << ": equation(" << iCnt + 1 << ")";
480  pDf[iCnt].EqDescription = os.str();
481  }
482  }
483 
484  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
485  pDf[iCnt].Order = (*i)->GetDofType(iCnt);
486  pDf[iCnt].EqOrder = (*i)->GetEqType(iCnt);
487  }
488  }
489  }
490 
491  /* per ogni elemento */
492  Elem* pEl = NULL;
493  if (ElemIter.bGetFirst(pEl)) {
494  do {
495  ASSERT(pEl != NULL);
497  "Elem type " << pEl->GetElemType()
498  << " (" << psElemNames[pEl->GetElemType()]
499  << "(" << pEl->GetLabel() << "))" << std::endl);
500 
501  /* chiede all'elemento quanti dof possiede */
502  unsigned int iNumDof = pEl->iGetNumDof();
503  if (iNumDof > 0) {
504  ElemWithDofs* pEWD = Cast<ElemWithDofs>(pEl);
505 
506  ASSERT(pEWD->iGetFirstIndex() >= 0);
507 
508  /* si fa passare il DofOwner */
509  Dof* pDf = &Dofs[pEWD->iGetFirstIndex()];
510 
511 #ifdef DEBUG
513  psElemNames[pEl->GetElemType()]
514  << "(" << pEWD->GetLabel() << "): "
515  "first dof = " << pDf->iIndex + 1
516  << std::endl);
517 #endif /* DEBUG */
518 
519  if (pds) {
520  unsigned int nd = pEWD->iGetNumDof();
521  integer fd = pDf->iIndex;
522 
523  out_ds << psElemNames[pEWD->GetElemType()]
524  << "(" << pEWD->GetLabel() << "): "
525  << nd << " " << fd + 1;
526  if (nd > 1) {
527  out_ds << "->" << fd + nd;
528  }
529  out_ds << std::endl;
530  if (uPrintFlags & PRINT_DOF_DESCRIPTION) {
531  pEWD->DescribeDof(out_ds,
532  " ");
533  }
534 
535  if (uPrintFlags & PRINT_EQ_DESCRIPTION) {
536  pEWD->DescribeEq(out_ds,
537  " ");
538  }
539  }
540 
541 
542  /* per ogni Dof, chiede all'elemento
543  * di che tipo e' e lo setta
544  * nel DofOwner */
545  std::vector<std::string> DofDesc;
546  pEWD->DescribeDof(DofDesc);
547  if (DofDesc.size() == iNumDof) {
548  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
549  pDf[iCnt].Description = DofDesc[iCnt];
550  }
551 
552  } else {
553  std::ostringstream os;
554  os << psElemNames[pEWD->GetElemType()]
555  << "(" << pEWD->GetLabel() << ")";
556  std::string name(os.str());
557 
558  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
559  os.str(name);
560  os.seekp(0, std::ios_base::end);
561  os << ": dof(" << iCnt + 1 << ")";
562  pDf[iCnt].Description = os.str();
563  }
564  }
565 
566  std::vector<std::string> EqDesc;
567  pEWD->DescribeEq(EqDesc);
568  if (EqDesc.size() == iNumDof) {
569  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
570  pDf[iCnt].EqDescription = EqDesc[iCnt];
571  }
572 
573  } else {
574  std::ostringstream os;
575  os << psElemNames[pEWD->GetElemType()]
576  << "(" << pEWD->GetLabel() << ")";
577  std::string name(os.str());
578 
579  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
580  os.str(name);
581  os.seekp(0, std::ios_base::end);
582  os << ": equation(" << iCnt + 1 << ")";
583  pDf[iCnt].EqDescription = os.str();
584  }
585  }
586 
587  for (unsigned int iCnt = 0; iCnt < iNumDof; iCnt++) {
588  pDf[iCnt].Order = pEWD->GetDofType(iCnt);
589  pDf[iCnt].EqOrder = pEWD->GetEqType(iCnt);
590  }
591  }
592  } while (ElemIter.bGetNext(pEl));
593  }
594 
595  /* FIXME: this should rather go before initial assembly */
596  /* NOTE: we run code anyway, but only print if requested/allowed
597  * for consistency checking purposes */
598 
599  /* per ogni elemento */
600  if (ElemIter.bGetFirst(pEl)) {
601  /* create node connection structure */
602  typedef std::set<const Elem *> elmap;
603  typedef std::map<const Node *, elmap *> nodemap;
604  std::vector<nodemap> connectedElems(Node::LASTNODETYPE);
605 
606  /* element connections get populated directly by elements */
607  std::vector<const Node *> connectedNodes;
608 
610  out_ds << "Element connections" << std::endl;
611  }
612 
613  do {
614  pEl->GetConnectedNodes(connectedNodes);
615 
616  if (connectedNodes.size() > 0) {
617  if (uPrintFlags & PRINT_EL_CONNECTION) {
618  out_ds << psElemNames[pEl->GetElemType()]
619  << "(" << pEl->GetLabel() << ") connecting" << std::endl;
620  }
621  for (std::vector<const Node *>::const_iterator i = connectedNodes.begin();
622  i != connectedNodes.end(); ++i)
623  {
624  const Node *real_i = (*i)->GetNode();
625  if (uPrintFlags & PRINT_EL_CONNECTION) {
626  out_ds << " "
627  << psNodeNames[real_i->GetNodeType()]
628  << "(" << real_i->GetLabel() << ")" << std::endl;
629  }
630 
631  nodemap::iterator n = connectedElems[real_i->GetNodeType()].find(real_i);
632  if (n == connectedElems[real_i->GetNodeType()].end()) {
633  connectedElems[real_i->GetNodeType()][real_i] = new elmap;
634  }
635  connectedElems[real_i->GetNodeType()][real_i]->insert(pEl);
636  }
637 
638  } else {
639  if (uPrintFlags & PRINT_EL_CONNECTION) {
640  out_ds << psElemNames[pEl->GetElemType()]
641  << "(" << pEl->GetLabel() << ") not connected" << std::endl;
642  }
643  }
644 
645  } while (ElemIter.bGetNext(pEl));
646 
647 
649  out_ds << "Node connections" << std::endl;
650  }
651  for (unsigned t = 0; t < Node::LASTNODETYPE; t++) {
652  for (nodemap::iterator n = connectedElems[t].begin();
653  n != connectedElems[t].end(); ++n)
654  {
655  if (uPrintFlags & PRINT_NODE_CONNECTION) {
656  out_ds << psNodeNames[n->first->GetNodeType()]
657  << "(" << n->first->GetLabel() << ") connected to" << std::endl;
658  }
659  for (elmap::const_iterator e = n->second->begin();
660  e != n->second->end(); ++e)
661  {
662  if (uPrintFlags & PRINT_NODE_CONNECTION) {
663  out_ds << " "
664  << psElemNames[(*e)->GetElemType()]
665  << "(" << (*e)->GetLabel() << ")" << std::endl;
666  }
667  }
668 
669  delete n->second;
670  n->second = 0;
671  }
672  }
673  }
674 } /* End of DataManager::DofOwnerInit() */
virtual DofOrder::Order GetEqType(unsigned int i) const
Definition: simentity.h:138
#define DEBUG_LEVEL_MATCH(level)
Definition: myassert.h:241
virtual StructDispNode::Type GetStructDispNodeType(void) const =0
std::ostream & DofStats(void) const
Definition: output.h:594
Definition: node.h:67
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
DofVecType Dofs
Definition: dataman.h:813
NodeVecType Nodes
Definition: dataman.h:743
OutputHandler OutHdl
Definition: dataman.h:105
virtual Elem::Type GetElemType(void) const =0
NodeContainerType NodeContainer
Definition: dataman.h:731
bool Open(const OutputHandler::OutFiles out)
Definition: output.cc:298
virtual StructNode::Type GetStructNodeType(void) const =0
DataManager::ElemContainerType::const_iterator begin(Elem::Type t) const
Definition: dataman.cc:902
struct DataManager::NodeDataStructure NodeData[Node::LASTNODETYPE]
virtual std::ostream & DescribeEq(std::ostream &out, const char *prefix="", bool bInitial=false) const
Definition: elem.cc:137
virtual integer iGetFirstMomentumIndex(void) const =0
virtual integer iGetFirstPositionIndex(void) const
Definition: strnode.h:452
#define ASSERT(expression)
Definition: colamd.c:977
VecIter< Elem * > ElemIter
Definition: dataman.h:612
virtual unsigned int iGetNumDof(void) const
Definition: elem.cc:118
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: elem.h:243
const char * psNodeNames[]
Definition: enums.cc:372
Definition: elem.h:75
virtual Node::Type GetNodeType(void) const =0
const char * psElemNames[]
Definition: enums.cc:39
virtual DofOrder::Order GetDofType(unsigned int) const
Definition: elem.cc:150
std::ostream & Log(void) const
Definition: output.h:541
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
long int integer
Definition: colamd.c:51
Definition: dofown.h:59
const Node * GetNode(void) const
Definition: node.h:111
unsigned int GetLabel(void) const
Definition: withlab.cc:62
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
unsigned uPrintFlags
Definition: dataman.h:156
virtual std::ostream & DescribeDof(std::ostream &out, const char *prefix="", bool bInitial=false) const
Definition: elem.cc:124

Here is the call graph for this function:

void DataManager::DofOwnerSet ( void  )
protected

Definition at line 1368 of file dataman2.cc.

References DEBUGCOUTFNAME, DEBUGLCOUT, DataManager::ElemDataStructure::DofOwnerType, DataManager::ElemDataStructure::ElemContainer, ElemData, Elem::GetElemType(), WithLabel::GetLabel(), Elem::iGetNumDof(), DofOwner::iNumDofs, Elem::LASTELEMTYPE, MYDEBUG_INIT, Nodes, DofOwnerOwner::pGetDofOwner(), psElemNames, and DofOwner::UNKNOWN.

Referenced by DataManager().

1369 {
1370  DEBUGCOUTFNAME("DataManager::DofOwnerSet");
1371 
1372  /* Setta i DofOwner dei nodi */
1373  for (NodeVecType::iterator i = Nodes.begin(); i != Nodes.end(); ++i) {
1374  DofOwner* pDO = const_cast<DofOwner *>((*i)->pGetDofOwner());
1375  pDO->iNumDofs = (*i)->iGetNumDof();
1376  }
1377 
1378  /* Setta i DofOwner degli elementi (chi li possiede) */
1379  for (int iCnt = 0; iCnt < Elem::LASTELEMTYPE; iCnt++) {
1381  if (DT != DofOwner::UNKNOWN) {
1382  DEBUGLCOUT(MYDEBUG_INIT, "Elem type " << iCnt
1383  << " (" << psElemNames[iCnt] << ")"
1384  << std::endl);
1385 
1386  for (ElemContainerType::const_iterator p = ElemData[iCnt].ElemContainer.begin();
1387  p != ElemData[iCnt].ElemContainer.end(); ++p)
1388  {
1389  ElemWithDofs* pEWD = Cast<ElemWithDofs>(p->second);
1390 
1392  << "(" << pEWD->GetLabel() << ")" << std::endl);
1393 
1394  DofOwner* pDO = const_cast<DofOwner *>(pEWD->pGetDofOwner());
1395  pDO->iNumDofs = pEWD->iGetNumDof();
1396  DEBUGLCOUT(MYDEBUG_INIT, " num dofs: " << pDO->iNumDofs << std::endl);
1397  }
1398  }
1399  }
1400 } /* end of DofOwnerSet() */
ElemContainerType ElemContainer
Definition: dataman.h:591
DofOwner::Type DofOwnerType
Definition: dataman.h:565
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
unsigned int iNumDofs
Definition: dofown.h:95
NodeVecType Nodes
Definition: dataman.h:743
virtual Elem::Type GetElemType(void) const =0
virtual const DofOwner * pGetDofOwner(void) const
Definition: dofown.h:113
virtual unsigned int iGetNumDof(void) const
Definition: elem.cc:118
const char * psElemNames[]
Definition: enums.cc:39
unsigned int GetLabel(void) const
Definition: withlab.cc:62
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244

Here is the call graph for this function:

doublereal DataManager::dReadScale ( MBDynParser HP,
enum DofOwner::Type  t 
) const

Definition at line 1491 of file dataman3.cc.

References dGetDefaultScale(), HighParser::GetReal(), and HighParser::IsKeyWord().

Referenced by ReadNodes(), and ReadStructNode().

1492 {
1494 
1495  if (!HP.IsKeyWord("scale")) {
1496  return d;
1497  }
1498 
1499  if (!HP.IsKeyWord("default")) {
1500  d = HP.GetReal(d);
1501  }
1502 
1503  return d;
1504 }
doublereal dGetDefaultScale(DofOwner::Type t) const
Definition: dofman.cc:64
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
double doublereal
Definition: colamd.c:52
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function:

void DataManager::DriveOutput ( OutputHandler OH) const

Definition at line 2429 of file dataman2.cc.

References OutputHandler::DRIVECALLERS, MBDynParser::GetDriveCallerContainer(), OutputHandler::IsOpen(), and MBPar.

Referenced by Output().

2430 {
2432  return;
2433  }
2434 
2436 
2437  for (MBDynParser::DCType::const_iterator i = DC.begin(); i != DC.end(); ++i) {
2438  i->second->Output(OH);
2439  }
2440 }
const DCType & GetDriveCallerContainer(void) const
Definition: mbpar.cc:854
std::map< unsigned, const DriveCaller * > DCType
Definition: mbpar.h:207
bool IsOpen(int out) const
Definition: output.cc:395
MBDynParser & MBPar
Definition: dataman.h:97

Here is the call graph for this function:

void DataManager::DriveTrace ( OutputHandler OH) const

Definition at line 2415 of file dataman2.cc.

References MBDynParser::GetDriveCallerContainer(), OutputHandler::IsOpen(), MBPar, and OutputHandler::TRACES.

Referenced by Output().

2416 {
2417  if (!OH.IsOpen(OutputHandler::TRACES)) {
2418  return;
2419  }
2420 
2422 
2423  for (MBDynParser::DCType::const_iterator i = DC.begin(); i != DC.end(); ++i) {
2424  i->second->Trace(OH);
2425  }
2426 }
const DCType & GetDriveCallerContainer(void) const
Definition: mbpar.cc:854
std::map< unsigned, const DriveCaller * > DCType
Definition: mbpar.h:207
bool IsOpen(int out) const
Definition: output.cc:395
MBDynParser & MBPar
Definition: dataman.h:97

Here is the call graph for this function:

void DataManager::ElemAssInit ( void  )

Definition at line 318 of file elman.cc.

References ASSERT, VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), DEBUGCOUT, DEBUGLCOUT, ElemIter, iMaxWorkNumColsJac, iMaxWorkNumItemsJac, iMaxWorkNumRowsJac, iMaxWorkNumRowsRes, MYDEBUG_INIT, pWorkMat, pWorkMatA, pWorkMatB, pWorkVec, SAFENEWWITHCONSTRUCTOR, and Elem::WorkSpaceDim().

Referenced by DataManager().

319 {
320  Elem* pE = 0;
321  if (ElemIter.bGetFirst(pE)) {
322  do {
323  /* Aggiorna le dimensioni massime degli spazi di lavoro */
324  integer iNumRows = 0;
325  integer iNumCols = 0;
326 
327  pE->WorkSpaceDim(&iNumRows, &iNumCols);
328 
329  if (iNumRows >= 0) {
330  // Assume a full Jacobian matrix
331  if (iNumRows > iMaxWorkNumRowsJac) {
332  iMaxWorkNumRowsJac = iNumRows;
333  DEBUGLCOUT(MYDEBUG_INIT, "Current max work rows number: "
334  << iMaxWorkNumRowsJac << std::endl);
335  }
336 
337  if (iNumCols > iMaxWorkNumColsJac) {
338  iMaxWorkNumColsJac = iNumCols;
339  DEBUGLCOUT(MYDEBUG_INIT, "Current max work cols number: "
340  << iMaxWorkNumColsJac << std::endl);
341  }
342  } else {
343  // Assume a sparse Jacobian matrix
344  iNumRows = std::abs(iNumRows);
345  }
346 
347  const integer iNumItems = iNumRows * iNumCols;
348 
349  if (iNumItems > iMaxWorkNumItemsJac) {
350  iMaxWorkNumItemsJac = iNumItems;
351  }
352 
353  if (iNumRows > iMaxWorkNumRowsRes) {
354  iMaxWorkNumRowsRes = iNumRows;
355  }
356 
357  } while (ElemIter.bGetNext(pE));
358  }
359 
364 
365  /* SubMatrixHandlers */
371 
377 
379 
383 
384  DEBUGCOUT("Creating working matrices:" << iMaxWorkNumRowsJac
385  << " x " << iMaxWorkNumColsJac << std::endl);
386 }
integer iMaxWorkNumItemsJac
Definition: dataman.h:628
VariableSubMatrixHandler * pWorkMatA
Definition: dataman.h:630
bool bGetNext(T &TReturn) const
Definition: veciter.h:118
integer iMaxWorkNumRowsRes
Definition: dataman.h:625
MySubVectorHandler * pWorkVec
Definition: dataman.h:633
VariableSubMatrixHandler * pWorkMatB
Definition: dataman.h:631
integer iMaxWorkNumRowsJac
Definition: dataman.h:626
#define DEBUGCOUT(msg)
Definition: myassert.h:232
integer iMaxWorkNumColsJac
Definition: dataman.h:627
#define ASSERT(expression)
Definition: colamd.c:977
VecIter< Elem * > ElemIter
Definition: dataman.h:612
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
Definition: elem.h:75
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const =0
bool bGetFirst(T &TReturn) const
Definition: veciter.h:88
long int integer
Definition: colamd.c:51
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
VariableSubMatrixHandler * pWorkMat
Definition: dataman.h:632

Here is the call graph for this function:

void DataManager::ElemDataInit ( void  )

Definition at line 248 of file elman.cc.

References VecIter< T >::bGetFirst(), VecIter< T >::bGetNext(), DEBUGCERR, DEBUGCOUT, DriveData, ElemData, ElemIter, Elems, DataManager::ElemDataStructure::iExpectedNum, VecIter< T >::Init(), iTotDrive, Drive::LASTDRIVETYPE, Elem::LASTELEMTYPE, ppDrive, and SAFENEWARR.

Referenced by DataManager().

249 {
250  unsigned iTotElem = 0;
251 
252  /* struttura degli elementi */
253  for (int iCnt = 0; iCnt < Elem::LASTELEMTYPE; iCnt++) {
254  iTotElem += ElemData[iCnt].iExpectedNum;
255  }
256 
257  DEBUGCOUT("iTotElem = " << iTotElem << std::endl);
258 
259  /* FIXME: reverse this:
260  * - read and populate ElemData[iCnt].ElemContainer first
261  * - then create Elems and fill it with Elem*
262  */
263  if (iTotElem > 0) {
264  Elems.resize(iTotElem);
265 
266  /* Inizializza l'iteratore degli elementi usato all'interno
267  * dell'ElemManager */
268  ElemIter.Init(&Elems[0], iTotElem);
269 
270  for (unsigned iCnt = 0; iCnt < iTotElem; iCnt++) {
271  Elems[iCnt] = 0;
272  }
273 
274  } else {
275  silent_cerr("warning, no elements are defined" << std::endl);
276  }
277 
278  /* struttura dei drivers */
279  for (int iCnt = 0; iCnt < Drive::LASTDRIVETYPE; iCnt++) {
280  iTotDrive += DriveData[iCnt].iNum;
281  }
282 
283  DEBUGCOUT("iTotDrive = " << iTotDrive << std::endl);
284 
285  if (iTotDrive > 0) {
287 
288  /* Puo' essere sostituito con un opportuno iteratore: */
289 #if 0
290  VecIter<Drive*> DriveIter(ppDrive, iTotDrive);
291  Drive* pTmp = NULL;
292  if (DriveIter.bGetFirst(pTmp)) {
293  do {
294  pTmp = NULL;
295  } while (DriveIter.bGetNext(pTmp));
296  }
297 #endif
298 
299  Drive** ppTmp = ppDrive;
300  while (ppTmp < ppDrive + iTotDrive) {
301  *ppTmp++ = NULL;
302  }
303 
304  DriveData[0].ppFirstDrive = ppDrive;
305  for (int iCnt = 0; iCnt < Drive::LASTDRIVETYPE-1; iCnt++) {
306  DriveData[iCnt+1].ppFirstDrive =
307  DriveData[iCnt].ppFirstDrive +
308  DriveData[iCnt].iNum;
309  }
310 
311  } else {
312  DEBUGCERR("warning, no drivers are defined" << std::endl);
313  }
314 }
ElemVecType Elems
Definition: dataman.h:609
Definition: drive.h:89
struct DataManager::@29 DriveData[Drive::LASTDRIVETYPE]
#define DEBUGCERR(msg)
Definition: myassert.h:235
unsigned int iTotDrive
Definition: dataman.h:622
#define DEBUGCOUT(msg)
Definition: myassert.h:232
VecIter< Elem * > ElemIter
Definition: dataman.h:612
Drive ** ppDrive
Definition: dataman.h:621
void Init(const T *p, unsigned i)
Definition: veciter.h:79
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
struct DataManager::ElemDataStructure ElemData[Elem::LASTELEMTYPE]

Here is the call graph for this function:

void DataManager::ElemManager ( void  )

Definition at line 51 of file elman.cc.

References OutputHandler::AERODYNAMIC, DofOwner::AERODYNAMIC, Elem::AERODYNAMIC, DofOwner::AEROMODAL, Elem::AEROMODAL, OutputHandler::AEROMODALS, Elem::AIRPROPERTIES, AIRPROPOWNER, OutputHandler::AIRPROPS, Elem::AUTOMATICSTRUCTURAL, Elem::BEAM, OutputHandler::BEAMS, Elem::BODY, Elem::BULK, DataManager::ElemDataStructure::DefaultOut(), DataManager::ElemDataStructure::Desc, DOFOWNER, DataManager::ElemDataStructure::DofOwnerType, DriveData, Elem::DRIVEN, DofOwner::ELECTRIC, Elem::ELECTRIC, DofOwner::ELECTRICBULK, Elem::ELECTRICBULK, ELEM, ElemData, EULER_123, Elem::EXTERNAL, OutputHandler::EXTERNALS, fDefaultOut, Elem::FORCE, OutputHandler::FORCES, DofOwner::GENEL, Elem::GENEL, OutputHandler::GENELS, DataManager::ElemDataStructure::GeneratesInertiaForces(), OutputHandler::GRAVITY, Elem::GRAVITY, GRAVITYOWNER, OutputHandler::HYDRAULIC, DofOwner::HYDRAULIC, Elem::HYDRAULIC, DataManager::ElemDataStructure::iDerivation, DataManager::ElemDataStructure::iExpectedNum, DofOwner::INDUCEDVELOCITY, Elem::INDUCEDVELOCITY, OutputHandler::INERTIA, Elem::INERTIA, INITIALASSEMBLY, DataManager::ElemDataStructure::IsUnique(), DofOwner::JOINT, Elem::JOINT, Elem::JOINT_REGULARIZATION, OutputHandler::JOINTS, Drive::LASTDRIVETYPE, Elem::LASTELEMTYPE, OutputHandler::LOADABLE, DofOwner::LOADABLE, Elem::LOADABLE, DataManager::ElemDataStructure::od, DataManager::ElemDataStructure::OutFile, AerodynamicOutput::OUTPUT_DEFAULT, Beam::OUTPUT_DEFAULT, DofOwner::PLATE, Elem::PLATE, OutputHandler::PLATES, OutputHandler::ROTORS, DataManager::ElemDataStructure::ShortDesc, DofOwner::THERMAL, Elem::THERMAL, OutputHandler::THERMALELEMENTS, DataManager::ElemDataStructure::ToBeUsedInAssembly(), DataManager::ElemDataStructure::uFlags, OutputHandler::UNKNOWN, DofOwner::UNKNOWN, DataManager::ElemDataStructure::uOutputFlags, and DataManager::ElemDataStructure::UsesAirProperties().

Referenced by DataManager().

52 {
53  /* Reset della struttura ElemData */
54  for (int i = 0; i < Elem::LASTELEMTYPE; i++) {
55  ElemData[i].iExpectedNum = 0;
57  ElemData[i].uFlags = 0U;
58  ElemData[i].DefaultOut(::fDefaultOut == 1); /* Da "output.h" */
59  ElemData[i].OutFile = OutputHandler::UNKNOWN; /* "output.h" */
60  ElemData[i].uOutputFlags = 0U;
61  ElemData[i].od = EULER_123;
62  }
63 
64  /* Add dof type */
76 
77  /* Add file type */
79  ElemData[Elem::AUTOMATICSTRUCTURAL].Desc = "AutomaticStructural";
81 
83  ElemData[Elem::JOINT].Desc = "Joint";
84  ElemData[Elem::JOINT].ShortDesc = "joint";
85 
87  ElemData[Elem::FORCE].Desc = "Force";
88  ElemData[Elem::FORCE].ShortDesc = "force";
89 
91  ElemData[Elem::BEAM].Desc = "Beam";
92  ElemData[Elem::BEAM].ShortDesc = "beam";
94 
96  ElemData[Elem::PLATE].Desc = "Plate";
97  ElemData[Elem::PLATE].ShortDesc = "plate";
98 
100  ElemData[Elem::AIRPROPERTIES].Desc = "AirProperties";
101  ElemData[Elem::AIRPROPERTIES].ShortDesc = "airprops";
102 
104  ElemData[Elem::GRAVITY].Desc = "Gravity";
105  ElemData[Elem::GRAVITY].ShortDesc = "gravity";
107