MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
body_vm.h File Reference
#include "elem.h"
#include "strnode.h"
#include "gravity.h"
Include dependency graph for body_vm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  VariableBody
 
class  DynamicVariableBody
 
class  StaticVariableBody
 

Functions

ElemReadVariableBody (DataManager *pDM, MBDynParser &HP, unsigned int uLabel, const StructNode *pStrNode)
 

Function Documentation

Elem* ReadVariableBody ( DataManager pDM,
MBDynParser HP,
unsigned int  uLabel,
const StructNode pStrNode 
)

Definition at line 1022 of file body_vm.cc.

References TplDriveCaller< T >::bIsDifferentiable(), DriveCaller::bIsDifferentiable(), DataManager::bIsInverseDynamics(), DataManager::bIsStaticModel(), Elem::BODY, DEBUGCOUTFNAME, DriveCaller::dGet(), StructNode::DYNAMIC, DataManager::fReadOutput(), TplDriveCaller< T >::Get(), MBDynParser::GetDriveCaller(), WithLabel::GetLabel(), IncludeParser::GetLineData(), DataManager::GetLogFile(), DynamicStructNode::GetStructNodeType(), StaticStructNode::GetStructNodeType(), MBDynParser::GetTplDriveCaller(), HighParser::IsArg(), MBDYN_EXCEPT_ARGS, MBDynParser::RF, SAFENEWWITHCONSTRUCTOR, and StructNode::STATIC.

Referenced by ReadBody().

1024 {
1025  DEBUGCOUTFNAME("ReadVariableBody");
1026 
1027  /* may be determined by a special DataManager parameter... */
1028  bool bStaticModel = pDM->bIsStaticModel();
1029  bool bInverseDynamics = pDM->bIsInverseDynamics();
1030 
1031  ReferenceFrame RF(pStrNode);
1032 
1033  const DriveCaller *pDCMass = HP.GetDriveCaller();
1034  if (!pDCMass->bIsDifferentiable()) {
1035  silent_cerr("VariableBody(" << uLabel << "): "
1036  "mass drive caller must be differentiable "
1037  "at line " << HP.GetLineData() << std::endl);
1039  }
1040 
1041  const TplDriveCaller<Vec3> *pDCXgc = HP.GetTplDriveCaller<Vec3>();
1042  if (!pDCXgc->bIsDifferentiable()) {
1043  silent_cerr("VariableBody(" << uLabel << "): "
1044  "center of mass drive caller must be differentiable "
1045  "at line " << HP.GetLineData() << std::endl);
1047  }
1048 
1049  const TplDriveCaller<Mat3x3> *pDCJgc_vm = HP.GetTplDriveCaller<Mat3x3>();
1050  if (!pDCJgc_vm->bIsDifferentiable()) {
1051  silent_cerr("VariableBody(" << uLabel << "): "
1052  "mass-related inertia matrix drive caller must be differentiable "
1053  "at line " << HP.GetLineData() << std::endl);
1055  }
1056 
1057  const TplDriveCaller<Mat3x3> *pDCJgc_vg = HP.GetTplDriveCaller<Mat3x3>();
1058  if (!pDCJgc_vg->bIsDifferentiable()) {
1059  silent_cerr("VariableBody(" << uLabel << "): "
1060  "geometry-related inertia matrix drive caller must be differentiable "
1061  "at line " << HP.GetLineData() << std::endl);
1063  }
1064 
1065  const DynamicStructNode* pDynamicNode = 0;
1066  const StaticStructNode* pStaticNode = 0;
1067 
1068  if (bStaticModel || bInverseDynamics) {
1069  /* static */
1070  pStaticNode = dynamic_cast<const StaticStructNode *>(pStrNode);
1071  if (pStaticNode == 0 || pStaticNode->GetStructNodeType() != StructNode::STATIC) {
1072  silent_cerr("VariableBody(" << uLabel << "): "
1073  "illegal structural node type "
1074  "for StructNode(" << pStrNode->GetLabel() << ") "
1075  "in " << (bStaticModel ? "static model" : "inverse dynamics") << " analysis "
1076  "at line " << HP.GetLineData() << std::endl);
1078  }
1079 
1080  } else {
1081  pDynamicNode = dynamic_cast<const DynamicStructNode*>(pStrNode);
1082  if (pDynamicNode == 0 || pDynamicNode->GetStructNodeType() != StructNode::DYNAMIC) {
1083  silent_cerr("VariableBody(" << uLabel << "): "
1084  "illegal structural node type "
1085  "for StructNode(" << pStrNode->GetLabel() << ") "
1086  "at line " << HP.GetLineData() << std::endl);
1088  }
1089  }
1090 
1091  flag fOut = pDM->fReadOutput(HP, Elem::BODY);
1092 
1093  /* Allocazione e costruzione */
1094  Elem *pEl = 0;
1095  if (bStaticModel || bInverseDynamics) {
1096  /* static */
1098  StaticVariableBody(uLabel, pStaticNode,
1099  pDCMass, pDCXgc, pDCJgc_vm, pDCJgc_vg, fOut));
1100 
1101  } else {
1103  DynamicVariableBody(uLabel, pDynamicNode,
1104  pDCMass, pDCXgc, pDCJgc_vm, pDCJgc_vg, fOut));
1105  }
1106 
1107  pDM->GetLogFile()
1108  << "variable body: " << uLabel
1109  << ' ' << pStrNode->GetLabel()
1110  << ' ' << pDCMass->dGet()
1111  << ' ' << pDCXgc->Get()
1112  << ' ' << pDCJgc_vm->Get()
1113  << ' ' << pDCJgc_vg->Get()
1114  << std::endl;
1115 
1116  /* Se non c'e' il punto e virgola finale */
1117  if (HP.IsArg()) {
1118  silent_cerr("VariableBody(" << uLabel << "): semicolon expected "
1119  "at line " << HP.GetLineData() << std::endl);
1121  }
1122 
1123  return pEl;
1124 } /* End of ReadVariableBody() */
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
TplDriveCaller< T > * GetTplDriveCaller(void)
Definition: mbpar.cc:2112
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual StructNode::Type GetStructNodeType(void) const
Definition: strnode.cc:3293
virtual T Get(const doublereal &dVar) const =0
bool bIsStaticModel(void) const
Definition: dataman.h:482
virtual bool bIsDifferentiable(void) const
Definition: drive.h:495
virtual bool bIsDifferentiable(void) const
Definition: tpldrive.h:65
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
virtual doublereal dGet(const doublereal &dVar) const =0
virtual bool IsArg(void)
Definition: parser.cc:807
Definition: elem.h:75
std::ostream & GetLogFile(void) const
Definition: dataman.h:326
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
virtual StructNode::Type GetStructNodeType(void) const
Definition: strnode.cc:2946
unsigned int GetLabel(void) const
Definition: withlab.cc:62
bool bIsInverseDynamics(void) const
Definition: dataman.h:493

Here is the call graph for this function: