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  virtual ~Body();
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);
69  void sethInd(int hInd_, int i=0);
70  /*******************************************************/
71 
72  /* INHERITED INTERFACE OF ELEMENT */
73  virtual void plot();
74  virtual void closePlot();
75  virtual std::string getType() const { return "Body"; }
77  /*******************************************************/
78 
79  /* INHERITED INTERFACE OF OBJECT */
80  virtual void init(InitStage stage);
81  /*******************************************************/
82 
83  /* INTERFACE FOR DERIVED CLASSES */
84 
90  virtual Contour* getContour(const std::string &name, bool check=true) const;
91 
97  virtual Frame* getFrame(const std::string &name, bool check=true) const;
98 
102  virtual Frame *getFrameOfReference() { return R; }
103 
107  virtual const Frame *getFrameOfReference() const { return R; }
108 
112  virtual void setFrameOfReference(Frame *frame) { R = frame; }
113  /*******************************************************/
114 
115  /* GETTER / SETTER */
116  const std::vector<Frame*>& getFrames() const { return frame; }
117  const std::vector<Contour*>& getContours() const { return contour; }
118  std::shared_ptr<OpenMBV::Group> getOpenMBVGrp() { return openMBVGrp; }
119  std::shared_ptr<OpenMBV::Body>& getOpenMBVBody() { return openMBVBody; }
120  /*******************************************************/
121 
126  int frameIndex(const Frame *frame_) const;
127 
132  int contourIndex(const Contour *contour_) const;
133 
134  virtual void initializeUsingXML(xercesc::DOMElement *element);
135 
136  virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const;
137 
138  fmatvec::Mat3xV& getPJT(int i=0, bool check=true) { assert((not check) or (not updPJ)); return PJT[i]; }
139  fmatvec::Mat3xV& getPJR(int i=0, bool check=true) { assert((not check) or (not updPJ)); return PJR[i]; }
140 
141  const fmatvec::Mat3xV& evalPJT() { if(updPJ) updateJacobians(); return PJT[0]; }
142  const fmatvec::Mat3xV& evalPJR() { if(updPJ) updateJacobians(); return PJR[0]; }
143 
144  void resetUpToDate();
145  virtual void resetPositionsUpToDate();
146  virtual void resetVelocitiesUpToDate();
147  virtual void resetJacobiansUpToDate();
148  virtual void resetGyroscopicAccelerationsUpToDate();
149  virtual void updateJacobians() { }
150 
151  protected:
155  virtual void addFrame(Frame * frame);
156 
160  virtual void addContour(Contour* contour);
161 
165  std::vector<Frame*> frame;
166  std::vector<Contour*> contour;
167 
172 
176  fmatvec::Mat3xV PJT[2], PJR[2];
177 
178  int nu[2], nq;
179 
180  bool updPos, updVel, updPJ;
181 
182  std::shared_ptr<OpenMBV::Body> openMBVBody;
183  std::shared_ptr<OpenMBV::Group> openMBVGrp;
184 
185  private:
186  std::string saved_frameOfReference;
187  };
188 
189 }
190 
191 #endif
192 
virtual void setFrameOfReference(Frame *frame)
Definition: body.h:112
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:176
Frame * R
frame of reference of the object
Definition: body.h:171
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:165
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:75
virtual const Frame * getFrameOfReference() const
Definition: body.h:107
virtual Frame * getFrameOfReference()
Definition: body.h:102
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:49
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 Home