49 bool bUseReferenceNodeForces,
50 bool bRotateReferenceNodeForces,
51 std::vector<unsigned>&
labels,
52 std::vector<const StructNode *>&
nodes,
53 std::vector<Vec3>& offsets,
56 bool bOutputAccelerations,
59 bool bSendAfterPredict,
61 unsigned uOutputFlags,
64 StructExtForce(uL, pDM, pRefNode, bUseReferenceNodeForces, bRotateReferenceNodeForces,
65 labels, nodes, offsets, bSorted, bLabels, bOutputAccelerations, uRot,
66 pEFH, bSendAfterPredict, iCoupling, uOutputFlags, fOut),
70 ASSERT(dynamic_cast<ExtFileHandlerEDGE *>(pEFH) != 0);
138 std::vector<PointData>::const_iterator point;
139 std::vector<Vec3>::iterator ix;
140 std::vector<Vec3>::iterator iv;
141 for (point =
m_Points.begin(), ix =
m_x.begin(), iv =
m_v.begin(); point !=
m_Points.end(); ++point, ++ix, ++iv) {
142 Vec3 f(point->pNode->GetRCurr()*point->Offset);
143 Vec3 x(point->pNode->GetXCurr() + f);
144 Vec3 v(point->pNode->GetVCurr() + point->pNode->GetWCurr().Cross(f));
146 *ix = RRef.
MulTV(x - xRef);
147 *iv = RRef.
MulTV(v - vRef - wRef.
Cross(x - xRef));
151 std::vector<PointData>::const_iterator point;
152 std::vector<Vec3>::iterator ix;
153 std::vector<Vec3>::iterator iv;
154 for (point =
m_Points.begin(), ix =
m_x.begin(), iv =
m_v.begin(); point !=
m_Points.end(); ++point, ++ix, ++iv) {
155 Vec3 f(point->pNode->GetRCurr()*point->Offset);
157 *ix = point->pNode->GetXCurr() + f;
158 *iv = point->pNode->GetVCurr() + point->pNode->GetWCurr().
Cross(f);
163 "ext_model, N, 0, 0, 3\n"
168 "grid_idents, IF, 1, " <<
m_Points.size() <<
", 0\n";
171 for (std::vector<PointData>::const_iterator point =
m_Points.begin(); point !=
m_Points.end(); ++point, ++cnt) {
179 outf << point->uLabel;
185 "str_coordinates, RF, 3, " <<
m_Points.size() <<
", 0\n";
187 for (
int c = 1;
c <= 3;
c++) {
189 for (std::vector<Vec3>::const_iterator i =
m_x.begin(); i !=
m_x.end(); ++i, ++cnt) {
205 "velocity, RF, 3, " <<
m_Points.size() <<
", 0\n";
207 for (
int c = 1;
c <= 3;
c++) {
209 for (std::vector<Vec3>::const_iterator i =
m_v.begin(); i !=
m_v.end(); ++i, ++cnt) {
264 typedef std::vector<std::vector<PointData>::iterator> RIndexType;
270 char buf[BUFSIZ], *p;
287 if (strncasecmp(buf,
"ext_model",
STRLENOF(
"ext_model")) == 0) {
290 size_t buflen =
sizeof(
buf) -
STRLENOF(
"ext_model");
291 p = &buf[0] +
STRLENOF(
"ext_model");
295 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
296 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
302 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"N\" "
303 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
309 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
310 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
316 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"0\" "
317 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
323 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
324 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
330 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"0\" "
331 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
337 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
338 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
344 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"2\" "
345 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
356 if (strncasecmp(buf,
"grid_idents",
STRLENOF(
"grid_idents")) == 0) {
359 size_t buflen =
sizeof(
buf) -
STRLENOF(
"grid_idents");
360 p = &buf[0] +
STRLENOF(
"grid_idents");
364 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
365 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
371 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"IF\" "
372 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
378 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
379 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
385 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"1\" "
386 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
392 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
393 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
399 long nids = strtol(p, &next, 10);
400 int save_errno = errno;
402 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to read IDs number field "
403 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
406 }
else if (save_errno == ERANGE) {
407 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): IDs number field overflows "
408 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
412 if (
unsigned(nids) !=
m_Points.size()) {
413 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): IDs number " << nids <<
" does not match "
414 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
422 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
423 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
429 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"0\" "
430 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
434 for (std::vector<unsigned>::iterator
id =
labels.begin();
id !=
labels.end(); ++id) {
440 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): invalid ID #" <<
id -
labels.begin() << std::endl);
444 if (std::find(
labels.begin(), id, unsigned(idx)) <
id) {
445 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): "
446 "duplicate ID #" <<
id -
labels.begin() <<
" \"" << idx <<
"\"" << std::endl);
456 for (std::vector<PointData>::iterator point =
m_Points.begin(); point !=
m_Points.end(); ++point) {
457 std::vector<unsigned>::iterator
id = std::find(
labels.begin(),
labels.end(), point->uLabel);
459 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): "
460 "ID \"" << point->uLabel <<
"\" missing" << std::endl);
464 points[
id -
labels.begin()] = point;
474 if (strncasecmp(buf,
"force",
STRLENOF(
"force")) == 0) {
482 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
483 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
489 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"RF\" "
490 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
496 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
497 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
503 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"3\" "
504 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
510 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
511 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
517 long nids = strtol(p, &next, 10);
518 int save_errno = errno;
520 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to read IDs number field "
521 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
524 }
else if (save_errno == ERANGE) {
525 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): IDs number field overflows "
526 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
529 if (
unsigned(nids) !=
m_Points.size()) {
530 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): IDs number " << nids <<
" does not match "
531 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
539 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip separator "
540 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
546 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unable to skip field \"0\" "
547 "at line=" << lineno <<
", \"" << buf[
sizeof(buf) - buflen] <<
"\"" << std::endl);
551 for (RIndexType::iterator p = points.begin(); p != points.end(); p++) {
561 for (RIndexType::const_iterator p = points.begin(); p != points.end(); p++) {
571 for (RIndexType::const_iterator p = points.begin(); p != points.end(); p++) {
584 silent_cerr(
"StructExtEDGEForce(" <<
GetLabel() <<
"): unexpected line=" << lineno <<
", "
585 "\"" << buf <<
"\"" << std::endl);
StructExtEDGEForce(unsigned int uL, DataManager *pDM, const StructNode *pRefNode, bool bUseReferenceNodeForces, bool bRotateReferenceNodeForces, std::vector< unsigned > &Labels, std::vector< const StructNode * > &Nodes, std::vector< Vec3 > &Offsets, bool bSorted, bool bLabels, bool bOutputAccelerations, unsigned bRot, ExtFileHandlerBase *pEFH, bool bSendAfterPredict, int iCoupling, unsigned uOutputFlags, flag fOut)
Vec3 Cross(const Vec3 &v) const
#define MBDYN_EXCEPT_ARGS
virtual const Mat3x3 & GetRCurr(void) const
char * mbedge_eat_sep(char *buf, size_t &buflen)
virtual void RecvFromFileDes(int infd)
virtual ~StructExtEDGEForce(void)
Vec3 MulTV(const Vec3 &v) const
std::vector< PointData > m_Points
int mbedge_goto_eol(std::istream &fin, char *buf, size_t bufsiz)
virtual const Vec3 & GetWCurr(void) const
#define ASSERT(expression)
char * mbedge_eat_field(char *buf, size_t &buflen, const char *val)
virtual const Vec3 & GetXCurr(void) const
virtual void SendToStream(std::ostream &outf, ExtFileHandlerBase::SendWhen when)
virtual const Vec3 & GetVCurr(void) const
virtual void SendToFileDes(int outfd, ExtFileHandlerBase::SendWhen when)
static doublereal buf[BUFSIZE]
unsigned int GetLabel(void) const
const StructNode * pRefNode
virtual void RecvFromStream(std::istream &inf)