|
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 <mbsimFlexibleBody/node_frame.h> 00025 00026 #include "mbsim/body.h" 00027 #include "mbsim/frame.h" 00028 00029 namespace MBSim { 00030 class DiscretizationInterface; 00031 class ContourPointData; 00032 } 00033 00034 namespace MBSimFlexibleBody { 00035 00036 const MBXMLUtils::NamespaceURI MBSIMFLEX("http://mbsim.berlios.de/MBSimFlexibleBody"); 00037 00053 class FlexibleBody : public MBSim::Body { 00054 public: 00059 FlexibleBody(const std::string &name); 00060 00064 virtual ~FlexibleBody(); 00065 00066 /* INHERITED INTERFACE OF OBJECTINTERFACE */ 00067 virtual void updatedq(double t, double dt) { qd = u*dt; } 00068 virtual void updateqd(double t) { qd = u; } 00069 virtual void updateh(double t, int k=0); 00070 virtual void updateM(double t, int k=0); 00071 virtual void updatedhdz(double t); 00072 virtual void updateStateDependentVariables(double t); 00073 virtual void updateJacobians(double t, int k=0); 00074 00075 /* INHERITED INTERFACE OF ELEMENT */ 00076 virtual void plot(double t, double dt=1); 00077 virtual std::string getType() const { return "FlexibleBody"; } 00078 virtual void initializeUsingXML(xercesc::DOMElement *element); 00079 /***************************************************/ 00080 00081 /* INHERITED INTERFACE OF OBJECT */ 00082 virtual void init(InitStage stage); 00083 virtual double computeKineticEnergy(); 00084 virtual double computePotentialEnergy(); 00085 virtual void setFrameOfReference(MBSim::Frame *frame); 00086 virtual void setq0(fmatvec::Vec q0_) { if(q0_.size()) MBSim::Body::setInitialGeneralizedPosition(q0_); q<<q0; } 00087 virtual void setu0(fmatvec::Vec u0_) { if(u0_.size()) MBSim::Body::setInitialGeneralizedVelocity(u0_); u<<u0; } 00088 /***************************************************/ 00089 00090 /* INTERFACE TO BE DEFINED IN DERIVED CLASSES */ 00094 virtual void BuildElements() = 0; 00095 00102 virtual void GlobalVectorContribution(int CurrentElement, const fmatvec::Vec &locVec, fmatvec::Vec &gloVec) = 0; 00103 00110 virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::Mat &locMat, fmatvec::Mat &gloMat) = 0; 00111 00118 virtual void GlobalMatrixContribution(int CurrentElement, const fmatvec::SymMat &locMat, fmatvec::SymMat &gloMat) = 0; 00119 00126 virtual void updateKinematicsForFrame(MBSim::ContourPointData &data, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame=0) = 0; 00127 00131 virtual void updateKinematicsAtNode(NodeFrame *frame, MBSim::Frame::Feature ff) { 00132 THROW_MBSIMERROR("updateKinematicsAtNode(): Not implemented for " + getType()); //TODO: make that interface prettier 00133 } 00134 00140 virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame=0) = 0; 00141 /***************************************************/ 00142 00143 /* GETTER / SETTER */ 00149 void setMassProportionalDamping(const double d_) { d_massproportional = d_; } 00150 /***************************************************/ 00151 00156 void addFrame(const std::string &name, const MBSim::ContourPointData &S_); 00157 00162 void addFrame(MBSim::Frame *frame, const MBSim::ContourPointData &S_); 00163 00168 void addFrame(const std::string &name, const int &id); 00169 00173 void addFrame(NodeFrame *frame); 00174 00178 void addFrame(MBSim::FixedRelativeFrame *frame); 00179 00180 void addContour(MBSim::Contour *contour); 00181 00191 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()) ;} 00192 00198 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()) ;} 00199 00200 protected: 00204 std::vector<MBSim::DiscretizationInterface*> discretization; 00205 00209 std::vector<fmatvec::Vec> qElement; 00210 00214 std::vector<fmatvec::Vec> uElement; 00215 00219 double d_massproportional; 00220 00224 std::vector<MBSim::ContourPointData> S_Frame; 00225 00226 // Workaround to free memory of contourFrame in dtor. 00227 // TODO: provide a consistent solution and remove the following line 00228 MBSim::Frame *contourFrame; 00229 00238 std::vector<MBSim::FixedRelativeFrame*> fixedRelativeFrames; 00239 00243 std::vector<NodeFrame*> nodeFrames; 00244 }; 00245 00252 template <class AT> 00253 class FlexibleBodyContinuum : public FlexibleBody { 00254 public: 00259 FlexibleBodyContinuum<AT>(const std::string &name) : FlexibleBody(name) {} 00260 00261 /* INHERITED INTERFACE OF ELEMENT */ 00262 virtual std::string getType() const { return "FlexibleBodyContinuum"; } 00263 00264 /* GETTER / SETTER */ 00265 void setContourNodes(const std::vector<AT> nodes) { userContourNodes = nodes; } 00266 00267 using FlexibleBody::addFrame; 00268 00273 void addFrame(const std::string &name, const AT& alpha) { 00274 MBSim::ContourPointData cp(alpha); 00275 FlexibleBody::addFrame(name,cp); 00276 } 00277 00282 void addFrame(MBSim::Frame *frame, const AT& alpha) { 00283 MBSim::ContourPointData cp(alpha); 00284 FlexibleBody::addFrame(frame,cp); 00285 } 00286 00287 void setNodeOffset(const AT nodeOffset_){ nodeOffset = nodeOffset_;} // TODO:: call this function in the init() of flexible body. 00288 AT getNodeOffset() const { return nodeOffset;} 00289 00290 protected: 00294 std::vector<AT> userContourNodes; 00295 00299 AT nodeOffset; 00300 00301 }; 00302 } 00303 00304 #endif /* _FLEXIBLE_BODY_H_ */ 00305
1.8.0