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

#include <modaledge.h>

Inheritance diagram for ExtModalForceEDGE:
Collaboration diagram for ExtModalForceEDGE:

Public Member Functions

 ExtModalForceEDGE (DataManager *pDM)
 
unsigned Recv (ExtFileHandlerBase *pEFH, unsigned uFlags, unsigned &uLabel, Vec3 &f, Vec3 &m, std::vector< doublereal > &a)
 
void Send (ExtFileHandlerBase *pEFH, unsigned uFlags, unsigned uLabel, const Vec3 &x, const Mat3x3 &R, const Vec3 &v, const Vec3 &w, const std::vector< doublereal > &q, const std::vector< doublereal > &qP)
 
- Public Member Functions inherited from ExtForceEDGE
 ExtForceEDGE (DataManager *pDM)
 
virtual ~ExtForceEDGE (void)
 
bool Prepare (ExtFileHandlerBase *pEFH, unsigned uLabel, bool bRigid, unsigned uModes)
 
- Public Member Functions inherited from ExtModalForceBase
virtual ~ExtModalForceBase (void)
 

Additional Inherited Members

- Public Types inherited from ExtModalForceBase
enum  BitMask {
  EMF_NONE = 0x0U, EMF_RIGID = 0x1U, EMF_MODAL = 0x2U, EMF_ALL = (EMF_RIGID | EMF_MODAL),
  EMF_RIGID_DETECT = 0x10U, EMF_MODAL_DETECT = 0x20U, EMF_RIGID_DETECT_MASK = (EMF_RIGID_DETECT | EMF_RIGID), EMF_MODAL_DETECT_MASK = (EMF_MODAL_DETECT | EMF_MODAL),
  EMF_DETECT_MASK = (EMF_RIGID_DETECT | EMF_MODAL_DETECT), EMF_ERR = 0x10000000U
}
 
- Protected Attributes inherited from ExtForceEDGE
const AirPropertiespAP
 

Detailed Description

Definition at line 77 of file modaledge.h.

Constructor & Destructor Documentation

ExtModalForceEDGE::ExtModalForceEDGE ( DataManager pDM)

Definition at line 286 of file modaledge.cc.

References NO_OP.

287 : ExtForceEDGE(pDM)
288 {
289  NO_OP;
290 }
#define NO_OP
Definition: myassert.h:74
ExtForceEDGE(DataManager *pDM)
Definition: modaledge.cc:43

Member Function Documentation

unsigned ExtModalForceEDGE::Recv ( ExtFileHandlerBase pEFH,
unsigned  uFlags,
unsigned &  uLabel,
Vec3 f,
Vec3 m,
std::vector< doublereal > &  a 
)
virtual

Implements ExtModalForceBase.

Definition at line 301 of file modaledge.cc.

References ASSERT, buf, ExtModalForceBase::EMF_ALL, ExtModalForceBase::EMF_MODAL, ExtModalForceBase::EMF_MODAL_DETECT_MASK, ExtModalForceBase::EMF_NONE, ExtFileHandlerBase::GetInStream(), MBDYN_EXCEPT_ARGS, mbedge_eat_field(), mbedge_eat_sep(), mbedge_goto_eol(), and STRLENOF.

307 {
308  std::istream& fin = *pEFH->GetInStream();
309  unsigned uOutFlags = ExtModalForceBase::EMF_NONE;
310 
311  ASSERT((uFlags & ExtModalForceBase::EMF_MODAL) != 0);
312  ASSERT((uFlags & ~ExtModalForceBase::EMF_ALL) == 0);
313 
314  // fake
315  uLabel = 0;
316 
317  // cycle
318  unsigned lineno = 0;
319  while (true) {
320  char buf[BUFSIZ], *p;
321  if (mbedge_goto_eol(fin, buf, sizeof(buf))) {
322  if (!fin) {
323  break;
324  }
325  }
326 
327  lineno++;
328 
329  if (buf[0] == '*') {
330  continue;
331  }
332 
333  if (strncasecmp(buf, "modal_force_flow", STRLENOF("modal_force_flow")) == 0) {
334  p = buf + STRLENOF("modal_force_flow");
335 
336  size_t buflen = sizeof(buf) - STRLENOF("modal_force_flow");
337  p = &buf[0] + STRLENOF("modal_force_flow");
338 
339  p = mbedge_eat_sep(p, buflen);
340  if (p == 0) {
341  silent_cerr("ExtModalForceEDGE: unable to skip separator "
342  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
344  }
345 
346  p = mbedge_eat_field(p, buflen, "R");
347  if (p == 0) {
348  silent_cerr("ExtModalForceEDGE: unable to skip field \"R\" "
349  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
351  }
352 
353  p = mbedge_eat_sep(p, buflen);
354  if (p == 0) {
355  silent_cerr("ExtModalForceEDGE: unable to skip separator "
356  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
358  }
359 
360  char *next;
361  errno = 0;
362  long nmodes = strtol(p, &next, 10);
363  int save_errno = errno;
364  if (next == p) {
365  silent_cerr("ExtModalForceEDGE: unable to skip modes number field "
366  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
368 
369  } else if (save_errno == ERANGE) {
370  silent_cerr("ExtModalForceEDGE: modes number field overflows "
371  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
373  }
374 
375  p = mbedge_eat_sep(next, buflen);
376  if (p == 0) {
377  silent_cerr("ExtModalForceEDGE: unable to skip separator "
378  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
380  }
381 
382  p = mbedge_eat_field(p, buflen, "1");
383  if (p == 0) {
384  silent_cerr("ExtModalForceEDGE: unable to skip field \"1\" "
385  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
387  }
388 
389  p = mbedge_eat_sep(p, buflen);
390  if (p == 0) {
391  silent_cerr("ExtModalForceEDGE: unable to skip separator "
392  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
394  }
395 
396  p = mbedge_eat_field(p, buflen, "0");
397  if (p == 0) {
398  silent_cerr("ExtModalForceEDGE: unable to skip field \"0\" "
399  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
401  }
402 
403  p = mbedge_eat_sep(p, buflen);
404  if (p == 0) {
405  silent_cerr("ExtModalForceEDGE: unable to skip separator "
406  "at line=" << lineno << ", \"" << buf[sizeof(buf) - buflen] << "\"" << std::endl);
408  }
409 
410  if (p[0] != '\0' && p[0] != '\n') {
411  silent_cerr("ExtModalForceEDGE: no line terminator "
412  "at line=" << lineno << ", \"" << p << "\"" << std::endl);
414  }
415 
416  if (std::vector<doublereal>::size_type(nmodes) != a.size()) {
417  silent_cerr("ExtModalForceEDGE: mode number mismatch, "
418  "expected " << a.size() << " got " << nmodes << std::endl);
420  }
421 
423  for (std::vector<doublereal>::iterator i = a.begin();
424  i != a.end(); ++i)
425  {
426  fin >> *i;
427  }
428 
429  uOutFlags |= (uFlags & ExtModalForceBase::EMF_MODAL_DETECT_MASK);
430  }
431 
432  // skip to eol
433  if (mbedge_goto_eol(fin, buf, sizeof(buf))) {
434  silent_cerr("ExtModalForceEDGE: unable to skip to end of line "
435  "at line=" << lineno << std::endl);
437  }
438  continue;
439  }
440 
441  silent_cerr("ExtModalForceEDGE: unexpected line=" << lineno << ", "
442  "\"" << buf << "\"" << std::endl);
444  }
445 
446  return uOutFlags;
447 }
virtual std::istream * GetInStream(void)
Definition: extforce.cc:78
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
char * mbedge_eat_sep(char *buf, size_t &buflen)
Definition: extedge.cc:74
int mbedge_goto_eol(std::istream &fin, char *buf, size_t bufsiz)
Definition: extedge.cc:49
#define ASSERT(expression)
Definition: colamd.c:977
char * mbedge_eat_field(char *buf, size_t &buflen, const char *val)
Definition: extedge.cc:94
#define STRLENOF(s)
Definition: mbdyn.h:166
static const doublereal a
Definition: hfluid_.h:289
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333

Here is the call graph for this function:

void ExtModalForceEDGE::Send ( ExtFileHandlerBase pEFH,
unsigned  uFlags,
unsigned  uLabel,
const Vec3 x,
const Mat3x3 R,
const Vec3 v,
const Vec3 w,
const std::vector< doublereal > &  q,
const std::vector< doublereal > &  qP 
)
virtual

Implements ExtModalForceBase.

Definition at line 461 of file modaledge.cc.

References ASSERT, ExtModalForceBase::EMF_ALL, ExtModalForceBase::EMF_MODAL, and ExtFileHandlerBase::GetOutStream().

467 {
468  std::ostream& fout = *pEFH->GetOutStream();
469  ASSERT((uFlags & ExtModalForceBase::EMF_MODAL) != 0);
470  ASSERT((uFlags & ~ExtModalForceBase::EMF_ALL) == 0);
471 
472  fout << "* MBDyn to EDGE modal dynamics\n"
473  "modal_state,N,0,0,2\n"
474  "modal_coordinate,R," << q.size() << ",1,0\n"
475  << q[0];
476  for (std::vector<doublereal>::const_iterator i = q.begin() + 1;
477  i < q.end(); ++i)
478  {
479  fout << " " << *i;
480  }
481  fout << "\n"
482  "modal_velocity,R," << qP.size() << ",1,0\n"
483  << qP[0];
484  for (std::vector<doublereal>::const_iterator i = qP.begin() + 1;
485  i < qP.end(); ++i)
486  {
487  fout << " " << *i;
488  }
489  fout << "\n";
490 }
#define ASSERT(expression)
Definition: colamd.c:977
virtual std::ostream * GetOutStream(void)
Definition: extforce.cc:72

Here is the call graph for this function:


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