mbsimflexiblebody  3.2.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) : MBSim::Contour2s(name), nj(0), nr(0), degU(0), degV(0), Ri(0.), Ra(0.) {
00056 #ifndef HAVE_NURBS
00057         throw MBSim::MBSimError("ERROR(NurbsDisk2s::NurbsDisk2s): External NURBS library not implemented!");
00058 #endif
00059       }
00060 
00064       virtual ~NurbsDisk2s();  
00065 
00066       /* INHERITED INTERFACE OF ELEMENT */
00067       virtual std::string getType() const { return "NurbsDisk2s"; }
00068       /***************************************************/
00069 
00070       /* INHERITED INTERFACE OF CONTOURCONTINUUM */
00071       virtual void computeRootFunctionPosition(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionPosition): Not implemented!"); }
00072       virtual void computeRootFunctionFirstTangent(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionFirstTangent): Not implemented!"); }
00073       virtual void computeRootFunctionNormal(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionNormal): Not implemented!"); }
00074       virtual void computeRootFunctionSecondTangent(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionSecondTangent): Not implemented!"); }
00075       /***************************************************/
00076 
00077       /* INHERITED INTERFACE OF CONTOUR */
00078       virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::FrameFeature ff);
00079       virtual void updateJacobiansForFrame(MBSim::ContourPointData &cp, int j = 0);
00080       virtual MBSim::ContactKinematics * findContactPairingWith(std::string type0, std::string type1) {
00081         return findContactPairingFlexible(type0.c_str(), type1.c_str());
00082       }
00083       /***************************************************/
00084 
00085 #ifdef HAVE_NURBS
00086 
00090       void initContourFromBody(MBSim::InitStage stage);
00091 #endif
00092 
00098       fmatvec::Vec transformCW(const fmatvec::Vec& WrPoint);
00099 
00100 #ifdef HAVE_NURBS
00101 
00107       fmatvec::Mat computeDirectionalDerivatives(const double &radius, const double &phi, const int &deg);
00108 #endif
00109 
00110 #ifdef HAVE_NURBS
00111 
00116       fmatvec::Mat computeCurvatures(const double &radius, const double &phi);
00117 #endif
00118 
00119 #ifdef HAVE_NURBS
00120 
00124       void computeUVector(const int NbPts); 
00125 #endif
00126 
00127 #ifdef HAVE_NURBS
00128 
00132       void computeVVector(const int NbPts);
00133 #endif
00134 
00135 #ifdef HAVE_NURBS
00136 
00139       void computeSurface();
00140 #endif
00141 
00142 #ifdef HAVE_NURBS
00143 
00146       void computeSurfaceVelocities();
00147 #endif
00148 
00149 #ifdef HAVE_NURBS
00150 
00153       void computeSurfaceJacobians();
00154 #endif
00155 
00156 #ifdef HAVE_NURBS
00157 
00162       fmatvec::Vec getControlPoints(const int u, const int v);
00163 #endif
00164 
00165 #ifdef HAVE_NURBS
00166 
00169       fmatvec::Vec getUVector();
00170 #endif
00171 
00172 #ifdef HAVE_NURBS
00173 
00176       fmatvec::Vec getVVector();
00177 #endif
00178 
00183       int testInsideBounds(const fmatvec::Vec &s);
00184 
00190       double computeError(const fmatvec::Vec &Vec1, const fmatvec::Vec &Vec2);
00191 
00192     protected:
00196       int RefDofs;
00197 
00201       int nj, nr;
00202 
00206       int degU, degV;
00207 
00211       double Ri, Ra;
00212 
00213 #ifdef HAVE_NURBS
00214 
00217       std::vector<MBSim::ContourPointData> jacobians; // size = number of interpolation points
00218 
00222       PlNurbsSurfaced *Surface; // an homogenous surface with accuracy of calculation of double (HSurface<double,3>)
00223 
00227       PlNurbsSurfaced *SurfaceVelocities;
00228 
00232       std::vector<PlNurbsSurfaced> SurfaceJacobiansOfTranslation; // size = number of generalized coordinates
00233 
00237       std::vector<PlNurbsSurfaced> SurfaceJacobiansOfRotation; // size = number of generalized coordinates
00238 
00242       PLib::Vector<double> *uvec; // nurbs++ needs this vector 
00243       PLib::Vector<double> *uVec; // knot-vector for azimuthal direction 
00244       PLib::Vector<double> *vvec; // nurbs++ needs this vector
00245       PLib::Vector<double> *vVec; // knot-vector for radial direction
00246 #endif
00247   };
00248 
00249 }
00250 
00251 #endif /* NURBSDISK2S_H_ */
00252