mbsimflexiblebody  4.0.0
MBSim Flexible Body Module
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 * martin.o.foerg@googlemail.com
19 */
20
21#ifndef _FLEXIBLE_BODY_H_
22#define _FLEXIBLE_BODY_H_
23
24#include "mbsimFlexibleBody/node_based_body.h"
25
26namespace MBSim {
27 class FixedRelativeFrame;
28 class ContourFrame;
29}
30
31namespace MBSimFlexibleBody {
32
33 class DiscretizationInterface;
34
50 class FlexibleBody : public NodeBasedBody {
51 public:
56 FlexibleBody(const std::string &name);
57
61 ~FlexibleBody() override;
62
63 /* INHERITED INTERFACE OF OBJECTINTERFACE */
64 void updateqd() override { qd = u; }
65 void updateh(int k=0) override;
66 void updateM() override;
67 void updatedhdz() override;
68
69 /* INHERITED INTERFACE OF ELEMENT */
70 void initializeUsingXML(xercesc::DOMElement *element) override;
71 /***************************************************/
72
73 /* INHERITED INTERFACE OF OBJECT */
74 void init(InitStage stage, const MBSim::InitConfigSet &config) override;
75 virtual double computeKineticEnergy();
76 virtual double computePotentialEnergy();
77 void setFrameOfReference(MBSim::Frame *frame) override;
78 virtual void setq0(const fmatvec::Vec &q0_) { if(q0_.size()) MBSim::Body::setGeneralizedInitialPosition(q0_); q <<= q0; }
79 virtual void setu0(const fmatvec::Vec &u0_) { if(u0_.size()) MBSim::Body::setGeneralizedInitialVelocity(u0_); u <<= u0; }
80 /***************************************************/
81
82 /* INTERFACE TO BE DEFINED IN DERIVED CLASSES */
86 virtual void BuildElements() = 0;
87
88 const fmatvec::Vec& getqElement(int i) { if(updEle) BuildElements(); return qElement[i]; }
89
90 const fmatvec::Vec& getuElement(int i) { if(updEle) BuildElements(); return uElement[i]; }
91
92 virtual fmatvec::Vec3 getAngles(int i) { return fmatvec::Vec3(); }
93 virtual fmatvec::Vec3 getDerivativeOfAngles(int i) { return fmatvec::Vec3(); }
94
101 virtual void GlobalVectorContribution(int CurrentElement, const fmatvec::Vec &locVec, fmatvec::Vec &gloVec) = 0;
102
109 virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::Mat &locMat, fmatvec::Mat &gloMat) = 0;
110
117 virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::SymMat &locMat, fmatvec::SymMat &gloMat) = 0;
118
119// /**
120// * \brief cartesian kinematic for contour or external frame (normal, tangent, binormal) is set by implementation class
121// * \param data contour parameter
122// * \param ff selection of specific calculations for frames
123// * \param frame optional: external frame, otherwise contour parameters are changed
124// */
125// virtual void updateKinematicsForFrame(MBSim::ContourPointData &data, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame=0) = 0;
126//
127// /*!
128// * \brief cartesian kinematic on a node
129// */
130// virtual void updateKinematicsAtNode(NodeFrame *frame, MBSim::Frame::Feature ff) {
131// throwError("updateKinematicsAtNode(): Not implemented for " + typid(*this).name()); //TODO: make that interface prettier
132// }
133//
134// /**
135// * \brief Jacobians and gyroscopes for contour or external frame are set by implementation class
136// * \param data contour parameter
137// * \param frame: optional external frame, otherwise contour parameters are changed
138// */
139// virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame=0) = 0;
140// /***************************************************/
141
142 /* GETTER / SETTER */
148 void setMassProportionalDamping(const double d_) { d_massproportional = d_; }
149 /***************************************************/
150
152
153 void addFrame(MBSim::ContourFrame *frame);
154
158 void addFrame(MBSim::FixedRelativeFrame *frame);
159
160 void addContour(MBSim::Contour *contour) override;
161
171 virtual void exportPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string(), const int & deg = 3, const bool &writePsFile = false){throwError("exportPositionVelocity(const std::string& filenamePos, const std::string& filenameVel, const int& deg, const bool& writePsFile) is not implemented for " + boost::core::demangle(typeid(*this).name())) ;}
172
178 virtual void importPositionVelocity(const std::string& filenamePos, const std::string& filenameVel = std::string()){throwError("importPositionVelocity(const std::string& filenamePos, const std::string& filenameVel) is not implemented for " + boost::core::demangle(typeid(*this).name())) ;}
179
180 void resetUpToDate() override;
181
182 protected:
186 std::vector<DiscretizationInterface*> discretization;
187
191 std::vector<fmatvec::Vec> qElement;
192
196 std::vector<fmatvec::Vec> uElement;
197
202
206// std::vector<MBSim::ContourPointData> S_Frame;
207
208 // Workaround to free memory of contourFrame in dtor.
209 // TODO: provide a consistent solution and remove the following line
210// MBSim::Frame *contourFrame;
211
217 bool updEle;
218 };
219
226 template <class AT>
228 public:
233 FlexibleBodyContinuum<AT>(const std::string &name) : FlexibleBody(name) {}
234
235 /* INHERITED INTERFACE OF ELEMENT */
236
237 /* GETTER / SETTER */
238 void setContourNodes(const std::vector<AT> nodes) { userContourNodes = nodes; }
239
240 void setNodeOffset(const AT nodeOffset_){ nodeOffset = nodeOffset_;} // TODO:: call this function in the init() of flexible body.
241 AT getNodeOffset() const { return nodeOffset;}
242
243 protected:
247 std::vector<AT> userContourNodes;
248
253 };
254}
255
256#endif /* _FLEXIBLE_BODY_H_ */
flexible body entirely described within MBSim holding all informations about continuum approximations
Definition: flexible_body.h:227
std::vector< AT > userContourNodes
grid for contact point detection
Definition: flexible_body.h:247
AT nodeOffset
offset of the ROTNODE from the TRANSNODE
Definition: flexible_body.h:252
upmost class for flexible body implementation
Definition: flexible_body.h:50
FlexibleBody(const std::string &name)
constructor
Definition: flexible_body.cc:39
double d_massproportional
damping factor for mass proportion, see BodyFlexible::setMassProportionalDamping()
Definition: flexible_body.h:201
virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::SymMat &locMat, fmatvec::SymMat &gloMat)=0
insert 'local' information in global matrices
virtual void GlobalVectorContribution(int CurrentElement, const fmatvec::Vec &locVec, fmatvec::Vec &gloVec)=0
insert 'local' information in global vectors
std::vector< DiscretizationInterface * > discretization
stl-vector of discretizations/finite elements
Definition: flexible_body.h:186
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:178
bool updEle
vector of contour parameters each describing a frame
Definition: flexible_body.h:217
std::vector< fmatvec::Vec > uElement
stl-vector of finite element wise velocities
Definition: flexible_body.h:196
~FlexibleBody() override
destructor
Definition: flexible_body.cc:41
std::vector< fmatvec::Vec > qElement
stl-vector of finite element wise positions
Definition: flexible_body.h:191
virtual void BuildElements()=0
references finite element coordinates to assembled coordinates
virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::Mat &locMat, fmatvec::Mat &gloMat)=0
insert 'local' information in global matrices
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:171
void setMassProportionalDamping(const double d_)
Jacobians and gyroscopes for contour or external frame are set by implementation class.
Definition: flexible_body.h:148
Definition: node_based_body.h:30
void addFrame(NodeBasedFrame *frame)
Definition: node_based_body.cc:70
std::vector< Frame * > frame
std::string name
fmatvec::Vec q0
fmatvec::Vec qd
fmatvec::Vec q