MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
strforce.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ElemReadStructuralForce (DataManager *pDM, MBDynParser &HP, unsigned int uLabel, bool bDisp, bool bCouple, bool bFollower, bool bInternal)
 

Function Documentation

Elem* ReadStructuralForce ( DataManager pDM,
MBDynParser HP,
unsigned int  uLabel,
bool  bDisp,
bool  bCouple,
bool  bFollower,
bool  bInternal 
)

Definition at line 2713 of file strforce.cc.

References DC2TDC(), DEBUGCOUT, Elem::FORCE, DataManager::fReadOutput(), ToBeOutput::fToBeOutput(), MBDynParser::GetDriveCaller(), WithLabel::GetLabel(), IncludeParser::GetLineData(), DataManager::GetLogFile(), MBDynParser::GetPosRel(), MBDynParser::GetUnitVecAbs(), MBDynParser::GetUnitVecRel(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, StructuralForce::OUTPUT_REL, ReadDCVecAbs(), ReadDCVecRel(), DataManager::ReadNode(), SAFENEWWITHCONSTRUCTOR, Node::STRUCTURAL, and Zero3.

Referenced by ReadForce().

2720 {
2721  Elem *pEl = 0;
2722  const char *sType = bCouple ? "Couple" : "Force";
2723 
2724  /* nodo collegato */
2725  const StructDispNode* pDispNode = pDM->ReadNode<const StructDispNode, Node::STRUCTURAL>(HP);
2726  const StructNode* pNode = dynamic_cast<const StructNode *>(pDispNode);
2727  ReferenceFrame rf;
2728  if (pNode) {
2729  rf = ReferenceFrame(pNode);
2730  }
2731  Vec3 Arm(Zero3);
2732 
2733  // FIXME: legacy...
2734  Vec3 Dir(Zero3);
2735  bool bLegacy(false);
2736  bool bGotPosition(false);
2737 
2738  /* distanza dal nodo (vettore di 3 elementi) (solo se e' una forza) */
2739  if (!bDisp) {
2740  if (pNode == 0) {
2741  silent_cerr(sType << "(" << uLabel << "): "
2742  "invalid node type at line " << HP.GetLineData() << std::endl);
2744  }
2745 
2746  if (HP.IsKeyWord("position")) {
2747  Arm = HP.GetPosRel(rf);
2748  bGotPosition = true;
2749  DEBUGCOUT("Arm is supplied" << std::endl);
2750 
2751  } else {
2752  if (!bCouple) {
2753  silent_cerr(sType << "(" << uLabel << "): "
2754  "\"position\" keyword expected "
2755  "at line " << HP.GetLineData() << "; "
2756  "still using deprecated syntax?"
2757  << std::endl);
2758 
2759  if (bFollower) {
2760  try {
2761  Dir = HP.GetUnitVecRel(rf);
2762  } catch (ErrNullNorm) {
2763  silent_cerr(sType << "(" << uLabel << ") has null direction" << std::endl);
2765  }
2766 
2767  } else {
2768  try {
2769  Dir = HP.GetUnitVecAbs(rf);
2770  } catch (ErrNullNorm) {
2771  silent_cerr(sType << "(" << uLabel << ") has null direction" << std::endl);
2773  }
2774  }
2775 
2776  Arm = HP.GetPosRel(rf);
2777 
2778  bLegacy = true;
2779  }
2780  }
2781  }
2782 
2783  const StructDispNode *pDispNode2 = 0;
2784  const StructNode *pNode2 = 0;
2785  Vec3 Arm2(Zero3);
2786  if (bInternal) {
2787  /* nodo collegato */
2788  pDispNode2 = pDM->ReadNode<const StructDispNode, Node::STRUCTURAL>(HP);
2789  pNode2 = dynamic_cast<const StructNode *>(pDispNode2);
2790 
2791  if (!bDisp) {
2792  if (pNode2 == 0) {
2793  silent_cerr(sType << "(" << uLabel << "): "
2794  "invalid node type at line " << HP.GetLineData() << std::endl);
2796  }
2797 
2798  ReferenceFrame rf2(pNode2);
2799 
2800  /* distanza dal nodo (vettore di 3 elementi) ( solo se e' una forza) */
2801  if (HP.IsKeyWord("position")) {
2802  Arm2 = HP.GetPosRel(rf2, rf, Arm);
2803  bGotPosition = true;
2804  DEBUGCOUT("Node 2 arm is supplied" << std::endl);
2805 
2806  } else if (bLegacy) {
2807  Arm2 = HP.GetPosRel(rf2, rf, Arm);
2808  }
2809  }
2810  }
2811 
2812  if (bCouple && bInternal && !bGotPosition) {
2813  silent_cerr(sType << "(" << uLabel << ") "
2814  "line " << HP.GetLineData() << ": "
2815  "warning, the syntax changed; "
2816  "you may safely ignore this warning if you used "
2817  "the syntax documented for MBDyn >= 1.3.7"
2818  << std::endl);
2819  }
2820 
2821  TplDriveCaller<Vec3>* pDC = 0;
2822  if (bLegacy) {
2823  pDC = DC2TDC(HP.GetDriveCaller(), Dir);
2824 
2825  } else {
2826  if (bFollower) {
2827  pDC = ReadDCVecRel(pDM, HP, rf);
2828 
2829  } else {
2830  pDC = ReadDCVecAbs(pDM, HP, rf);
2831  }
2832  }
2833 
2834  bool bOutRel(false);
2835  if (bFollower && HP.IsKeyWord("output" "relative")) {
2836  bOutRel = true;
2837  }
2838 
2839  flag fOut = pDM->fReadOutput(HP, Elem::FORCE);
2840 
2841  if (bOutRel) {
2843  }
2844 
2845  /* Alloca la forza */
2846  if (!bCouple) {
2847  if (!bFollower) {
2848  if (!bInternal) {
2849  if (bDisp) {
2852  AbsoluteDispForce(uLabel, pDispNode, pDC, fOut));
2853 
2854  } else {
2856  AbsoluteForce,
2857  AbsoluteForce(uLabel, pNode, pDC, Arm, fOut));
2858  }
2859 
2860  } else {
2861  if (bDisp) {
2864  AbsoluteInternalDispForce(uLabel, pDispNode, pDispNode2, pDC, fOut));
2865 
2866  } else {
2869  AbsoluteInternalForce(uLabel, pNode, pNode2, pDC, Arm, Arm2, fOut));
2870  }
2871  }
2872 
2873  } else {
2874  if (!bInternal) {
2876  FollowerForce,
2877  FollowerForce(uLabel, pNode, pDC, Arm, fOut));
2878 
2879  } else {
2882  FollowerInternalForce(uLabel, pNode, pNode2, pDC, Arm, Arm2, fOut));
2883  }
2884  }
2885 
2886  } else {
2887  if (!bFollower) {
2888  if (!bInternal) {
2891  AbsoluteCouple(uLabel, pNode, pDC, fOut));
2892 
2893  } else {
2896  AbsoluteInternalCouple(uLabel, pNode, pNode2, pDC, fOut));
2897  }
2898 
2899  } else {
2900  if (!bInternal) {
2903  FollowerCouple(uLabel, pNode, pDC, fOut));
2904 
2905  } else {
2908  FollowerInternalCouple(uLabel, pNode, pNode2, pDC, fOut));
2909  }
2910  }
2911  }
2912 
2913  std::ostream& os = pDM->GetLogFile();
2914 
2915  os << "structural";
2916  if (bInternal) {
2917  os << " internal";
2918  }
2919  if (bFollower) {
2920  os << " follower";
2921  } else {
2922  os << " absolute";
2923  if (bDisp) {
2924  os << " displacement";
2925  }
2926  }
2927  if (bCouple) {
2928  os << " couple";
2929  } else {
2930  os << " force";
2931  }
2932  os << ": " << uLabel << ' ' << pDispNode->GetLabel()
2933  << ' ' << Arm;
2934 
2935  if (pDispNode2 != 0) {
2936  os << ' ' << pDispNode2->GetLabel() << ' ' << Arm2;
2937  }
2938 
2939  if (bFollower && (pEl->fToBeOutput() & StructuralForce::OUTPUT_REL)) {
2940  os << " output_relative";
2941  }
2942 
2943  os << std::endl;
2944 
2945  return pEl;
2946 }
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
TplDriveCaller< Vec3 > * ReadDCVecAbs(const DataManager *pDM, MBDynParser &HP, const ReferenceFrame &rf)
Vec3 GetPosRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1331
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
#define DEBUGCOUT(msg)
Definition: myassert.h:232
TplDriveCaller< T > * DC2TDC(DriveCaller *pDC, T &t)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
Vec3 GetUnitVecAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1716
Definition: elem.h:75
std::ostream & GetLogFile(void) const
Definition: dataman.h:326
virtual flag fToBeOutput(void) const
Definition: output.cc:884
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
Vec3 GetUnitVecRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1695
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62
Node * ReadNode(MBDynParser &HP, Node::Type type) const
Definition: dataman3.cc:2309
TplDriveCaller< Vec3 > * ReadDCVecRel(const DataManager *pDM, MBDynParser &HP, const ReferenceFrame &rf)

Here is the call graph for this function: