|
mbsimflexiblebody
4.0.0
|
00001 /* Copyright (C) 2004-2011 MBSim Development Team 00002 * 00003 * This library is free software; you can redistribute it and/or 00004 * modify it under the terms of the GNU Lesser General Public 00005 * License as published by the Free Software Foundation; either 00006 * version 2.1 of the License, or (at your option) any later version. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public 00014 * License along with this library; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00016 * 00017 * Contact: thorsten.schindler@mytum.de 00018 * rzander@users.berlios.de 00019 */ 00020 00021 #ifndef _FLEXIBLE_BODY_H_ 00022 #define _FLEXIBLE_BODY_H_ 00023 00024 #include "mbsim/body.h" 00025 #include "mbsim/frame.h" 00026 00027 namespace MBSim { 00028 class DiscretizationInterface; 00029 class ContourPointData; 00030 } 00031 00032 namespace MBSimFlexibleBody { 00033 00034 const MBXMLUtils::NamespaceURI MBSIMFLEX("http://mbsim.berlios.de/MBSimFlexibleBody"); 00035 00051 class FlexibleBody : public MBSim::Body { 00052 public: 00057 FlexibleBody(const std::string &name); 00058 00062 virtual ~FlexibleBody(); 00063 00064 /* INHERITED INTERFACE OF OBJECTINTERFACE */ 00065 virtual void updatedq(double t, double dt) { qd = u*dt; } 00066 virtual void updateqd(double t) { qd = u; } 00067 virtual void updateh(double t, int k=0); 00068 virtual void updateM(double t, int k=0); 00069 virtual void updatedhdz(double t); 00070 virtual void updateStateDependentVariables(double t); 00071 virtual void updateJacobians(double t, int k=0); 00072 00073 /* INHERITED INTERFACE OF ELEMENT */ 00074 virtual void plot(double t, double dt=1); 00075 virtual std::string getType() const { return "FlexibleBody"; } 00076 virtual void initializeUsingXML(xercesc::DOMElement *element); 00077 /***************************************************/ 00078 00079 /* INHERITED INTERFACE OF OBJECT */ 00080 virtual void init(InitStage stage); 00081 virtual double computeKineticEnergy(); 00082 virtual double computePotentialEnergy(); 00083 virtual void setFrameOfReference(MBSim::Frame *frame); 00084 void setq0(fmatvec::Vec q0_) { if(q0_.size()) MBSim::Body::setInitialGeneralizedPosition(q0_); q<<q0; } 00085 void setu0(fmatvec::Vec u0_) { if(u0_.size()) MBSim::Body::setInitialGeneralizedVelocity(u0_); u<<u0; } 00086 /***************************************************/ 00087 00088 /* INTERFACE TO BE DEFINED IN DERIVED CLASSES */ 00092 virtual void BuildElements() = 0; 00093 00100 virtual void GlobalVectorContribution(int CurrentElement, const fmatvec::Vec &locVec, fmatvec::Vec &gloVec) = 0; 00101 00108 virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::Mat &locMat, fmatvec::Mat &gloMat) = 0; 00109 00116 virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::SymMat &locMat, fmatvec::SymMat &gloMat) = 0; 00117 00124 virtual void updateKinematicsForFrame(MBSim::ContourPointData &data, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame=0) = 0; 00125 00131 virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame=0) = 0; 00132 /***************************************************/ 00133 00134 /* GETTER / SETTER */ 00140 void setMassProportionalDamping(const double d_) { d_massproportional = d_; } 00141 /***************************************************/ 00142 00147 void addFrame(const std::string &name, const MBSim::ContourPointData &S_); 00148 00153 void addFrame(MBSim::Frame *frame, const MBSim::ContourPointData &S_); 00154 00159 void addFrame(const std::string &name, const int &id); 00160 00165 void addFrame(MBSim::Frame *frame, const int &id); 00166 00167 void addContour(MBSim::Contour *contour); 00168 00178 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()) ;} 00179 00185 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()) ;} 00186 00187 protected: 00191 std::vector<MBSim::DiscretizationInterface*> discretization; 00192 00196 std::vector<fmatvec::Vec> qElement; 00197 00201 std::vector<fmatvec::Vec> uElement; 00202 00206 double d_massproportional; 00207 00211 std::vector<MBSim::ContourPointData> S_Frame; 00212 00213 // Workaround to free memory of contourFrame in dtor. 00214 // TODO: provide a consistent solution and remove the following line 00215 MBSim::Frame *contourFrame; 00216 }; 00217 00224 template <class AT> 00225 class FlexibleBodyContinuum : public FlexibleBody { 00226 public: 00231 FlexibleBodyContinuum<AT>(const std::string &name) : FlexibleBody(name) {} 00232 00233 /* INHERITED INTERFACE OF ELEMENT */ 00234 virtual std::string getType() const { return "FlexibleBodyContinuum"; } 00235 00236 /* GETTER / SETTER */ 00237 void setContourNodes(const std::vector<AT> nodes) { userContourNodes = nodes; } 00238 00239 using FlexibleBody::addFrame; 00240 00245 void addFrame(const std::string &name, const AT& alpha) { 00246 MBSim::ContourPointData cp(alpha); 00247 FlexibleBody::addFrame(name,cp); 00248 } 00249 00254 void addFrame(MBSim::Frame *frame, const AT& alpha) { 00255 MBSim::ContourPointData cp(alpha); 00256 FlexibleBody::addFrame(frame,cp); 00257 } 00258 00259 protected: 00263 std::vector<AT> userContourNodes; 00264 }; 00265 } 00266 00267 #endif /* _FLEXIBLE_BODY_H_ */ 00268
1.8.0