mbsimflexiblebody  4.0.0
MBSim Flexible Body Module
node_based_body.h
1 /* Copyright (C) 2004-2016 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef _NODE_BASED_BODY_H_
21 #define _NODE_BASED_BODY_H_
22 
23 #include "mbsim/objects/body.h"
24 #include "mbsimFlexibleBody/namespace.h"
25 
26 namespace MBSimFlexibleBody {
27 
28  class NodeBasedFrame;
29 
30  class NodeBasedBody : public MBSim::Body {
31  public:
32  NodeBasedBody(const std::string &name) : Body(name) { }
33  void resetUpToDate() override;
34  virtual void updatePositions(int i);
35  virtual void updateVelocities(int i);
36  virtual void updateAccelerations(int i);
37  virtual void updateJacobians(int i, int j=0);
38  virtual void updateGyroscopicAccelerations(int i);
39  virtual void updateStresses(int i);
40  const fmatvec::Vec3& evalNodalPosition(int i) { if(updNodalPos[i]) updatePositions(i); return WrOP[i]; }
41  const fmatvec::Vec3& evalNodalVelocity(int i) { if(updNodalVel[i]) updateVelocities(i); return WvP[i]; }
42  const fmatvec::Vec3& evalNodalAcceleration(int i) { if(updNodalAcc[i]) updateAccelerations(i); return WaP[i]; }
43  const fmatvec::Mat3xV& evalNodalJacobianOfTranslation(int i, int j=0) { if(updNodalJac[j][i]) updateJacobians(i,j); return WJP[j][i]; }
44  const fmatvec::Vec3& evalNodalGyroscopicAccelerationOfTranslation(int i) { if(updNodalGA[i]) updateGyroscopicAccelerations(i); return WjP[i]; }
45  const fmatvec::Vec3& evalNodalDisplacement(int i) { if(updNodalPos[i]) updatePositions(i); return disp[i]; }
46  const fmatvec::Vector<fmatvec::Fixed<6>, double>& evalNodalStress(int i) { if(updNodalStress[i]) updateStresses(i); return sigma[i]; }
47  fmatvec::SqrMat3& getNodalOrientation(int i, bool check=true) { assert((not check) or (not updNodalPos[i])); return AWK[i]; }
48  fmatvec::Vec3& getNodalAngularVelocity(int i, bool check=true) { assert((not check) or (not updNodalVel[i])); return Wom[i]; }
49  fmatvec::Vec3& getNodalAngularAcceleration(int i, bool check=true) { assert((not check) or (not updNodalAcc[i])); return Wpsi[i]; }
50  fmatvec::Mat3xV& getNodalJacobianOfRotation(int i, int j=0, bool check=true) { assert((not check) or (not updNodalJac[j][i])); return WJR[j][i]; }
51  fmatvec::Vec3& getNodalGyroscopicAccelerationOfRotation(int i, bool check=true) { assert((not check) or (not updNodalGA[i])); return WjR[i]; }
57 
58  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
59 
60  int getNumberOfNodes() { if(updSize) calcSize(); return nn; }
61  int getNodeIndex(int nodeNumber) const { return nodeMap[nodeNumber]; }
62 
63  protected:
64  std::vector<fmatvec::Vec3> WrOP, WvP, Wom, WaP, Wpsi, WjP, WjR, disp;
65  std::vector<fmatvec::SqrMat3> AWK;
66  std::vector<fmatvec:: Mat3xV> WJP[2], WJR[2];
67  std::vector<bool> updNodalPos, updNodalVel, updNodalAcc, updNodalGA, updNodalStress;
68  std::vector<bool> updNodalJac[2];
69  std::vector<fmatvec::Vector<fmatvec::Fixed<6>, double>> sigma;
70  int nn{0};
71  std::vector<int> nodeMap, nodeNumbers;
72  };
73 
74 }
75 
76 #endif
node based frame
Definition: node_based_frame.h:31
void addFrame(NodeBasedFrame *frame)
Definition: node_based_body.cc:70
std::string name
std::vector< Frame * > frame
Body(const std::string &name)
Definition: node_based_body.h:30
virtual void addFrame(Frame *frame)