mbsimflexiblebody  4.0.0
flexible_body_1s_21_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: thomas.cebulla@mytum.de
00018  */
00019 
00020 #ifndef _FLEXIBLE_BODY_1S_21_COSSERAT_H_
00021 #define _FLEXIBLE_BODY_1S_21_COSSERAT_H_
00022 
00023 #include <fmatvec/fmatvec.h>
00024 #include "mbsimFlexibleBody/flexible_body/flexible_body_1s_cosserat.h"
00025 #include "mbsimFlexibleBody/flexible_body.h"
00026 #include "mbsimFlexibleBody/pointer.h"
00027 #include "mbsimFlexibleBody/contours/flexible_band.h"
00028 #include "mbsimFlexibleBody/contours/cylinder_flexible.h"
00029 #include "mbsimFlexibleBody/flexible_body/finite_elements/finite_element_1s_21_cosserat_translation.h"
00030 #include "mbsimFlexibleBody/flexible_body/finite_elements/finite_element_1s_21_cosserat_rotation.h"
00031 #ifdef HAVE_OPENMBVCPPINTERFACE
00032 #include <openmbvcppinterface/spineextrusion.h>
00033 #endif
00034 
00035 namespace MBSimFlexibleBody {
00036 
00057   class FlexibleBody1s21Cosserat : public FlexibleBody1sCosserat {
00058     public:
00059 
00065       FlexibleBody1s21Cosserat(const std::string &name, bool openStructure);
00066 
00070       virtual ~FlexibleBody1s21Cosserat();
00071 
00072       /* INHERITED INTERFACE OF FLEXIBLE BODY */
00073       virtual void updateM(double t, int k = 0);
00074       virtual void BuildElements();
00075       virtual void GlobalVectorContribution(int n, const fmatvec::Vec& locVec, fmatvec::Vec& gloVec);
00076       virtual void GlobalMatrixContribution(int n, const fmatvec::Mat& locMat, fmatvec::Mat& gloMat);
00077       virtual void GlobalMatrixContribution(int n, const fmatvec::SymMat& locMat, fmatvec::SymMat& gloMat);
00078       virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::Frame::Frame::Feature ff, MBSim::Frame *frame = 0);
00079       virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame = 0);
00080       virtual void exportPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string(), const int & deg = 3, const bool & writePsFile = false);
00081       virtual void importPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string());
00082       /***************************************************/
00083 
00084       /* INHERITED INTERFACE OF OBJECT */
00085       virtual void init(InitStage stage);
00086       virtual double computePotentialEnergy();
00087       virtual void facLLM(int i = 0);
00088 //      virtual void updatedu(double t, double dt);
00089       /***************************************************/
00090 
00091       /* INHERITED INTERFACE OF OBJECTINTERFACE */
00092       virtual void updateh(double t, int i = 0);
00093       virtual void updateStateDependentVariables(double t);
00094 
00095       /* INHERITED INTERFACE OF ELEMENT */
00096       virtual void plot(double t, double dt = 1);
00097       virtual std::string getType() const {
00098         return "FlexibleBody1s21Cosserat";
00099       }
00100       /***************************************************/
00101 
00102       /* GETTER / SETTER */
00103       void setNumberElements(int n);
00104 
00105       void setMomentsInertia(double I1_);
00106       void setCurlRadius(double R1_);
00107       void setMaterialDamping(double cEps0D_, double cEps1D_);
00108 
00109 #ifdef HAVE_OPENMBVCPPINTERFACE
00110       void setOpenMBVSpineExtrusion(OpenMBV::SpineExtrusion* body) {
00111         openMBVBody = body;
00112       }
00113 #endif
00114 
00115       int getNumberElements() const {
00116         return Elements;
00117       }
00118       double getLength() const {
00119         return L;
00120       }
00121       bool isOpenStructure() const {
00122         return openStructure;
00123       }
00124 
00125       /* \brief Set SVD=true for POD model reduction
00126        * \param  reduced mass matrix
00127        */
00128       void enablePOD(const std::string & h5Path, int reduceMode = 0, int POMSize = 0);
00129       /***************************************************/
00130 
00135       fmatvec::Vec computeState(double s);
00136 
00142       fmatvec::Vec3 computeAngles(double sGlobal, const fmatvec::Vec & vec);
00143 
00147       void initInfo();
00148 
00149     protected:
00150 
00154       fmatvec::SymMat MConst;
00155 
00159       fmatvec::SymMat LLMConst;
00160 
00164       bool JInterp;
00165 
00166 
00170       bool PODreduced;
00171 
00175       fmatvec::Mat U;
00176 
00180       fmatvec::Vec qFull;
00181 
00185       fmatvec::Vec uFull;
00186 
00190       fmatvec::Vec hFull;
00191 
00192       FlexibleBody1s21Cosserat(); // standard constructor
00193       FlexibleBody1s21Cosserat(const FlexibleBody1s21Cosserat&); // copy constructor
00194       FlexibleBody1s21Cosserat& operator=(const FlexibleBody1s21Cosserat&); // assignment operator
00195 
00202       void BuildElementTranslation(const double& sGlobal, double& sLocal, int& currentElementTranslation);
00203 
00207       void initM();
00208 
00214       void computeBoundaryCondition();
00215 
00222       void GlobalVectorContributionRotation(int n, const fmatvec::Vec& locVec, fmatvec::Vec& gloVec);
00223 
00229       fmatvec::Mat readPositionMatrix(const std::string & h5File, const std::string & job);
00230 
00237       int findPOMSize(const fmatvec::Mat & POM, const fmatvec::Mat &SVD, double precission = 1 - 1.e-3);
00238 
00239   };
00240 
00241   inline void FlexibleBody1s21Cosserat::updateM(double t, int k) {
00242     M[k] << MConst;
00243   }
00244 
00245   inline void FlexibleBody1s21Cosserat::facLLM(int k) {
00246     LLM[k] << LLMConst;
00247   }
00248 
00249   inline void FlexibleBody1s21Cosserat::setMomentsInertia(double I1_) {
00250     I1 = I1_;
00251   }
00252 
00253   inline void FlexibleBody1s21Cosserat::setCurlRadius(double R1_) {
00254     R1 = R1_;
00255     if (initialised)
00256       for (int i = 0; i < Elements; i++)
00257         static_cast<FiniteElement1s21CosseratRotation*>(rotationDiscretization[i])->setCurlRadius(R1);
00258   }
00259   inline void FlexibleBody1s21Cosserat::setMaterialDamping(double cEps0D_, double cEps1D_) {
00260     cEps0D = cEps0D_;
00261     cEps1D = cEps1D_;
00262     if (initialised)
00263       for (int i = 0; i < Elements; i++)
00264         static_cast<FiniteElement1s21CosseratTranslation*>(discretization[i])->setMaterialDamping(Elements * cEps0D, cEps1D);
00265   }
00266 
00267 }
00268 
00269 #endif /* _FLEXIBLE_BODY_1S_21_COSSERAT_H_ */
00270