48 silent_cerr(
"ExtForceEDGE::ExtForceEDGE: "
49 "warning, unable to link to air properties (no airstream contribution to velocity)" << std::endl);
60 bool bRigid,
unsigned uModes)
92 std::vector<doublereal>&
a)
106 char buf[BUFSIZ], *p;
119 if (strncasecmp(buf,
"body_forces",
STRLENOF(
"body_forces")) == 0) {
120 size_t buflen =
sizeof(
buf) -
STRLENOF(
"body_forces");
121 p = &buf[0] +
STRLENOF(
"body_forces");
125 silent_cerr(
"ExtRigidForceEDGE: unable to skip separator "
126 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
132 silent_cerr(
"ExtRigidForceEDGE: unable to skip field \"R\" "
133 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
139 silent_cerr(
"ExtRigidForceEDGE: unable to skip separator "
140 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
146 silent_cerr(
"ExtRigidForceEDGE: unable to skip field \"1\" "
147 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
153 silent_cerr(
"ExtRigidForceEDGE: unable to skip separator "
154 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
160 silent_cerr(
"ExtRigidForceEDGE: unable to skip field \"6\" "
161 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
167 silent_cerr(
"ExtRigidForceEDGE: unable to skip separator "
168 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
174 silent_cerr(
"ExtRigidForceEDGE: unable to skip field \"0\" "
175 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
181 silent_cerr(
"ExtRigidForceEDGE: unable to skip separator "
182 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
186 if (p[0] !=
'\0' && p[0] !=
'\n') {
187 silent_cerr(
"ExtRigidForceEDGE: no line terminator "
188 "at line=" << lineno <<
", \"" << p <<
"\"" << std::endl);
194 for (
int i = 0; i < 6; i++) {
205 silent_cerr(
"ExtRigidForceEDGE: unable to skip to end of line "
206 "at line=" << lineno << std::endl);
212 silent_cerr(
"ExtRigidForceEDGE: unexpected line=" << lineno <<
", "
213 "\"" << buf <<
"\"" << std::endl);
249 const std::vector<doublereal>& q,
250 const std::vector<doublereal>& qP)
266 fout <<
"* MBDyn to EDGE rigid body dynamics\n"
267 "body_dynamics,N,0,0,3\n"
268 "* Body linear velocity in body axes\n"
270 << vB(1) <<
" " << vB(2) <<
" " << vB(3) <<
"\n"
271 "* Body angular velocity in body axes\n"
273 << wB(1) <<
" " << wB(2) <<
" " << wB(3) <<
"\n"
274 "* Body reference frame cosines (listed by columns)\n"
277 <<
R(1, 1) <<
" " <<
R(2, 1) <<
" " <<
R(3, 1) <<
"\n"
278 <<
R(1, 2) <<
" " <<
R(2, 2) <<
" " <<
R(3, 2) <<
"\n"
279 <<
R(1, 3) <<
" " <<
R(2, 3) <<
" " <<
R(3, 3) <<
"\n";
306 std::vector<doublereal>&
a)
320 char buf[BUFSIZ], *p;
333 if (strncasecmp(buf,
"modal_force_flow",
STRLENOF(
"modal_force_flow")) == 0) {
334 p = buf +
STRLENOF(
"modal_force_flow");
336 size_t buflen =
sizeof(
buf) -
STRLENOF(
"modal_force_flow");
337 p = &buf[0] +
STRLENOF(
"modal_force_flow");
341 silent_cerr(
"ExtModalForceEDGE: unable to skip separator "
342 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
348 silent_cerr(
"ExtModalForceEDGE: unable to skip field \"R\" "
349 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
355 silent_cerr(
"ExtModalForceEDGE: unable to skip separator "
356 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
362 long nmodes = strtol(p, &next, 10);
363 int save_errno = errno;
365 silent_cerr(
"ExtModalForceEDGE: unable to skip modes number field "
366 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
369 }
else if (save_errno == ERANGE) {
370 silent_cerr(
"ExtModalForceEDGE: modes number field overflows "
371 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
377 silent_cerr(
"ExtModalForceEDGE: unable to skip separator "
378 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
384 silent_cerr(
"ExtModalForceEDGE: unable to skip field \"1\" "
385 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
391 silent_cerr(
"ExtModalForceEDGE: unable to skip separator "
392 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
398 silent_cerr(
"ExtModalForceEDGE: unable to skip field \"0\" "
399 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
405 silent_cerr(
"ExtModalForceEDGE: unable to skip separator "
406 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
410 if (p[0] !=
'\0' && p[0] !=
'\n') {
411 silent_cerr(
"ExtModalForceEDGE: no line terminator "
412 "at line=" << lineno <<
", \"" << p <<
"\"" << std::endl);
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);
423 for (std::vector<doublereal>::iterator i = a.begin();
434 silent_cerr(
"ExtModalForceEDGE: unable to skip to end of line "
435 "at line=" << lineno << std::endl);
441 silent_cerr(
"ExtModalForceEDGE: unexpected line=" << lineno <<
", "
442 "\"" << buf <<
"\"" << std::endl);
465 const std::vector<doublereal>& q,
466 const std::vector<doublereal>& qP)
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"
476 for (std::vector<doublereal>::const_iterator i = q.begin() + 1;
482 "modal_velocity,R," << qP.size() <<
",1,0\n"
484 for (std::vector<doublereal>::const_iterator i = qP.begin() + 1;
virtual std::istream * GetInStream(void)
virtual ~ExtForceEDGE(void)
#define MBDYN_EXCEPT_ARGS
virtual Vec3 GetVelocity(const Vec3 &) const
char * mbedge_eat_sep(char *buf, size_t &buflen)
bool Prepare(ExtFileHandlerBase *pEFH, unsigned uLabel, bool bRigid, unsigned uModes)
Vec3 MulTV(const Vec3 &v) const
Elem * pFindElem(Elem::Type Typ, unsigned int uElem, unsigned int iDeriv) const
unsigned Recv(ExtFileHandlerBase *pEFH, unsigned uFlags, unsigned &uLabel, Vec3 &f, Vec3 &m, std::vector< doublereal > &a)
int mbedge_goto_eol(std::istream &fin, char *buf, size_t bufsiz)
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)
unsigned Recv(ExtFileHandlerBase *pEFH, unsigned uFlags, unsigned &uLabel, Vec3 &f, Vec3 &m, std::vector< doublereal > &a)
#define ASSERT(expression)
virtual std::ostream * GetOutStream(void)
char * mbedge_eat_field(char *buf, size_t &buflen, const char *val)
const AirProperties * pAP
ExtRigidForceEDGE(DataManager *pDM)
ExtForceEDGE(DataManager *pDM)
static const doublereal a
static doublereal buf[BUFSIZE]
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)
ExtModalForceEDGE(DataManager *pDM)