MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
gravity.cc File Reference
#include "mbconfig.h"
#include "dataman.h"
#include "gravity.h"
Include dependency graph for gravity.cc:

Go to the source code of this file.

Functions

ElemReadGravity (DataManager *pDM, MBDynParser &HP)
 

Function Documentation

Elem* ReadGravity ( DataManager pDM,
MBDynParser HP 
)

Definition at line 237 of file gravity.cc.

References AbsRefFrame, DataManager::fReadOutput(), IncludeParser::GetLineData(), MBDynParser::GetPosAbs(), HighParser::GetReal(), Elem::GRAVITY, HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, ReadDC3D(), SAFENEWWITHCONSTRUCTOR, and Zero3.

Referenced by DataManager::ReadElems().

238 {
239  Elem *pE = 0;
240 
241  if (HP.IsKeyWord("central")) {
242  Vec3 X0 = ::Zero3;
243  if (HP.IsKeyWord("origin")) {
244  X0 = HP.GetPosAbs(::AbsRefFrame);
245  }
246 
247  if (!HP.IsKeyWord("mass")) {
248  silent_cerr("Gravity: \"mass\" keyword expected at line " << HP.GetLineData() << std::endl);
250  }
251  doublereal dM = HP.GetReal();
252  if (dM <= std::numeric_limits<doublereal>::epsilon()) {
253  silent_cerr("Gravity: mass " << dM << " is negative or too small at line " << HP.GetLineData() << std::endl);
255  }
256 
257  if (!HP.IsKeyWord("G")) {
258  silent_cerr("Gravity: \"G\" keyword expected at line " << HP.GetLineData() << std::endl);
260  }
261  // 6.673 84 x 10-11 m3 kg-1 s-2, http://physics.nist.gov/cuu/Constants/index.html
262  doublereal dG = 6.67384e-11;
263  if (!HP.IsKeyWord("si")) {
264  dG = HP.GetReal();
265  if (dG <= std::numeric_limits<doublereal>::epsilon()) {
266  silent_cerr("Gravity: gravity constant " << dG << " is negative or too small at line " << HP.GetLineData() << std::endl);
268  }
269  }
270 
272 
273  } else {
274  if (!HP.IsKeyWord("uniform")) {
275  silent_cerr("Gravity: "
276  "<type> expected "
277  "at line " << HP.GetLineData() << "; "
278  "assuming \"uniform\""
279  << std::endl);
280  }
281 
282  TplDriveCaller<Vec3>* pDC = ReadDC3D(pDM, HP);
283 
284  flag fOut = pDM->fReadOutput(HP, Elem::GRAVITY);
285 
287  }
288 
289  return pE;
290 }
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
const Vec3 Zero3(0., 0., 0.)
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
const ReferenceFrame AbsRefFrame(0, Vec3(0., 0., 0), Mat3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), Vec3(0., 0., 0), Vec3(0., 0., 0), EULER_123)
TplDriveCaller< Vec3 > * ReadDC3D(const DataManager *pDM, MBDynParser &HP)
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
Vec3 GetPosAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1401
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
Definition: elem.h:75
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function: