mbsimflexiblebody 4.0.0 MBSim Flexible Body Module

flexible_planar_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_NURBS_CONTOUR_H_
21 #define _FLEXIBLE_PLANAR_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
43 class FlexiblePlanarNurbsContour : public FlexibleContour {
44 public:
49 FlexiblePlanarNurbsContour(const std::string &name="") : FlexibleContour(name) { }
50
54 ~FlexiblePlanarNurbsContour() 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 evalWn_t(const fmatvec::Vec2 &zeta);
64 fmatvec::Vec3 evalWs_t(const fmatvec::Vec2 &zeta) override;
65 fmatvec::Vec3 evalWu_t(const fmatvec::Vec2 &zeta) override;
66 fmatvec::Vec3 evalPosition(const fmatvec::Vec2 &zeta) override;
67 fmatvec::Vec3 evalWs(const fmatvec::Vec2 &zeta) override;
68 fmatvec::Vec3 evalWt(const fmatvec::Vec2 &zeta) override;
69 fmatvec::Vec3 evalParDer1Ws(const fmatvec::Vec2 &zeta);
70 fmatvec::Vec3 evalParDer1Wu(const fmatvec::Vec2 &zeta) override;
71 fmatvec::Vec3 evalParWvCParEta(const fmatvec::Vec2 &zeta) override;
72 fmatvec::Vec3 evalParWuPart(const fmatvec::Vec2 &zeta) override;
73
74 void updatePositions(MBSim::Frame *frame) override;
75 void updateVelocities(MBSim::Frame *frame) override;
76 void updateAccelerations(MBSim::Frame *frame) override;
77 void updateJacobians(MBSim::Frame *frame, int j=0) override;
78 void updateGyroscopicAccelerations(MBSim::Frame *frame) override;
79 /***************************************************/
80
81 /* GETTER / SETTER */
82 void setInterpolation(bool interpolation_) { interpolation = interpolation_; }
83 void setNodeNumbers(const fmatvec::VecVI &node) { index <<= node; }
84 void setKnotVector(const fmatvec::VecV &knot_) { knot <<= knot_; }
85 void setDegree(int degree_) { degree = degree_; }
86 /***************************************************/
87
88 void plot() override;
89
90 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))) {
91 OpenMBVDynamicNurbsCurve ombv(diffuseColor,transparency,pointSize,lineWidth);
92 openMBVNurbsCurve=ombv.createOpenMBV();
93 }
94
95 void initializeUsingXML(xercesc::DOMElement *element) override;
96
97 bool isZetaOutside(const fmatvec::Vec2 &zeta) override;
98
99 void setOpen(bool open_) { open = open_; }
100
101 void resetUpToDate() override { updCrvPos = true; updCrvVel = true; updCrvJac = true; updCrvGA = true; }
102
103 void updateCurvePositions();
104 void updateCurveVelocities();
105 void updateCurveJacobians();
106 void updateCurveGyroscopicAccelerations();
107
108 protected:
109 double continueEta(double eta_);
110 void updateHessianMatrix(double eta);
111 void updateHessianMatrix_t(double eta);
112 const fmatvec::MatVx4& evalHessianMatrix(double eta){ if(updCrvPos or fabs(eta-etaOld)>1e-13) updateHessianMatrix(eta); return hess; }
113 const fmatvec::MatVx4& evalHessianMatrix_t(double eta){ updateHessianMatrix_t(eta); return hess_t; }
114
115 bool interpolation{false};
116 fmatvec::VecVI index;
117 fmatvec::VecV knot;
118 int degree{3};
119 bool open{false};
120 MBSim::NurbsCurve crvPos, crvVel, crvGA;
121 std::vector<MBSim::NurbsCurve> crvJac;
122 double etaOld{-1e10};
123 fmatvec::MatVx4 hess, hess_t, hessTmp;
124 bool updCrvPos{true};
125 bool updCrvVel{true};
126 bool updCrvJac{true};
127 bool updCrvGA{true};
128
129 std::shared_ptr<OpenMBV::DynamicNurbsCurve> openMBVNurbsCurve;
130 };
131
132 }
133
134 #endif
MBSimFlexibleBody::FlexibleContour
flexible planar contour
Definition: flexible_contour.h:36
MBSimFlexibleBody::FlexiblePlanarNurbsContour
flexible planar nurbs contour
Definition: flexible_planar_nurbs_contour.h:43
MBSimFlexibleBody::FlexiblePlanarNurbsContour::~FlexiblePlanarNurbsContour
~FlexiblePlanarNurbsContour() override=default
destructor
MBSimFlexibleBody::FlexiblePlanarNurbsContour::FlexiblePlanarNurbsContour
FlexiblePlanarNurbsContour(const std::string &name="")
constructor
Definition: flexible_planar_nurbs_contour.h:49
MBSim::Element::InitStage
InitStage
MBSim::ContourFrame
MBSim::Element::name
std::string name
MBSim::Frame
MBSim::NurbsCurve