opensurgsim
Fem2DElementTriangle.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_PHYSICS_FEM2DELEMENTTRIANGLE_H
17 #define SURGSIM_PHYSICS_FEM2DELEMENTTRIANGLE_H
18 
19 #include <array>
20 
21 #include "SurgSim/Physics/Fem.h"
22 #include "SurgSim/Physics/FemElement.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace Physics
28 {
29 SURGSIM_STATIC_REGISTRATION(Fem2DElementTriangle);
30 
52 {
53  typedef Eigen::Matrix<double, 3, 3> Matrix33Type;
54 
55  typedef Eigen::Matrix<double, 3, 6> Matrix36Type;
56  typedef Eigen::Matrix<double, 6, 6> Matrix66Type;
57 
58  typedef Eigen::Matrix<double, 3, 9> Matrix39Type;
59  typedef Eigen::Matrix<double, 9, 9> Matrix99Type;
60 
61 public:
64 
68  explicit Fem2DElementTriangle(std::array<size_t, 3> nodeIds);
69 
74  explicit Fem2DElementTriangle(std::shared_ptr<FemElementStructs::FemElementParameter> elementData);
75 
77 
78 
79  void setThickness(double thickness);
81 
84  double getThickness() const;
85 
86  void initialize(const SurgSim::Math::OdeState& state) override;
87 
88  double getVolume(const SurgSim::Math::OdeState& state) const override;
89 
91  const SurgSim::Math::Vector& naturalCoordinate) const override;
92 
94  const SurgSim::Math::Vector& cartesianCoordinate) const override;
95 
96 protected:
98  void initializeMembers();
99 
104 
108  virtual void computeLocalStiffness(const SurgSim::Math::OdeState& state,
109  Eigen::Matrix<double, 18, 18>* localStiffnessMatrix);
110 
114  void computeStiffness(const SurgSim::Math::OdeState& state, SurgSim::Math::Matrix* stiffnessMatrix);
115 
119  virtual void computeLocalMass(const SurgSim::Math::OdeState& state,
120  Eigen::Matrix<double, 18, 18>* localMassMatrix);
121 
125  void computeMass(const SurgSim::Math::OdeState& state, SurgSim::Math::Matrix* massMatrix);
126 
127  void doUpdateFMDK(const Math::OdeState& state, int options) override;
128 
130  Eigen::Matrix<double, 18, 1> m_x0;
131 
134 
136  Eigen::Matrix<double, 18, 18> m_MLocal;
138  Eigen::Matrix<double, 18, 18> m_KLocal;
139 
141  double m_restArea;
142 
144  double m_thickness;
145 
149 
154 
155  // Thin-plate (bending/twisting) specific data structure
156  // DOF simulated: (z, thetaX, thetaY)
157  // "A Study Of Three-Node Triangular Plate Bending Elements", Jean-Louis Batoz
158  // Numerical Methods in Engineering, vol 15, 1771-1812 (1980)
159  // Indices are as follow:
160  // 0 1 2 denotes triangle's points ABC:
161  // 4 (mid-edge 12) 5 (mid-edge 20) 6 (mid-edge 01) denotes mid-edge points
162  // Data structures having only mid-edge information are 0 based (0->4 (mid-egde 12) ; 1->5 ; 2->6)
163 
173 
174 
180 
181 
186 
187 
191  std::array<double, 9> batozDhxDxi(double xi, double eta) const;
195  std::array<double, 9> batozDhxDeta(double xi, double eta) const;
199  std::array<double, 9> batozDhyDxi(double xi, double eta) const;
203  std::array<double, 9> batozDhyDeta(double xi, double eta) const;
207  Matrix39Type batozStrainDisplacement(double xi, double eta) const;
208 
209 private:
213  void computeLocalMembraneMass(const SurgSim::Math::OdeState& state,
214  Eigen::Matrix<double, 18, 18>* localMassMatrix);
215 
221  void computeLocalPlateMass(const SurgSim::Math::OdeState& state,
222  Eigen::Matrix<double, 18, 18>* localMassMatrix);
223 
228  void computeIntegral_dTd();
229 
234  void computeIntegral_HxHxT();
235 
240  void computeIntegral_HyHyT();
241 };
242 
243 } // namespace Physics
244 
245 } // namespace SurgSim
246 
247 #endif // SURGSIM_PHYSICS_FEM2DELEMENTTRIANGLE_H
void computeShapeFunctionsParameters(const SurgSim::Math::OdeState &restState)
Compute the various shape functions (membrane and plate deformations) parameters. ...
Definition: Fem2DElementTriangle.cpp:693
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Matrix39Type batozStrainDisplacement(double xi, double eta) const
Batoz strain displacement matrix evaluated at a given point.
Definition: Fem2DElementTriangle.cpp:894
double getVolume(const SurgSim::Math::OdeState &state) const override
Gets the element volume based on the input state (in m-3)
Definition: Fem2DElementTriangle.cpp:81
Eigen::Matrix< double, 18, 18 > m_MLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem2DElementTriangle.h:136
void computeStiffness(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *stiffnessMatrix)
Computes the triangle&#39;s stiffness matrix.
Definition: Fem2DElementTriangle.cpp:252
std::array< double, 9 > batozDhxDeta(double xi, double eta) const
Batoz derivative dHx/deta.
Definition: Fem2DElementTriangle.cpp:833
SurgSim::Math::Vector computeCartesianCoordinate(const SurgSim::Math::OdeState &state, const SurgSim::Math::Vector &naturalCoordinate) const override
Computes a given natural coordinate in cartesian coordinates.
Definition: Fem2DElementTriangle.cpp:306
void computeMass(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *massMatrix)
Computes the triangle&#39;s mass matrix.
Definition: Fem2DElementTriangle.cpp:164
double m_thickness
Thickness of the element.
Definition: Fem2DElementTriangle.h:144
SurgSim::Math::Vector3d m_ek
Batoz variable .
Definition: Fem2DElementTriangle.h:172
double m_restArea
The triangle rest area.
Definition: Fem2DElementTriangle.h:141
void setThickness(double thickness)
Sets the triangle&#39;s thickness.
Definition: Fem2DElementTriangle.cpp:68
SurgSim::Math::Matrix33d m_membraneShapeFunctionsParameters
Membrane (in-plane) deformation.
Definition: Fem2DElementTriangle.h:153
double getThickness() const
Gets the triangle&#39;s thickness.
Definition: Fem2DElementTriangle.cpp:76
2D FemElement based on a triangle with a constant thickness
Definition: Fem2DElementTriangle.h:51
SurgSim::Math::Vector3d m_lij_sqr
Batoz variable .
Definition: Fem2DElementTriangle.h:167
std::array< double, 9 > batozDhxDxi(double xi, double eta) const
Batoz derivative dHx/dxi.
Definition: Fem2DElementTriangle.cpp:811
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
Base class for all Fem Element (1D, 2D, 3D) It handles the node ids to which it is connected and requ...
Definition: FemElement.h:45
SurgSim::Math::Vector3d m_yij
Batoz variable .
Definition: Fem2DElementTriangle.h:166
virtual void computeLocalStiffness(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *localStiffnessMatrix)
Computes the triangle&#39;s local stiffness matrix.
Definition: Fem2DElementTriangle.cpp:182
SurgSim::Math::Matrix m_integralHyiHyj
Plate mass matrix: integral terms related to the dof .
Definition: Fem2DElementTriangle.h:184
std::array< double, 9 > batozDhyDxi(double xi, double eta) const
Batoz derivative dHy/dxi.
Definition: Fem2DElementTriangle.cpp:854
SurgSim::Math::Vector3d m_bk
Batoz variable .
Definition: Fem2DElementTriangle.h:169
Eigen::Matrix< double, 18, 18 > m_KLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem2DElementTriangle.h:138
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
virtual void computeLocalMass(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *localMassMatrix)
Computes the triangle&#39;s local mass matrix.
Definition: Fem2DElementTriangle.cpp:156
SurgSim::Math::Vector3d m_tk
Batoz variable .
Definition: Fem2DElementTriangle.h:178
SurgSim::Math::Matrix33d computeRotation(const SurgSim::Math::OdeState &state)
Computes the triangle element&#39;s rotation given a state.
Definition: Fem2DElementTriangle.cpp:270
SurgSim::Math::Matrix m_integral_dT_d
Plate mass matrix: integral terms related to the dof .
Definition: Fem2DElementTriangle.h:183
SurgSim::Math::Matrix33d m_initialRotation
Initial rotation matrix for the element.
Definition: Fem2DElementTriangle.h:133
SurgSim::Math::Vector3d m_qk
Batoz variable .
Definition: Fem2DElementTriangle.h:177
Eigen::Matrix< double, 18, 1 > m_x0
The element&#39;s rest state.
Definition: Fem2DElementTriangle.h:130
std::array< double, 9 > batozDhyDeta(double xi, double eta) const
Batoz derivative dHy/deta.
Definition: Fem2DElementTriangle.cpp:874
SurgSim::Math::Vector3d m_dk
Batoz variable .
Definition: Fem2DElementTriangle.h:171
SurgSim::Math::Matrix m_integralHxiHxj
Plate mass matrix: integral terms related to the dof .
Definition: Fem2DElementTriangle.h:185
SurgSim::Math::Vector3d m_rk
Batoz variable .
Definition: Fem2DElementTriangle.h:179
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
void initializeMembers()
Initializes variables needed before Initialize() is called.
Definition: Fem2DElementTriangle.cpp:90
SurgSim::Math::Vector3d m_ck
Batoz variable .
Definition: Fem2DElementTriangle.h:170
SurgSim::Math::Vector3d m_ak
Batoz variable .
Definition: Fem2DElementTriangle.h:168
Fem2DElementTriangle()
Constructor.
Definition: Fem2DElementTriangle.cpp:44
void initialize(const SurgSim::Math::OdeState &state) override
Initialize the FemElement once everything has been set.
Definition: Fem2DElementTriangle.cpp:99
void doUpdateFMDK(const Math::OdeState &state, int options) override
Update the FemElement based on the given state.
Definition: Fem2DElementTriangle.cpp:325
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Math::Vector3d m_Pk
Batoz variable .
Definition: Fem2DElementTriangle.h:176
SurgSim::Math::Vector computeNaturalCoordinate(const SurgSim::Math::OdeState &state, const SurgSim::Math::Vector &cartesianCoordinate) const override
Computes a natural coordinate given a global coordinate.
Definition: Fem2DElementTriangle.cpp:317
SurgSim::Math::Vector3d m_xij
Batoz variable .
Definition: Fem2DElementTriangle.h:165