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 
50  class Body : public Object {
51  public:
56  Body(const std::string &name);
57 
61  virtual ~Body();
62 
63  void setGeneralizedInitialPosition(const fmatvec::Vec &q0_) { q0 = q0_; }
64  void setGeneralizedInitialVelocity(const fmatvec::Vec &u0_) { u0 = u0_; }
65  void setGeneralizedInitialPosition(double q0_) { q0 = fmatvec::Vec(1,fmatvec::INIT,q0_); }
66  void setGeneralizedInitialVelocity(double u0_) { u0 = fmatvec::Vec(1,fmatvec::INIT,u0_); }
67 
68  /* INHERITED INTERFACE OF OBJECTINTERFACE */
69  void sethSize(int hSize_, int i=0);
70  void sethInd(int hInd_, int i=0);
71  /*******************************************************/
72 
73  /* INHERITED INTERFACE OF ELEMENT */
74  virtual void plot();
75  virtual void closePlot();
76  virtual std::string getType() const { return "Body"; }
78  /*******************************************************/
79 
80  /* INHERITED INTERFACE OF OBJECT */
81  virtual void init(InitStage stage);
82  /*******************************************************/
83 
84  /* INTERFACE FOR DERIVED CLASSES */
85 
91  virtual Contour* getContour(const std::string &name, bool check=true) const;
92 
98  virtual Frame* getFrame(const std::string &name, bool check=true) const;
99 
103  virtual Frame *getFrameOfReference() { return R; }
104 
108  virtual const Frame *getFrameOfReference() const { return R; }
109 
113  virtual void setFrameOfReference(Frame *frame) { R = frame; }
114  /*******************************************************/
115 
116  /* GETTER / SETTER */
117  const std::vector<Frame*>& getFrames() const { return frame; }
118  const std::vector<Contour*>& getContours() const { return contour; }
119  std::shared_ptr<OpenMBV::Group> getOpenMBVGrp() { return openMBVGrp; }
120  std::shared_ptr<OpenMBV::Body>& getOpenMBVBody() { return openMBVBody; }
121  /*******************************************************/
122 
127  int frameIndex(const Frame *frame_) const;
128 
133  int contourIndex(const Contour *contour_) const;
134 
135  virtual void initializeUsingXML(xercesc::DOMElement *element);
136 
137  virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const;
138 
139  fmatvec::Mat3xV& getPJT(int i=0, bool check=true) { assert((not check) or (not updPJ)); return PJT[i]; }
140  fmatvec::Mat3xV& getPJR(int i=0, bool check=true) { assert((not check) or (not updPJ)); return PJR[i]; }
141 
142  const fmatvec::Mat3xV& evalPJT() { if(updPJ) updateJacobians(); return PJT[0]; }
143  const fmatvec::Mat3xV& evalPJR() { if(updPJ) updateJacobians(); return PJR[0]; }
144 
145  void resetUpToDate();
146  virtual void resetPositionsUpToDate();
147  virtual void resetVelocitiesUpToDate();
148  virtual void resetJacobiansUpToDate();
149  virtual void resetGyroscopicAccelerationsUpToDate();
150  virtual void updateJacobians() { }
151 
152  protected:
156  virtual void addFrame(Frame * frame);
157 
161  virtual void addContour(Contour* contour);
162 
166  std::vector<Frame*> frame;
167  std::vector<Contour*> contour;
168 
173 
177  fmatvec::Mat3xV PJT[2], PJR[2];
178 
179  int nu[2], nq;
180 
181  bool updPos, updVel, updPJ;
182 
183  std::shared_ptr<OpenMBV::Body> openMBVBody;
184  std::shared_ptr<OpenMBV::Group> openMBVGrp;
185 
186  private:
187  std::string saved_frameOfReference;
188  };
189 
190 }
191 
192 #endif
193 
virtual void setFrameOfReference(Frame *frame)
Definition: body.h:113
virtual ~Body()
destructor
Definition: body.cc:37
virtual void closePlot()
closes plot file
Definition: body.cc:73
int contourIndex(const Contour *contour_) const
Definition: body.cc:185
Vector< Ref, double > Vec
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:48
virtual void init(InitStage stage)
initialize object at start of simulation with respect to contours and frames
Definition: body.cc:93
virtual void plot()
plots time dependent data
Definition: body.cc:62
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:163
fmatvec::Mat3xV PJT[2]
Definition: body.h:177
Frame * R
frame of reference of the object
Definition: body.h:172
virtual Contour * getContour(const std::string &name, bool check=true) const
Definition: body.cc:149
InitStage
The stages of the initialization.
Definition: element.h:97
virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const
Get the Element named name in the container named container.
Definition: body.cc:205
std::string name
name of element
Definition: element.h:298
std::vector< Frame * > frame
vector of frames and contours
Definition: body.h:166
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:37
Body(const std::string &name)
constructor
Definition: body.cc:35
int frameIndex(const Frame *frame_) const
Definition: body.cc:177
virtual void addContour(Contour *contour)
Definition: body.cc:131
virtual void setDynamicSystemSolver(DynamicSystemSolver *sys)
sets the used dynamics system solver to the element
Definition: body.cc:84
virtual std::string getType() const
Definition: body.h:76
virtual const Frame * getFrameOfReference() const
Definition: body.h:108
virtual Frame * getFrameOfReference()
Definition: body.h:103
Element(const std::string &name)
constructor
Definition: element.cc:44
virtual void addFrame(Frame *frame)
Definition: body.cc:140
base class for all mechanical bodies with mass and generalised coordinates
Definition: body.h:50
class for all objects having own dynamics and mass
Definition: object.h:42
fmatvec::Vec q0
initial position, velocity
Definition: object.h:303

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML