Fem2DElementTriangle.h
Go to the documentation of this file.
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"
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:
214  Eigen::Matrix<double, 18, 18>* localMassMatrix);
215 
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
SurgSim::Physics::Fem2DElementTriangle::Matrix36Type
Eigen::Matrix< double, 3, 6 > Matrix36Type
Definition: Fem2DElementTriangle.h:55
SurgSim::Physics::Fem2DElementTriangle
2D FemElement based on a triangle with a constant thickness
Definition: Fem2DElementTriangle.h:51
SurgSim::Physics::Fem2DElementTriangle::computeIntegral_HxHxT
void computeIntegral_HxHxT()
Computes the integral terms Hy.Hy^T over the parametrized triangle area.
Definition: Fem2DElementTriangle.cpp:481
SurgSim::Physics::Fem2DElementTriangle::m_ak
SurgSim::Math::Vector3d m_ak
Batoz variable .
Definition: Fem2DElementTriangle.h:168
SurgSim::Physics::Fem2DElementTriangle::m_integralHxiHxj
SurgSim::Math::Matrix m_integralHxiHxj
Plate mass matrix: integral terms related to the dof .
Definition: Fem2DElementTriangle.h:185
SurgSim::Physics::Fem2DElementTriangle::initialize
void initialize(const SurgSim::Math::OdeState &state) override
Initialize the FemElement once everything has been set.
Definition: Fem2DElementTriangle.cpp:100
SurgSim::Math::OdeState
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
SurgSim::Physics::Fem2DElementTriangle::m_ck
SurgSim::Math::Vector3d m_ck
Batoz variable .
Definition: Fem2DElementTriangle.h:170
SurgSim::Physics::Fem2DElementTriangle::m_integralHyiHyj
SurgSim::Math::Matrix m_integralHyiHyj
Plate mass matrix: integral terms related to the dof .
Definition: Fem2DElementTriangle.h:184
SurgSim::Physics::Fem2DElementTriangle::batozDhyDxi
std::array< double, 9 > batozDhyDxi(double xi, double eta) const
Batoz derivative dHy/dxi.
Definition: Fem2DElementTriangle.cpp:862
SurgSim::Physics::Fem2DElementTriangle::m_Pk
SurgSim::Math::Vector3d m_Pk
Batoz variable .
Definition: Fem2DElementTriangle.h:176
SurgSim::Physics::Fem2DElementTriangle::computeNaturalCoordinate
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:325
SurgSim::Physics::Fem2DElementTriangle::m_xij
SurgSim::Math::Vector3d m_xij
Batoz variable .
Definition: Fem2DElementTriangle.h:165
SurgSim::Physics::Fem2DElementTriangle::m_KLocal
Eigen::Matrix< double, 18, 18 > m_KLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem2DElementTriangle.h:138
SurgSim::Physics::Fem2DElementTriangle::Matrix99Type
Eigen::Matrix< double, 9, 9 > Matrix99Type
Definition: Fem2DElementTriangle.h:59
SurgSim::Physics::Fem2DElementTriangle::computeLocalMass
virtual void computeLocalMass(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *localMassMatrix)
Computes the triangle's local mass matrix.
Definition: Fem2DElementTriangle.cpp:157
SurgSim::Physics::Fem2DElementTriangle::Matrix66Type
Eigen::Matrix< double, 6, 6 > Matrix66Type
Definition: Fem2DElementTriangle.h:56
SurgSim::Physics::Fem2DElementTriangle::m_tk
SurgSim::Math::Vector3d m_tk
Batoz variable .
Definition: Fem2DElementTriangle.h:178
SurgSim::Physics::Fem2DElementTriangle::batozDhxDeta
std::array< double, 9 > batozDhxDeta(double xi, double eta) const
Batoz derivative dHx/deta.
Definition: Fem2DElementTriangle.cpp:841
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Physics::Fem2DElementTriangle::computeCartesianCoordinate
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:307
SurgSim::Physics::Fem2DElementTriangle::getVolume
double getVolume(const SurgSim::Math::OdeState &state) const override
Gets the element volume based on the input state (in m-3)
Definition: Fem2DElementTriangle.cpp:82
SurgSim::Physics::Fem2DElementTriangle::Matrix33Type
Eigen::Matrix< double, 3, 3 > Matrix33Type
Definition: Fem2DElementTriangle.h:53
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::Fem2DElementTriangle::m_thickness
double m_thickness
Thickness of the element.
Definition: Fem2DElementTriangle.h:144
SurgSim::Physics::Fem2DElementTriangle::Matrix39Type
Eigen::Matrix< double, 3, 9 > Matrix39Type
Definition: Fem2DElementTriangle.h:58
SurgSim::Physics::Fem2DElementTriangle::computeRotation
SurgSim::Math::Matrix33d computeRotation(const SurgSim::Math::OdeState &state)
Computes the triangle element's rotation given a state.
Definition: Fem2DElementTriangle.cpp:271
SurgSim::Physics::Fem2DElementTriangle::m_initialRotation
SurgSim::Math::Matrix33d m_initialRotation
Initial rotation matrix for the element.
Definition: Fem2DElementTriangle.h:133
SurgSim::Physics::Fem2DElementTriangle::computeMass
void computeMass(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *massMatrix)
Computes the triangle's mass matrix.
Definition: Fem2DElementTriangle.cpp:165
SurgSim::Physics::Fem2DElementTriangle::m_qk
SurgSim::Math::Vector3d m_qk
Batoz variable .
Definition: Fem2DElementTriangle.h:177
SurgSim::Physics::Fem2DElementTriangle::m_x0
Eigen::Matrix< double, 18, 1 > m_x0
The element's rest state.
Definition: Fem2DElementTriangle.h:130
SurgSim::Physics::Fem2DElementTriangle::m_dk
SurgSim::Math::Vector3d m_dk
Batoz variable .
Definition: Fem2DElementTriangle.h:171
SurgSim::Physics::Fem2DElementTriangle::m_membraneShapeFunctionsParameters
SurgSim::Math::Matrix33d m_membraneShapeFunctionsParameters
Membrane (in-plane) deformation.
Definition: Fem2DElementTriangle.h:153
SurgSim::Physics::Fem2DElementTriangle::computeIntegral_dTd
void computeIntegral_dTd()
Computes the integral terms d^T.d over the parametrized triangle area.
Definition: Fem2DElementTriangle.cpp:347
SurgSim::Math::Matrix33d
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
SurgSim::Physics::Fem2DElementTriangle::setThickness
void setThickness(double thickness)
Sets the triangle's thickness.
Definition: Fem2DElementTriangle.cpp:69
SurgSim::Physics::Fem2DElementTriangle::m_rk
SurgSim::Math::Vector3d m_rk
Batoz variable .
Definition: Fem2DElementTriangle.h:179
SurgSim::Physics::Fem2DElementTriangle::initializeMembers
void initializeMembers()
Initializes variables needed before Initialize() is called.
Definition: Fem2DElementTriangle.cpp:91
SurgSim::Physics::Fem2DElementTriangle::Fem2DElementTriangle
Fem2DElementTriangle()
Constructor.
Definition: Fem2DElementTriangle.cpp:45
SurgSim::Physics::Fem2DElementTriangle::m_yij
SurgSim::Math::Vector3d m_yij
Batoz variable .
Definition: Fem2DElementTriangle.h:166
SurgSim::Physics::Fem2DElementTriangle::doUpdateFMDK
void doUpdateFMDK(const Math::OdeState &state, int options) override
Update the FemElement based on the given state.
Definition: Fem2DElementTriangle.cpp:333
SurgSim::Physics::Fem2DElementTriangle::computeLocalStiffness
virtual void computeLocalStiffness(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *localStiffnessMatrix)
Computes the triangle's local stiffness matrix.
Definition: Fem2DElementTriangle.cpp:183
SurgSim::Physics::Fem2DElementTriangle::batozStrainDisplacement
Matrix39Type batozStrainDisplacement(double xi, double eta) const
Batoz strain displacement matrix evaluated at a given point.
Definition: Fem2DElementTriangle.cpp:902
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Physics::Fem2DElementTriangle::m_MLocal
Eigen::Matrix< double, 18, 18 > m_MLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem2DElementTriangle.h:136
SurgSim::Physics::Fem2DElementTriangle::computeShapeFunctionsParameters
void computeShapeFunctionsParameters(const SurgSim::Math::OdeState &restState)
Compute the various shape functions (membrane and plate deformations) parameters.
Definition: Fem2DElementTriangle.cpp:701
SurgSim::Physics::FemElement
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::Physics::Fem2DElementTriangle::m_bk
SurgSim::Math::Vector3d m_bk
Batoz variable .
Definition: Fem2DElementTriangle.h:169
SurgSim::Physics::Fem2DElementTriangle::computeIntegral_HyHyT
void computeIntegral_HyHyT()
Computes the integral terms Hx.Hx^T over the parametrized triangle area.
Definition: Fem2DElementTriangle.cpp:591
SurgSim::Physics::Fem2DElementTriangle::computeStiffness
void computeStiffness(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *stiffnessMatrix)
Computes the triangle's stiffness matrix.
Definition: Fem2DElementTriangle.cpp:253
Fem.h
FemElement.h
SurgSim::Physics::Fem2DElementTriangle::m_restArea
double m_restArea
The triangle rest area.
Definition: Fem2DElementTriangle.h:141
SurgSim::Physics::Fem2DElementTriangle::m_ek
SurgSim::Math::Vector3d m_ek
Batoz variable .
Definition: Fem2DElementTriangle.h:172
SurgSim::Physics::Fem2DElementTriangle::getThickness
double getThickness() const
Gets the triangle's thickness.
Definition: Fem2DElementTriangle.cpp:77
SurgSim::Physics::Fem2DElementTriangle::m_lij_sqr
SurgSim::Math::Vector3d m_lij_sqr
Batoz variable .
Definition: Fem2DElementTriangle.h:167
SurgSim::Physics::Fem2DElementTriangle::batozDhxDxi
std::array< double, 9 > batozDhxDxi(double xi, double eta) const
Batoz derivative dHx/dxi.
Definition: Fem2DElementTriangle.cpp:819
SurgSim::Physics::Fem2DElementTriangle::m_integral_dT_d
SurgSim::Math::Matrix m_integral_dT_d
Plate mass matrix: integral terms related to the dof .
Definition: Fem2DElementTriangle.h:183
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Physics::Fem2DElementTriangle::computeLocalPlateMass
void computeLocalPlateMass(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *localMassMatrix)
Computes the triangle's local plate part mass matrix.
Definition: Fem2DElementTriangle.cpp:139
SurgSim::Physics::Fem2DElementTriangle::computeLocalMembraneMass
void computeLocalMembraneMass(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *localMassMatrix)
Computes the triangle's local membrane part mass matrix.
Definition: Fem2DElementTriangle.cpp:123
SurgSim::Physics::Fem2DElementTriangle::batozDhyDeta
std::array< double, 9 > batozDhyDeta(double xi, double eta) const
Batoz derivative dHy/deta.
Definition: Fem2DElementTriangle.cpp:882
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes.
Definition: Macros.h:21