mbsimflexiblebody  4.0.0
MBSim Flexible Body Module
flexible_planar_ffr_nurbs_contour.h
1 /* Copyright (C) 2004-2018 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: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef _FLEXIBLE_PLANAR_FFR_NURBS_CONTOUR_H_
21 #define _FLEXIBLE_PLANAR_FFR_NURBS_CONTOUR_H_
22 
23 #include "mbsimFlexibleBody/contours/flexible_contour.h"
24 
25 #include "mbsim/utils/boost_parameters.h"
26 #include <mbsimFlexibleBody/utils/openmbv_utils.h>
27 #include <mbsim/numerics/nurbs/nurbs_curve.h>
28 
29 namespace OpenMBV {
30  class DynamicNurbsCurve;
31 }
32 
33 namespace MBSim {
34  class ContourFrame;
35 }
36 
37 namespace MBSimFlexibleBody {
38 
44  public:
50 
54  ~FlexiblePlanarFfrNurbsContour() override = default;
55 
56  /* INHERITED INTERFACE OF ELEMENT */
57  /***************************************************/
58 
59  /* INHERITED INTERFACE OF CONTOUR */
60  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
61  MBSim::ContourFrame* createContourFrame(const std::string &name="P") override;
62  double getCurvature(const fmatvec::Vec2 &zeta);
63  fmatvec::Vec3 evalWs_t(const fmatvec::Vec2 &zeta) override;
64  fmatvec::Vec3 evalWu_t(const fmatvec::Vec2 &zeta) override;
65  fmatvec::Vec3 evalPosition(const fmatvec::Vec2 &zeta) override;
66  fmatvec::Vec3 evalWs(const fmatvec::Vec2 &zeta) override;
67  fmatvec::Vec3 evalWt(const fmatvec::Vec2 &zeta) override;
68  fmatvec::Vec3 evalParDer1Ws(const fmatvec::Vec2 &zeta);
69  fmatvec::Vec3 evalParDer1Wu(const fmatvec::Vec2 &zeta) override;
70  fmatvec::Vec3 evalParWvCParEta(const fmatvec::Vec2 &zeta) override;
71  fmatvec::Vec3 evalParWuPart(const fmatvec::Vec2 &zeta) override;
72 
73  fmatvec::Vec3 evalKs_t(const fmatvec::Vec2 &zeta);
74  fmatvec::Vec3 evalKu_t(const fmatvec::Vec2 &zeta);
75  fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta);
76  fmatvec::Vec3 evalKs(const fmatvec::Vec2 &zeta);
77  fmatvec::Vec3 evalKt(const fmatvec::Vec2 &zeta);
78  fmatvec::Vec3 evalParDer1Ks(const fmatvec::Vec2 &zeta);
79  fmatvec::Vec3 evalParDer1Ku(const fmatvec::Vec2 &zeta);
80 
81  void updatePositions(MBSim::Frame *frame) override;
82  void updateVelocities(MBSim::Frame *frame) override;
83  void updateAccelerations(MBSim::Frame *frame) override;
84  void updateJacobians(MBSim::Frame *frame, int j=0) override;
85  void updateGyroscopicAccelerations(MBSim::Frame *frame) override;
86  /***************************************************/
87 
88  /* GETTER / SETTER */
89  void setInterpolation(bool interpolation_) { interpolation = interpolation_; }
90  void setNodeNumbers(const fmatvec::VecVI &node) { index <<= node; }
91  void setKnotVector(const fmatvec::VecV &knot_) { knot <<= knot_; }
92  void setDegree(int degree_) { degree = degree_; }
93  /***************************************************/
94 
95  void plot() override;
96 
97  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, MBSim::tag, (optional (diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
98  OpenMBVDynamicNurbsCurve ombv(diffuseColor,transparency,pointSize,lineWidth);
99  openMBVNurbsCurve=ombv.createOpenMBV();
100  }
101 
102  void initializeUsingXML(xercesc::DOMElement *element) override;
103 
104  bool isZetaOutside(const fmatvec::Vec2 &zeta) override;
105 
106  void setOpen(bool open_) { open = open_; }
107 
108  void resetUpToDate() override { updPos = true; updVel = true; }
109 
110  protected:
111  double continueEta(double eta_);
112  void updateHessianMatrix(double eta);
113  void updateGlobalRelativePosition(double eta);
114  void updateGlobalRelativeVelocity(double eta);
115  const fmatvec::MatVx4& evalHessianMatrixPos(double eta) { if(fabs(eta-etaOld)>1e-13) updateHessianMatrix(eta); return hessPos; }
116  const std::vector<fmatvec::MatVx4>& evalHessianMatrixPhi(double eta) { if(fabs(eta-etaOld)>1e-13) updateHessianMatrix(eta); return hessPhi; }
117  const fmatvec::Vec3& evalGlobalRelativePosition(double eta) { if(updPos) updateGlobalRelativePosition(eta); return WrPS; }
118  const fmatvec::Vec3& evalGlobalRelativeVelocity(double eta) { if(updVel) updateGlobalRelativeVelocity(eta); return Wvrel; }
119 
120  MBSim::Frame *R;
121  bool interpolation{false};
122  fmatvec::VecVI index;
123  fmatvec::VecV knot;
124  int degree{3};
125  bool open{false};
126  MBSim::NurbsCurve crvPos;
127  std::vector<MBSim::NurbsCurve> crvPhi;
128  double etaOld{-1e10};
129  fmatvec::MatVx4 hessPos;
130  std::vector<fmatvec::MatVx4> hessPhi;
131  fmatvec::Vec3 WrPS, Wvrel;
132  bool updPos{true};
133  bool updVel{true};
134 
135  std::shared_ptr<OpenMBV::DynamicNurbsCurve> openMBVNurbsCurve;
136  };
137 
138 }
139 
140 #endif
flexible planar contour
Definition: flexible_contour.h:36
FlexiblePlanarFfrNurbsContour(const std::string &name="")
constructor
Definition: flexible_planar_ffr_nurbs_contour.h:49
flexible planar nurbs contour with local interpolation
Definition: flexible_planar_ffr_nurbs_contour.h:43
~FlexiblePlanarFfrNurbsContour() override=default
destructor
std::string name