mbsimflexiblebody  4.0.0
nurbs_disk_2s.h
00001 /* Copyright (C) 2004-2011 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 NURBSDISK2S_H_
00021 #define NURBSDISK2S_H_
00022 
00023 #include "fmatvec/fmatvec.h"
00024 #include "mbsim/mbsim_event.h"
00025 #include "mbsim/contours/contour2s.h"
00026 #include "mbsimFlexibleBody/utils/contact_utils.h"
00027 
00028 #ifdef HAVE_NURBS
00029 #include "nurbs++/nurbs.h"
00030 #include "nurbs++/nurbsS.h"
00031 #include "nurbs++/vector.h"
00032 #endif
00033 
00034 namespace MBSimFlexibleBody {
00035 
00049   class NurbsDisk2s : public MBSim::Contour2s {
00050     public:
00055       NurbsDisk2s(const std::string &name);
00056 
00060       virtual ~NurbsDisk2s();  
00061 
00062       /* INHERITED INTERFACE OF ELEMENT */
00063       virtual std::string getType() const { return "NurbsDisk2s"; }
00064       /***************************************************/
00065 
00066       /* INHERITED INTERFACE OF CONTOURCONTINUUM */
00067       virtual void computeRootFunctionPosition(MBSim::ContourPointData &cp) { THROW_MBSIMERROR("(NurbsDisk2s::computeRootFunctionPosition): Not implemented!"); }
00068       virtual void computeRootFunctionFirstTangent(MBSim::ContourPointData &cp) { THROW_MBSIMERROR("(NurbsDisk2s::computeRootFunctionFirstTangent): Not implemented!"); }
00069       virtual void computeRootFunctionNormal(MBSim::ContourPointData &cp) { THROW_MBSIMERROR("(NurbsDisk2s::computeRootFunctionNormal): Not implemented!"); }
00070       virtual void computeRootFunctionSecondTangent(MBSim::ContourPointData &cp) { THROW_MBSIMERROR("(NurbsDisk2s::computeRootFunctionSecondTangent): Not implemented!"); }
00071       /***************************************************/
00072 
00073       /* INHERITED INTERFACE OF CONTOUR */
00074       virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::Frame::Frame::Feature ff);
00075       virtual void updateJacobiansForFrame(MBSim::ContourPointData &cp, int j = 0);
00076       virtual MBSim::ContactKinematics * findContactPairingWith(std::string type0, std::string type1) {
00077         return findContactPairingFlexible(type0.c_str(), type1.c_str());
00078       }
00079       /***************************************************/
00080 
00081 #ifdef HAVE_NURBS
00082 
00086       void initContourFromBody(InitStage stage);
00087 #endif
00088 
00094       fmatvec::Vec transformCW(const fmatvec::Vec& WrPoint);
00095 
00096 #ifdef HAVE_NURBS
00097 
00103       fmatvec::Mat computeDirectionalDerivatives(const double &radius, const double &phi, const int &deg);
00104 #endif
00105 
00106 #ifdef HAVE_NURBS
00107 
00112       fmatvec::Mat computeCurvatures(const double &radius, const double &phi);
00113 #endif
00114 
00115 #ifdef HAVE_NURBS
00116 
00120       void computeUVector(const int NbPts); 
00121 #endif
00122 
00123 #ifdef HAVE_NURBS
00124 
00128       void computeVVector(const int NbPts);
00129 #endif
00130 
00131 #ifdef HAVE_NURBS
00132 
00135       void computeSurface();
00136 #endif
00137 
00138 #ifdef HAVE_NURBS
00139 
00142       void computeSurfaceVelocities();
00143 #endif
00144 
00145 #ifdef HAVE_NURBS
00146 
00149       void computeSurfaceJacobians();
00150 #endif
00151 
00152 #ifdef HAVE_NURBS
00153 
00158       fmatvec::Vec getControlPoints(const int u, const int v);
00159 #endif
00160 
00161 #ifdef HAVE_NURBS
00162 
00165       fmatvec::Vec getUVector();
00166 #endif
00167 
00168 #ifdef HAVE_NURBS
00169 
00172       fmatvec::Vec getVVector();
00173 #endif
00174 
00179       int testInsideBounds(const fmatvec::Vec &s);
00180 
00186       double computeError(const fmatvec::Vec &Vec1, const fmatvec::Vec &Vec2);
00187 
00188     protected:
00192       int RefDofs;
00193 
00197       int nj, nr;
00198 
00202       int degU, degV;
00203 
00207       double Ri, Ra;
00208 
00209 #ifdef HAVE_NURBS
00210 
00213       std::vector<MBSim::ContourPointData> jacobians; // size = number of interpolation points
00214 
00218       PlNurbsSurfaced *Surface; // an homogenous surface with accuracy of calculation of double (HSurface<double,3>)
00219 
00223       PlNurbsSurfaced *SurfaceVelocities;
00224 
00228       std::vector<PlNurbsSurfaced> SurfaceJacobiansOfTranslation; // size = number of generalized coordinates
00229 
00233       std::vector<PlNurbsSurfaced> SurfaceJacobiansOfRotation; // size = number of generalized coordinates
00234 
00238       PLib::Vector<double> *uvec; // nurbs++ needs this vector 
00239       PLib::Vector<double> *uVec; // knot-vector for azimuthal direction 
00240       PLib::Vector<double> *vvec; // nurbs++ needs this vector
00241       PLib::Vector<double> *vVec; // knot-vector for radial direction
00242 #endif
00243   };
00244 
00245 }
00246 
00247 #endif /* NURBSDISK2S_H_ */
00248