All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
body.h
1 /* Copyright (C) 2004-2014 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 _BODY_H_
21 #define _BODY_H_
22 
23 #include <mbsim/objects/object.h>
24 namespace OpenMBV {
25  class Body;
26 }
27 
28 namespace MBSim {
29 
30  class Frame;
31  class Contour;
32 
49  class Body : public Object {
50  public:
55  Body(const std::string &name);
56 
60  ~Body() override;
61 
62  void setGeneralizedInitialPosition(const fmatvec::Vec &q0_) { q0 = q0_; }
63  void setGeneralizedInitialVelocity(const fmatvec::Vec &u0_) { u0 = u0_; }
64  void setGeneralizedInitialPosition(double q0_) { q0 = fmatvec::Vec(1,fmatvec::INIT,q0_); }
65  void setGeneralizedInitialVelocity(double u0_) { u0 = fmatvec::Vec(1,fmatvec::INIT,u0_); }
66 
67  /* INHERITED INTERFACE OF OBJECTINTERFACE */
68  void sethSize(int hSize_, int i=0) override;
69  void sethInd(int hInd_, int i=0) override;
70  /*******************************************************/
71 
72  /* INHERITED INTERFACE OF ELEMENT */
73  void plot() override;
74  void setDynamicSystemSolver(DynamicSystemSolver *sys) override;
75  /*******************************************************/
76 
77  /* INHERITED INTERFACE OF OBJECT */
78  void init(InitStage stage, const InitConfigSet &config) override;
79  /*******************************************************/
80 
81  /* INTERFACE FOR DERIVED CLASSES */
82 
88  virtual Contour* getContour(const std::string &name, bool check=true) const;
89 
95  virtual Frame* getFrame(const std::string &name, bool check=true) const;
96 
100  virtual Frame *getFrameOfReference() { return R; }
101 
105  virtual const Frame *getFrameOfReference() const { return R; }
106 
110  virtual void setFrameOfReference(Frame *frame) { R = frame; }
111  /*******************************************************/
112 
113  /* GETTER / SETTER */
114  const std::vector<Frame*>& getFrames() const { return frame; }
115  const std::vector<Contour*>& getContours() const { return contour; }
116  std::shared_ptr<OpenMBV::Group> getOpenMBVGrp() override { return openMBVGrp; }
117  std::shared_ptr<OpenMBV::Body>& getOpenMBVBody() { return openMBVBody; }
118  /*******************************************************/
119 
124  int frameIndex(const Frame *frame_) const;
125 
130  int contourIndex(const Contour *contour_) const;
131 
132  void initializeUsingXML(xercesc::DOMElement *element) override;
133 
134  Element * getChildByContainerAndName(const std::string &container, const std::string &name) const override;
135 
136  fmatvec::Mat3xV& getPJT(int i=0, bool check=true) { assert((not check) or (not updPJ)); return PJT[i]; }
137  fmatvec::Mat3xV& getPJR(int i=0, bool check=true) { assert((not check) or (not updPJ)); return PJR[i]; }
138 
139  const fmatvec::Mat3xV& evalPJT() { if(updPJ) updateJacobians(); return PJT[0]; }
140  const fmatvec::Mat3xV& evalPJR() { if(updPJ) updateJacobians(); return PJR[0]; }
141 
142  void resetUpToDate() override;
143  virtual void resetPositionsUpToDate();
144  virtual void resetVelocitiesUpToDate();
145  virtual void resetJacobiansUpToDate();
146  virtual void resetGyroscopicAccelerationsUpToDate();
147  virtual void updateJacobians() { }
148 
149  protected:
153  virtual void addFrame(Frame * frame);
154 
158  virtual void addContour(Contour* contour);
159 
163  std::vector<Frame*> frame;
164  std::vector<Contour*> contour;
165 
170 
174  fmatvec::Mat3xV PJT[2], PJR[2];
175 
176  bool updPos, updVel, updPJ;
177 
178  std::shared_ptr<OpenMBV::Body> openMBVBody;
179  std::shared_ptr<OpenMBV::Group> openMBVGrp;
180 
181  private:
182  std::string saved_frameOfReference;
183  };
184 
185 }
186 
187 #endif
188 
virtual void setFrameOfReference(Frame *frame)
Definition: body.h:110
int contourIndex(const Contour *contour_) const
Definition: body.cc:164
Vector< Ref, double > Vec
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:46
basic class for contour definition for rigid (which do not know about their shape) and flexible (they...
Definition: contour.h:40
virtual Frame * getFrame(const std::string &name, bool check=true) const
Definition: body.cc:142
fmatvec::Mat3xV PJT[2]
Definition: body.h:174
Frame * R
frame of reference of the object
Definition: body.h:169
virtual Contour * getContour(const std::string &name, bool check=true) const
Definition: body.cc:128
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: body.cc:80
InitStage
The stages of the initialization.
Definition: element.h:62
Element * getChildByContainerAndName(const std::string &container, const std::string &name) const override
Get the Element named name in the container named container.
Definition: body.cc:184
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: body.cc:71
std::string name
name of element
Definition: element.h:235
std::vector< Frame * > frame
vector of frames and contours
Definition: body.h:163
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
Body(const std::string &name)
constructor
Definition: body.cc:35
int frameIndex(const Frame *frame_) const
Definition: body.cc:156
virtual void addContour(Contour *contour)
Definition: body.cc:110
void plot() override
plots time dependent data
Definition: body.cc:62
~Body() override
destructor
Definition: body.cc:37
virtual const Frame * getFrameOfReference() const
Definition: body.h:105
virtual Frame * getFrameOfReference()
Definition: body.h:100
Element(const std::string &name)
constructor
Definition: element.cc:72
virtual void addFrame(Frame *frame)
Definition: body.cc:119
base class for all mechanical bodies with mass and generalised coordinates
Definition: body.h:49
class for all objects having own dynamics and mass
Definition: object.h:43
fmatvec::Vec q0
initial position, velocity
Definition: object.h:317

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Home