mbsimflexiblebody  4.0.0
flexible_body_1s_33_cosserat.h
00001 /* Copyright (C) 2004-2012 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  */
00019 
00020 #ifndef _FLEXIBLE_BODY_1S_33_COSSERAT_H_
00021 #define _FLEXIBLE_BODY_1S_33_COSSERAT_H_
00022 
00023 #include "flexible_body_1s_cosserat.h"
00024 #include "mbsimFlexibleBody/flexible_body.h"
00025 #include "mbsimFlexibleBody/pointer.h"
00026 //#include "mbsimFlexibleBody/contours/flexible_band.h"
00027 //#include "mbsimFlexibleBody/contours/cylinder_flexible.h"
00028 #include "mbsimFlexibleBody/flexible_body/finite_elements/finite_element_1s_33_cosserat_translation.h"
00029 #include "mbsimFlexibleBody/flexible_body/finite_elements/finite_element_1s_33_cosserat_rotation.h"
00030 #ifdef HAVE_OPENMBVCPPINTERFACE
00031 #include <openmbvcppinterface/spineextrusion.h>
00032 
00033 #endif
00034 
00035 namespace MBSimFlexibleBody {
00036 
00037 //  class NurbsCurve1s;
00038 
00062   class FlexibleBody1s33Cosserat : public FlexibleBody1sCosserat {
00063     public:
00064 
00070       FlexibleBody1s33Cosserat(const std::string &name, bool openStructure);
00071 
00075       virtual ~FlexibleBody1s33Cosserat();
00076 
00077       /* INHERITED INTERFACE OF FLEXIBLE BODY */
00078       virtual void BuildElements();
00079       virtual void GlobalVectorContribution(int n, const fmatvec::Vec& locVec, fmatvec::Vec& gloVec);
00080       virtual void GlobalMatrixContribution(int n, const fmatvec::Mat& locMat, fmatvec::Mat& gloMat);
00081       virtual void GlobalMatrixContribution(int n, const fmatvec::SymMat& locMat, fmatvec::SymMat& gloMat);
00082       virtual void updateKinematicsAtNode(NodeFrame *frame, MBSim::Frame::Feature ff);
00083       virtual void updateJacobiansAtNode(NodeFrame *frame, MBSim::Frame::Feature ff);
00084       virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame=0);
00085       virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame = 0);
00086       virtual void exportPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string(), const int & deg = 3, const bool & writePsFile = false);
00087       virtual void importPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string());
00088       /***************************************************/
00089 
00090       /* INHERITED INTERFACE OF OBJECT */
00091       virtual void init(InitStage stage);
00092       virtual double computePotentialEnergy();
00093       virtual void facLLM(int i = 0);
00094       /***************************************************/
00095 
00096       /* INHERITED INTERFACE OF OBJECTINTERFACE */
00097       virtual void updateh(double t, int i = 0);
00098       virtual void updateStateDependentVariables(double t);
00099 
00100       /* INHERITED INTERFACE OF ELEMENT */
00101       virtual void plot(double t, double dt = 1);
00102       virtual std::string getType() const {
00103         return "FlexibleBody1s33Cosserat";
00104       }
00105       /***************************************************/
00106 
00107       /* GETTER / SETTER */
00108       void setNumberElements(int n);
00109 
00110       void setMomentsInertia(double I1_, double I2_, double I0_);
00111 
00112       void setCurlRadius(double R1_, double R2_);
00113       void setMaterialDamping(double cEps0D_, double cEps1D_, double cEps2D_);
00114 
00115       virtual int getNumberOfElementDOF() const {
00116         return 6;
00117       }
00118 
00119       int getNumberElements() const {
00120         return Elements;
00121       }
00122       int getNumberDOFs() const {
00123         return qSize;
00124       }
00125       double getLength() const {
00126         return L;
00127       }
00128       bool isOpenStructure() const {
00129         return openStructure;
00130       }
00131       /***************************************************/
00132 
00137       fmatvec::Vec computeState(double s);
00138 
00144       fmatvec::Vec3 computeAngles(double sGlobal, const fmatvec::Vec & vec);
00145 
00149       void initInfo();
00150 
00165       void BuildElementTranslation(const double& sGlobal, double& sLocal, int& currentElementTranslation);
00166 
00167     protected:
00168 
00172       bool JTransInterp;
00173 
00180       double I2, I0;
00181 
00187       double R2;
00188 
00192       double cEps2D;
00193 
00194       FlexibleBody1s33Cosserat(); // standard constructor
00195       FlexibleBody1s33Cosserat(const FlexibleBody1s33Cosserat&); // copy constructor
00196       FlexibleBody1s33Cosserat& operator=(const FlexibleBody1s33Cosserat&); // assignment operator
00197 
00201       void initM();
00202 
00208       void computeBoundaryCondition();
00209 
00216       void GlobalVectorContributionRotation(int n, const fmatvec::Vec& locVec, fmatvec::Vec& gloVec);
00217   };
00218 
00219   inline void FlexibleBody1s33Cosserat::setMomentsInertia(double I1_, double I2_, double I0_) {
00220     I1 = I1_;
00221     I2 = I2_;
00222     I0 = I0_;
00223   }
00224 
00225   inline void FlexibleBody1s33Cosserat::setCurlRadius(double R1_, double R2_) {
00226     R1 = R1_;
00227     R2 = R2_;
00228     if (initialised)
00229       for (int i = 0; i < Elements; i++)
00230         static_cast<FiniteElement1s33CosseratRotation*>(rotationDiscretization[i])->setCurlRadius(R1, R2);
00231   }
00232   inline void FlexibleBody1s33Cosserat::setMaterialDamping(double cEps0D_, double cEps1D_, double cEps2D_) {
00233     cEps0D = cEps0D_;
00234     cEps1D = cEps1D_;
00235     cEps2D = cEps2D_;
00236     if (initialised)
00237       for (int i = 0; i < Elements; i++)
00238         static_cast<FiniteElement1s33CosseratTranslation*>(discretization[i])->setMaterialDamping(Elements * cEps0D, cEps1D, cEps2D);
00239   }
00240 
00241 }
00242 
00243 #endif /* _FLEXIBLE_BODY_1S_33_COSSERAT_H_ */
00244