mbsimflexiblebody  3.0.0
nurbs_disk_2s.h
1 /* Copyright (C) 2004-2011 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: thorsten.schindler@mytum.de
18  */
19 
20 #ifndef NURBSDISK2S_H_
21 #define NURBSDISK2S_H_
22 
23 #include "fmatvec.h"
24 #include "mbsim/mbsim_event.h"
25 #include "mbsim/contours/contour2s.h"
26 #include "mbsimFlexibleBody/utils/contact_utils.h"
27 
28 #ifdef HAVE_NURBS
29 #define MY_PACKAGE_BUGREPORT PACKAGE_BUGREPORT
30 #define MY_PACKAGE_NAME PACKAGE_NAME
31 #define MY_PACKAGE_VERSION PACKAGE_VERSION
32 #define MY_PACKAGE_TARNAME PACKAGE_TARNAME
33 #define MY_PACKAGE_STRING PACKAGE_STRING
34 #undef PACKAGE_BUGREPORT
35 #undef PACKAGE_NAME
36 #undef PACKAGE_VERSION
37 #undef PACKAGE_TARNAME
38 #undef PACKAGE_STRING
39 #include "nurbs.h"
40 #undef PACKAGE_BUGREPORT
41 #undef PACKAGE_NAME
42 #undef PACKAGE_VERSION
43 #undef PACKAGE_TARNAME
44 #undef PACKAGE_STRING
45 #include "nurbsS.h"
46 #undef PACKAGE_BUGREPORT
47 #undef PACKAGE_NAME
48 #undef PACKAGE_VERSION
49 #undef PACKAGE_TARNAME
50 #undef PACKAGE_STRING
51 #include "vector.h"
52 #define PACKAGE_BUGREPORT MY_PACKAGE_BUGREPORT
53 #define PACKAGE_NAME MY_PACKAGE_NAME
54 #define PACKAGE_VERSION MY_PACKAGE_VERSION
55 #define PACKAGE_TARNAME MY_PACKAGE_TARNAME
56 #define PACKAGE_STRING MY_PACKAGE_STRING
57 #endif
58 
59 namespace MBSimFlexibleBody {
60 
74  class NurbsDisk2s : public MBSim::Contour2s {
75  public:
80  NurbsDisk2s(const std::string &name) : MBSim::Contour2s(name), nj(0), nr(0), degU(0), degV(0), Ri(0.), Ra(0.) {
81 #ifndef HAVE_NURBS
82  throw MBSim::MBSimError("ERROR(NurbsDisk2s::NurbsDisk2s): External NURBS library not implemented!");
83 #endif
84  }
85 
89  virtual ~NurbsDisk2s();
90 
91  /* INHERITED INTERFACE OF ELEMENT */
92  virtual std::string getType() const { return "NurbsDisk2s"; }
93  /***************************************************/
94 
95  /* INHERITED INTERFACE OF CONTOURCONTINUUM */
96  virtual void computeRootFunctionPosition(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionPosition): Not implemented!"); }
97  virtual void computeRootFunctionFirstTangent(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionFirstTangent): Not implemented!"); }
98  virtual void computeRootFunctionNormal(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionNormal): Not implemented!"); }
99  virtual void computeRootFunctionSecondTangent(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsDisk2s::computeRootFunctionSecondTangent): Not implemented!"); }
100  /***************************************************/
101 
102  /* INHERITED INTERFACE OF CONTOUR */
103  virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::FrameFeature ff);
104  virtual void updateJacobiansForFrame(MBSim::ContourPointData &cp, int j = 0);
105  virtual MBSim::ContactKinematics * findContactPairingWith(std::string type0, std::string type1) {
106  return findContactPairingFlexible(type0.c_str(), type1.c_str());
107  }
108  /***************************************************/
109 
110 #ifdef HAVE_NURBS
111 
115  void initContourFromBody(MBSim::InitStage stage);
116 #endif
117 
123  fmatvec::Vec transformCW(const fmatvec::Vec& WrPoint);
124 
125 #ifdef HAVE_NURBS
126 
132  fmatvec::Mat computeDirectionalDerivatives(const double &radius, const double &phi, const int &deg);
133 #endif
134 
135 #ifdef HAVE_NURBS
136 
141  fmatvec::Mat computeCurvatures(const double &radius, const double &phi);
142 #endif
143 
144 #ifdef HAVE_NURBS
145 
149  void computeUVector(const int NbPts);
150 #endif
151 
152 #ifdef HAVE_NURBS
153 
157  void computeVVector(const int NbPts);
158 #endif
159 
160 #ifdef HAVE_NURBS
161 
164  void computeSurface();
165 #endif
166 
167 #ifdef HAVE_NURBS
168 
171  void computeSurfaceVelocities();
172 #endif
173 
174 #ifdef HAVE_NURBS
175 
178  void computeSurfaceJacobians();
179 #endif
180 
181 #ifdef HAVE_NURBS
182 
187  fmatvec::Vec getControlPoints(const int u, const int v);
188 #endif
189 
190 #ifdef HAVE_NURBS
191 
194  fmatvec::Vec getUVector();
195 #endif
196 
197 #ifdef HAVE_NURBS
198 
201  fmatvec::Vec getVVector();
202 #endif
203 
208  int testInsideBounds(const fmatvec::Vec &s);
209 
215  double computeError(const fmatvec::Vec &Vec1, const fmatvec::Vec &Vec2);
216 
217  protected:
221  int RefDofs;
222 
226  int nj, nr;
227 
231  int degU, degV;
232 
236  double Ri, Ra;
237 
238 #ifdef HAVE_NURBS
239 
242  std::vector<MBSim::ContourPointData> jacobians; // size = number of interpolation points
243 
247  PlNurbsSurfaced *Surface; // an homogenous surface with accuracy of calculation of double (HSurface<double,3>)
248 
252  PlNurbsSurfaced *SurfaceVelocities;
253 
257  std::vector<PlNurbsSurfaced> SurfaceJacobiansOfTranslation; // size = number of generalized coordinates
258 
262  std::vector<PlNurbsSurfaced> SurfaceJacobiansOfRotation; // size = number of generalized coordinates
263 
267  PLib::Vector<double> *uvec; // nurbs++ needs this vector
268  PLib::Vector<double> *uVec; // knot-vector for azimuthal direction
269  PLib::Vector<double> *vvec; // nurbs++ needs this vector
270  PLib::Vector<double> *vVec; // knot-vector for radial direction
271 #endif
272  };
273 
274 }
275 
276 #endif /* NURBSDISK2S_H_ */
277