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 updateKinematicsAtNode(NodeFrame *frame, MBSim::Frame::Feature ff);
00079       virtual void updateJacobiansAtNode(NodeFrame *frame, MBSim::Frame::Feature ff);
00080       virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::Frame::Feature ff, MBSim::Frame *frame = 0);
00081       virtual void updateJacobiansForFrame(MBSim::ContourPointData &data, MBSim::Frame *frame = 0);
00082       virtual void exportPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string(), const int & deg = 3, const bool & writePsFile = false);
00083       virtual void importPositionVelocity(const std::string & filenamePos, const std::string & filenameVel = std::string());
00084       /***************************************************/
00085 
00086       /* INHERITED INTERFACE OF OBJECT */
00087       virtual void init(InitStage stage);
00088       virtual double computePotentialEnergy();
00089       virtual void facLLM(int i = 0);
00090 //      virtual void updatedu(double t, double dt);
00091       /***************************************************/
00092 
00093       /* INHERITED INTERFACE OF OBJECTINTERFACE */
00094       virtual void updateh(double t, int i = 0);
00095       virtual void updateStateDependentVariables(double t);
00096 
00097       /* INHERITED INTERFACE OF ELEMENT */
00098       virtual void plot(double t, double dt = 1);
00099       virtual std::string getType() const {
00100         return "FlexibleBody1s21Cosserat";
00101       }
00102       /***************************************************/
00103 
00104       /* GETTER / SETTER */
00105       void setNumberElements(int n);
00106 
00107       void setMomentsInertia(double I1_);
00108       void setCurlRadius(double R1_);
00109       void setMaterialDamping(double cEps0D_, double cEps1D_);
00110 
00111       virtual fmatvec::Mat3xV transformJacobian(fmatvec::Mat3xV J) {
00112         if (PODreduced)
00113           return J * U;
00114         return J;
00115       }
00116 
00117       virtual int getNumberOfElementDOF() const {
00118         return 3;
00119       }
00120 
00121       int getNumberElements() const {
00122         return Elements;
00123       }
00124       double getLength() const {
00125         return L;
00126       }
00127       virtual int getqSizeFull() const {
00128         return qFull.size();
00129       }
00130       bool isOpenStructure() const {
00131         return openStructure;
00132       }
00133 
00134       /* \brief Set SVD=true for POD model reduction
00135        * \param  reduced mass matrix
00136        */
00137       void enablePOD(const std::string & h5Path, int reduceMode = 0, int POMSize = 0);
00138       /***************************************************/
00139 
00144       fmatvec::Vec computeState(double s);
00145 
00151       fmatvec::Vec3 computeAngles(double sGlobal, const fmatvec::Vec & vec);
00152 
00156       void initInfo();
00157 
00164       void BuildElementTranslation(const double& sGlobal, double& sLocal, int& currentElementTranslation);
00165 
00166     protected:
00167 
00171       fmatvec::SymMat MConst;
00172 
00176       fmatvec::SymMat LLMConst;
00177 
00181       bool JInterp;
00182 
00186       bool PODreduced;
00187 
00191       fmatvec::Mat U;
00192 
00196       fmatvec::Vec qFull;
00197 
00201       fmatvec::Vec uFull;
00202 
00206       fmatvec::Vec hFull;
00207 
00208       FlexibleBody1s21Cosserat(); // standard constructor
00209       FlexibleBody1s21Cosserat(const FlexibleBody1s21Cosserat&); // copy constructor
00210       FlexibleBody1s21Cosserat& operator=(const FlexibleBody1s21Cosserat&); // assignment operator
00211 
00215       void initM();
00216 
00222       void computeBoundaryCondition();
00223 
00230       void GlobalVectorContributionRotation(int n, const fmatvec::Vec& locVec, fmatvec::Vec& gloVec);
00231 
00237       fmatvec::Mat readPositionMatrix(const std::string & h5File, const std::string & job);
00238 
00245       int findPOMSize(const fmatvec::Mat & POM, const fmatvec::Mat &SVD, double precission = 1 - 1.e-3);
00246 
00247   }
00248   ;
00249 
00250   inline void FlexibleBody1s21Cosserat::updateM(double t, int k) {
00251     M[k] << MConst;
00252   }
00253 
00254   inline void FlexibleBody1s21Cosserat::facLLM(int k) {
00255     LLM[k] << LLMConst;
00256   }
00257 
00258   inline void FlexibleBody1s21Cosserat::setMomentsInertia(double I1_) {
00259     I1 = I1_;
00260   }
00261 
00262   inline void FlexibleBody1s21Cosserat::setCurlRadius(double R1_) {
00263     R1 = R1_;
00264     if (initialised)
00265       for (int i = 0; i < Elements; i++)
00266         static_cast<FiniteElement1s21CosseratRotation*>(rotationDiscretization[i])->setCurlRadius(R1);
00267   }
00268   inline void FlexibleBody1s21Cosserat::setMaterialDamping(double cEps0D_, double cEps1D_) {
00269     cEps0D = cEps0D_;
00270     cEps1D = cEps1D_;
00271     if (initialised)
00272       for (int i = 0; i < Elements; i++)
00273         static_cast<FiniteElement1s21CosseratTranslation*>(discretization[i])->setMaterialDamping(Elements * cEps0D, cEps1D);
00274   }
00275 
00276 }
00277 
00278 #endif /* _FLEXIBLE_BODY_1S_21_COSSERAT_H_ */
00279