All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
flexible_body.h
1 /* Copyright (C) 2004-2015 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: thorsten.schindler@mytum.de
18  * rzander@users.berlios.de
19  */
20 
21 #ifndef _FLEXIBLE_BODY_H_
22 #define _FLEXIBLE_BODY_H_
23 
24 #include <mbsimFlexibleBody/node_frame.h>
25 
26 #include "mbsim/body.h"
27 #include "mbsim/frame.h"
28 
29 namespace MBSim {
30  class DiscretizationInterface;
31  class ContourPointData;
32 }
33 
34 namespace MBSimFlexibleBody {
35 
36  const MBXMLUtils::NamespaceURI MBSIMFLEX("http://www.mbsim-env.de/MBSimFlexibleBody");
37 
53  class FlexibleBody : public MBSim::Body {
54  public:
59  FlexibleBody(const std::string &name);
60 
64  virtual ~FlexibleBody();
65 
66  /* INHERITED INTERFACE OF OBJECTINTERFACE */
67  virtual void updatedq(double t, double dt) { qd = u*dt; }
68  virtual void updateqd(double t) { qd = u; }
69  virtual void updateh(double t, int k=0);
70  virtual void updateM(double t, int k=0);
71  virtual void updatedhdz(double t);
72  virtual void updateStateDependentVariables(double t);
73  virtual void updateJacobians(double t, int k=0);
74 
75  /* INHERITED INTERFACE OF ELEMENT */
76  virtual void plot(double t, double dt=1);
77  virtual std::string getType() const { return "FlexibleBody"; }
78  virtual void initializeUsingXML(xercesc::DOMElement *element);
79  /***************************************************/
80 
81  /* INHERITED INTERFACE OF OBJECT */
82  virtual void init(InitStage stage);
83  virtual double computeKineticEnergy();
84  virtual double computePotentialEnergy();
85  virtual void setFrameOfReference(MBSim::Frame *frame);
86  virtual void setq0(fmatvec::Vec q0_) { if(q0_.size()) MBSim::Body::setInitialGeneralizedPosition(q0_); q<<q0; }
87  virtual void setu0(fmatvec::Vec u0_) { if(u0_.size()) MBSim::Body::setInitialGeneralizedVelocity(u0_); u<<u0; }
88  /***************************************************/
89 
90  /* INTERFACE TO BE DEFINED IN DERIVED CLASSES */
94  virtual void BuildElements() = 0;
95 
102  virtual void GlobalVectorContribution(int CurrentElement, const fmatvec::Vec &locVec, fmatvec::Vec &gloVec) = 0;
103 
110  virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::Mat &locMat, fmatvec::Mat &gloMat) = 0;
111 
118  virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::SymMat &locMat, fmatvec::SymMat &gloMat) = 0;
119 
126  virtual void updateKinematicsForFrame(MBSim::ContourPointData &data, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame=0) = 0;
127 
132  THROW_MBSIMERROR("updateKinematicsAtNode(): Not implemented for " + getType()); //TODO: make that interface prettier
133  }
134 
140  virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame=0) = 0;
141  /***************************************************/
142 
143  /* GETTER / SETTER */
149  void setMassProportionalDamping(const double d_) { d_massproportional = d_; }
150  /***************************************************/
151 
156  void addFrame(const std::string &name, const MBSim::ContourPointData &S_);
157 
162  void addFrame(MBSim::Frame *frame, const MBSim::ContourPointData &S_);
163 
168  void addFrame(const std::string &name, const int &id);
169 
173  void addFrame(NodeFrame *frame);
174 
178  void addFrame(MBSim::FixedRelativeFrame *frame);
179 
180  void addContour(MBSim::Contour *contour);
181 
191  virtual void exportPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string(), const int & deg = 3, const bool &writePsFile = false){throw MBSim::MBSimError("exportPositionVelocity(const std::string& filenamePos, const std::string& filenameVel, const int& deg, const bool& writePsFile) is not implemented for " + this->getType()) ;}
192 
198  virtual void importPositionVelocity(const std::string& filenamePos, const std::string& filenameVel = std::string()){throw MBSim::MBSimError("importPositionVelocity(const std::string& filenamePos, const std::string& filenameVel) is not implemented for " + this->getType()) ;}
199 
200  protected:
204  std::vector<MBSim::DiscretizationInterface*> discretization;
205 
209  std::vector<fmatvec::Vec> qElement;
210 
214  std::vector<fmatvec::Vec> uElement;
215 
220 
224  std::vector<MBSim::ContourPointData> S_Frame;
225 
226  // Workaround to free memory of contourFrame in dtor.
227  // TODO: provide a consistent solution and remove the following line
228  MBSim::Frame *contourFrame;
229 
238  std::vector<MBSim::FixedRelativeFrame*> fixedRelativeFrames;
239 
243  std::vector<NodeFrame*> nodeFrames;
244  };
245 
252  template <class AT>
254  public:
259  FlexibleBodyContinuum<AT>(const std::string &name) : FlexibleBody(name) {}
260 
261  /* INHERITED INTERFACE OF ELEMENT */
262  virtual std::string getType() const { return "FlexibleBodyContinuum"; }
263 
264  /* GETTER / SETTER */
265  void setContourNodes(const std::vector<AT> nodes) { userContourNodes = nodes; }
266 
268 
273  void addFrame(const std::string &name, const AT& alpha) {
274  MBSim::ContourPointData cp(alpha);
275  FlexibleBody::addFrame(name,cp);
276  }
277 
282  void addFrame(MBSim::Frame *frame, const AT& alpha) {
283  MBSim::ContourPointData cp(alpha);
284  FlexibleBody::addFrame(frame,cp);
285  }
286 
287  void setNodeOffset(const AT nodeOffset_){ nodeOffset = nodeOffset_;} // TODO:: call this function in the init() of flexible body.
288  AT getNodeOffset() const { return nodeOffset;}
289 
290  protected:
294  std::vector<AT> userContourNodes;
295 
300 
301  };
302 }
303 
304 #endif /* _FLEXIBLE_BODY_H_ */
305 
virtual void BuildElements()=0
references finite element coordinates to assembled coordinates
upmost class for flexible body implementation
Definition: flexible_body.h:53
double d_massproportional
damping factor for mass proportion, see BodyFlexible::setMassProportionalDamping() ...
Definition: flexible_body.h:219
FlexibleBody(const std::string &name)
constructor
Definition: flexible_body.cc:44
AT nodeOffset
offset of the ROTNODE from the TRANSNODE
Definition: flexible_body.h:299
virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::Mat &locMat, fmatvec::Mat &gloMat)=0
insert &#39;local&#39; information in global matrices
std::vector< MBSim::FixedRelativeFrame * > fixedRelativeFrames
list of all contour frames
Definition: flexible_body.h:238
std::vector< MBSim::DiscretizationInterface * > discretization
stl-vector of discretizations/finite elements
Definition: flexible_body.h:204
fmatvec::Vec q
std::vector< MBSim::ContourPointData > S_Frame
vector of contour parameters each describing a frame
Definition: flexible_body.h:224
virtual void importPositionVelocity(const std::string &filenamePos, const std::string &filenameVel=std::string())
imports the interpolated position and optional the velocity files (created with exportPositionVelocit...
Definition: flexible_body.h:198
virtual ~FlexibleBody()
destructor
Definition: flexible_body.cc:49
flexible body entirely described within MBSim holding all informations about continuum approximations...
Definition: flexible_body.h:253
void setMassProportionalDamping(const double d_)
set mass proportional damping
Definition: flexible_body.h:149
std::vector< fmatvec::Vec > uElement
stl-vector of finite element wise velocities
Definition: flexible_body.h:214
void addFrame(MBSim::Frame *frame, const AT &alpha)
Definition: flexible_body.h:282
std::vector< fmatvec::Vec > qElement
stl-vector of finite element wise positions
Definition: flexible_body.h:209
void addFrame(const std::string &name, const MBSim::ContourPointData &S_)
std::vector< AT > userContourNodes
grid for contact point detection
Definition: flexible_body.h:294
std::string name
std::vector< Frame * > frame
virtual void updateKinematicsForFrame(MBSim::ContourPointData &data, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame=0)=0
cartesian kinematic for contour or external frame (normal, tangent, binormal) is set by implementatio...
std::vector< NodeFrame * > nodeFrames
list of all Node-Frames
Definition: flexible_body.h:243
virtual void GlobalVectorContribution(int CurrentElement, const fmatvec::Vec &locVec, fmatvec::Vec &gloVec)=0
insert &#39;local&#39; information in global vectors
virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame=0)=0
Jacobians and gyroscopes for contour or external frame are set by implementation class.
virtual void updateKinematicsAtNode(NodeFrame *frame, MBSim::Frame::Feature ff)
cartesian kinematic on a node
Definition: flexible_body.h:131
void addFrame(const std::string &name, const AT &alpha)
Definition: flexible_body.h:273
cartesian frame on nodes of flexible bodies
Definition: node_frame.h:31
virtual void exportPositionVelocity(const std::string &filenamePos, const std::string &filenameVel=std::string(), const int &deg=3, const bool &writePsFile=false)
interpolates the position and optional the velocity coordinates of the flexible body with Nurbs-packa...
Definition: flexible_body.h:191
fmatvec::Vec qd
fmatvec::Vec q0

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML