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

#include <strmappingext.h>

Inheritance diagram for StructMappingExtForce:
Collaboration diagram for StructMappingExtForce:

Classes

struct  NodeData
 
struct  OffsetData
 

Public Member Functions

 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)
 
virtual ~StructMappingExtForce (void)
 
virtual Force::Type GetForceType (void) const
 
void WorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
SubVectorHandlerAssRes (SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Output (OutputHandler &OH) const
 
virtual void GetConnectedNodes (std::vector< const Node * > &connectedNodes) const
 
- Public Member Functions inherited from Elem
 Elem (unsigned int uL, flag fOut)
 
virtual ~Elem (void)
 
virtual unsigned int iGetNumDof (void) const
 
virtual std::ostream & DescribeDof (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeDof (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual std::ostream & DescribeEq (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeEq (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual DofOrder::Order GetDofType (unsigned int) const
 
virtual void AssMats (VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bInverseDynamics (void) const
 
void SetInverseDynamicsFlags (unsigned uIDF)
 
unsigned GetInverseDynamicsFlags (void) const
 
bool bIsErgonomy (void) const
 
bool bIsRightHandSide (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr, const VectorHandler &XPrimePrimeCurr, InverseDynamics::Order iOrder=InverseDynamics::INVERSE_DYNAMICS)
 
virtual int GetNumConnectedNodes (void) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from SimulationEntity
 SimulationEntity (void)
 
virtual ~SimulationEntity (void)
 
virtual bool bIsValidIndex (unsigned int i) const
 
virtual DofOrder::Order GetEqType (unsigned int i) const
 
virtual HintParseHint (DataManager *pDM, const char *s) const
 
virtual void BeforePredict (VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
 
virtual void DerivativesUpdate (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Update (const VectorHandler &XCurr, InverseDynamics::Order iOrder)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP, const VectorHandler &XPP)
 
virtual unsigned int iGetNumPrivData (void) const
 
virtual unsigned int iGetPrivDataIdx (const char *s) const
 
virtual doublereal dGetPrivData (unsigned int i) const
 
virtual std::ostream & OutputAppend (std::ostream &out) const
 
virtual void ReadInitialState (MBDynParser &HP)
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from ExtForce
 ExtForce (unsigned int uL, DataManager *pDM, ExtFileHandlerBase *pEFH, bool bSendAfterPredict, int iCoupling, flag fOut)
 
virtual ~ExtForce (void)
 
virtual void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *h=0)
 
virtual void Update (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP)
 
virtual void AfterPredict (VectorHandler &X, VectorHandler &XP)
 
virtual void InitialWorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
virtual VariableSubMatrixHandlerInitialAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerInitialAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr)
 
- Public Member Functions inherited from Force
 Force (unsigned int uL, flag fOut)
 
virtual ~Force (void)
 
virtual Elem::Type GetElemType (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, doublereal, const VectorHandler &, const VectorHandler &)
 
virtual std::ostream & Restart (std::ostream &out) const
 
virtual unsigned int iGetInitialNumDof (void) const
 
- Public Member Functions inherited from InitialAssemblyElem
 InitialAssemblyElem (unsigned int uL, flag fOut)
 
virtual ~InitialAssemblyElem (void)
 
- Public Member Functions inherited from SubjectToInitialAssembly
 SubjectToInitialAssembly (void)
 
virtual ~SubjectToInitialAssembly (void)
 

Protected Member Functions

bool Prepare (ExtFileHandlerBase *pEFH)
 
void Send (ExtFileHandlerBase *pEFH, ExtFileHandlerBase::SendWhen when)
 
void Recv (ExtFileHandlerBase *pEFH)
 
virtual void SendToStream (std::ostream &outf, ExtFileHandlerBase::SendWhen when)
 
virtual void SendToFileDes (int outfd, ExtFileHandlerBase::SendWhen when)
 
virtual void RecvFromStream (std::istream &inf)
 
virtual void RecvFromFileDes (int infd)
 
- Protected Member Functions inherited from ExtForce
void Send (ExtFileHandlerBase::SendWhen when)
 
void Recv (void)
 

Protected Attributes

const StructNodepRefNode
 
bool bUseReferenceNodeForces
 
bool bRotateReferenceNodeForces
 
Vec3 F0
 
Vec3 M0
 
Vec3 F1
 
Vec3 M1
 
Vec3 F2
 
Vec3 M2
 
SpMapMatrixHandlerpH
 
unsigned m_uResSize
 
std::vector< NodeDataNodes
 
unsigned uPoints
 
unsigned uMappedPoints
 
bool bLabels
 
bool bOutputAccelerations
 
unsigned uRRot
 
std::vector< uint32_t > m_qlabels
 
STLVectorHandler m_x
 
STLVectorHandler m_xP
 
STLVectorHandler m_xPP
 
STLVectorHandler m_q
 
STLVectorHandler m_qP
 
STLVectorHandler m_qPP
 
STLVectorHandler m_f
 
STLVectorHandler m_p
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 
- Protected Attributes inherited from ExtForce
Converged c
 
ExtFileHandlerBasepEFH
 
bool bSendAfterPredict
 
int iCoupling
 
int iCouplingCounter
 
bool bFirstSend
 
bool bFirstRecv
 

Additional Inherited Members

- Public Types inherited from Elem
enum  Type {
  UNKNOWN = -1, AIRPROPERTIES = 0, INDUCEDVELOCITY, AUTOMATICSTRUCTURAL,
  GRAVITY, BODY, JOINT, JOINT_REGULARIZATION,
  BEAM, PLATE, FORCE, INERTIA,
  ELECTRICBULK, ELECTRIC, THERMAL, HYDRAULIC,
  BULK, LOADABLE, DRIVEN, EXTERNAL,
  AEROMODAL, AERODYNAMIC, GENEL, SOCKETSTREAM_OUTPUT,
  RTAI_OUTPUT = SOCKETSTREAM_OUTPUT, LASTELEMTYPE
}
 
- Public Types inherited from SimulationEntity
typedef std::vector< Hint * > Hints
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from ExtForce
enum  { COUPLING_NONE = -2, COUPLING_STAGGERED = -1, COUPLING_LOOSE = 0, COUPLING_TIGHT = 1 }
 
- Public Types inherited from Force
enum  Type {
  UNKNOWN = -1, ABSTRACTFORCE = 0, ABSTRACTINTERNALFORCE, ABSOLUTEDISPFORCE,
  ABSOLUTEINTERNALDISPFORCE, ABSOLUTEFORCE, FOLLOWERFORCE, ABSOLUTECOUPLE,
  FOLLOWERCOUPLE, ABSOLUTEINTERNALFORCE, FOLLOWERINTERNALFORCE, ABSOLUTEINTERNALCOUPLE,
  FOLLOWERINTERNALCOUPLE, TOTALFORCE, TOTALINTERNALFORCE, EXTERNALSTRUCTURAL,
  MODALFORCE, EXTERNALMODAL, LASTFORCETYPE
}
 

Detailed Description

Definition at line 46 of file strmappingext.h.

Constructor & Destructor Documentation

StructMappingExtForce::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 
)

Definition at line 47 of file strmappingext.cc.

References ASSERT, WithLabel::GetLabel(), SparseMatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), m_qPP, m_uResSize, m_xPP, MBC_ROT_EULER_123, MBC_ROT_MAT, MBC_ROT_THETA, MBDYN_EXCEPT_ARGS, Nodes, uMappedPoints, uPoints, and Zero3.

64 : Elem(uL, fOut),
65 ExtForce(uL, pDM, pEFH, bSendAfterPredict, iCoupling, fOut),
66 pRefNode(pRefNode),
69 F0(Zero3), M0(Zero3),
70 F1(Zero3), M1(Zero3),
71 F2(Zero3), M2(Zero3),
72 pH(pH),
73 m_uResSize(0),
74 uPoints(nodes.size()),
75 uMappedPoints(pH ? unsigned(pH->iGetNumRows())/3 : 0),
78 uRRot(uRRot),
79 m_qlabels(pH ? mappedlabels : labels),
80 m_x(3*uPoints),
81 m_xP(3*uPoints),
82 m_xPP(0),
85 m_qPP(0),
86 m_f(3*uPoints),
88 {
89  ASSERT(nodes.size() == offsets.size());
90  if (pH) {
91  ASSERT(3*uPoints == unsigned(pH->iGetNumCols()));
92  ASSERT(3*uMappedPoints == unsigned(pH->iGetNumRows()));
93  }
94 
95  if (pRefNode) {
96  switch (uRRot) {
97  case MBC_ROT_THETA:
98  case MBC_ROT_MAT:
99  case MBC_ROT_EULER_123:
100  break;
101 
102  default:
103  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
104  "invalid reference node rotation type " << uRRot << std::endl);
106  }
107 
109  m_uResSize += 6;
110  }
111  }
112 
113  const StructDispNode *pNode = 0;
114  unsigned uNodes = 0;
115  std::vector<const StructDispNode *>::const_iterator p;
116  for (p = nodes.begin(); p != nodes.end(); ++p) {
117  if (*p != pNode) {
118  pNode = *p;
119  uNodes++;
120  }
121  }
122 
123  Nodes.resize(uNodes);
124  p = nodes.begin();
125  std::vector<const StructDispNode *>::const_iterator pPrev = p;
126  std::vector<NodeData>::iterator n = Nodes.begin();
127  while (true) {
128  ++p;
129  if ((p == nodes.end()) || (*p != *pPrev)) {
130  n->pNode = *pPrev;
131  n->Offsets.resize(p - pPrev);
132  for (std::vector<OffsetData>::iterator i = n->Offsets.begin(); i != n->Offsets.end(); ++i) {
133  i->Offset = ::Zero3;
134  }
135  n->F = Zero3;
136  n->M = Zero3;
137 
138  if (dynamic_cast<const StructNode *>(n->pNode) == 0) {
139  switch (n->Offsets.size()) {
140  case 1: // regular rotationless node
141  case 2: // special rotationless node for "membrane"
142  break;
143 
144  default:
145  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
146  "too many offsets for StructDispNode(" << n->pNode->GetLabel() << ")"
147  << std::endl);
149  }
150 
151  m_uResSize += 3;
152 
153  } else {
154  m_uResSize += 6;
155  }
156 
157  if (p == nodes.end()) {
158  break;
159  }
160 
161  ++n;
162  pPrev = p;
163  }
164  }
165 
166  unsigned uPts = 0;
167  n = Nodes.begin();
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()) {
172  ++n;
173  uPts = 0;
174 
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++)
178  {
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"
184  << std::endl);
186  }
187  }
188  }
189  }
190 
191  // FIXME: pass labels
192  n->Offsets[uPts].uLabel = unsigned(-1);
193  n->Offsets[uPts].Offset = *o;
194  n->Offsets[uPts].F = Zero3;
195 
196  if (bLabels) {
197  n->Offsets[uPts].uLabel = *l;
198  ++l;
199  }
200  }
201 
202  if (bOutputAccelerations) {
203  for (unsigned i = 0; i < nodes.size(); i++) {
204  const DynamicStructDispNode *pDSN = dynamic_cast<const DynamicStructDispNode *>(Nodes[i].pNode);
205  if (pDSN == 0) {
206  silent_cerr("StructMappingExtForce"
207  "(" << GetLabel() << "): "
208  "StructNode(" << Nodes[i].pNode->GetLabel() << ") "
209  "is not dynamic"
210  << std::endl);
212  }
213 
214  const_cast<DynamicStructDispNode *>(pDSN)->ComputeAccelerations(true);
215  }
216 
217  m_xPP.resize(3*uPoints);
218  m_qPP.resize(3*uMappedPoints);
219 
220  }
221 }
const Vec3 Zero3(0., 0., 0.)
STLVectorHandler m_xPP
Definition: strmappingext.h:86
STLVectorHandler m_qPP
Definition: strmappingext.h:89
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
bool bSendAfterPredict
Definition: extforce.h:196
integer iGetNumRows(void) const
Definition: spmh.h:113
std::vector< uint32_t > m_qlabels
Definition: strmappingext.h:82
STLVectorHandler m_x
Definition: strmappingext.h:84
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
ExtForce(unsigned int uL, DataManager *pDM, ExtFileHandlerBase *pEFH, bool bSendAfterPredict, int iCoupling, flag fOut)
Definition: extforce.cc:677
integer iGetNumCols(void) const
Definition: spmh.h:117
static int labels
#define ASSERT(expression)
Definition: colamd.c:977
static int nodes
STLVectorHandler m_q
Definition: strmappingext.h:87
STLVectorHandler m_p
Definition: strmappingext.h:92
SpMapMatrixHandler * pH
Definition: strmappingext.h:56
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48
STLVectorHandler m_xP
Definition: strmappingext.h:85
STLVectorHandler m_qP
Definition: strmappingext.h:88
STLVectorHandler m_f
Definition: strmappingext.h:91

Here is the call graph for this function:

StructMappingExtForce::~StructMappingExtForce ( void  )
virtual

Definition at line 223 of file strmappingext.cc.

References NO_OP.

224 {
225  NO_OP;
226 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

SubVectorHandler & StructMappingExtForce::AssRes ( SubVectorHandler WorkVec,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 987 of file strmappingext.cc.

References VectorHandler::Add(), ASSERT, bRotateReferenceNodeForces, ToBeOutput::bToBeOutput(), bUseReferenceNodeForces, ExtForce::COUPLING_NONE, grad::Cross(), F0, F1, F2, StructNode::GetRCurr(), StructDispNode::GetXCurr(), ExtForce::iCoupling, StructDispNode::iGetFirstMomentumIndex(), M0, M1, M2, m_uResSize, Nodes, pRefNode, SubVectorHandler::PutRowIndex(), ExtForce::Recv(), VectorHandler::Resize(), VectorHandler::ResizeReset(), and Zero3.

991 {
992  ExtForce::Recv();
993 
994  if (iCoupling == COUPLING_NONE) {
995  WorkVec.Resize(0);
996  return WorkVec;
997  }
998 
999 
1000  if (pRefNode) {
1001  integer iSize(0);
1002 
1003  WorkVec.ResizeReset(m_uResSize);
1004 
1005  const Vec3& xRef = pRefNode->GetXCurr();
1006  const Mat3x3& RRef = pRefNode->GetRCurr();
1007 
1008  // manipulate
1011  F1 = RRef*F0;
1012  M1 = RRef*M0;
1013 
1014  } else {
1015  F1 = F0;
1016  M1 = M0;
1017  }
1018  }
1019 
1020  F2 = Zero3;
1021  M2 = Zero3;
1022  for (unsigned n = 0; n < Nodes.size(); n++) {
1023  integer iFirstIndex = Nodes[n].pNode->iGetFirstMomentumIndex();
1024  integer iDim;
1025 
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);
1029  iDim = 6;
1030 
1031  } else {
1032  iDim = 3;
1033  }
1034 
1035  for (int r = 1; r <= iDim; r++) {
1036  WorkVec.PutRowIndex(iSize + r, iFirstIndex + r);
1037  }
1038 
1040  // compute Global Reference Node Forces, even if they are not used, for output only :)
1041  F2 += Nodes[n].F;
1042  M2 += Nodes[n].M + (Nodes[n].pNode->GetXCurr() - xRef).Cross(Nodes[n].F);
1043  }
1044 
1045  iSize += iDim;
1046  }
1047 
1049  integer iFirstIndex = pRefNode->iGetFirstMomentumIndex();
1050  for (int r = 1; r <= 6; r++) {
1051  WorkVec.PutRowIndex(iSize + r, iFirstIndex + r);
1052  }
1053 
1054  F1 -= F2;
1055  M1 -= M2;
1056  WorkVec.Add(iSize + 1, F1);
1057  WorkVec.Add(iSize + 4, M1);
1058 
1059  iSize += 6;
1060  }
1061 
1062  ASSERT(iSize == m_uResSize);
1063 
1064  } else {
1065  integer iSize(0);
1066 
1067  WorkVec.ResizeReset(m_uResSize);
1068 
1069  for (unsigned n = 0; n < Nodes.size(); n++) {
1070  integer iFirstIndex = Nodes[n].pNode->iGetFirstMomentumIndex();
1071  integer iDim;
1072 
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);
1076  iDim = 6;
1077 
1078  } else {
1079  iDim = 3;
1080  }
1081 
1082  for (int r = 1; r <= iDim; r++) {
1083  WorkVec.PutRowIndex(iSize + r, iFirstIndex + r);
1084  }
1085 
1086  iSize += iDim;
1087  }
1088 
1089  ASSERT(iSize == m_uResSize);
1090  }
1091 
1092  return WorkVec;
1093 }
const Vec3 Zero3(0., 0., 0.)
virtual bool bToBeOutput(void) const
Definition: output.cc:890
Definition: matvec3.h:98
virtual void ResizeReset(integer)
Definition: vh.cc:55
void Recv(void)
Definition: extforce.cc:798
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
virtual integer iGetFirstMomentumIndex(void) const =0
#define ASSERT(expression)
Definition: colamd.c:977
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
Definition: matvec.h:3248
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
virtual void Add(integer iRow, const Vec3 &v)
Definition: vh.cc:63
int iCoupling
Definition: extforce.h:212
long int integer
Definition: colamd.c:51
const StructNode * pRefNode
Definition: strmappingext.h:48
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

void StructMappingExtForce::GetConnectedNodes ( std::vector< const Node * > &  connectedNodes) const
virtual

Reimplemented from Elem.

Definition at line 1126 of file strmappingext.cc.

References Nodes, and pRefNode.

1127 {
1128  unsigned n = Nodes.size();
1129  if (pRefNode) {
1130  n++;
1131  }
1132  connectedNodes.resize(n);
1133 
1134  for (n = 0; n < Nodes.size(); n++) {
1135  connectedNodes[n] = Nodes[n].pNode;
1136  }
1137 
1138  if (pRefNode) {
1139  connectedNodes[n] = pRefNode;
1140  }
1141 }
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
const StructNode * pRefNode
Definition: strmappingext.h:48
virtual Force::Type StructMappingExtForce::GetForceType ( void  ) const
inlinevirtual

Implements Force.

Definition at line 126 of file strmappingext.h.

References Force::EXTERNALSTRUCTURAL.

126  {
128  };
void StructMappingExtForce::Output ( OutputHandler OH) const
virtual

Reimplemented from ToBeOutput.

Definition at line 1096 of file strmappingext.cc.

References ToBeOutput::bToBeOutput(), F0, F1, F2, OutputHandler::FORCES, OutputHandler::Forces(), WithLabel::GetLabel(), M0, M1, M2, Nodes, pRefNode, and OutputHandler::UseText().

1097 {
1098  if (bToBeOutput()) {
1099  if (OH.UseText(OutputHandler::FORCES)) {
1100  std::ostream& out = OH.Forces();
1101 
1102  if (pRefNode) {
1103  out << GetLabel() << "#" << pRefNode->GetLabel()
1104  << " " << F0
1105  << " " << M0
1106  << " " << F1
1107  << " " << M1
1108  << " " << F2
1109  << " " << M2
1110  << std::endl;
1111  }
1112 
1113  for (unsigned n = 0; n < Nodes.size(); n++) {
1114  out << GetLabel() << "@" << Nodes[n].pNode->GetLabel()
1115  << " " << Nodes[n].F
1116  << " " << Nodes[n].M
1117  << std::endl;
1118  }
1119  }
1120 
1121  /* TODO: NetCDF */
1122  }
1123 }
virtual bool bToBeOutput(void) const
Definition: output.cc:890
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48
std::ostream & Forces(void) const
Definition: output.h:450
bool UseText(int out) const
Definition: output.cc:446

Here is the call graph for this function:

bool StructMappingExtForce::Prepare ( ExtFileHandlerBase pEFH)
protectedvirtual

Implements ExtForce.

Definition at line 242 of file strmappingext.cc.

References bLabels, bOutputAccelerations, buf, ExtFileHandlerBase::GetInFileDes(), ExtFileHandlerBase::GetInStream(), WithLabel::GetLabel(), ExtFileHandlerBase::GetOutFileDes(), ExtFileHandlerBase::GetOutStream(), ExtFileHandlerBase::GetRecvFlags(), ExtFileHandlerBase::GetSendFlags(), MBC_ACCELS, MBC_LABELS, MBC_MODAL, MBC_MODAL_NODAL_MASK, MBC_NODAL, MBC_REF_NODE, MBC_REF_NODE_ROT_MASK, MBC_ROT_MASK, MBC_ROT_NONE, MBC_U_ROT_2_REF_NODE_ROT, MBDYN_EXCEPT_ARGS, ExtFileHandlerBase::NEGOTIATE_CLIENT, ExtFileHandlerBase::NEGOTIATE_NO, ExtFileHandlerBase::NEGOTIATE_SERVER, ExtFileHandlerBase::NegotiateRequest(), pH, pRefNode, uMappedPoints, uPoints, and uRRot.

243 {
244  bool bResult = true;
245 
246  switch (pEFH->NegotiateRequest()) {
248  break;
249 
251  std::ostream *outfp = pEFH->GetOutStream();
252  if (outfp) {
253 
254 #ifdef USE_SOCKET
255  } else {
256  char buf[sizeof(uint32_t) + sizeof(uint32_t)];
257  uint32_t *uint32_ptr;
258 
259  uint32_ptr = (uint32_t *)&buf[0];
260  uint32_ptr[0] = MBC_NODAL | MBC_U_ROT_2_REF_NODE_ROT(uRRot);
261  if (pRefNode != 0) {
262  uint32_ptr[0] |= MBC_REF_NODE;
263  }
264 
265  if (bLabels) {
266  uint32_ptr[0] |= MBC_LABELS;
267  }
268 
269  if (bOutputAccelerations) {
270  uint32_ptr[0] |= MBC_ACCELS;
271  }
272 
273  uint32_ptr[1] = uPoints;
274 
275  ssize_t rc = send(pEFH->GetOutFileDes(),
276  (const void *)buf, sizeof(buf),
277  pEFH->GetSendFlags());
278  if (rc == -1) {
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 << ")"
284  << std::endl);
286 
287  } else if (rc != sizeof(buf)) {
288  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
289  "negotiation request send() failed "
290  "(sent " << rc << " of " << sizeof(buf) << " bytes)"
291  << std::endl);
293  }
294 #endif // USE_SOCKET
295  }
296  } break;
297 
299  unsigned uN;
300  unsigned uNodal;
301  bool bRef;
302  unsigned uRR;
303  unsigned uR;
304  bool bA;
305  bool bL;
306 
307  std::istream *infp = pEFH->GetInStream();
308  if (infp) {
309  // TODO: stream negotiation?
310 
311 #ifdef USE_SOCKET
312  } else {
313  char buf[sizeof(uint32_t) + sizeof(uint32_t)];
314  uint32_t *uint32_ptr;
315 
316  ssize_t rc = recv(pEFH->GetInFileDes(),
317  (void *)buf, sizeof(buf),
318  pEFH->GetRecvFlags());
319  if (rc == -1) {
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 << ")"
325  << std::endl);
327 
328  } else if (rc != sizeof(buf)) {
329  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
330  "negotiation response recv() failed "
331  "(got " << rc << " of " << sizeof(buf) << " bytes)"
332  << std::endl);
334  }
335 
336  uint32_ptr = (uint32_t *)&buf[0];
337  uNodal = (uint32_ptr[0] & MBC_MODAL_NODAL_MASK);
338  bRef = (uint32_ptr[0] & MBC_REF_NODE);
339  uRR = (uint32_ptr[0] & MBC_REF_NODE_ROT_MASK);
340  uR = (uint32_ptr[0] & MBC_ROT_MASK);
341  bL = (uint32_ptr[0] & MBC_LABELS);
342  bA = (uint32_ptr[0] & MBC_ACCELS);
343 
344  uN = uint32_ptr[1];
345 #endif // USE_SOCKET
346  }
347 
348  if (uNodal != MBC_NODAL) {
349  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
350  "negotiation response failed: expecting MBC_NODAL "
351  "(=" << MBC_MODAL << "), got " << uNodal
352  << std::endl);
353  bResult = false;
354  }
355 
356  if ((pRefNode != 0 && !bRef) || (pRefNode == 0 && bRef)) {
357  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
358  "negotiation response failed: reference node configuration mismatch "
359  "(local=" << (pRefNode != 0 ? "yes" : "no") << ", remote=" << (bRef ? "yes" : "no") << ")"
360  << std::endl);
361  bResult = false;
362  }
363 
364  if (uR != MBC_ROT_NONE) {
365  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
366  "negotiation response failed: orientation output mismatch "
367  "(local=" << MBC_ROT_NONE << ", remote=" << uR << ")"
368  << std::endl);
369  bResult = false;
370  }
371 
372  if (uRR != MBC_U_ROT_2_REF_NODE_ROT(uRRot)) {
373  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
374  "negotiation response failed: reference node orientation output mismatch "
375  "(local=" << MBC_U_ROT_2_REF_NODE_ROT(uRRot) << ", remote=" << uR << ")"
376  << std::endl);
377  bResult = false;
378  }
379 
380  if (bL != bLabels) {
381  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
382  "negotiation response failed: labels output mismatch "
383  "(local=" << (bLabels ? "yes" : "no") << ", remote=" << (bL ? "yes" : "no") << ")"
384  << std::endl);
385  bResult = false;
386  }
387 
388  if (bA != bOutputAccelerations) {
389  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
390  "negotiation response failed: acceleration output mismatch "
391  "(local=" << (bOutputAccelerations ? "yes" : "no") << ", remote=" << (bA ? "yes" : "no") << ")"
392  << std::endl);
393  bResult = false;
394  }
395 
396  unsigned uMP = pH ? uMappedPoints : uPoints;
397  if (uN != uMP) {
398  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
399  "negotiation response failed: node number mismatch "
400  "(local=" << uMP << ", remote=" << uN << ")"
401  << std::endl);
402  bResult = false;
403  }
404  } break;
405 
406  default:
408  }
409 
410  return bResult;
411 }
virtual std::istream * GetInStream(void)
Definition: extforce.cc:78
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual int GetInFileDes(void)
Definition: extforce.cc:99
virtual int GetOutFileDes(void)
Definition: extforce.cc:85
Definition: mbc.h:65
Definition: mbc.h:71
virtual Negotiate NegotiateRequest(void) const
Definition: extforce.cc:63
Definition: mbc.h:66
virtual int GetRecvFlags(void) const
Definition: extforce.cc:106
virtual std::ostream * GetOutStream(void)
Definition: extforce.cc:72
#define MBC_U_ROT_2_REF_NODE_ROT(u)
Definition: mbc.h:248
SpMapMatrixHandler * pH
Definition: strmappingext.h:56
virtual int GetSendFlags(void) const
Definition: extforce.cc:92
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
Definition: mbc.h:73
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48

Here is the call graph for this function:

void StructMappingExtForce::Recv ( ExtFileHandlerBase pEFH)
protectedvirtual

Implements ExtForce.

Definition at line 765 of file strmappingext.cc.

References ExtFileHandlerBase::GetInFileDes(), ExtFileHandlerBase::GetInStream(), RecvFromFileDes(), and RecvFromStream().

766 {
767  std::istream *infp = pEFH->GetInStream();
768  if (infp) {
769  RecvFromStream(*infp);
770 
771  } else {
772  RecvFromFileDes(pEFH->GetInFileDes());
773  }
774 }
virtual std::istream * GetInStream(void)
Definition: extforce.cc:78
virtual int GetInFileDes(void)
Definition: extforce.cc:99
virtual void RecvFromStream(std::istream &inf)
virtual void RecvFromFileDes(int infd)

Here is the call graph for this function:

void StructMappingExtForce::RecvFromFileDes ( int  infd)
protectedvirtual

Reimplemented in StructMembraneMappingExtForce.

Definition at line 830 of file strmappingext.cc.

References bLabels, buf, F0, WithLabel::GetLabel(), StructNode::GetRCurr(), ExtFileHandlerBase::GetRecvFlags(), labels, M0, m_f, m_p, m_qlabels, MatrixHandler::MatTVecMul(), MBDYN_EXCEPT_ARGS, Nodes, ExtForce::pEFH, pH, pRefNode, and Zero3.

Referenced by Recv().

831 {
832 #ifdef USE_SOCKET
833  if (pRefNode) {
834  size_t ulen = 0;
835  char buf[sizeof(uint32_t) + 6*sizeof(doublereal)];
836  doublereal *f;
837  ssize_t len;
838 
839  if (bLabels) {
840  ulen = sizeof(uint32_t);
841  }
842 
843  ulen += 6*sizeof(doublereal);
844 
845  len = recv(infd, (void *)buf, ulen, pEFH->GetRecvFlags());
846  if (len == -1) {
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);
853 
854  } else if (unsigned(len) != ulen) {
855  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
856  "recv() failed " "(got " << len << " of "
857  << ulen << " bytes)" << std::endl);
859  }
860 
861  if (bLabels) {
862  uint32_t *uint32_ptr = (uint32_t *)buf;
863  unsigned l = uint32_ptr[0];
864  if (l != pRefNode->GetLabel()) {
865  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
866  "invalid reference node label "
867  "(wanted " << pRefNode->GetLabel() << ", got " << l << ")"
868  << std::endl);
870  }
871  f = (doublereal *)&uint32_ptr[1];
872 
873  } else {
874  f = (doublereal *)buf;
875  }
876 
877  F0 = Vec3(&f[0]);
878  M0 = Vec3(&f[3]);
879  }
880 
881  if (bLabels) {
882  // Hack!
883  ssize_t len = recv(infd, (void *)&m_p[0], sizeof(uint32_t)*m_p.size(),
884  pEFH->GetRecvFlags());
885  if (len == -1) {
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);
892 
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);
898  }
899 
900  uint32_t *labels = (uint32_t *)&m_p[0];
901  for (unsigned l = 0; l < m_qlabels.size(); l++) {
902  if (labels[l] != m_qlabels[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);
907  }
908  }
909  }
910 
911  size_t fsize;
912  double *fp;
913 
914  if (pH) {
915  fp = &m_p[0];
916  fsize = sizeof(double)*m_p.size();
917 
918  } else {
919  fp = &m_f[0];
920  fsize = sizeof(double)*m_f.size();
921  }
922 
923  ssize_t len = recv(infd, (void *)fp, fsize, pEFH->GetRecvFlags());
924  if (len == -1) {
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);
931 
932  } else if (unsigned(len) != fsize) {
933  silent_cerr("StructMappingExtForce(" << GetLabel() << "): "
934  "recv() failed " "(got " << len << " of "
935  << fsize << " bytes)" << std::endl);
937  }
938 
939  if (pH) {
940  pH->MatTVecMul(m_f, m_p);
941  }
942 
943  if (pRefNode) {
944  for (unsigned p3 = 0, n = 0; n < Nodes.size(); n++) {
945  Nodes[n].F = Zero3;
946  Nodes[n].M = Zero3;
947  const StructNode *pNode(dynamic_cast<const StructNode *>(Nodes[n].pNode));
948  if (pNode != 0) {
949  for (unsigned o = 0; o < Nodes[n].Offsets.size(); o++, p3 += 3) {
950  Nodes[n].Offsets[o].F = pRefNode->GetRCurr()*Vec3(&m_f[p3]);
951  Nodes[n].F += Nodes[n].Offsets[o].F;
952  Vec3 f(pNode->GetRCurr()*Nodes[n].Offsets[o].Offset);
953  Nodes[n].M += f.Cross(Nodes[n].Offsets[o].F);
954  }
955 
956  } else {
957  Nodes[n].Offsets[0].F = pRefNode->GetRCurr()*Vec3(&m_f[p3]);
958  Nodes[n].F += Nodes[n].Offsets[0].F;
959  }
960  }
961 
962  } else {
963  for (unsigned p3 = 0, n = 0; n < Nodes.size(); n++) {
964  Nodes[n].F = Zero3;
965  Nodes[n].M = Zero3;
966  const StructNode *pNode(dynamic_cast<const StructNode *>(Nodes[n].pNode));
967  if (pNode != 0) {
968  for (unsigned o = 0; o < Nodes[n].Offsets.size(); o++, p3 += 3) {
969  Nodes[n].Offsets[o].F = Vec3(&m_f[p3]);
970  Nodes[n].F += Nodes[n].Offsets[o].F;
971  Vec3 f(pNode->GetRCurr()*Nodes[n].Offsets[o].Offset);
972  Nodes[n].M += f.Cross(Nodes[n].Offsets[o].F);
973  }
974 
975  } else {
976  Nodes[n].Offsets[0].F = Vec3(&m_f[p3]);
977  Nodes[n].F += Nodes[n].Offsets[0].F;
978  }
979  }
980  }
981 #else // ! USE_SOCKET
983 #endif // ! USE_SOCKET
984 }
const Vec3 Zero3(0., 0., 0.)
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
std::vector< uint32_t > m_qlabels
Definition: strmappingext.h:82
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
static int labels
virtual int GetRecvFlags(void) const
Definition: extforce.cc:106
ExtFileHandlerBase * pEFH
Definition: extforce.h:193
STLVectorHandler m_p
Definition: strmappingext.h:92
SpMapMatrixHandler * pH
Definition: strmappingext.h:56
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
virtual VectorHandler & MatTVecMul(VectorHandler &out, const VectorHandler &in) const
Definition: mh.cc:341
double doublereal
Definition: colamd.c:52
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48
STLVectorHandler m_f
Definition: strmappingext.h:91

Here is the call graph for this function:

void StructMappingExtForce::RecvFromStream ( std::istream &  inf)
protectedvirtual

Reimplemented in StructMembraneMappingExtForce.

Definition at line 777 of file strmappingext.cc.

References bLabels, F0, WithLabel::GetLabel(), M0, MBC_ROT_NONE, MBDYN_EXCEPT_ARGS, Nodes, Vec3::pGetVec(), pRefNode, and uRRot.

Referenced by Recv().

778 {
779 #if 0
780  if (pRefNode) {
781  unsigned l;
782  doublereal *f = F0.pGetVec(), *m = M0.pGetVec();
783 
784  if (bLabels) {
785  inf >> l;
786  }
787 
788  inf >> f[0] >> f[1] >> f[2];
789  if (uRRot != MBC_ROT_NONE) {
790  inf >> m[0] >> m[1] >> m[2];
791  }
792  }
793 
794  for (unsigned i = 0; i < Nodes.size(); i++) {
795  /* assume unsigned int label */
796  unsigned l;
797  doublereal f[3], m[3];
798 
799  if (bLabels) {
800  inf >> l;
801 
802  if (Nodes[i]->GetLabel() != l) {
803  silent_cerr("StructMappingExtForce"
804  "(" << GetLabel() << "): "
805  "invalid " << i << "-th label " << l
806  << std::endl);
808  }
809  }
810 
811  inf
812  >> f[0] >> f[1] >> f[2];
813  if (uRot != MBC_ROT_NONE) {
814  inf >> m[0] >> m[1] >> m[2];
815  }
816 
817  if (!inf) {
818  break;
819  }
820 
821  F[i] = Vec3(f);
822  if (uRot != MBC_ROT_NONE) {
823  M[i] = Vec3(m);
824  }
825  }
826 #endif
827 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
const doublereal * pGetVec(void) const
Definition: matvec3.h:192
double doublereal
Definition: colamd.c:52
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48

Here is the call graph for this function:

void StructMappingExtForce::Send ( ExtFileHandlerBase pEFH,
ExtFileHandlerBase::SendWhen  when 
)
protectedvirtual

Implements ExtForce.

Definition at line 417 of file strmappingext.cc.

References ExtFileHandlerBase::GetOutFileDes(), ExtFileHandlerBase::GetOutStream(), SendToFileDes(), and SendToStream().

418 {
419  std::ostream *outfp = pEFH->GetOutStream();
420  if (outfp) {
421  SendToStream(*outfp, when);
422 
423  } else {
424  SendToFileDes(pEFH->GetOutFileDes(), when);
425  }
426 }
virtual int GetOutFileDes(void)
Definition: extforce.cc:85
virtual void SendToFileDes(int outfd, ExtFileHandlerBase::SendWhen when)
virtual void SendToStream(std::ostream &outf, ExtFileHandlerBase::SendWhen when)
virtual std::ostream * GetOutStream(void)
Definition: extforce.cc:72

Here is the call graph for this function:

void StructMappingExtForce::SendToFileDes ( int  outfd,
ExtFileHandlerBase::SendWhen  when 
)
protectedvirtual

Reimplemented in StructMembraneMappingExtForce.

Definition at line 600 of file strmappingext.cc.

References bLabels, bOutputAccelerations, Vec3::Cross(), dRaDegr, WithLabel::GetLabel(), StructNode::GetRCurr(), StructDispNode::GetVCurr(), StructNode::GetWCurr(), StructNode::GetWPCurr(), StructDispNode::GetXCurr(), StructDispNode::GetXPPCurr(), m_q, m_qlabels, m_qP, m_qPP, m_x, m_xP, m_xPP, MatR2EulerAngles123(), MatrixHandler::MatVecMul(), MBC_ROT_EULER_123, MBC_ROT_MAT, MBC_ROT_THETA, MBDYN_EXCEPT_ARGS, Mat3x3::MulTV(), Nodes, Mat3x3::pGetMat(), Vec3::pGetVec(), pH, pRefNode, STLVectorHandler::Put(), R, uRRot, and RotManip::VecRot().

Referenced by Send().

601 {
602 #ifdef USE_SOCKET
603  if (pRefNode) {
604  const Vec3& xRef = pRefNode->GetXCurr();
605  const Mat3x3& RRef = pRefNode->GetRCurr();
606  const Vec3& xpRef = pRefNode->GetVCurr();
607  const Vec3& wRef = pRefNode->GetWCurr();
608  const Vec3& xppRef = pRefNode->GetXPPCurr();
609  const Vec3& wpRef = pRefNode->GetWPCurr();
610 
611  if (bLabels) {
612  uint32_t l = pRefNode->GetLabel();
613  send(outfd, (void *)&l, sizeof(l), 0);
614  }
615 
616  send(outfd, (void *)xRef.pGetVec(), 3*sizeof(doublereal), 0);
617  switch (uRRot) {
618  case MBC_ROT_MAT:
619  send(outfd, (void *)RRef.pGetMat(), 9*sizeof(doublereal), 0);
620  break;
621 
622  case MBC_ROT_THETA: {
623  Vec3 Theta(RotManip::VecRot(RRef));
624  send(outfd, (void *)Theta.pGetVec(), 3*sizeof(doublereal), 0);
625  } break;
626 
627  case MBC_ROT_EULER_123: {
629  send(outfd, (void *)E.pGetVec(), 3*sizeof(doublereal), 0);
630  } break;
631  }
632  send(outfd, (void *)xpRef.pGetVec(), 3*sizeof(doublereal), 0);
633  send(outfd, (void *)wRef.pGetVec(), 3*sizeof(doublereal), 0);
634  if (bOutputAccelerations) {
635  send(outfd, (void *)xppRef.pGetVec(), 3*sizeof(doublereal), 0);
636  send(outfd, (void *)wpRef.pGetVec(), 3*sizeof(doublereal), 0);
637  }
638 
639  for (unsigned p3 = 0, n = 0; n < Nodes.size(); n++) {
640  const StructNode *pNode(dynamic_cast<const StructNode *>(Nodes[n].pNode));
641  if (pNode != 0) {
642  for (unsigned o = 0; o < Nodes[n].Offsets.size(); o++, p3 += 3) {
643  Vec3 f(pNode->GetRCurr()*Nodes[n].Offsets[o].Offset);
644  Vec3 x(pNode->GetXCurr() + f);
645  Vec3 Dx(x - xRef);
646  Vec3 v(pNode->GetVCurr() + pNode->GetWCurr().Cross(f));
647  Vec3 Dv(v - xpRef - wRef.Cross(Dx));
648  const Vec3& w(pNode->GetWCurr());
649 
650  Vec3 xTilde(RRef.MulTV(Dx));
651  m_x.Put(p3 + 1, xTilde);
652 
653  Vec3 vTilde(RRef.MulTV(Dv));
654  m_xP.Put(p3 + 1, vTilde);
655 
656  if (bOutputAccelerations) {
657  const Vec3& xpp = pNode->GetXPPCurr();
658  const Vec3& wp = pNode->GetWPCurr();
659 
660  Vec3 xppTilde(RRef.MulTV(xpp - xppRef - wpRef.Cross(Dx)
661  - wRef.Cross(wRef.Cross(Dx) + Dv*2)
662  + wp.Cross(f) + w.Cross(w.Cross(f))));
663  m_xPP.Put(p3 + 1, xppTilde);
664  }
665  }
666 
667  } else {
668  Vec3 Dx(Nodes[n].pNode->GetXCurr() - xRef);
669  Vec3 Dv(Nodes[n].pNode->GetVCurr() - xpRef - wRef.Cross(Dx));
670 
671  Vec3 xTilde(RRef.MulTV(Dx));
672  m_x.Put(p3 + 1, xTilde);
673 
674  Vec3 vTilde(RRef.MulTV(Dv));
675  m_xP.Put(p3 + 1, vTilde);
676 
677  if (bOutputAccelerations) {
678  Vec3 xppTilde(RRef.MulTV(Nodes[n].pNode->GetXPPCurr()
679  - xppRef - wpRef.Cross(Dx)
680  - wRef.Cross(wRef.Cross(Dx) + Dv*2)));
681  m_xPP.Put(p3 + 1, xppTilde);
682  }
683 
684  p3 += 3;
685  }
686  }
687 
688  } else {
689  for (unsigned p3 = 0, n = 0; n < Nodes.size(); n++) {
690  const StructNode *pNode(dynamic_cast<const StructNode *>(Nodes[n].pNode));
691  if (pNode != 0) {
692  for (unsigned o = 0; o < Nodes[n].Offsets.size(); o++, p3 +=3 ) {
693  /*
694  p = x + f
695  R = R
696  v = xp + w cross f
697  w = w
698  a = xpp + wp cross f + w cross w cross f
699  wp = wp
700  */
701 
702  // Optimization of the above formulas
703  const Mat3x3& R = pNode->GetRCurr();
704  Vec3 f = R*Nodes[n].Offsets[o].Offset;
705  Vec3 x = pNode->GetXCurr() + f;
706  const Vec3& w = pNode->GetWCurr();
707  Vec3 wCrossf = w.Cross(f);
708  Vec3 v = pNode->GetVCurr() + wCrossf;
709 
710  m_x.Put(p3 + 1, x);
711  m_xP.Put(p3 + 1, v);
712 
713  if (bOutputAccelerations) {
714  const Vec3& wp = pNode->GetWPCurr();
715  Vec3 xpp = pNode->GetXPPCurr() + wp.Cross(f) + w.Cross(wCrossf);
716 
717  m_xPP.Put(p3 + 1, xpp);
718  }
719  }
720 
721  } else {
722  m_x.Put(p3 + 1, Nodes[n].pNode->GetXCurr());
723  m_xP.Put(p3 + 1, Nodes[n].pNode->GetVCurr());
724 
725  if (bOutputAccelerations) {
726  m_xPP.Put(p3 + 1, Nodes[n].pNode->GetXPPCurr());
727  }
728 
729  p3 += 3;
730  }
731  }
732  }
733 
734  if (bLabels) {
735  send(outfd, &m_qlabels[0], sizeof(uint32_t)*m_qlabels.size(), 0);
736  }
737 
738  if (pH) {
739  pH->MatVecMul(m_q, m_x);
740  pH->MatVecMul(m_qP, m_xP);
741 
742  send(outfd, &m_q[0], sizeof(double)*m_q.size(), 0);
743  send(outfd, &m_qP[0], sizeof(double)*m_qP.size(), 0);
744 
745  if (bOutputAccelerations) {
746  pH->MatVecMul(m_qPP, m_xPP);
747  send(outfd, &m_qPP[0], sizeof(double)*m_qPP.size(), 0);
748  }
749 
750  } else {
751  send(outfd, &m_x[0], sizeof(double)*m_x.size(), 0);
752  send(outfd, &m_xP[0], sizeof(double)*m_xP.size(), 0);
753 
754  if (bOutputAccelerations) {
755  send(outfd, &m_xPP[0], sizeof(double)*m_xPP.size(), 0);
756  }
757  }
758 
759 #else // ! USE_SOCKET
761 #endif // ! USE_SOCKET
762 }
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
STLVectorHandler m_xPP
Definition: strmappingext.h:86
STLVectorHandler m_qPP
Definition: strmappingext.h:89
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
std::vector< uint32_t > m_qlabels
Definition: strmappingext.h:82
STLVectorHandler m_x
Definition: strmappingext.h:84
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
Vec3 MulTV(const Vec3 &v) const
Definition: matvec3.cc:482
virtual void Put(integer iRow, const Vec3 &v)
Definition: stlvh.cc:181
Vec3 MatR2EulerAngles123(const Mat3x3 &R)
Definition: matvec3.cc:893
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
const doublereal dRaDegr
Definition: matvec3.cc:884
virtual const Vec3 & GetWPCurr(void) const
Definition: strnode.h:1042
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
const doublereal * pGetMat(void) const
Definition: matvec3.h:743
STLVectorHandler m_q
Definition: strmappingext.h:87
const doublereal * pGetVec(void) const
Definition: matvec3.h:192
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
SpMapMatrixHandler * pH
Definition: strmappingext.h:56
virtual const Vec3 & GetXPPCurr(void) const
Definition: strnode.h:334
double doublereal
Definition: colamd.c:52
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48
virtual VectorHandler & MatVecMul(VectorHandler &out, const VectorHandler &in) const
Definition: mh.cc:332
STLVectorHandler m_xP
Definition: strmappingext.h:85
Mat3x3 R
STLVectorHandler m_qP
Definition: strmappingext.h:88

Here is the call graph for this function:

void StructMappingExtForce::SendToStream ( std::ostream &  outf,
ExtFileHandlerBase::SendWhen  when 
)
protectedvirtual

Reimplemented in StructMembraneMappingExtForce.

Definition at line 429 of file strmappingext.cc.

References a, bLabels, bOutputAccelerations, Vec3::Cross(), grad::Cross(), dRaDegr, WithLabel::GetLabel(), StructNode::GetRCurr(), StructDispNode::GetVCurr(), StructNode::GetWCurr(), StructNode::GetWPCurr(), StructDispNode::GetXCurr(), StructDispNode::GetXPPCurr(), MatR2EulerAngles123(), MBC_ROT_EULER_123, MBC_ROT_MAT, MBC_ROT_NONE, MBC_ROT_THETA, Mat3x3::MulTM(), Mat3x3::MulTV(), Nodes, pRefNode, R, and RotManip::VecRot().

Referenced by Send().

430 {
431  if (pRefNode) {
432  const Vec3& xRef = pRefNode->GetXCurr();
433  const Mat3x3& RRef = pRefNode->GetRCurr();
434  const Vec3& xpRef = pRefNode->GetVCurr();
435  const Vec3& wRef = pRefNode->GetWCurr();
436  const Vec3& xppRef = pRefNode->GetXPPCurr();
437  const Vec3& wpRef = pRefNode->GetWPCurr();
438 
439  if (bLabels) {
440  outf
441  << pRefNode->GetLabel()
442  << " ";
443  }
444 
445  outf
446  << xRef
447  << " " << RRef
448  << " " << xpRef
449  << " " << wRef;
450 
451  if (bOutputAccelerations) {
452  outf
453  << " " << xppRef
454  << " " << wpRef;
455  }
456  outf << std::endl;
457 
458  for (unsigned i = 0; i < Nodes.size(); i++) {
459 #if 0
460  Vec3 f(Nodes[i]->GetRCurr()*Offsets[i]);
461  Vec3 x(Nodes[i]->GetXCurr() + f);
462  Vec3 Dx(x - xRef);
463  Mat3x3 DR(RRef.MulTM(Nodes[i]->GetRCurr()));
464  Vec3 v(Nodes[i]->GetVCurr() + Nodes[i]->GetWCurr().Cross(f));
465  Vec3 Dv(v - xpRef - wRef.Cross(Dx));
466  const Vec3& w(Nodes[i]->GetWCurr());
467 
468  // manipulate
469 
470  if (bLabels) {
471  outf
472  << Nodes[i]->GetLabel()
473  << " ";
474  }
475 
476  outf
477  << RRef.MulTV(Dx);
478 
479  switch (uRot) {
480  case MBC_ROT_NONE:
481  break;
482 
483  case MBC_ROT_MAT:
484  outf
485  << " " << DR;
486  break;
487 
488  case MBC_ROT_THETA:
489  outf
490  << " " << RotManip::VecRot(DR);
491  break;
492 
493  case MBC_ROT_EULER_123:
494  outf
495  << " " << MatR2EulerAngles123(DR)*dRaDegr;
496  break;
497  }
498 
499  outf
500  << " " << RRef.MulTV(Dv);
501 
502  if (uRot != MBC_ROT_NONE) {
503  outf
504  << " " << RRef.MulTV(w - wRef);
505  }
506 
507  if (bOutputAccelerations) {
508  const Vec3& xpp(Nodes[i]->GetXPPCurr());
509 
510  outf
511  << " " << RRef.MulTV(xpp - xppRef - wpRef.Cross(Dx)
512  - wRef.Cross(wRef.Cross(Dx) + Dv*2));
513  if (uRot != MBC_ROT_NONE) {
514  const Vec3& wp(Nodes[i]->GetWPCurr());
515 
516  outf
517  << " " << RRef.MulTV(wp - wpRef - wRef.Cross(w));
518  }
519  }
520  outf << std::endl;
521 #endif
522  }
523 
524  } else {
525  for (unsigned i = 0; i < Nodes.size(); i++) {
526 #if 0
527  /*
528  p = x + f
529  R = R
530  v = xp + w cross f
531  w = w
532  a = xpp + wp cross f + w cross w cross f
533  wp = wp
534  */
535 
536  // Optimization of the above formulas
537  const Mat3x3& R = Nodes[i]->GetRCurr();
538  Vec3 f = R*Offsets[i];
539  Vec3 x = Nodes[i]->GetXCurr() + f;
540  const Vec3& w = Nodes[i]->GetWCurr();
541  Vec3 wCrossf = w.Cross(f);
542  Vec3 v = Nodes[i]->GetVCurr() + wCrossf;
543 
544  if (bLabels) {
545  outf
546  << Nodes[i]->GetLabel()
547  << " ";
548  }
549 
550  outf
551  << x;
552 
553  switch (uRot) {
554  case MBC_ROT_NONE:
555  break;
556 
557  case MBC_ROT_MAT:
558  outf
559  << " " << R;
560  break;
561 
562  case MBC_ROT_THETA:
563  outf
564  << " " << RotManip::VecRot(R);
565  break;
566 
567  case MBC_ROT_EULER_123:
568  outf
569  << " " << MatR2EulerAngles123(R)*dRaDegr;
570  break;
571  }
572  outf
573  << " " << v;
574 
575  if (uRot != MBC_ROT_NONE) {
576  outf
577  << " " << w;
578  }
579 
580  if (bOutputAccelerations) {
581  const Vec3& wp = Nodes[i]->GetWPCurr();
582  Vec3 a = Nodes[i]->GetXPPCurr() + wp.Cross(f) + w.Cross(wCrossf);
583 
584  outf
585  << " " << a;
586 
587  if (uRot != MBC_ROT_NONE) {
588  outf
589  << " " << wp;
590  }
591  }
592 
593  outf << std::endl;
594 #endif
595  }
596  }
597 }
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
Vec3 MulTV(const Vec3 &v) const
Definition: matvec3.cc:482
Vec3 MatR2EulerAngles123(const Mat3x3 &R)
Definition: matvec3.cc:893
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
const doublereal dRaDegr
Definition: matvec3.cc:884
virtual const Vec3 & GetWPCurr(void) const
Definition: strnode.h:1042
Mat3x3 MulTM(const Mat3x3 &m) const
Definition: matvec3.cc:500
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
Definition: matvec.h:3248
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
static const doublereal a
Definition: hfluid_.h:289
virtual const Vec3 & GetXPPCurr(void) const
Definition: strnode.h:334
unsigned int GetLabel(void) const
Definition: withlab.cc:62
const StructNode * pRefNode
Definition: strmappingext.h:48
Mat3x3 R

Here is the call graph for this function:

void StructMappingExtForce::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 229 of file strmappingext.cc.

References ExtForce::COUPLING_NONE, ExtForce::iCoupling, Nodes, and pRefNode.

230 {
231  if (iCoupling == COUPLING_NONE) {
232  *piNumRows = 0;
233  *piNumCols = 0;
234 
235  } else {
236  *piNumRows = (pRefNode ? 6 : 0) + 6*Nodes.size();
237  *piNumCols = 1;
238  }
239 }
std::vector< NodeData > Nodes
Definition: strmappingext.h:73
int iCoupling
Definition: extforce.h:212
const StructNode * pRefNode
Definition: strmappingext.h:48

Member Data Documentation

bool StructMappingExtForce::bOutputAccelerations
protected
bool StructMappingExtForce::bRotateReferenceNodeForces
protected

Definition at line 50 of file strmappingext.h.

Referenced by AssRes().

bool StructMappingExtForce::bUseReferenceNodeForces
protected

Definition at line 49 of file strmappingext.h.

Referenced by AssRes().

Vec3 StructMappingExtForce::F1
protected

Definition at line 52 of file strmappingext.h.

Referenced by AssRes(), and Output().

Vec3 StructMappingExtForce::F2
protected

Definition at line 53 of file strmappingext.h.

Referenced by AssRes(), and Output().

Vec3 StructMappingExtForce::M1
protected

Definition at line 52 of file strmappingext.h.

Referenced by AssRes(), and Output().

Vec3 StructMappingExtForce::M2
protected

Definition at line 53 of file strmappingext.h.

Referenced by AssRes(), and Output().

STLVectorHandler StructMappingExtForce::m_f
protected
STLVectorHandler StructMappingExtForce::m_p
protected
STLVectorHandler StructMappingExtForce::m_q
protected

Definition at line 87 of file strmappingext.h.

Referenced by SendToFileDes(), and StructMembraneMappingExtForce::SendToFileDes().

std::vector<uint32_t> StructMappingExtForce::m_qlabels
protected
STLVectorHandler StructMappingExtForce::m_qP
protected

Definition at line 88 of file strmappingext.h.

Referenced by SendToFileDes(), and StructMembraneMappingExtForce::SendToFileDes().

STLVectorHandler StructMappingExtForce::m_qPP
protected
unsigned StructMappingExtForce::m_uResSize
protected

Definition at line 71 of file strmappingext.h.

Referenced by AssRes(), and StructMappingExtForce().

STLVectorHandler StructMappingExtForce::m_x
protected

Definition at line 84 of file strmappingext.h.

Referenced by SendToFileDes(), and StructMembraneMappingExtForce::SendToFileDes().

STLVectorHandler StructMappingExtForce::m_xP
protected

Definition at line 85 of file strmappingext.h.

Referenced by SendToFileDes(), and StructMembraneMappingExtForce::SendToFileDes().

STLVectorHandler StructMappingExtForce::m_xPP
protected
unsigned StructMappingExtForce::uMappedPoints
protected

Definition at line 75 of file strmappingext.h.

Referenced by Prepare(), and StructMappingExtForce().

unsigned StructMappingExtForce::uPoints
protected

Definition at line 74 of file strmappingext.h.

Referenced by Prepare(), and StructMappingExtForce().

unsigned StructMappingExtForce::uRRot
protected

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