50 bool bUseReferenceNodeForces,
51 bool bRotateReferenceNodeForces,
52 std::vector<const StructDispNode *>&
nodes,
53 std::vector<Vec3>& offsets,
54 std::vector<unsigned>&
labels,
56 std::vector<uint32_t>& mappedlabels,
58 bool bOutputAccelerations,
61 bool bSendAfterPredict,
65 ExtForce(uL, pDM, pEFH, bSendAfterPredict, iCoupling, fOut),
67 bUseReferenceNodeForces(bUseReferenceNodeForces),
68 bRotateReferenceNodeForces(bRotateReferenceNodeForces),
74 uPoints(nodes.size()),
75 uMappedPoints(pH ? unsigned(pH->iGetNumRows())/3 : 0),
77 bOutputAccelerations(bOutputAccelerations),
79 m_qlabels(pH ? mappedlabels : labels),
84 m_qP(3*uMappedPoints),
89 ASSERT(nodes.size() == offsets.size());
103 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
104 "invalid reference node rotation type " << uRRot << std::endl);
108 if (bUseReferenceNodeForces) {
115 std::vector<const StructDispNode *>::const_iterator p;
116 for (p = nodes.begin(); p != nodes.end(); ++p) {
123 Nodes.resize(uNodes);
125 std::vector<const StructDispNode *>::const_iterator pPrev = p;
126 std::vector<NodeData>::iterator n =
Nodes.begin();
129 if ((p == nodes.end()) || (*p != *pPrev)) {
131 n->Offsets.resize(p - pPrev);
132 for (std::vector<OffsetData>::iterator i = n->Offsets.begin(); i != n->Offsets.end(); ++i) {
138 if (dynamic_cast<const StructNode *>(n->pNode) == 0) {
139 switch (n->Offsets.size()) {
145 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
146 "too many offsets for StructDispNode(" << n->pNode->GetLabel() <<
")"
157 if (p == nodes.end()) {
168 std::vector<Vec3>::const_iterator o = offsets.begin();
169 std::vector<uint32_t>::iterator l = labels.begin();
170 for (; o != offsets.end(); ++o, uPts++) {
171 if (uPts == n->Offsets.size()) {
175 if (dynamic_cast<const StructNode *>(n->pNode) == 0) {
176 for (std::vector<StructMappingExtForce::OffsetData>::const_iterator i = n->Offsets.begin();
177 i != n->Offsets.end(); i++)
179 if (!i->Offset.IsNull()) {
180 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
181 "offset #" << (i - n->Offsets.begin())
182 <<
" (" << i->Offset <<
") "
183 "for StructDispNode(" << n->pNode->GetLabel() <<
") is not zero"
192 n->Offsets[uPts].uLabel = unsigned(-1);
193 n->Offsets[uPts].Offset = *o;
194 n->Offsets[uPts].F =
Zero3;
197 n->Offsets[uPts].uLabel = *l;
202 if (bOutputAccelerations) {
203 for (
unsigned i = 0; i < nodes.size(); i++) {
206 silent_cerr(
"StructMappingExtForce"
256 char buf[
sizeof(uint32_t) +
sizeof(uint32_t)];
257 uint32_t *uint32_ptr;
259 uint32_ptr = (uint32_t *)&buf[0];
276 (
const void *)buf,
sizeof(buf),
279 int save_errno = errno;
280 char *err_msg = strerror(save_errno);
281 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
282 "negotiation request send() failed "
283 "(" << save_errno <<
": " << err_msg <<
")"
287 }
else if (rc !=
sizeof(buf)) {
288 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
289 "negotiation request send() failed "
290 "(sent " << rc <<
" of " <<
sizeof(buf) <<
" bytes)"
313 char buf[
sizeof(uint32_t) +
sizeof(uint32_t)];
314 uint32_t *uint32_ptr;
317 (
void *)buf,
sizeof(buf),
320 int save_errno = errno;
321 char *err_msg = strerror(save_errno);
322 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
323 "negotiation response recv() failed "
324 "(" << save_errno <<
": " << err_msg <<
")"
328 }
else if (rc !=
sizeof(buf)) {
329 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
330 "negotiation response recv() failed "
331 "(got " << rc <<
" of " <<
sizeof(buf) <<
" bytes)"
336 uint32_ptr = (uint32_t *)&buf[0];
349 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
350 "negotiation response failed: expecting MBC_NODAL "
357 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
358 "negotiation response failed: reference node configuration mismatch "
359 "(local=" << (
pRefNode != 0 ?
"yes" :
"no") <<
", remote=" << (bRef ?
"yes" :
"no") <<
")"
365 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
366 "negotiation response failed: orientation output mismatch "
373 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
374 "negotiation response failed: reference node orientation output mismatch "
381 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
382 "negotiation response failed: labels output mismatch "
383 "(local=" << (
bLabels ?
"yes" :
"no") <<
", remote=" << (bL ?
"yes" :
"no") <<
")"
389 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
390 "negotiation response failed: acceleration output mismatch "
398 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
399 "negotiation response failed: node number mismatch "
400 "(local=" << uMP <<
", remote=" << uN <<
")"
458 for (
unsigned i = 0; i <
Nodes.size(); i++) {
472 <<
Nodes[i]->GetLabel()
500 <<
" " << RRef.
MulTV(Dv);
504 <<
" " << RRef.
MulTV(w - wRef);
511 <<
" " << RRef.
MulTV(xpp - xppRef - wpRef.
Cross(Dx)
512 - wRef.
Cross(wRef.Cross(Dx) + Dv*2));
517 <<
" " << RRef.
MulTV(wp - wpRef - wRef.
Cross(w));
525 for (
unsigned i = 0; i <
Nodes.size(); i++) {
538 Vec3 f = R*Offsets[i];
546 <<
Nodes[i]->GetLabel()
613 send(outfd, (
void *)&l,
sizeof(l), 0);
639 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
640 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
642 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 += 3) {
679 - xppRef - wpRef.
Cross(Dx)
689 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
690 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
692 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 +=3 ) {
742 send(outfd, &
m_q[0],
sizeof(
double)*
m_q.size(), 0);
743 send(outfd, &
m_qP[0],
sizeof(
double)*
m_qP.size(), 0);
747 send(outfd, &
m_qPP[0],
sizeof(
double)*
m_qPP.size(), 0);
751 send(outfd, &
m_x[0],
sizeof(
double)*
m_x.size(), 0);
752 send(outfd, &
m_xP[0],
sizeof(
double)*
m_xP.size(), 0);
755 send(outfd, &
m_xPP[0],
sizeof(
double)*
m_xPP.size(), 0);
759 #else // ! USE_SOCKET
761 #endif // ! USE_SOCKET
788 inf >> f[0] >> f[1] >> f[2];
790 inf >> m[0] >> m[1] >> m[2];
794 for (
unsigned i = 0; i <
Nodes.size(); i++) {
803 silent_cerr(
"StructMappingExtForce"
805 "invalid " << i <<
"-th label " << l
812 >> f[0] >> f[1] >> f[2];
814 inf >> m[0] >> m[1] >> m[2];
840 ulen =
sizeof(uint32_t);
847 int save_errno = errno;
848 char *err_msg = strerror(save_errno);
849 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
850 "recv() failed (" << save_errno <<
": "
851 << err_msg <<
")" << std::endl);
854 }
else if (
unsigned(len) != ulen) {
855 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
856 "recv() failed " "(got " << len <<
" of "
857 << ulen <<
" bytes)" << std::endl);
862 uint32_t *uint32_ptr = (uint32_t *)buf;
863 unsigned l = uint32_ptr[0];
865 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
866 "invalid reference node label "
883 ssize_t len = recv(infd, (
void *)&
m_p[0],
sizeof(uint32_t)*
m_p.size(),
886 int save_errno = errno;
887 char *err_msg = strerror(save_errno);
888 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
889 "recv() failed (" << save_errno <<
": "
890 << err_msg <<
")" << std::endl);
893 }
else if (
unsigned(len) !=
sizeof(
double)*
m_p.size()) {
894 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
895 "recv() failed " "(got " << len <<
" of "
896 <<
sizeof(uint32_t)*
m_p.size() <<
" bytes)" << std::endl);
901 for (
unsigned l = 0; l <
m_qlabels.size(); l++) {
903 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
904 "label mismatch for point #" << l <<
"/" <<
m_qlabels.size()
905 <<
" local=" <<
m_qlabels[l] <<
" remote=" << labels[l] << std::endl);
916 fsize =
sizeof(double)*
m_p.size();
920 fsize =
sizeof(double)*
m_f.size();
925 int save_errno = errno;
926 char *err_msg = strerror(save_errno);
927 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
928 "recv() failed (" << save_errno <<
": "
929 << err_msg <<
")" << std::endl);
932 }
else if (
unsigned(len) != fsize) {
933 silent_cerr(
"StructMappingExtForce(" <<
GetLabel() <<
"): "
934 "recv() failed " "(got " << len <<
" of "
935 << fsize <<
" bytes)" << std::endl);
944 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
947 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
949 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 += 3) {
963 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
966 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
968 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 += 3) {
981 #else // ! USE_SOCKET
983 #endif // ! USE_SOCKET
1022 for (
unsigned n = 0; n <
Nodes.size(); n++) {
1023 integer iFirstIndex =
Nodes[n].pNode->iGetFirstMomentumIndex();
1026 WorkVec.
Add(iSize + 1,
Nodes[n].F);
1027 if (dynamic_cast<const StructNode *>(
Nodes[n].pNode)) {
1028 WorkVec.
Add(iSize + 4,
Nodes[n].M);
1035 for (
int r = 1; r <= iDim; r++) {
1050 for (
int r = 1; r <= 6; r++) {
1056 WorkVec.
Add(iSize + 1,
F1);
1057 WorkVec.
Add(iSize + 4,
M1);
1069 for (
unsigned n = 0; n <
Nodes.size(); n++) {
1070 integer iFirstIndex =
Nodes[n].pNode->iGetFirstMomentumIndex();
1073 WorkVec.
Add(iSize + 1,
Nodes[n].F);
1074 if (dynamic_cast<const StructNode *>(
Nodes[n].pNode)) {
1075 WorkVec.
Add(iSize + 4,
Nodes[n].M);
1082 for (
int r = 1; r <= iDim; r++) {
1100 std::ostream& out = OH.
Forces();
1113 for (
unsigned n = 0; n <
Nodes.size(); n++) {
1115 <<
" " <<
Nodes[n].F
1116 <<
" " <<
Nodes[n].M
1128 unsigned n =
Nodes.size();
1132 connectedNodes.resize(n);
1134 for (n = 0; n <
Nodes.size(); n++) {
1135 connectedNodes[n] =
Nodes[n].pNode;
1152 bool bUseReferenceNodeForces,
1153 bool bRotateReferenceNodeForces,
1154 std::vector<const StructDispNode *>&
nodes,
1155 std::vector<Vec3>& offsets,
1156 std::vector<unsigned>&
labels,
1157 std::vector<NodeConnData>& nodesConn,
1159 std::vector<uint32_t>& mappedlabels,
1161 bool bOutputAccelerations,
1164 bool bSendAfterPredict,
1169 pRefNode, bUseReferenceNodeForces, bRotateReferenceNodeForces,
1170 nodes, offsets, labels, pH, mappedlabels,
1171 bLabels, bOutputAccelerations, uRRot,
1172 pEFH, bSendAfterPredict, iCoupling,
1176 for (
unsigned n = 0; n <
NodesConn.size(); n++) {
1219 for (
unsigned i = 0; i <
Nodes.size(); i++) {
1221 Vec3 f(
Nodes[i]->GetRCurr()*Offsets[i]);
1233 <<
Nodes[i]->GetLabel()
1261 <<
" " << RRef.
MulTV(Dv);
1265 <<
" " << RRef.
MulTV(w - wRef);
1269 const Vec3& xpp(
Nodes[i]->GetXPPCurr());
1272 <<
" " << RRef.
MulTV(xpp - xppRef - wpRef.
Cross(Dx)
1273 - wRef.
Cross(wRef.Cross(Dx) + Dv*2));
1278 <<
" " << RRef.
MulTV(wp - wpRef - wRef.
Cross(w));
1286 for (
unsigned i = 0; i <
Nodes.size(); i++) {
1299 Vec3 f = R*Offsets[i];
1303 Vec3 v =
Nodes[i]->GetVCurr() + wCrossf;
1307 <<
Nodes[i]->GetLabel()
1374 send(outfd, (
void *)&l,
sizeof(l), 0);
1400 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
1401 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
1403 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 += 3) {
1438 for (
unsigned o = 0; o < 2; o++, p3 += 3) {
1450 - xppRef - wpRef.
Cross(Dx)
1468 - xppRef - wpRef.
Cross(Dx)
1479 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
1480 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
1482 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 +=3 ) {
1521 for (
unsigned o = 0; o < 2; o++, p3 += 3) {
1552 send(outfd, &
m_q[0],
sizeof(
double)*
m_q.size(), 0);
1553 send(outfd, &
m_qP[0],
sizeof(
double)*
m_qP.size(), 0);
1557 send(outfd, &
m_qPP[0],
sizeof(
double)*
m_qPP.size(), 0);
1561 send(outfd, &
m_x[0],
sizeof(
double)*
m_x.size(), 0);
1562 send(outfd, &
m_xP[0],
sizeof(
double)*
m_xP.size(), 0);
1565 send(outfd, &
m_xPP[0],
sizeof(
double)*
m_xPP.size(), 0);
1569 #else // ! USE_SOCKET
1571 #endif // ! USE_SOCKET
1586 inf >> f[0] >> f[1] >> f[2];
1588 inf >> m[0] >> m[1] >> m[2];
1592 for (
unsigned i = 0; i <
Nodes.size(); i++) {
1601 silent_cerr(
"StructMembraneMappingExtForce"
1603 "invalid " << i <<
"-th label " << l
1610 >> f[0] >> f[1] >> f[2];
1612 inf >> m[0] >> m[1] >> m[2];
1638 ulen =
sizeof(uint32_t);
1645 int save_errno = errno;
1646 char *err_msg = strerror(save_errno);
1647 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1648 "recv() failed (" << save_errno <<
": "
1649 << err_msg <<
")" << std::endl);
1652 }
else if (
unsigned(len) != ulen) {
1653 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1654 "recv() failed " "(got " << len <<
" of "
1655 << ulen <<
" bytes)" << std::endl);
1660 uint32_t *uint32_ptr = (uint32_t *)buf;
1661 unsigned l = uint32_ptr[0];
1663 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1664 "invalid reference node label "
1681 ssize_t len = recv(infd, (
void *)&
m_p[0],
sizeof(uint32_t)*
m_p.size(),
1684 int save_errno = errno;
1685 char *err_msg = strerror(save_errno);
1686 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1687 "recv() failed (" << save_errno <<
": "
1688 << err_msg <<
")" << std::endl);
1691 }
else if (
unsigned(len) !=
sizeof(
double)*
m_p.size()) {
1692 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1693 "recv() failed " "(got " << len <<
" of "
1694 <<
sizeof(uint32_t)*
m_p.size() <<
" bytes)" << std::endl);
1699 for (
unsigned l = 0; l <
m_qlabels.size(); l++) {
1701 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1702 "label mismatch for point #" << l <<
"/" <<
m_qlabels.size()
1703 <<
" local=" <<
m_qlabels[l] <<
" remote=" << labels[l] << std::endl);
1714 fsize =
sizeof(double)*
m_p.size();
1718 fsize =
sizeof(double)*
m_f.size();
1723 int save_errno = errno;
1724 char *err_msg = strerror(save_errno);
1725 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1726 "recv() failed (" << save_errno <<
": "
1727 << err_msg <<
")" << std::endl);
1730 }
else if (
unsigned(len) != fsize) {
1731 silent_cerr(
"StructMembraneMappingExtForce(" <<
GetLabel() <<
"): "
1732 "recv() failed " "(got " << len <<
" of "
1733 << fsize <<
" bytes)" << std::endl);
1742 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
1745 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
1747 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 += 3) {
1751 Nodes[n].M += f.Cross(
Nodes[n].Offsets[o].F);
1756 for (
unsigned o = 0; o < 2; o++, p3 += 3) {
1769 for (
unsigned p3 = 0, n = 0; n <
Nodes.size(); n++) {
1772 const StructNode *pNode(dynamic_cast<const StructNode *>(
Nodes[n].pNode));
1774 for (
unsigned o = 0; o <
Nodes[n].Offsets.size(); o++, p3 += 3) {
1778 Nodes[n].M += f.Cross(
Nodes[n].Offsets[o].F);
1783 for (
unsigned o = 0; o < 2; o++, p3 += 3) {
1795 #else // ! USE_SOCKET
1797 #endif // ! USE_SOCKET
1806 unsigned int uLabel)
1811 bool bSendAfterPredict;
1812 ReadExtForce(pDM, HP, uLabel, pEFH, bSendAfterPredict, iCoupling);
1819 bool bLabels(
false);
1821 bool bOutputAccelerations(
false);
1822 bool bUseReferenceNodeForces(
true);
1823 bool bRotateReferenceNodeForces(
true);
1825 bool bGotLabels(
false);
1826 bool bGotRot(
false);
1827 bool bGotAccels(
false);
1828 bool bGotUseRefForces(
false);
1830 while (HP.
IsArg()) {
1832 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1833 "use of \"no labels\" deprecated in favor of \"labels, { yes | no }\" at line "
1837 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1838 "\"no labels\" already specified at line "
1848 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1849 "\"labels\" already specified at line "
1855 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1856 "\"labels\" must be either \"yes\" or \"no\" at line "
1862 }
else if (HP.
IsKeyWord(
"orientation")) {
1864 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1865 "\"orientation\" already specified at line "
1873 }
else if (HP.
IsKeyWord(
"orientation" "vector")) {
1876 }
else if (HP.
IsKeyWord(
"orientation" "matrix")) {
1879 }
else if (HP.
IsKeyWord(
"euler" "123")) {
1883 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1884 "unknown \"orientation\" format at line "
1891 }
else if (HP.
IsKeyWord(
"accelerations")) {
1893 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1894 "\"accelerations\" already specified at line "
1899 if (!HP.
GetYesNo(bOutputAccelerations)) {
1900 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1901 "\"accelerations\" must be either \"yes\" or \"no\" at line "
1907 }
else if (HP.
IsKeyWord(
"use" "reference" "node" "forces")) {
1908 if (pRefNode == 0) {
1909 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1910 "\"use reference node forces\" only meaningful when reference node is used at line "
1915 if (bGotUseRefForces) {
1916 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1917 "\"use reference node forces\" already specified at line "
1922 if (!HP.
GetYesNo(bUseReferenceNodeForces)) {
1923 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1924 "\"use reference node forces\" must be either \"yes\" or \"no\" at line "
1928 bGotUseRefForces =
true;
1930 if (bUseReferenceNodeForces && HP.
IsKeyWord(
"rotate" "reference" "node" "forces")) {
1931 if (!HP.
GetYesNo(bRotateReferenceNodeForces)) {
1932 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1933 "\"rotate reference node forces\" must be either \"yes\" or \"no\" at line "
1945 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1946 "\"points number\" keyword expected "
1951 int nPoints = HP.
GetInt();
1953 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): illegal points number " << nPoints <<
1958 std::vector<const StructDispNode *> Nodes(nPoints);
1959 std::vector<Vec3> Offsets(nPoints, ::
Zero3);
1960 std::vector<uint32_t> Labels;
1962 Labels.resize(nPoints);
1964 bool bMembrane(
false);
1965 std::vector<StructMembraneMappingExtForce::NodeConnData> NodesConn;
1967 std::map<unsigned, bool> Got;
1969 for (
unsigned n = 0, p = 0; p < unsigned(nPoints); n++) {
1973 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1974 "StructNode(" << uL <<
") out of order "
1987 for (
unsigned n = 0; n < 4; n++) {
1989 if ((n%2) && pNn == ncd.
pNode[n - 1]) {
1990 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
1991 "nodes #" << n <<
" and #" << n - 1 <<
" are the same in \"membrane\" mapping for StructNode(" << uL <<
") at line " << HP.
GetLineData() << std::endl);
2003 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2004 "invalid h1 in \"membrane\" mapping for StructNode(" << uL <<
") at line " << HP.
GetLineData() << std::endl);
2012 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2013 "invalid (negative) point label " << l
2022 if (p ==
unsigned(nPoints)) {
2023 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2024 "second point in \"membrane\" mapping for StructNode(" << uL <<
") exceeds points number " << nPoints <<
" at line " << HP.
GetLineData() << std::endl);
2033 if (h2 == 0. || h1*h2 > 0.) {
2034 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2035 "invalid h2 in \"membrane\" mapping for StructNode(" << uL <<
") at line " << HP.
GetLineData() << std::endl);
2043 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2044 "invalid (negative) point label " << l
2055 if (p ==
unsigned(nPoints)) {
2056 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2057 "point " << p <<
" offset from StructNode(" << pNode->
GetLabel() <<
") exceeds expected value " << nPoints
2065 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2066 "invalid (negative) point label " << l
2079 NodesConn.push_back(ncd);
2085 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2086 "unable to parse echo file name "
2092 std::ofstream out(s);
2094 out.setf(std::ios::scientific);
2096 bool bGotSurface(
false);
2097 bool bGotOutput(
false);
2098 bool bGotOrder(
false);
2099 bool bGotBaseNode(
false);
2100 bool bGotWeight(
false);
2102 bool bGotPrecision(
false);
2113 std::string surface;
2118 bool bWeightInf(
false);
2122 if (bGotPrecision) {
2123 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2124 "\"precision\" already specified "
2128 bGotPrecision =
true;
2130 int iPrecision = HP.
GetInt();
2131 if (iPrecision <= 0) {
2132 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2133 "invalid echo precision " << iPrecision
2138 out.precision(iPrecision);
2142 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2143 "\"surface\" already specified "
2150 if (surface.empty()) {
2151 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2152 "invalid \"surface\" "
2159 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2160 "\"output\" already specified "
2167 if (output.empty()) {
2168 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2169 "invalid \"output\" "
2176 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2177 "\"order\" already specified "
2184 if (order < 1 || order > 3) {
2185 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2186 "invalid order=" << order <<
", must be 1 <= order <= 3 "
2193 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2194 "\"basenode\" already specified "
2198 bGotBaseNode =
true;
2201 if (basenode <= 0) {
2202 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2203 "invalid basenode=" << basenode <<
", must be > 0 "
2210 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2211 "\"weight\" already specified "
2223 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2224 "invalid weight=" << weight <<
", must be >= -2 or \"inf\" "
2235 time_t t = std::time(NULL);
2236 const char *user = std::getenv(
"USER");
2237 const char *
host = std::getenv(
"HOSTNAME");
2238 if (user == 0) user =
"nobody";
2239 if (host == 0) host =
"unknown";
2242 <<
"# Generated by MBDyn StructMappingExtForce(" << uLabel <<
")" << std::endl
2243 <<
"# " << user <<
"@" << host << std::endl
2244 <<
"# " << std::ctime(&t)
2245 <<
"# labels: " << (bLabels ?
"on" :
"off") << std::endl;
2253 <<
"# reference: " << pRefNode->
GetLabel() << std::endl
2254 <<
"# position: " << xRef << std::endl
2259 <<
"# points: " << nPoints << std::endl;
2262 out <<
"# surface: " << surface << std::endl;
2266 out <<
"# output: " << output << std::endl;
2270 out <<
"# order: " << order << std::endl;
2274 out <<
"# basenode: " << basenode << std::endl;
2279 out <<
"# weight: inf" << std::endl;
2281 out <<
"# weight: " << weight << std::endl;
2285 for (
unsigned n = 0, p = 0; p < unsigned(nPoints); p++) {
2286 if (p > 0 && Nodes[p] != Nodes[p - 1]) {
2291 out << Labels[p] <<
" ";
2295 const StructNode *pNode(dynamic_cast<const StructNode *>(Nodes[p]));
2301 if (NodesConn[n].pNode[0] != 0) {
2302 Vec3 e1(NodesConn[n].pNode[1]->GetXCurr() - NodesConn[n].pNode[0]->GetXCurr());
2303 Vec3 e2(NodesConn[n].pNode[3]->GetXCurr() - NodesConn[n].pNode[2]->GetXCurr());
2307 if (Nodes[p + 1] == Nodes[p]) {
2308 h = e3*NodesConn[n].h1;
2311 h = e3*NodesConn[n].h2;
2315 x = RRef.
MulTV(Nodes[p]->GetXCurr() + h - xRef);
2317 out << x << std::endl;
2326 std::vector<uint32_t> MappedLabels;
2327 if (HP.
IsKeyWord(
"mapped" "points" "number")) {
2328 int nMappedPoints = 0;
2333 nMappedPoints = HP.
GetInt();
2334 if (nMappedPoints <= 0) {
2335 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2336 "invalid mapped points number " << nMappedPoints
2346 ASSERT((nMappedPoints%3) == 0);
2347 ASSERT(nCols == 3*nPoints);
2351 MappedLabels.resize(nMappedPoints);
2352 if (HP.
IsKeyWord(
"mapped" "labels" "file")) {
2354 if (sFileName == 0) {
2355 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2356 "unable to read mapped labels file name "
2361 std::ifstream in(sFileName);
2363 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2364 "unable to open mapped labels file "
2365 "\"" << sFileName <<
"\" "
2374 }
while (c !=
'\n');
2379 for (
unsigned l = 0; l < unsigned(nMappedPoints); l++) {
2383 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2384 "unable to read mapped label #" << l <<
"/" << nMappedPoints
2385 <<
" from mapped labels file \"" << sFileName <<
"\"" << std::endl);
2389 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2390 "invalid (negative) mapped label #" << l <<
"/" << nMappedPoints
2391 <<
" from mapped labels file \"" << sFileName <<
"\"" << std::endl);
2394 MappedLabels[l] = i;
2398 for (
unsigned l = 0; l < unsigned(nMappedPoints); l++) {
2401 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2402 "invalid (negative) mapped label #" << l <<
"/" << nMappedPoints
2406 MappedLabels[l] = i;
2411 for (
unsigned l = 1; l < unsigned(nMappedPoints); l++) {
2412 for (
unsigned c = 0;
c < l;
c++) {
2413 if (MappedLabels[l] == MappedLabels[
c]) {
2415 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2416 "duplicate mapped label " << MappedLabels[l] <<
": "
2417 "#" << l <<
"==#" << c << std::endl);
2423 silent_cerr(
"StructMappingExtForce(" << uLabel <<
"): "
2424 << duplicate <<
" duplicate mapped labels"
2436 bUseReferenceNodeForces, bRotateReferenceNodeForces,
2437 Nodes, Offsets, Labels, NodesConn,
2440 bLabels, bOutputAccelerations, uRRot,
2441 pEFH, bSendAfterPredict, iCoupling, fOut));
2446 bUseReferenceNodeForces, bRotateReferenceNodeForces,
2447 Nodes, Offsets, Labels,
2450 bLabels, bOutputAccelerations, uRRot,
2451 pEFH, bSendAfterPredict, iCoupling, fOut));
flag fReadOutput(MBDynParser &HP, const T &t) const
virtual std::istream * GetInStream(void)
const Vec3 Zero3(0., 0., 0.)
Vec3 Cross(const Vec3 &v) const
virtual bool bToBeOutput(void) const
static void output(const LoadableElem *pEl, OutputHandler &OH)
#define MBDYN_EXCEPT_ARGS
virtual int GetInFileDes(void)
virtual int GetOutFileDes(void)
virtual void ResizeReset(integer)
virtual integer GetInt(integer iDefval=0)
virtual const Mat3x3 & GetRCurr(void) const
doublereal Norm(void) const
virtual void RecvFromStream(std::istream &inf)
virtual ~StructMappingExtForce(void)
const StructDispNode * pNode[4]
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
integer iGetNumRows(void) const
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
StructMappingExtForce(unsigned int uL, DataManager *pDM, const StructNode *pRefNode, bool bUseReferenceNodeForces, bool bRotateReferenceNodeForces, std::vector< const StructDispNode * > &Nodes, std::vector< Vec3 > &Offsets, std::vector< unsigned > &Labels, SpMapMatrixHandler *pH, std::vector< uint32_t > &MappedLabels, bool bLabels, bool bOutputAccelerations, unsigned uRRot, ExtFileHandlerBase *pEFH, bool bSendAfterPredict, int iCoupling, flag fOut)
std::vector< uint32_t > m_qlabels
void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
std::vector< NodeData > Nodes
Vec3 VecRot(const Mat3x3 &Phi)
virtual void SendToStream(std::ostream &outf, ExtFileHandlerBase::SendWhen when)
virtual void SendToFileDes(int outfd, ExtFileHandlerBase::SendWhen when)
Vec3 MulTV(const Vec3 &v) const
virtual Negotiate NegotiateRequest(void) const
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
bool Prepare(ExtFileHandlerBase *pEFH)
integer iGetNumCols(void) const
virtual void RecvFromFileDes(int infd)
bool bRotateReferenceNodeForces
Vec3 GetPosRel(const ReferenceFrame &rf)
virtual bool IsKeyWord(const char *sKeyWord)
virtual void Put(integer iRow, const Vec3 &v)
bool bOutputAccelerations
virtual int GetRecvFlags(void) const
ExtFileHandlerBase * pEFH
virtual void Output(OutputHandler &OH) const
Vec3 MatR2EulerAngles123(const Mat3x3 &R)
virtual integer iGetFirstMomentumIndex(void) const =0
virtual void SendToStream(std::ostream &outf, ExtFileHandlerBase::SendWhen when)
virtual const Vec3 & GetWCurr(void) const
virtual const Vec3 & GetWPCurr(void) const
#define ASSERT(expression)
virtual std::ostream * GetOutStream(void)
Mat3x3 MulTM(const Mat3x3 &m) const
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
virtual const Vec3 & GetXCurr(void) const
virtual void Add(integer iRow, const Vec3 &v)
std::vector< NodeConnData > NodesConn
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
static std::stack< cleanup * > c
const doublereal * pGetMat(void) const
virtual void RecvFromStream(std::istream &inf)
virtual bool GetYesNo(bool &bRet)
#define MBC_U_ROT_2_REF_NODE_ROT(u)
virtual ~StructMembraneMappingExtForce(void)
const doublereal * pGetVec(void) const
bool bUseReferenceNodeForces
void Send(ExtFileHandlerBase *pEFH, ExtFileHandlerBase::SendWhen when)
virtual const Vec3 & GetVCurr(void) const
StructMembraneMappingExtForce(unsigned int uL, DataManager *pDM, const StructNode *pRefNode, bool bUseReferenceNodeForces, bool bRotateReferenceNodeForces, std::vector< const StructDispNode * > &Nodes, std::vector< Vec3 > &Offsets, std::vector< unsigned > &Labels, std::vector< NodeConnData > &NodesConn, SpMapMatrixHandler *pH, std::vector< uint32_t > &MappedLabels, bool bLabels, bool bOutputAccelerations, unsigned uRRot, ExtFileHandlerBase *pEFH, bool bSendAfterPredict, int iCoupling, flag fOut)
static const doublereal a
Elem * ReadStructMappingExtForce(DataManager *pDM, MBDynParser &HP, unsigned int uLabel)
virtual int GetSendFlags(void) const
virtual const Vec3 & GetXPPCurr(void) const
static doublereal buf[BUFSIZE]
virtual VectorHandler & MatTVecMul(VectorHandler &out, const VectorHandler &in) const
virtual void RecvFromFileDes(int infd)
virtual HighParser::ErrOut GetLineData(void) const
unsigned int GetLabel(void) const
const StructNode * pRefNode
Node * ReadNode(MBDynParser &HP, Node::Type type) const
virtual VectorHandler & MatVecMul(VectorHandler &out, const VectorHandler &in) const
void ReadExtForce(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, ExtFileHandlerBase *&pEFH, bool &bSendAfterPredict, int &iCoupling)
virtual void Resize(integer iNewSize)=0
std::ostream & Forces(void) const
virtual void SendToFileDes(int outfd, ExtFileHandlerBase::SendWhen when)
bool UseText(int out) const
SpMapMatrixHandler * ReadSparseMappingMatrix(MBDynParser &HP, integer &nRows, integer &nCols)
virtual doublereal GetReal(const doublereal &dDefval=0.0)