MBSim

Project Page
kinetic_excitation.h
00001 /* Copyright (C) 2004-2013 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: martin.o.foerg@googlemail.com
00018  */
00019 
00020 #ifndef _KINETICEXCITATION_H_
00021 #define _KINETICEXCITATION_H_
00022 
00023 #include <mbsim/link_mechanics.h>
00024 #include <mbsim/frame.h>
00025 #include <mbsim/functions/function.h>
00026 
00027 #ifdef HAVE_OPENMBVCPPINTERFACE
00028 #include "mbsim/utils/boost_parameters.h"
00029 #include "mbsim/utils/openmbv_utils.h"
00030 #endif
00031 
00032 namespace MBSim {
00033 
00040   class KineticExcitation : public LinkMechanics {
00041     public:
00046       KineticExcitation(const std::string &name="");
00047 
00051       virtual ~KineticExcitation();
00052 
00053       /* INHERITED INTERFACE OF LINKINTERFACE */
00054       virtual void updateh(double t, int i=0);
00055       virtual void updateg(double) {}
00056       virtual void updategd(double) {}
00057       /***************************************************/
00058 
00059       /* INHERITED INTERFACE OF EXTRADYNAMICINTERFACE */
00060       virtual void init(InitStage stage);
00061       /***************************************************/
00062 
00063       /* INHERITED INTERFACE OF LINK */
00064       void calclaSize(int j);
00065       bool isActive() const { return true; }
00066       bool isSingleValued() const { return true; }
00067       bool gActiveChanged() { return false; }
00068       /***************************************************/
00069       
00070       /* INHERITED INTERFACE OF ELEMENT */
00071       virtual void plot(double t, double dt = 1);
00072       /***************************************************/
00073 
00077       void setForceDirection(const fmatvec::Mat3xV& fd);
00078 
00082       void setMomentDirection(const fmatvec::Mat3xV& md);
00083 
00088       void setForceFunction(Function<fmatvec::VecV(double)> *func);
00089 
00091       void setMomentFunction(Function<fmatvec::VecV(double)> *func);
00092 
00096       void setFrameOfReferenceID(int ID) { refFrameID=ID; }
00097 
00098       using LinkMechanics::connect;
00099 
00104       void connect(MBSim::Frame *frame1, MBSim::Frame *frame2);
00105 
00106 #ifdef HAVE_OPENMBVCPPINTERFACE
00107 
00108       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))) { 
00109         OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00110         std::vector<bool> which; which.resize(2, false);
00111         which[1]=true;
00112         LinkMechanics::setOpenMBVForceArrow(ombv.createOpenMBV(), which);
00113       }
00114 
00116       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))) { 
00117         OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
00118         std::vector<bool> which; which.resize(2, false);
00119         which[1]=true;
00120         LinkMechanics::setOpenMBVMomentArrow(ombv.createOpenMBV(), which);
00121       }
00122 #endif
00123 
00124       void initializeUsingXML(xercesc::DOMElement *element);
00125       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00126 
00127       virtual std::string getType() const { return "KineticExcitation"; }
00128 
00129     protected:
00133       Frame *refFrame;
00134       int refFrameID;
00135 
00139       fmatvec::Mat3xV forceDir, momentDir;
00140 
00144       Function<fmatvec::VecV(double)> *F, *M;
00145 
00149       Frame C;
00150 
00151     private:
00152       std::string saved_ref, saved_ref1, saved_ref2;
00153   };
00154 
00155 }
00156 
00157 #endif /* _KINETICEXCITATION_H_ */
00158