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 
00026 namespace MBSim {
00027 
00028   template <class Ret, class Arg> class Function1;
00029 
00036   class KineticExcitation : public LinkMechanics {
00037     public:
00042       KineticExcitation(const std::string &name="");
00043 
00047       virtual ~KineticExcitation();
00048 
00049       /* INHERITED INTERFACE OF LINKINTERFACE */
00050       virtual void updateh(double t, int i=0);
00051       virtual void updateg(double) {}
00052       virtual void updategd(double) {}
00053       /***************************************************/
00054 
00055       /* INHERITED INTERFACE OF EXTRADYNAMICINTERFACE */
00056       virtual void init(InitStage stage);
00057       /***************************************************/
00058 
00059       /* INHERITED INTERFACE OF LINK */
00060       void calclaSize(int j);
00061       bool isActive() const { return true; }
00062       bool isSingleValued() const { return true; }
00063       bool gActiveChanged() { return false; }
00064       /***************************************************/
00065       
00066       /* INHERITED INTERFACE OF ELEMENT */
00067       virtual void plot(double t, double dt = 1);
00068       /***************************************************/
00069 
00074       void setForce(fmatvec::Mat dir, Function1<fmatvec::Vec,double> *func);
00075 
00077       void setMoment(fmatvec::Mat dir, Function1<fmatvec::Vec,double> *func);
00078 
00082       void setFrameOfReference(Frame *ref_) { refFrame=ref_; }
00083 
00084       using LinkMechanics::connect;
00085 
00090       void connect(MBSim::Frame *frame1, MBSim::Frame *frame2);
00091 
00092 #ifdef HAVE_OPENMBVCPPINTERFACE
00093 
00094       void setOpenMBVForceArrow(OpenMBV::Arrow *arrow) {
00095         std::vector<bool> which; which.resize(2, false);
00096         which[1]=true;
00097         LinkMechanics::setOpenMBVForceArrow(arrow, which);
00098       }
00099 
00101       void setOpenMBVMomentArrow(OpenMBV::Arrow *arrow) {
00102         std::vector<bool> which; which.resize(2, false);
00103         which[1]=true;
00104         LinkMechanics::setOpenMBVMomentArrow(arrow, which);
00105       }
00106 #endif
00107 
00108       void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00109       virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *element);
00110 
00111       virtual std::string getType() const { return "KineticExcitation"; }
00112 
00113     protected:
00117       Frame *refFrame;
00118 
00122       fmatvec::Mat3xV forceDir, momentDir;
00123 
00127       Function1<fmatvec::Vec,double> *F, *M;
00128 
00132       Frame C;
00133 
00134     private:
00135       std::string saved_frameOfReference, saved_ref, saved_ref1, saved_ref2;
00136   };
00137 
00138 }
00139 
00140 #endif /* _KINETICEXCITATION_H_ */
00141