mbsimflexiblebody 4.0.0 MBSim Flexible Body Module

flexible_spatial_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_SPATIAL_NURBS_CONTOUR_H_
21 #define _FLEXIBLE_SPATIAL_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_surface.h>
28
29 namespace OpenMBV {
30 class DynamicNurbsSurface;
31 }
32
33 namespace MBSim {
34 class ContourFrame;
35 }
36
37 namespace MBSimFlexibleBody {
38
43 class FlexibleSpatialNurbsContour : public FlexibleContour {
44 public:
49 FlexibleSpatialNurbsContour(const std::string &name="") : FlexibleContour(name) { }
50
54 ~FlexibleSpatialNurbsContour() 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) override;
64 fmatvec::Vec3 evalWs_t(const fmatvec::Vec2 &zeta) override;
65 fmatvec::Vec3 evalWt_t(const fmatvec::Vec2 &zeta) override;
66 fmatvec::Vec3 evalWu_t(const fmatvec::Vec2 &zeta) override;
67 fmatvec::Vec3 evalWv_t(const fmatvec::Vec2 &zeta) override;
68 fmatvec::Vec3 evalPosition(const fmatvec::Vec2 &zeta) override;
69 fmatvec::Vec3 evalWs(const fmatvec::Vec2 &zeta) override;
70 fmatvec::Vec3 evalWt(const fmatvec::Vec2 &zeta) override;
71 fmatvec::Vec3 evalParDer1Ws(const fmatvec::Vec2 &zeta);
72 fmatvec::Vec3 evalParDer2Ws(const fmatvec::Vec2 &zeta);
73 fmatvec::Vec3 evalParDer1Wt(const fmatvec::Vec2 &zeta);
74 fmatvec::Vec3 evalParDer2Wt(const fmatvec::Vec2 &zeta);
75 fmatvec::Vec3 evalParDer1Wu(const fmatvec::Vec2 &zeta) override;
76 fmatvec::Vec3 evalParDer2Wu(const fmatvec::Vec2 &zeta) override;
77 fmatvec::Vec3 evalParDer1Wv(const fmatvec::Vec2 &zeta) override;
78 fmatvec::Vec3 evalParDer2Wv(const fmatvec::Vec2 &zeta) override;
79 fmatvec::Vec3 evalParDer1Wn(const fmatvec::Vec2 &zeta) override;
80 fmatvec::Vec3 evalParDer2Wn(const fmatvec::Vec2 &zeta) override;
81 fmatvec::Vec3 evalParWvCParEta(const fmatvec::Vec2 &zeta) override;
82 fmatvec::Vec3 evalParWvCParXi(const fmatvec::Vec2 &zeta) override;
83 fmatvec::Vec3 evalParWuPart(const fmatvec::Vec2 &zeta) override;
84 fmatvec::Vec3 evalParWvPart(const fmatvec::Vec2 &zeta) override;
85 fmatvec::Vec3 evalParWnPart(const fmatvec::Vec2 &zeta) override;
86
87 void updatePositions(MBSim::Frame *frame) override;
88 void updateVelocities(MBSim::Frame *frame) override;
89 void updateAccelerations(MBSim::Frame *frame) override;
90 void updateJacobians(MBSim::Frame *frame, int j=0) override;
91 void updateGyroscopicAccelerations(MBSim::Frame *frame) override;
92 /***************************************************/
93
94 /* GETTER / SETTER */
95 void setInterpolation(bool interpolation_) { interpolation = interpolation_; }
96 void setNodeNumbers(const fmatvec::MatVI &node) { index <<= node; }
97 void setEtaKnotVector(const fmatvec::VecV &uKnot_) { uKnot <<= uKnot_; }
98 void setXiKnotVector(const fmatvec::VecV &vKnot_) { vKnot <<= vKnot_; }
99 void setEtaDegree(int etaDegree_) { etaDegree = etaDegree_; }
100 void setXiDegree(int xiDegree_) { xiDegree = xiDegree_; }
101 /***************************************************/
102
103 void plot() override;
104
105 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))) {
106 OpenMBVDynamicNurbsSurface ombv(diffuseColor,transparency,pointSize,lineWidth);
107 openMBVNurbsSurface=ombv.createOpenMBV();
108 }
109
110 void initializeUsingXML(xercesc::DOMElement *element) override;
111
112 // void setNodes(const std::vector<double> &nodes_) { etaNodes = nodes_; }
113
114 bool isZetaOutside(const fmatvec::Vec2 &zeta) override;
115
116 void setOpenEta(bool openEta_) { openEta = openEta_; }
117 void setOpenXi(bool openXi_) { openXi = openXi_; }
118
119 void resetUpToDate() override { updSrfPos = true; updSrfVel = true; updSrfJac = true; updSrfGA = true; }
120
121 void updateSurfacePositions();
122 void updateSurfaceVelocities();
123 void updateSurfaceJacobians();
124 void updateSurfaceGyroscopicAccelerations();
125
126 protected:
127 fmatvec::Vec2 continueZeta(const fmatvec::Vec2 &zeta_);
128 void updateHessianMatrix(const fmatvec::Vec2 &zeta);
129 void updateHessianMatrix_t(const fmatvec::Vec2 &zeta);
130 const fmatvec::GeneralMatrix<fmatvec::Vec4>& evalHessianMatrix(const fmatvec::Vec2 &zeta){ if(updSrfPos or fabs(zeta(0)-zetaOld(0))>1e-13 or fabs(zeta(1)-zetaOld(1))>1e-13) updateHessianMatrix(zeta); return hess; }
131 const fmatvec::GeneralMatrix<fmatvec::Vec4>& evalHessianMatrix_t(const fmatvec::Vec2 &zeta){ updateHessianMatrix_t(zeta); return hess_t; }
132
133 bool interpolation{false};
134 fmatvec::MatVI index;
135 fmatvec::VecV uKnot, vKnot;
136 int etaDegree{3};
137 int xiDegree{3};
138 bool openEta{false};
139 bool openXi{false};
140 MBSim::NurbsSurface srfPos, srfVel, srfGA;
141 std::vector<MBSim::NurbsSurface> srfJac;
142 fmatvec::Vec2 zetaOld;
143 fmatvec::GeneralMatrix<fmatvec::Vec4> hess, hess_t, hessTmp;
144 bool updSrfPos{true};
145 bool updSrfVel{true};
146 bool updSrfJac{true};
147 bool updSrfGA{true};
148
149 std::shared_ptr<OpenMBV::DynamicNurbsSurface> openMBVNurbsSurface;
150 };
151
152 }
153
154 #endif
MBSimFlexibleBody::FlexibleContour
flexible planar contour
Definition: flexible_contour.h:36
MBSimFlexibleBody::FlexibleSpatialNurbsContour
flexible spatial nurbs contour
Definition: flexible_spatial_nurbs_contour.h:43
MBSim::NurbsSurface
MBSim::Element::InitStage
InitStage
MBSim::ContourFrame
MBSim::Element::name
std::string name
MBSimFlexibleBody::FlexibleSpatialNurbsContour::FlexibleSpatialNurbsContour
FlexibleSpatialNurbsContour(const std::string &name="")
constructor
Definition: flexible_spatial_nurbs_contour.h:49
MBSim::Frame
MBSimFlexibleBody::FlexibleSpatialNurbsContour::~FlexibleSpatialNurbsContour
~FlexibleSpatialNurbsContour() override=default
destructor
fmatvec::GeneralMatrix< fmatvec::Vec4 >