All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
floating_frame_link.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 _FLOATING_FRAME_LINK_H_
21 #define _FLOATING_FRAME_LINK_H_
22 
23 #include "mbsim/links/link.h"
24 #include "mbsim/frames/floating_relative_frame.h"
25 
26 #include "mbsim/utils/boost_parameters.h"
27 #include "mbsim/utils/openmbv_utils.h"
28 
29 namespace OpenMBV {
30  class Group;
31  class Arrow;
32 }
33 
34 namespace H5 {
35  class Group;
36 }
37 
38 namespace MBSim {
43  class FloatingFrameLink : public Link {
44  public:
49  FloatingFrameLink(const std::string &name);
50 
51  /* INHERITED INTERFACE OF LINKINTERFACE */
52  virtual void updatedhdz();
53  /***************************************************/
54 
55  /* INHERITED INTERFACE OF EXTRADYNAMICINTERFACE */
56  virtual void init(InitStage stage);
57  /***************************************************/
58 
59  /* INHERITED INTERFACE OF ELEMENT */
60  std::string getType() const { return "Link"; }
61  virtual void plot();
62  virtual void closePlot();
63  /***************************************************/
64 
65  void calclaSize(int j);
66  void calcgSize(int j);
67  void calcgdSize(int j);
68  void calcrFactorSize(int j);
69  void calccorrSize(int j);
70 
71  void initializeUsingXML(xercesc::DOMElement *element);
72 
73  void updateW(int i = 0);
74  void updateh(int i = 0);
75  void updateg();
76  void updategd();
77 
78  /* INHERITED INTERFACE OF LINK */
79  virtual void updateWRef(const fmatvec::Mat& ref, int i=0);
80  virtual void updateVRef(const fmatvec::Mat& ref, int i=0);
81  virtual void updatehRef(const fmatvec::Vec &hRef, int i=0);
82  virtual void updatedhdqRef(const fmatvec::Mat& ref, int i=0);
83  virtual void updatedhduRef(const fmatvec::SqrMat& ref, int i=0);
84  virtual void updatedhdtRef(const fmatvec::Vec& ref, int i=0);
85  virtual void updaterRef(const fmatvec::Vec &ref, int i=0);
86  /***************************************************/
87 
88  void connect(Frame *frame0, Frame* frame1) {
89  frame[0] = frame0;
90  frame[1] = frame1;
91  }
92 
93  Frame* getFrame(int i) { return frame[i]; }
94 
98  void setFrameOfReferenceID(int ID) { refFrameID = ID; }
99 
100  void resetUpToDate();
101  void updatePositions(Frame *frame);
102  virtual void updatePositions();
103  virtual void updateVelocities();
104  void updateGeneralizedPositions();
105  void updateGeneralizedVelocities();
106  void updateGeneralizedForces();
107  void updateForce();
108  void updateMoment();
109  void updateForceDirections();
110  void updateR();
111  virtual void updatelaF() { }
112  virtual void updatelaM() { }
113  const fmatvec::Vec3& evalGlobalRelativePosition() { if(updPos) updatePositions(); return WrP0P1; }
114  const fmatvec::Vec3& evalGlobalRelativeVelocity() { if(updVel) updateVelocities(); return WvP0P1; }
115  const fmatvec::Vec3& evalGlobalRelativeAngularVelocity() { if(updVel) updateVelocities(); return WomP0P1; }
116  const fmatvec::Mat3xV& evalGlobalForceDirection() { if(updFD) updateForceDirections(); return DF; }
117  const fmatvec::Mat3xV& evalGlobalMomentDirection() { if(updFD) updateForceDirections(); return DM; }
118  const fmatvec::Vec3& evalForce() { if(updF) updateForce(); return F; }
119  const fmatvec::Vec3& evalMoment() { if(updM) updateMoment(); return M; }
120  const fmatvec::Mat3xV& evalRF() { if(updRMV) updateR(); return RF; }
121  const fmatvec::Mat3xV& evalRM() { if(updRMV) updateR(); return RM; }
122  const fmatvec::VecV& evallaF() { if(updlaF) updatelaF(); return lambdaF; }
123  const fmatvec::VecV& evallaM() { if(updlaM) updatelaM(); return lambdaM; }
124 
126  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVForce, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
127  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
128  setOpenMBVForce(ombv.createOpenMBV());
129  }
131  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMoment, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::toPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
132  OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
133  setOpenMBVMoment(ombv.createOpenMBV());
134  }
135  void setOpenMBVForce(const std::shared_ptr<OpenMBV::Arrow> &arrow) { openMBVArrowF = arrow; }
136  void setOpenMBVMoment(const std::shared_ptr<OpenMBV::Arrow> &arrow) { openMBVArrowM = arrow; }
137 
138  protected:
142  fmatvec::Vec3 WrP0P1, WvP0P1, WomP0P1;
143 
144  fmatvec::Mat3xV DF, DM;
145 
146  fmatvec::Vec3 F, M;
147 
148  fmatvec::Mat3xV RF, RM;
149 
153  fmatvec::Mat3xV forceDir, momentDir;
154 
155  fmatvec::VecV lambdaF, lambdaM;
156 
160  fmatvec::RangeV iF, iM;
161 
165  std::vector<Frame*> frame;
166 
167  std::shared_ptr<OpenMBV::Group> openMBVForceGrp;
168  std::shared_ptr<OpenMBV::Arrow> openMBVArrowF;
169  std::shared_ptr<OpenMBV::Arrow> openMBVArrowM;
170 
171  bool updPos, updVel, updFD, updF, updM, updRMV, updlaF, updlaM;
172 
177  int refFrameID;
178 
183 
184  private:
185  std::string saved_ref1, saved_ref2;
186  };
187 }
188 
189 #endif /* _LINK_MECHANICS_H_ */
190 
Definition: openmbv_utils.h:54
cartesian frame on rigid bodies
Definition: floating_relative_frame.h:31
InitStage
The stages of the initialization.
Definition: element.h:97
std::string name
name of element
Definition: element.h:298
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:37

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML