MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
modalforce.h File Reference
#include <vector>
#include <string>
#include "extforce.h"
#include "modal.h"
Include dependency graph for modalforce.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ModalForce
 

Functions

ElemReadModalForce (DataManager *pDM, MBDynParser &HP, unsigned int uLabel)
 

Function Documentation

Elem* ReadModalForce ( DataManager pDM,
MBDynParser HP,
unsigned int  uLabel 
)

Definition at line 145 of file modalforce.cc.

References Elem::FORCE, DataManager::fReadOutput(), MBDynParser::GetDriveCaller(), HighParser::GetInt(), WithLabel::GetLabel(), IncludeParser::GetLineData(), Modal::GetModeList(), HighParser::GetReal(), HighParser::IsKeyWord(), Elem::JOINT, MBDYN_EXCEPT_ARGS, Modal::pGetModalNode(), DataManager::ReadElem(), SAFENEWWITHCONSTRUCTOR, and Modal::uGetNModes().

Referenced by ReadForce().

148 {
149  const Modal *pModal = pDM->ReadElem<const Modal, const Joint, Elem::JOINT>(HP);
150 
151  std::vector<unsigned int> modeList;
152  if (HP.IsKeyWord("list")) {
153  const std::vector<unsigned int>& uModeList = pModal->GetModeList();
154  std::vector<bool> gotIt(pModal->uGetNModes());
155  for (integer i = 0; i < pModal->uGetNModes(); i++) {
156  gotIt[i] = false;
157  }
158 
159  int iNumModes = HP.GetInt();
160  if (iNumModes <= 0 || iNumModes > pModal->uGetNModes()) {
161  silent_cerr("ModalForce(" << uLabel << "): "
162  "illegal mode number " << iNumModes
163  << " at line " << HP.GetLineData() << std::endl);
165  }
166  modeList.resize(iNumModes);
167 
168  for (int i = 0; i < iNumModes; i++) {
169  int iM = HP.GetInt();
170  if (iM <= 0) {
171  silent_cerr("ModalForce(" << uLabel << "): "
172  "illegal mode " << iM
173  << " at line " << HP.GetLineData()
174  << std::endl);
176  }
177 
178  std::vector<unsigned int>::const_iterator
179  iv = std::find(uModeList.begin(), uModeList.end(), (unsigned int)iM);
180  if (iv == uModeList.end()) {
181  silent_cerr("ModalForce(" << uLabel << "): "
182  "mode " << iM << " not active "
183  "in Modal(" << pModal->GetLabel() << ")"
184  "at line " << HP.GetLineData() << std::endl);
186  }
187  int iModeIdx = iv - uModeList.begin();
188 
189  if (gotIt[iModeIdx]) {
190  silent_cerr("ModalForce(" << uLabel << "): "
191  "mode " << iModeIdx << " already set "
192  "at line " << HP.GetLineData() << std::endl);
194  }
195 
196  modeList[i] = iModeIdx + 1;
197  gotIt[iModeIdx] = true;
198  }
199 
200  } else {
201  modeList.resize(pModal->uGetNModes());
202  for (integer i = 0; i < pModal->uGetNModes(); i++) {
203  modeList[i] = i + 1;
204  }
205  }
206 
207  std::vector<DriveCaller *> f(modeList.size());
208  Mat3xN *Mt = 0;
209  Mat3xN *Mr = 0;
210  const StructNode *pNode = pModal->pGetModalNode();
211  if (pNode) {
212  Mt = new Mat3xN(modeList.size(), 0.);
213  Mr = new Mat3xN(modeList.size(), 0.);
214  }
215  for (unsigned i = 0; i < f.size(); i++) {
216  f[i] = HP.GetDriveCaller(false);
217  if (f[i] == 0) {
218  silent_cerr("ModalForce(" << uLabel << "): "
219  "unable to read DriveCaller for mode #" << i + 1
220  << " (mode number " << modeList[i] << ") "
221  "at line " << HP.GetLineData() << std::endl);
223  }
224 
225  if (pNode && HP.IsKeyWord("resultant")) {
226  for (unsigned r = 1; r <= 3; r++) {
227  (*Mt)(r, i + 1) = HP.GetReal();
228  }
229 
230  for (unsigned r = 1; r <= 3; r++) {
231  (*Mr)(r, i + 1) = HP.GetReal();
232  }
233  }
234  }
235 
236  flag fOut = pDM->fReadOutput(HP, Elem::FORCE);
237  Elem *pEl = 0;
239  ModalForce(uLabel, pModal, modeList, f, Mt, Mr, fOut));
240 
241  return pEl;
242 }
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
const ModalNode * pGetModalNode(void) const
Definition: modal.h:395
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
Elem * ReadElem(MBDynParser &HP, Elem::Type type) const
Definition: dataman3.cc:2334
integer uGetNModes(void) const
Definition: modal.h:363
Definition: modal.h:74
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
Definition: elem.h:75
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
Definition: joint.h:50
long int integer
Definition: colamd.c:51
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const std::vector< unsigned int > & GetModeList(void) const
Definition: modal.h:367
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function: