mbsim 4.0.0 MBSim Kernel

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 _SPATIAL_NURBS_CONTOUR_H_
21 #define _SPATIAL_NURBS_CONTOUR_H_
22
23 #include "mbsim/contours/rigid_contour.h"
24 #include "mbsim/utils/boost_parameters.h"
25 #include "mbsim/utils/openmbv_utils.h"
26 #include "mbsim/numerics/nurbs/nurbs_surface.h"
27 #include <openmbvcppinterface/nurbssurface.h>
28
29 namespace MBSim {
30
35 class SpatialNurbsContour : public RigidContour {
36 public:
37 enum Interpolation {
38 equallySpaced = 0,
39 chordLength,
40 none,
41 unknown
42 };
43
48 SpatialNurbsContour(const std::string &name="", Frame *R=nullptr) : RigidContour(name,R) { }
49
53 ~SpatialNurbsContour() override = default;
54
55 /* INHERITED INTERFACE OF ELEMENT */
56 /***************************************************/
57
58 /* INHERITED INTERFACE OF CONTOUR */
59 void init(InitStage stage, const InitConfigSet &config) override;
60 double getCurvature(const fmatvec::Vec2 &zeta);
61 fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta) override;
62 fmatvec::Vec3 evalKs(const fmatvec::Vec2 &zeta) override;
63 fmatvec::Vec3 evalKt(const fmatvec::Vec2 &zeta) override;
64 fmatvec::Vec3 evalParDer1Ks(const fmatvec::Vec2 &zeta) override;
65 fmatvec::Vec3 evalParDer2Ks(const fmatvec::Vec2 &zeta) override;
66 fmatvec::Vec3 evalParDer1Kt(const fmatvec::Vec2 &zeta) override;
67 fmatvec::Vec3 evalParDer2Kt(const fmatvec::Vec2 &zeta) override;
68 /***************************************************/
69
70 /* GETTER / SETTER */
71 void setInterpolation(Interpolation interpolation_) { interpolation = interpolation_; }
72 void setControlPoints(const fmatvec::MatVx4 &cp_) { cp <<= cp_; }
73 void setControlPoints(const fmatvec::MatVx3 &cp_);
74 void setControlPoints(const std::vector<std::vector<fmatvec::Vec4>> &cp_);
75 void setControlPoints(const std::vector<std::vector<fmatvec::Vec3>> &cp_);
76 void setNumberOfEtaControlPoints(int nu_) { nu = nu_; }
77 void setNumberOfXiControlPoints(int nv_) { nv = nv_; }
78 void setEtaKnotVector(const fmatvec::VecV &uKnot_) { uKnot <<= uKnot_; }
79 void setXiKnotVector(const fmatvec::VecV &vKnot_) { vKnot <<= vKnot_; }
80 void setEtaDegree(int etaDegree_) { etaDegree = etaDegree_; }
81 void setXiDegree(int xiDegree_) { xiDegree = xiDegree_; }
82 /***************************************************/
83
84 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
85 OpenMBVColoredBody ombv(diffuseColor,transparency,pointSize,lineWidth);
86 openMBVRigidBody=ombv.createOpenMBV<OpenMBV::NurbsSurface>();
87 }
88
89 void initializeUsingXML(xercesc::DOMElement *element) override;
90
91 bool isZetaOutside(const fmatvec::Vec2 &zeta) override;
92
93 void setOpenEta(bool openEta_) { openEta = openEta_; }
94 void setOpenXi(bool openXi_) { openXi = openXi_; }
95
96 protected:
97 void updateHessianMatrix(const fmatvec::Vec2 &zeta);
98 const fmatvec::GeneralMatrix<fmatvec::Vec4>& evalHessianMatrix(const fmatvec::Vec2 &zeta){ if(fabs(zeta(0)-zetaOld(0))>1e-13 or fabs(zeta(1)-zetaOld(1))>1e-13) updateHessianMatrix(zeta); return hess; }
99
100 Interpolation interpolation{none};
101 fmatvec::MatVx4 cp;
102 int nu{0};
103 int nv{0};
104 fmatvec::VecV uKnot, vKnot;
105 int etaDegree{3};
106 int xiDegree{3};
107 bool openEta{false};
108 bool openXi{false};
109 NurbsSurface srf;
110 fmatvec::Vec2 zetaOld;
111 fmatvec::GeneralMatrix<fmatvec::Vec4> hess;
112 };
113
114 }
115
116 #endif
MBSim::RigidContour
basic class for rigid contours
Definition: rigid_contour.h:37
MBSim::SpatialNurbsContour::SpatialNurbsContour
SpatialNurbsContour(const std::string &name="", Frame *R=nullptr)
constructor
Definition: spatial_nurbs_contour.h:48
MBSim::SpatialNurbsContour::~SpatialNurbsContour
~SpatialNurbsContour() override=default
destructor
OpenMBV::NurbsSurface
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::Frame
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
MBSim::RigidContour::R
Frame * R
coordinate system of contour
Definition: rigid_contour.h:133
MBSim::SpatialNurbsContour
nurbs surface
Definition: spatial_nurbs_contour.h:35
MBSim::SpatialNurbsContour::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: spatial_nurbs_contour.cc:83
fmatvec::GeneralMatrix< fmatvec::Vec4 >
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30