MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
dataman3.cc File Reference
#include "mbconfig.h"
#include <limits>
#include <unistd.h>
#include <cfloat>
#include "dataman.h"
#include "dataman_.h"
#include "modules.h"
#include "readlinsol.h"
#include "drive.h"
#include "drive_.h"
#include "filedrv.h"
#include "presnode.h"
#include "j2p.h"
#include "sah.h"
#include "thermalnode.h"
#include "aeroelem.h"
#include "beam.h"
#include "rbk_impl.h"
Include dependency graph for dataman3.cc:

Go to the source code of this file.

Classes

class  NotAllowed
 

Functions

static int GetDofOrder (MBDynParser &HP, Node *pNode, int iIndex)
 
ScalarDof ReadScalarDof (const DataManager *pDM, MBDynParser &HP, bool bDof, bool bOrder)
 
OrientationDescription ReadOrientationDescription (MBDynParser &HP)
 
OrientationDescription ReadOptionalOrientationDescription (DataManager *pDM, MBDynParser &HP)
 

Function Documentation

static int GetDofOrder ( MBDynParser HP,
Node pNode,
int  iIndex 
)
static

Definition at line 2360 of file dataman3.cc.

References StructDispNode::ComputeAccelerations(), DofOrder::DIFFERENTIAL, SimulationEntity::GetDofType(), HighParser::GetInt(), WithLabel::GetLabel(), IncludeParser::GetLineData(), Node::GetNodeType(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, and psNodeNames.

Referenced by ReadScalarDof().

2361 {
2362  /*
2363  * Ordine del grado di liberta' da considerare
2364  * (stato, oppure derivata se esiste)
2365  */
2366  int iOrder = 0;
2367 
2368  if (HP.IsKeyWord("differential")) {
2369  iOrder = 1;
2370 
2371  } else if (HP.IsKeyWord("order")) {
2372  iOrder = HP.GetInt();
2373  if (iOrder < 0 || iOrder > 2) {
2374  silent_cerr(psNodeNames[pNode->GetNodeType()]
2375  << "(" << pNode->GetLabel() << "): "
2376  "illegal order " << iOrder
2377  << " at line " << HP.GetLineData()
2378  << std::endl);
2380 
2381  } else if (iOrder == 2) {
2382  DynamicStructNode *pStrNode = dynamic_cast<DynamicStructNode *>(pNode);
2383  if (pStrNode == 0) {
2384  silent_cerr(psNodeNames[pNode->GetNodeType()]
2385  << "(" << pNode->GetLabel() << "): "
2386  "order " << iOrder << " not allowed "
2387  "at line " << HP.GetLineData()
2388  << std::endl);
2390  }
2391  pStrNode->ComputeAccelerations(true);
2392  }
2393  }
2394 
2395  if (iOrder > 0) {
2396  if (pNode->GetDofType(iIndex-1) != DofOrder::DIFFERENTIAL) {
2397  silent_cerr(psNodeNames[pNode->GetNodeType()]
2398  << "(" << pNode->GetLabel()
2399  << "): invalid order for index " << iIndex
2400  << " variable at line " << HP.GetLineData()
2401  << std::endl);
2403  }
2404  return iOrder;
2405  }
2406 
2407  if (HP.IsKeyWord("algebraic")) {
2408  return 0;
2409  } /* else */
2410 
2411  silent_cerr(psNodeNames[pNode->GetNodeType()]
2412  << "(" << pNode->GetLabel()
2413  << "): unknown or illegal order for index " << iIndex << std::endl
2414  << "(hint: you may need to specify "
2415  "\"differential\" or \"algebraic\" or \"order <n>\" when referencing " << std::endl
2416  << "a generic degree of freedom at line "
2417  << HP.GetLineData() << ")" << std::endl);
2418 
2420 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
virtual DofOrder::Order GetDofType(unsigned int i) const =0
virtual bool ComputeAccelerations(bool b)
Definition: strnode.cc:194
const char * psNodeNames[]
Definition: enums.cc:372
virtual Node::Type GetNodeType(void) const =0
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

OrientationDescription ReadOptionalOrientationDescription ( DataManager pDM,
MBDynParser HP 
)

Definition at line 2531 of file dataman3.cc.

References EULER_123, IncludeParser::GetLineData(), DataManager::GetOrientationDescription(), HighParser::IsKeyWord(), ReadOrientationDescription(), and UNKNOWN_ORIENTATION_DESCRIPTION.

Referenced by ReadAerodynamicCustomOutput(), ReadBeamCustomOutput(), ReadStructNode(), and MBDynParser::Reference_int().

2532 {
2534 
2535  if (HP.IsKeyWord("orientation" "description")) {
2536  dod = ReadOrientationDescription(HP);
2537 
2538  } else if (pDM != 0) {
2539  /* get a sane default */
2540  dod = pDM->GetOrientationDescription();
2541 
2542  } else {
2543  dod = EULER_123;
2544  silent_cerr("Warning, data manager not defined yet, "
2545  "using default orientation (\"euler 123\") "
2546  "at line " << HP.GetLineData() << std::endl);
2547  }
2548 
2549  return dod;
2550 }
OrientationDescription ReadOrientationDescription(MBDynParser &HP)
Definition: dataman3.cc:2502
OrientationDescription
Definition: matvec3.h:1597
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
OrientationDescription GetOrientationDescription(void) const
Definition: dataman.cc:857
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

OrientationDescription ReadOrientationDescription ( MBDynParser HP)

Definition at line 2502 of file dataman3.cc.

References EULER_123, EULER_313, EULER_321, IncludeParser::GetLineData(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, ORIENTATION_MATRIX, ORIENTATION_VECTOR, and UNKNOWN_ORIENTATION_DESCRIPTION.

Referenced by Eu2PhiDCR::Read(), DataManager::ReadControl(), and ReadOptionalOrientationDescription().

2503 {
2505 
2506  if (HP.IsKeyWord("euler" "123")) {
2507  dod = EULER_123;
2508 
2509  } else if (HP.IsKeyWord("euler" "313")) {
2510  dod = EULER_313;
2511 
2512  } else if (HP.IsKeyWord("euler" "321")) {
2513  dod = EULER_321;
2514 
2515  } else if (HP.IsKeyWord("orientation" "vector")) {
2516  dod = ORIENTATION_VECTOR;
2517 
2518  } else if (HP.IsKeyWord("orientation" "matrix")) {
2519  dod = ORIENTATION_MATRIX;
2520 
2521  } else {
2522  silent_cerr("Unknown orientation description "
2523  "at line " << HP.GetLineData() << std::endl);
2525  }
2526 
2527  return dod;
2528 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
OrientationDescription
Definition: matvec3.h:1597
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

ScalarDof ReadScalarDof ( const DataManager pDM,
MBDynParser HP,
bool  bDof,
bool  bOrder 
)

Definition at line 2423 of file dataman3.cc.

References DEBUGLCOUT, DofOrder::DIFFERENTIAL, GetDofOrder(), SimulationEntity::GetDofType(), HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::GetWord(), SimulationEntity::iGetNumDof(), MBDYN_EXCEPT_ARGS, MYDEBUG_INPUT, DataManager::pFindNode(), psNodeNames, psReadNodesNodes, SAFENEWWITHCONSTRUCTOR, and Node::UNKNOWN.

Referenced by DofDCR::Read(), ReadBulk(), ReadElectric(), ReadForce(), ReadGenel(), DataManager::ReadNodes(), and ReadScalarValue().

2424 {
2425  /* tabella delle parole chiave */
2426  KeyTable KDof(HP, psReadNodesNodes);
2427 
2428  /* Label del nodo */
2429  int iNode = HP.GetInt();
2430  if (iNode < 0) {
2431  silent_cerr("ReadScalarDof: invalid node label " << iNode
2432  << " at line " << HP.GetLineData() << std::endl);
2434  }
2435 
2436  unsigned uNode = unsigned(iNode);
2437  DEBUGLCOUT(MYDEBUG_INPUT, "Linked to Node " << uNode << std::endl);
2438 
2439  /* Tipo del nodo */
2440  Node::Type Type = Node::Type(HP.GetWord());
2441  if (Type == Node::UNKNOWN) {
2442  silent_cerr("ReadScalarDof: unknown node type "
2443  "at line " << HP.GetLineData() << std::endl);
2445  }
2446  DEBUGLCOUT(MYDEBUG_INPUT, "Node type: " << psNodeNames[Type] << std::endl);
2447 
2448  /* verifica di esistenza del nodo */
2449  Node* pNode = pDM->pFindNode(Type, uNode);
2450  if (pNode == 0) {
2451  silent_cerr(psNodeNames[Type] << "(" << uNode << ") not defined"
2452  " at line " << HP.GetLineData() << std::endl);
2454  }
2455 
2456  /* si procura il numero di dof del nodo */
2457  unsigned int iMaxIndex = pNode->iGetNumDof();
2458  DEBUGLCOUT(MYDEBUG_INPUT, "max index: " << iMaxIndex << std::endl);
2459 
2460  if (bDof && iMaxIndex == 0) {
2461  silent_cerr(psNodeNames[Type] << "(" << uNode << ") must have dofs "
2462  "at line " << HP.GetLineData() << std::endl);
2464  }
2465 
2466  /* se il nodo ha piu' di un dof, chiede quale dof si desidera */
2467  unsigned int iIndex = 1;
2468  if (iMaxIndex > 1) {
2469  iIndex = HP.GetInt();
2470  if (iIndex < 1 || iIndex > iMaxIndex) {
2471  silent_cerr("Illegal index " << iIndex << ", "
2472  << psNodeNames[Type] << "(" << uNode << ") "
2473  "has only " << iMaxIndex << " dofs "
2474  "at line " << HP.GetLineData() << std::endl);
2476  }
2477  DEBUGLCOUT(MYDEBUG_INPUT, "index: " << iIndex << std::endl);
2478  }
2479 
2480  /* se e' richiesto l'order del dof e se il dof e' differenziale ... */
2481  int iOrder = 0;
2482  if (bOrder && pNode->iGetNumDof() > 0
2483  && pNode->GetDofType(iIndex-1) == DofOrder::DIFFERENTIAL)
2484  {
2485  iOrder = GetDofOrder(HP, pNode, iIndex);
2486  }
2487  DEBUGLCOUT(MYDEBUG_INPUT, "order: " << iOrder << std::endl);
2488 
2489  /* se il nodo non e' scalare, alloca un Node2Scalar che lo wrappa */
2490  if (iMaxIndex > 1) {
2491  NodeDof nd(iIndex - 1, pNode);
2492 
2493  pNode = 0;
2494  /* Chi dealloca questa memoria? ci vorrebbe l'handle */
2496  }
2497 
2498  return ScalarDof(dynamic_cast<ScalarNode *>(pNode), iOrder, iIndex);
2499 }
const char * psReadNodesNodes[]
Definition: enums.cc:398
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: node.h:67
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
Type
Definition: node.h:71
virtual DofOrder::Order GetDofType(unsigned int i) const =0
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
static int GetDofOrder(MBDynParser &HP, Node *pNode, int iIndex)
Definition: dataman3.cc:2360
virtual unsigned int iGetNumDof(void) const =0
const char * psNodeNames[]
Definition: enums.cc:372
virtual int GetWord(void)
Definition: parser.cc:1083
Definition: node.h:578
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
Node * pFindNode(Node::Type Typ, unsigned int uNode) const
Definition: nodeman.cc:179
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244

Here is the call graph for this function: