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

#include <inertia.h>

Inheritance diagram for Inertia:
Collaboration diagram for Inertia:

Public Types

enum  { OUTPUT_LOG = ToBeOutput::OUTPUT_PRIVATE, OUTPUT_OUT = (ToBeOutput::OUTPUT_PRIVATE << 1), OUTPUT_ALWAYS = (ToBeOutput::OUTPUT_PRIVATE << 2) }
 
- Public Types inherited from Elem
enum  Type {
  UNKNOWN = -1, AIRPROPERTIES = 0, INDUCEDVELOCITY, AUTOMATICSTRUCTURAL,
  GRAVITY, BODY, JOINT, JOINT_REGULARIZATION,
  BEAM, PLATE, FORCE, INERTIA,
  ELECTRICBULK, ELECTRIC, THERMAL, HYDRAULIC,
  BULK, LOADABLE, DRIVEN, EXTERNAL,
  AEROMODAL, AERODYNAMIC, GENEL, SOCKETSTREAM_OUTPUT,
  RTAI_OUTPUT = SOCKETSTREAM_OUTPUT, LASTELEMTYPE
}
 
- Public Types inherited from SimulationEntity
typedef std::vector< Hint * > Hints
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 

Public Member Functions

 Inertia (unsigned int uL, const std::string &sN, std::set< const ElemGravityOwner * > &elements, const Vec3 &x0, const Mat3x3 &r0, std::ostream &log, flag fOut)
 
virtual ~Inertia (void)
 
doublereal dGetM (void) const
 
virtual Elem::Type GetElemType (void) const
 
virtual unsigned int iGetInitialNumDof (void) const
 
virtual std::ostream & Restart (std::ostream &out) const
 
virtual void Output (OutputHandler &OH) const
 
void WorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bInverseDynamics (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr, const VectorHandler &XPrimePrimeCurr, InverseDynamics::Order iOrder=InverseDynamics::INVERSE_DYNAMICS)
 
virtual void InitialWorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
virtual VariableSubMatrixHandlerInitialAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerInitialAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr)
 
virtual void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
 
virtual unsigned int iGetNumPrivData (void) const
 
virtual unsigned int iGetPrivDataIdx (const char *s) const
 
virtual doublereal dGetPrivData (unsigned int i) const
 
- Public Member Functions inherited from Elem
 Elem (unsigned int uL, flag fOut)
 
virtual ~Elem (void)
 
virtual unsigned int iGetNumDof (void) const
 
virtual std::ostream & DescribeDof (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeDof (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual std::ostream & DescribeEq (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeEq (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual DofOrder::Order GetDofType (unsigned int) const
 
virtual void AssMats (VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
void SetInverseDynamicsFlags (unsigned uIDF)
 
unsigned GetInverseDynamicsFlags (void) const
 
bool bIsErgonomy (void) const
 
bool bIsRightHandSide (void) const
 
virtual int GetNumConnectedNodes (void) const
 
virtual void GetConnectedNodes (std::vector< const Node * > &connectedNodes) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from SimulationEntity
 SimulationEntity (void)
 
virtual ~SimulationEntity (void)
 
virtual bool bIsValidIndex (unsigned int i) const
 
virtual DofOrder::Order GetEqType (unsigned int i) const
 
virtual HintParseHint (DataManager *pDM, const char *s) const
 
virtual void BeforePredict (VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
 
virtual void AfterPredict (VectorHandler &X, VectorHandler &XP)
 
virtual void Update (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void DerivativesUpdate (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Update (const VectorHandler &XCurr, InverseDynamics::Order iOrder)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP, const VectorHandler &XPP)
 
virtual std::ostream & OutputAppend (std::ostream &out) const
 
virtual void ReadInitialState (MBDynParser &HP)
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from ElemGravityOwner
 ElemGravityOwner (unsigned int uL, flag fOut)
 
virtual ~ElemGravityOwner (void)
 
Vec3 GetS (void) const
 
Mat3x3 GetJ (void) const
 
Vec3 GetB (void) const
 
Vec3 GetG (void) const
 
- Public Member Functions inherited from GravityOwner
 GravityOwner (void)
 
virtual ~GravityOwner (void)
 
void PutGravity (const Gravity *pG)
 
virtual bool bGetGravity (const Vec3 &X, Vec3 &Acc) const
 
- Public Member Functions inherited from InitialAssemblyElem
 InitialAssemblyElem (unsigned int uL, flag fOut)
 
virtual ~InitialAssemblyElem (void)
 
- Public Member Functions inherited from SubjectToInitialAssembly
 SubjectToInitialAssembly (void)
 
virtual ~SubjectToInitialAssembly (void)
 
- Public Member Functions inherited from CenterOfMass
 CenterOfMass (std::set< const ElemGravityOwner * > &elements)
 
virtual ~CenterOfMass (void)
 

Protected Member Functions

Vec3 GetS_int (void) const
 
Mat3x3 GetJ_int (void) const
 
virtual void Collect_int (void)
 
virtual std::ostream & Output_int (std::ostream &out) const
 
void OutputPrepare_int (OutputHandler &OH, std::string &name)
 
void OutputPrepare (OutputHandler &OH)
 
- Protected Member Functions inherited from ElemGravityOwner
virtual Vec3 GetB_int (void) const
 
virtual Vec3 GetG_int (void) const
 

Protected Attributes

unsigned flags
 
Vec3 X0
 
Mat3x3 R0
 
Mat3x3 J0
 
Mat3x3 R_princ
 
Vec3 J_princ
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 
- Protected Attributes inherited from GravityOwner
GravitypGravity
 
- Protected Attributes inherited from CenterOfMass
std::set< const
ElemGravityOwner * > 
elements
 
doublereal dMass
 
Vec3 S
 
Mat3x3 J
 
Vec3 X_cm
 
Vec3 V_cm
 
Vec3 Omega_cm
 
Mat3x3 J_cm
 

Detailed Description

Definition at line 71 of file inertia.h.

Member Enumeration Documentation

anonymous enum
Enumerator
OUTPUT_LOG 
OUTPUT_OUT 
OUTPUT_ALWAYS 

Definition at line 74 of file inertia.h.

Constructor & Destructor Documentation

Inertia::Inertia ( unsigned int  uL,
const std::string &  sN,
std::set< const ElemGravityOwner * > &  elements,
const Vec3 x0,
const Mat3x3 r0,
std::ostream &  log,
flag  fOut 
)

Definition at line 160 of file inertia.cc.

References Collect_int(), done, Eye3, flags, Vec3::IsNull(), Output_int(), WithLabel::PutName(), R0, and X0.

162 : Elem(uL, fOut),
163 ElemGravityOwner(uL, fOut),
164 InitialAssemblyElem(uL, fOut),
166 #ifdef USE_NETCDF
167 Var_dMass(0),
168 Var_X_cm(0),
169 Var_V_cm(0),
170 Var_Omega_cm(0),
171 Var_DX(0),
172 Var_dx(0),
173 Var_Jp(0),
174 Var_Phip(0),
175 #endif // USE_NETCDF
176 flags(0), X0(x0), R0(r0)
177 {
178  this->PutName(sN);
179 
180  if (!X0.IsNull()) {
181  flags |= 1;
182  }
183 
184  if (!(R0 - Eye3).IsNull()) {
185  flags |= 2;
186  }
187 
188  bool done(false);
189  if ((fOut & 0x1) & !silent_output) {
190  if (!done) {
191  Collect_int();
192  done = true;
193  }
194  Output_int(std::cout);
195  }
196 
197  if (fOut & 0x2) {
198  if (!done) {
199  Collect_int();
200  done = true;
201  }
202  Output_int(log);
203  }
204 }
void PutName(const std::string &sN)
Definition: withlab.cc:56
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
ElemGravityOwner(unsigned int uL, flag fOut)
Definition: gravity.cc:223
std::set< const ElemGravityOwner * > elements
Definition: inertia.h:45
virtual std::ostream & Output_int(std::ostream &out) const
Definition: inertia.cc:132
bool IsNull(void) const
Definition: matvec3.h:472
GradientExpression< UnaryExpr< FuncLog, Expr > > log(const GradientExpression< Expr > &u)
Definition: gradient.h:2976
CenterOfMass(std::set< const ElemGravityOwner * > &elements)
Definition: inertia.cc:102
unsigned flags
Definition: inertia.h:82
virtual void Collect_int(void)
Definition: inertia.cc:233
Vec3 X0
Definition: inertia.h:83
Mat3x3 R0
Definition: inertia.h:84
static unsigned done
Definition: gust.cc:209
InitialAssemblyElem(unsigned int uL, flag fOut)
Definition: elem.cc:233
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41

Here is the call graph for this function:

Inertia::~Inertia ( void  )
virtual

Definition at line 206 of file inertia.cc.

References NO_OP.

207 {
208  NO_OP;
209 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

VariableSubMatrixHandler & Inertia::AssJac ( VariableSubMatrixHandler WorkMat,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 363 of file inertia.cc.

References VariableSubMatrixHandler::SetNullMatrix().

367 {
368  WorkMat.SetNullMatrix();
369  return WorkMat;
370 }
void SetNullMatrix(void)
Definition: submat.h:1159

Here is the call graph for this function:

VariableSubMatrixHandler & Inertia::AssJac ( VariableSubMatrixHandler WorkMat,
const VectorHandler XCurr 
)
virtual

Reimplemented from Elem.

Definition at line 408 of file inertia.cc.

References VariableSubMatrixHandler::SetNullMatrix().

410 {
411  WorkMat.SetNullMatrix();
412  return WorkMat;
413 }
void SetNullMatrix(void)
Definition: submat.h:1159

Here is the call graph for this function:

SubVectorHandler & Inertia::AssRes ( SubVectorHandler WorkVec,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 373 of file inertia.cc.

References Collect_int(), and VectorHandler::Resize().

377 {
378  WorkVec.Resize(0);
379 
380  Collect_int();
381 
382  return WorkVec;
383 }
virtual void Collect_int(void)
Definition: inertia.cc:233
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

SubVectorHandler & Inertia::AssRes ( SubVectorHandler WorkVec,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr,
const VectorHandler XPrimePrimeCurr,
InverseDynamics::Order  iOrder = InverseDynamics::INVERSE_DYNAMICS 
)
virtual

Reimplemented from Elem.

Definition at line 393 of file inertia.cc.

References Collect_int(), and VectorHandler::Resize().

398 {
399  WorkVec.Resize(0);
400 
401  Collect_int();
402 
403  return WorkVec;
404 }
virtual void Collect_int(void)
Definition: inertia.cc:233
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

bool Inertia::bInverseDynamics ( void  ) const
virtual

Reimplemented from Elem.

Definition at line 386 of file inertia.cc.

387 {
388  return true;
389 }
void Inertia::Collect_int ( void  )
protectedvirtual

Reimplemented from CenterOfMass.

Definition at line 233 of file inertia.cc.

References CenterOfMass::Collect_int(), CenterOfMass::dMass, Mat3x3::EigSym(), Eye3, flags, WithLabel::GetLabel(), CenterOfMass::J, J0, CenterOfMass::J_cm, J_princ, MatCrossCross, Mat3x3::MulMT(), R0, R_princ, X0, CenterOfMass::X_cm, and Zero3.

Referenced by AssRes(), Inertia(), and InitialAssRes().

234 {
236 
237  if (dMass < std::numeric_limits<doublereal>::epsilon()) {
238  silent_cerr("Inertia(" << GetLabel() << "): "
239  "mass is null" << std::endl);
240 
241  R_princ = Eye3;
242  J_princ = Zero3;
243 
244  } else {
246  }
247 
248  if (flags) {
249  if (flags & 1) {
250  Vec3 DX = X_cm - X0;
251  J0 = J + Mat3x3(MatCrossCross, X0, X0*dMass)
252  + Mat3x3(MatCrossCross, DX, X0*dMass)
253  + Mat3x3(MatCrossCross, X0, DX*dMass);
254  }
255 
256  if (flags & 2) {
257  if (flags & 1) {
258  J0 = R0*J0.MulMT(R0);
259  } else {
260  J0 = R0*J.MulMT(R0);
261  }
262  }
263 
264  } else {
265  J0 = J;
266  }
267 }
const Vec3 Zero3(0., 0., 0.)
Definition: matvec3.h:98
Mat3x3 R_princ
Definition: inertia.h:87
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
Mat3x3 J_cm
Definition: inertia.h:55
Mat3x3 J0
Definition: inertia.h:85
doublereal dMass
Definition: inertia.h:47
unsigned flags
Definition: inertia.h:82
bool EigSym(Vec3 &EigenValues) const
Definition: matvec3.cc:255
Vec3 X_cm
Definition: inertia.h:52
Vec3 J_princ
Definition: inertia.h:88
Vec3 X0
Definition: inertia.h:83
const MatCrossCross_Manip MatCrossCross
Definition: matvec3.cc:640
Mat3x3 R0
Definition: inertia.h:84
Mat3x3 J
Definition: inertia.h:49
Mat3x3 MulMT(const Mat3x3 &m) const
Definition: matvec3.cc:444
unsigned int GetLabel(void) const
Definition: withlab.cc:62
virtual void Collect_int(void)
Definition: inertia.cc:59

Here is the call graph for this function:

doublereal Inertia::dGetM ( void  ) const
virtual

Reimplemented from ElemGravityOwner.

Definition at line 213 of file inertia.cc.

References CenterOfMass::dMass.

214 {
215  return dMass;
216 }
doublereal dMass
Definition: inertia.h:47
doublereal Inertia::dGetPrivData ( unsigned int  i) const
virtual

Reimplemented from SimulationEntity.

Definition at line 561 of file inertia.cc.

References CenterOfMass::dMass, J0, J_princ, MBDYN_EXCEPT_ARGS, CenterOfMass::Omega_cm, CenterOfMass::V_cm, and CenterOfMass::X_cm.

562 {
563 
564  unsigned int what = (i - 1)/3;
565  unsigned int which = (i - 1)%3 + 1;
566 
567  switch (what) {
568  case 0:
569  // center of mass position
570  return X_cm(which);
571 
572  case 1:
573  // principal inertia axes Euler vector components
574  return 0.;
575 
576  case 2:
577  // center of mass velocity
578  return V_cm(which);
579 
580  case 3:
581  // angular velocity
582  return Omega_cm(which);
583 
584  case 4:
585  // principal inertia moments
586  return J_princ(which);
587  }
588 
589  // mass
590  if (i == 25) {
591  return dMass;
592  }
593 
594  // inertia tensor
595  int ir = (i - 15 - 1)%3 + 1;
596  int ic = (i - 15 - 1)/3 + 1;
597 
598  return J0(ir, ic);
599 
601 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Vec3 V_cm
Definition: inertia.h:53
Mat3x3 J0
Definition: inertia.h:85
doublereal dMass
Definition: inertia.h:47
Vec3 Omega_cm
Definition: inertia.h:54
Vec3 X_cm
Definition: inertia.h:52
Vec3 J_princ
Definition: inertia.h:88
Elem::Type Inertia::GetElemType ( void  ) const
virtual

Implements Elem.

Definition at line 220 of file inertia.cc.

References Elem::INERTIA.

221 {
222  return Elem::INERTIA;
223 }
Mat3x3 Inertia::GetJ_int ( void  ) const
protectedvirtual

Reimplemented from ElemGravityOwner.

Definition at line 126 of file inertia.cc.

References CenterOfMass::J.

127 {
128  return J;
129 }
Mat3x3 J
Definition: inertia.h:49
Vec3 Inertia::GetS_int ( void  ) const
protectedvirtual

Reimplemented from ElemGravityOwner.

Definition at line 119 of file inertia.cc.

References CenterOfMass::S.

120 {
121  return S;
122 }
Vec3 S
Definition: inertia.h:48
unsigned int Inertia::iGetInitialNumDof ( void  ) const
virtual

Implements SubjectToInitialAssembly.

Definition at line 227 of file inertia.cc.

228 {
229  return 0;
230 }
unsigned int Inertia::iGetNumPrivData ( void  ) const
virtual

Reimplemented from SimulationEntity.

Definition at line 457 of file inertia.cc.

458 {
459  return
460  +3 // X[1-3]
461  +3 // Phi[1-3]
462  +3 // V[1-3]
463  +3 // Omega[1-3]
464  +3 // principal inertia moments
465  +3*3 // inertia tensor
466  +1 // mass
467  ;
468 }
unsigned int Inertia::iGetPrivDataIdx ( const char *  s) const
virtual

Reimplemented from SimulationEntity.

Definition at line 471 of file inertia.cc.

References STRLENOF.

472 {
473  unsigned int idx = 0;
474 
475  switch (s[0]) {
476  case 'X':
477  break;
478 
479  case 'P':
480  if (strncasecmp(s, "Phi", STRLENOF("Phi")) != 0) {
481  return 0;
482  }
483  s += STRLENOF("Phi") - 1;
484  idx = 3;
485  break;
486 
487  case 'V':
488  idx = 6;
489  break;
490 
491  case 'O':
492  if (strncasecmp(s, "Omega", STRLENOF("Omega")) != 0) {
493  return 0;
494  }
495  s += STRLENOF("Omega") - 1;
496  idx = 9;
497  break;
498 
499  case 'J':
500  if (s[1] == 'P') {
501  s++;
502  idx = 12;
503  break;
504  }
505  idx = 15;
506  break;
507 
508  case 'm':
509  if (s[1] != '\0') {
510  return 0;
511  }
512  return 25;
513 
514  default:
515  return 0;
516  }
517 
518  s++;
519  if (s[0] != '[') {
520  return 0;
521  }
522 
523  s++;
524  switch (s[0]) {
525  case '1':
526  case '2':
527  case '3':
528  idx += s[0] - '0';
529  s++;
530  if (idx > 15) {
531  if (s[0] != ',') {
532  return 0;
533  }
534  s++;
535  switch (s[0]) {
536  case '1':
537  case '2':
538  case '3':
539  break;
540 
541  default:
542  return 0;
543  }
544  idx += 3*(s[0] - '1');
545  s++;
546  }
547  break;
548 
549  default:
550  return 0;
551  }
552 
553  //s++;
554  if (strcmp(s, "]") != 0) {
555  return 0;
556  }
557  return idx;
558 }
#define STRLENOF(s)
Definition: mbdyn.h:166
VariableSubMatrixHandler & Inertia::InitialAssJac ( VariableSubMatrixHandler WorkMat,
const VectorHandler XCurr 
)
virtual

Implements SubjectToInitialAssembly.

Definition at line 429 of file inertia.cc.

References VariableSubMatrixHandler::SetNullMatrix().

431 {
432  WorkMat.SetNullMatrix();
433  return WorkMat;
434 }
void SetNullMatrix(void)
Definition: submat.h:1159

Here is the call graph for this function:

SubVectorHandler & Inertia::InitialAssRes ( SubVectorHandler WorkVec,
const VectorHandler XCurr 
)
virtual

Implements SubjectToInitialAssembly.

Definition at line 438 of file inertia.cc.

References Collect_int(), and VectorHandler::Resize().

439 {
440  WorkVec.Resize(0);
441 
442  Collect_int();
443 
444  return WorkVec;
445 }
virtual void Collect_int(void)
Definition: inertia.cc:233
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

void Inertia::InitialWorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements SubjectToInitialAssembly.

Definition at line 421 of file inertia.cc.

422 {
423  *piNumRows = 0;
424  *piNumCols = 0;
425 }
void Inertia::Output ( OutputHandler OH) const
virtual

Reimplemented from ToBeOutput.

Definition at line 277 of file inertia.cc.

References CenterOfMass::dMass, ToBeOutput::fToBeOutput(), OutputHandler::GetCurrentStep(), OutputHandler::INERTIA, J_princ, Mat3x3::MulTV(), CenterOfMass::Omega_cm, OUTPUT_ALWAYS, Output_int(), Vec3::pGetVec(), R0, R_princ, OutputHandler::UseNetCDF(), OutputHandler::UseText(), CenterOfMass::V_cm, RotManip::VecRot(), X0, and CenterOfMass::X_cm.

278 {
279  if (fToBeOutput() & (0x1 | Inertia::OUTPUT_ALWAYS)) {
281  Output_int(std::cout);
282  }
283 
284 #ifdef USE_NETCDF
286 
287  Vec3 DX(X_cm - X0);
288  Vec3 dx = R0.MulTV(DX);
289  Vec3 Phip = RotManip::VecRot(R_princ);
290 
291  Var_dMass->put_rec(&dMass, OH.GetCurrentStep());
292  Var_X_cm->put_rec(X_cm.pGetVec(), OH.GetCurrentStep());
293  Var_V_cm->put_rec(V_cm.pGetVec(), OH.GetCurrentStep());
294  Var_Omega_cm->put_rec(Omega_cm.pGetVec(), OH.GetCurrentStep());
295 
296  Var_DX->put_rec(DX.pGetVec(), OH.GetCurrentStep());
297  Var_dx->put_rec(dx.pGetVec(), OH.GetCurrentStep());
298  Var_Jp->put_rec(J_princ.pGetVec(), OH.GetCurrentStep());
299  Var_Phip->put_rec(Phip.pGetVec(), OH.GetCurrentStep());
300 
301  }
302 #endif // USE_NETCDF
303  }
304 }
Definition: matvec3.h:98
bool UseNetCDF(int out) const
Definition: output.cc:491
Mat3x3 R_princ
Definition: inertia.h:87
Vec3 V_cm
Definition: inertia.h:53
virtual std::ostream & Output_int(std::ostream &out) const
Definition: inertia.cc:132
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
Vec3 MulTV(const Vec3 &v) const
Definition: matvec3.cc:482
doublereal dMass
Definition: inertia.h:47
Vec3 Omega_cm
Definition: inertia.h:54
long GetCurrentStep(void) const
Definition: output.h:116
Vec3 X_cm
Definition: inertia.h:52
Vec3 J_princ
Definition: inertia.h:88
Vec3 X0
Definition: inertia.h:83
Mat3x3 R0
Definition: inertia.h:84
const doublereal * pGetVec(void) const
Definition: matvec3.h:192
virtual flag fToBeOutput(void) const
Definition: output.cc:884
bool UseText(int out) const
Definition: output.cc:446

Here is the call graph for this function:

std::ostream & Inertia::Output_int ( std::ostream &  out) const
protectedvirtual

Reimplemented from CenterOfMass.

Definition at line 132 of file inertia.cc.

References CenterOfMass::dMass, WithLabel::GetLabel(), WithLabel::GetName(), CenterOfMass::J_cm, J_princ, MatCrossCross, Mat3x3::MulTM(), Mat3x3::MulTV(), CenterOfMass::Output_int(), R0, R_princ, RotManip::VecRot(), X0, and CenterOfMass::X_cm.

Referenced by Inertia(), and Output().

133 {
134  out
135  << "inertia: " << GetLabel()
136  << ( GetName().empty() ? "" : ( std::string(" \"") + GetName() + "\"" ) )
137  << std::endl;
138  Vec3 DX(X_cm - X0);
139  Mat3x3 JX(J_cm - Mat3x3(MatCrossCross, DX, DX*dMass));
141  << " Xcg-X: " << DX << std::endl
142  << " R^T*(Xcg-X): " << R0.MulTV(DX) << std::endl
143  << " J(X): " << JX << std::endl
144  << " R^T*J(X)*R: " << R0.MulTM(JX)*R0 << std::endl
145  << " Rp: " << R_princ << std::endl
146  << " Thetap: " << RotManip::VecRot(R_princ) << std::endl
147  << " Jp: " << J_princ << std::endl;
148 
149  //printf("\n\nmassa %1.16e\n",dMass);
150  //Vec3 tmp = R0.MulTV(X_cm-X0);
151  //printf("xcg %1.16e %1.16e %1.16e\n", tmp(1), tmp(2), tmp(3) );
152  //printf("RR %1.16e %1.16e %1.16e\n", R_princ(1,1), R_princ(1,2), R_princ(1,3) );
153  //printf("RR %1.16e %1.16e %1.16e\n", R_princ(2,1), R_princ(2,2), R_princ(2,3) );
154  //printf("RR %1.16e %1.16e %1.16e\n", R_princ(3,1), R_princ(3,2), R_princ(3,3) );
155  //printf("JJ %1.16e %1.16e %1.16e\n\n\n", J_princ(1), J_princ(2), J_princ(3) );
156  return out;
157 }
Definition: matvec3.h:98
Mat3x3 R_princ
Definition: inertia.h:87
Mat3x3 J_cm
Definition: inertia.h:55
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
Vec3 MulTV(const Vec3 &v) const
Definition: matvec3.cc:482
doublereal dMass
Definition: inertia.h:47
Vec3 X_cm
Definition: inertia.h:52
Mat3x3 MulTM(const Mat3x3 &m) const
Definition: matvec3.cc:500
Vec3 J_princ
Definition: inertia.h:88
Vec3 X0
Definition: inertia.h:83
const MatCrossCross_Manip MatCrossCross
Definition: matvec3.cc:640
Mat3x3 R0
Definition: inertia.h:84
const std::string & GetName(void) const
Definition: withlab.cc:68
unsigned int GetLabel(void) const
Definition: withlab.cc:62
virtual std::ostream & Output_int(std::ostream &out) const
Definition: inertia.cc:47

Here is the call graph for this function:

void Inertia::OutputPrepare ( OutputHandler OH)
protectedvirtual

Reimplemented from ToBeOutput.

Definition at line 323 of file inertia.cc.

References ToBeOutput::bToBeOutput(), OutputHandler::INERTIA, OutputPrepare_int(), and OutputHandler::UseNetCDF().

324 {
325  if (bToBeOutput()) {
326 #ifdef USE_NETCDF
328  {
329  std::string name;
330  OutputPrepare_int(OH, name);
331 
332  Var_dMass = OH.CreateVar<doublereal>(name + "M", "kg",
333  "total mass");
334  Var_X_cm = OH.CreateVar<Vec3>(name + "X_cm", "m",
335  "center of mass position (x, y, z)");
336  Var_V_cm = OH.CreateVar<Vec3>(name + "V_cm", "m/s",
337  "center of mass velocity (x, y, z)");
338  Var_Omega_cm = OH.CreateVar<Vec3>(name + "Omega_cm", "rad/s",
339  "center of mass angular velocity (x, y, z)");
340 
341  Var_DX = OH.CreateVar<Vec3>(name + "DX", "m",
342  "relative center of mass position, global frame (x, y, z)");
343  Var_dx = OH.CreateVar<Vec3>(name + "dx", "m",
344  "relative center of mass position, local frame (x, y, z)");
345  Var_Jp = OH.CreateVar<Vec3>(name + "Jp", "kg*m^2",
346  "global inertia matrix, w.r.t. principal axes");
347  Var_Phip = OH.CreateVar<Vec3>(name + "Phip", "-",
348  "orientation vector of principal axes, global frame");
349 
350  }
351 #endif // USE_NETCDF
352  }
353 }
virtual bool bToBeOutput(void) const
Definition: output.cc:890
Definition: matvec3.h:98
bool UseNetCDF(int out) const
Definition: output.cc:491
void OutputPrepare_int(OutputHandler &OH, std::string &name)
Definition: inertia.cc:307
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

void Inertia::OutputPrepare_int ( OutputHandler OH,
std::string &  name 
)
protected

Definition at line 307 of file inertia.cc.

References ASSERT, WithLabel::GetLabel(), OutputHandler::IsOpen(), and OutputHandler::NETCDF.

Referenced by OutputPrepare().

308 {
309 #ifdef USE_NETCDF
311 
312  std::ostringstream os;
313  os << "elem.inertia." << GetLabel();
314  (void)OH.CreateVar(os.str(), "inertia");
315 
316  os << ".";
317  name = os.str();
318 
319 #endif // USE_NETCDF
320 }
bool IsOpen(int out) const
Definition: output.cc:395
#define ASSERT(expression)
Definition: colamd.c:977
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

std::ostream & Inertia::Restart ( std::ostream &  out) const
virtual

Implements Elem.

Definition at line 271 of file inertia.cc.

272 {
273  return out;
274 }
void Inertia::SetValue ( DataManager pDM,
VectorHandler X,
VectorHandler XP,
SimulationEntity::Hints ph = 0 
)
virtual

Implements ElemGravityOwner.

Definition at line 449 of file inertia.cc.

References NO_OP.

452 {
453  NO_OP;
454 }
#define NO_OP
Definition: myassert.h:74
void Inertia::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 356 of file inertia.cc.

357 {
358  *piNumRows = 0;
359  *piNumCols = 0;
360 }

Member Data Documentation

unsigned Inertia::flags
protected

Definition at line 82 of file inertia.h.

Referenced by Collect_int(), and Inertia().

Mat3x3 Inertia::J0
protected

Definition at line 85 of file inertia.h.

Referenced by Collect_int(), and dGetPrivData().

Vec3 Inertia::J_princ
protected

Definition at line 88 of file inertia.h.

Referenced by Collect_int(), dGetPrivData(), Output(), and Output_int().

Mat3x3 Inertia::R0
protected

Definition at line 84 of file inertia.h.

Referenced by Collect_int(), Inertia(), Output(), and Output_int().

Mat3x3 Inertia::R_princ
protected

Definition at line 87 of file inertia.h.

Referenced by Collect_int(), Output(), and Output_int().

Vec3 Inertia::X0
protected

Definition at line 83 of file inertia.h.

Referenced by Collect_int(), Inertia(), Output(), and Output_int().


The documentation for this class was generated from the following files: