1359 bool bSendAfterPredict;
1360 ReadExtForce(pDM, HP, uLabel, pEFH, bSendAfterPredict, iCoupling);
1368 bool bLabels(
false);
1370 bool bOutputAccelerations(
false);
1371 bool bUseReferenceNodeForces(
true);
1372 bool bRotateReferenceNodeForces(
true);
1374 bool bGotSorted(
false);
1375 bool bGotLabels(
false);
1376 bool bGotRot(
false);
1377 bool bGotAccels(
false);
1378 bool bGotUseRefForces(
false);
1380 while (HP.
IsArg()) {
1382 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1383 "use of \"unsorted\" deprecated in favor of \"sorted, { yes | no }\" at line "
1387 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1388 "\"unsorted\" already specified at line "
1398 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1399 "\"sorted\" already specified at line "
1405 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1406 "\"sorted\" must be either \"yes\" or \"no\" at line "
1412 }
else if (HP.
IsKeyWord(
"no" "labels")) {
1413 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1414 "use of \"no labels\" deprecated in favor of \"labels, { yes | no }\" at line "
1418 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1419 "\"no labels\" already specified at line "
1429 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1430 "\"labels\" already specified at line "
1436 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1437 "\"labels\" must be either \"yes\" or \"no\" at line "
1443 }
else if (HP.
IsKeyWord(
"orientation")) {
1445 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1446 "\"orientation\" already specified at line "
1454 }
else if (HP.
IsKeyWord(
"orientation" "vector")) {
1457 }
else if (HP.
IsKeyWord(
"orientation" "matrix")) {
1460 }
else if (HP.
IsKeyWord(
"euler" "123")) {
1464 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1465 "unknown \"orientation\" format at line "
1472 }
else if (HP.
IsKeyWord(
"accelerations")) {
1474 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1475 "\"accelerations\" already specified at line "
1480 if (!HP.
GetYesNo(bOutputAccelerations)) {
1481 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1482 "\"accelerations\" must be either \"yes\" or \"no\" at line "
1488 }
else if (HP.
IsKeyWord(
"use" "reference" "node" "forces")) {
1489 if (pRefNode == 0) {
1490 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1491 "\"use reference node forces\" only meaningful when reference node is used at line "
1496 if (bGotUseRefForces) {
1497 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1498 "\"use reference node forces\" already specified at line "
1503 if (!HP.
GetYesNo(bUseReferenceNodeForces)) {
1504 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1505 "\"use reference node forces\" must be either \"yes\" or \"no\" at line "
1509 bGotUseRefForces =
true;
1511 if (bUseReferenceNodeForces && HP.
IsKeyWord(
"rotate" "reference" "node" "forces")) {
1512 if (!HP.
GetYesNo(bRotateReferenceNodeForces)) {
1513 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1514 "\"rotate reference node forces\" must be either \"yes\" or \"no\" at line "
1525 if (!bLabels && !bSorted) {
1526 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1527 "\"no labels\" and \"unsorted\" incompatible" << std::endl);
1533 silent_cerr(
"StructExtForce(" << uLabel <<
"): illegal node number " << n <<
1538 std::vector<unsigned> Labels;
1539 std::vector<unsigned>::iterator curr_label;
1542 curr_label = Labels.begin();
1544 std::vector<const StructNode *> Nodes(n);
1545 std::vector<Vec3> Offsets(n);
1547 for (
int i = 0; i < n; i++ ) {
1557 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1558 "invalid label for point #" << i <<
" at line "
1565 ul = Nodes[i]->GetLabel();
1568 if (std::find(Labels.begin(), curr_label, ul) < curr_label) {
1569 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1570 "duplicate label for point #" << i <<
" at line "
1587 for (
int j = 0; j < i; j++) {
1588 if (Nodes[j] == Nodes[i]) {
1590 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1591 "warning, point #" << i <<
" is identical to point #" << j <<
" (same node, same offset)" << std::endl);
1593 silent_cerr(
"StructExtForce(" << uLabel <<
"): "
1594 "warning, point #" << i <<
" is based on same node of point #" << j <<
" (offsets differ)" << std::endl);
1604 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1605 "unable to parse echo file name "
1613 int save_errno = errno;
1614 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1615 "unable to open file \"" << s <<
"\" (" << save_errno <<
": " << strerror(save_errno) <<
")" << std::endl);
1620 std::ofstream out(s);
1622 out.setf(std::ios::scientific);
1624 for (
unsigned i = 0; i < Nodes.size(); i++) {
1628 out << Nodes[i]->GetLabel();
1631 out <<
" " << (Nodes[i]->GetXCurr() + Offsets[i]) <<
" ";
1634 out << Nodes[i]->GetRCurr();
1646 out <<
" " << Nodes[i]->GetVCurr() + Nodes[i]->GetWCurr().Cross(Offsets[i])
1647 <<
" " << Nodes[i]->GetWCurr()
1660 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1661 "unexpected arg at line " << HP.
GetLineData() << std::endl);
1668 if (dynamic_cast<ExtFileHandlerEDGE *>(pEFH)) {
1671 bUseReferenceNodeForces, bRotateReferenceNodeForces,
1672 Labels, Nodes, Offsets,
1673 bSorted, bLabels, bOutputAccelerations, uRot,
1674 pEFH, bSendAfterPredict, iCoupling, uOutputFlags, fOut));
1679 bUseReferenceNodeForces, bRotateReferenceNodeForces,
1680 Labels, Nodes, Offsets,
1681 bSorted, bLabels, bOutputAccelerations, uRot,
1682 pEFH, bSendAfterPredict, iCoupling, uOutputFlags, fOut));
1685 if (out.is_open()) {
flag fReadOutput(MBDynParser &HP, const T &t) const
const Vec3 Zero3(0., 0., 0.)
#define MBDYN_EXCEPT_ARGS
virtual integer GetInt(integer iDefval=0)
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
Vec3 VecRot(const Mat3x3 &Phi)
Vec3 GetPosRel(const ReferenceFrame &rf)
virtual bool IsKeyWord(const char *sKeyWord)
Vec3 MatR2EulerAngles123(const Mat3x3 &R)
virtual void SendToStream(std::ostream &outf, ExtFileHandlerBase::SendWhen when)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
virtual bool GetYesNo(bool &bRet)
virtual HighParser::ErrOut GetLineData(void) const
Node * ReadNode(MBDynParser &HP, Node::Type type) const
void ReadExtForce(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, ExtFileHandlerBase *&pEFH, bool &bSendAfterPredict, int &iCoupling)
bool IsExactlySame(const doublereal &d1, const doublereal &d2)