All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
22 
23 namespace SurgSim
24 {
25 
26 namespace Physics
27 {
28 
46 {
47  typedef Eigen::Matrix<double, 3, 3> Matrix33Type;
48 
49  typedef Eigen::Matrix<double, 3, 6> Matrix36Type;
50  typedef Eigen::Matrix<double, 6, 6> Matrix66Type;
51 
52  typedef Eigen::Matrix<double, 3, 9> Matrix39Type;
53  typedef Eigen::Matrix<double, 9, 9> Matrix99Type;
54 
55 public:
59  explicit Fem2DElementTriangle(std::array<size_t, 3> nodeIds);
60 
63  void setThickness(double thickness);
64 
67  double getThickness() const;
68 
72  virtual void initialize(const SurgSim::Math::OdeState& state) override;
73 
77  virtual double getVolume(const SurgSim::Math::OdeState& state) const override;
78 
86  virtual void addForce(const SurgSim::Math::OdeState& state, SurgSim::Math::Vector* F,
87  double scale = 1.0) override;
88 
96  virtual void addMass(const SurgSim::Math::OdeState& state, SurgSim::Math::Matrix* M,
97  double scale = 1.0) override;
98 
108  virtual void addDamping(const SurgSim::Math::OdeState& state, SurgSim::Math::Matrix* D,
109  double scale = 1.0) override;
110 
119  virtual void addStiffness(const SurgSim::Math::OdeState& state, SurgSim::Math::Matrix* K,
120  double scale = 1.0) override;
121 
133 
144  virtual void addMatVec(const SurgSim::Math::OdeState& state, double alphaM, double alphaD, double alphaK,
146 
148  const SurgSim::Math::OdeState& state,
149  const SurgSim::Math::Vector& naturalCoordinate) const;
150 
152  const SurgSim::Math::OdeState& state,
153  const SurgSim::Math::Vector& cartesianCoordinate) const override;
154 
155 protected:
160 
164  void computeStiffness(const SurgSim::Math::OdeState& state,
165  Eigen::Matrix<double, 18, 18>* k);
166 
170  void computeMass(const SurgSim::Math::OdeState& state, Eigen::Matrix<double, 18, 18>* m);
171 
173  Eigen::Matrix<double, 18, 1> m_x0;
174 
177 
179  Eigen::Matrix<double, 18, 18> m_M;
181  Eigen::Matrix<double, 18, 18> m_MLocal;
183  Eigen::Matrix<double, 18, 18> m_K;
185  Eigen::Matrix<double, 18, 18> m_KLocal;
186 
188  double m_restArea;
189 
191  double m_thickness;
192 
196 
201 
214  SurgSim::Math::Vector3d m_bk; //< 3/4 xij yij/lij2
215  SurgSim::Math::Vector3d m_ck; //< (1/4 xij^2 - 1/2 yij^2)/lij^2
217  SurgSim::Math::Vector3d m_ek; //< (1/4 yij^2 - 1/2 xij^2)/lij^2
218  //...and more variables for the derivatives
219  SurgSim::Math::Vector3d m_Pk; //< -6xij/lij^2 = 6 m_ak
220  SurgSim::Math::Vector3d m_qk; //< 3xijyij/lij^2 = 4 m_bk
221  SurgSim::Math::Vector3d m_tk; //< -6yij/lij^2 = 6 m_dk
222  SurgSim::Math::Vector3d m_rk; //< 3yij^2/lij^2
226  std::array<double, 9> batozDhxDxi(double xi, double neta) const;
230  std::array<double, 9> batozDhxDneta(double xi, double neta) const;
234  std::array<double, 9> batozDhyDxi(double xi, double neta) const;
238  std::array<double, 9> batozDhyDneta(double xi, double neta) const;
242  Matrix39Type batozStrainDisplacement(double xi, double neta) const;
243 };
244 
245 } // namespace Physics
246 
247 } // namespace SurgSim
248 
249 #endif // SURGSIM_PHYSICS_FEM2DELEMENTTRIANGLE_H
Eigen::Matrix< double, 9, 9 > Matrix99Type
Definition: Fem2DElementTriangle.h:53
void computeShapeFunctionsParameters(const SurgSim::Math::OdeState &restState)
Compute the various shape functions (membrane and plate deformations) parameters. ...
Definition: Fem2DElementTriangle.cpp:405
std::array< double, 9 > batozDhxDneta(double xi, double neta) const
Batoz derivative dHx/dneta.
Definition: Fem2DElementTriangle.cpp:537
virtual double getVolume(const SurgSim::Math::OdeState &state) const override
Gets the element's volume based on the input state.
Definition: Fem2DElementTriangle.cpp:65
Eigen::Matrix< double, 18, 18 > m_MLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem2DElementTriangle.h:181
Eigen::Matrix< double, 3, 9 > Matrix39Type
Definition: Fem2DElementTriangle.h:52
virtual void addFMDK(const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, SurgSim::Math::Matrix *M, SurgSim::Math::Matrix *D, SurgSim::Math::Matrix *K) override
Adds the element's force vector, mass, stiffness and damping matrices (computed for a given state) in...
Definition: Fem2DElementTriangle.cpp:125
double m_thickness
Thickness of the element.
Definition: Fem2DElementTriangle.h:191
SurgSim::Math::Vector3d m_ek
Definition: Fem2DElementTriangle.h:217
virtual SurgSim::Math::Vector computeCartesianCoordinate(const SurgSim::Math::OdeState &state, const SurgSim::Math::Vector &naturalCoordinate) const
Computes a given natural coordinate in cartesian coordinates.
Definition: Fem2DElementTriangle.cpp:379
double m_restArea
The triangle rest area.
Definition: Fem2DElementTriangle.h:188
void setThickness(double thickness)
Sets the triangle's thickness.
Definition: Fem2DElementTriangle.cpp:52
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Math::Matrix33d m_membraneShapeFunctionsParameters
Membrane (in-plane) deformation.
Definition: Fem2DElementTriangle.h:200
void computeMass(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *m)
Computes the triangle's mass matrix.
Definition: Fem2DElementTriangle.cpp:171
2D FemElement based on a triangle with a constant thickness
Definition: Fem2DElementTriangle.h:45
SurgSim::Math::Vector3d m_lij_sqr
Definition: Fem2DElementTriangle.h:212
virtual void addForce(const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, double scale=1.0) override
Adds the element's force (computed for a given state) to a complete system force vector F (assembly) ...
Definition: Fem2DElementTriangle.cpp:97
virtual void addMass(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *M, double scale=1.0) override
Adds the element's mass matrix M (computed for a given state) to a complete system mass matrix M (ass...
Definition: Fem2DElementTriangle.cpp:109
OdeState defines the state y of an ode of 2nd order of the form M(x,v).a = F(x, v) with boundary cond...
Definition: OdeState.h:34
Base class for all Fem Element (1D, 2D, 3D) It handles the node ids to which it is connected and requ...
Definition: FemElement.h:42
SurgSim::Math::Vector3d m_yij
Definition: Fem2DElementTriangle.h:211
virtual void addMatVec(const SurgSim::Math::OdeState &state, double alphaM, double alphaD, double alphaK, const SurgSim::Math::Vector &x, SurgSim::Math::Vector *F)
Adds the element's matrix-vector contribution F += (alphaM.M + alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly)
Definition: Fem2DElementTriangle.cpp:140
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:67
Matrix39Type batozStrainDisplacement(double xi, double neta) const
Batoz strain displacement matrix evaluated at a given point.
Definition: Fem2DElementTriangle.cpp:597
std::array< double, 9 > batozDhyDneta(double xi, double neta) const
Batoz derivative dHy/dneta.
Definition: Fem2DElementTriangle.cpp:577
SurgSim::Math::Vector3d m_bk
Definition: Fem2DElementTriangle.h:214
Eigen::Matrix< double, 18, 18 > m_KLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem2DElementTriangle.h:185
std::array< double, 9 > batozDhyDxi(double xi, double neta) const
Batoz derivative dHy/dxi.
Definition: Fem2DElementTriangle.cpp:557
SurgSim::Math::Vector3d m_tk
Definition: Fem2DElementTriangle.h:221
Eigen::Matrix< double, 18, 18 > m_M
Mass matrix (in global coordinate frame)
Definition: Fem2DElementTriangle.h:179
Eigen::Matrix< double, 6, 6 > Matrix66Type
Definition: Fem2DElementTriangle.h:50
Eigen::Matrix< double, 3, 3 > Matrix33Type
Definition: Fem2DElementTriangle.h:47
SurgSim::Math::Matrix33d m_initialRotation
Initial rotation matrix for the element.
Definition: Fem2DElementTriangle.h:176
SurgSim::Math::Vector3d m_qk
Definition: Fem2DElementTriangle.h:220
Eigen::Matrix< double, 18, 1 > m_x0
The element's rest state.
Definition: Fem2DElementTriangle.h:173
SurgSim::Math::Vector3d m_dk
Definition: Fem2DElementTriangle.h:216
Eigen::Matrix< double, 3, 6 > Matrix36Type
Definition: Fem2DElementTriangle.h:49
SurgSim::Math::Vector3d m_rk
Definition: Fem2DElementTriangle.h:222
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
double getThickness() const
Gets the triangle's thickness.
Definition: Fem2DElementTriangle.cpp:60
SurgSim::Math::Vector3d m_ck
Definition: Fem2DElementTriangle.h:215
SurgSim::Math::Vector3d m_ak
Definition: Fem2DElementTriangle.h:213
virtual void initialize(const SurgSim::Math::OdeState &state) override
Initializes the FemElement once everything has been set.
Definition: Fem2DElementTriangle.cpp:74
virtual void addDamping(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *D, double scale=1.0) override
Adds the element's damping matrix D (= -df/dv) (computed for a given state) to a complete system damp...
Definition: Fem2DElementTriangle.cpp:114
SurgSim::Math::Vector3d m_Pk
Definition: Fem2DElementTriangle.h:219
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
Eigen::Matrix< double, 18, 18 > m_K
Stiffness matrix (in global coordinate frame)
Definition: Fem2DElementTriangle.h:183
void computeStiffness(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 18, 18 > *k)
Computes the triangle's stiffness matrix.
Definition: Fem2DElementTriangle.cpp:259
virtual void addStiffness(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *K, double scale=1.0) override
Adds the element's stiffness matrix K (= -df/dx) (computed for a given state) to a complete system st...
Definition: Fem2DElementTriangle.cpp:119
virtual 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:397
SurgSim::Math::Vector3d m_xij
Thin-plate (bending/twisting) specific data structure DOF simulated: (z, thetaX, thetaY) "A Study Of ...
Definition: Fem2DElementTriangle.h:210
void computeInitialRotation(const SurgSim::Math::OdeState &state)
Computes the triangle element's initial rotation.
Definition: Fem2DElementTriangle.cpp:347
Fem2DElementTriangle(std::array< size_t, 3 > nodeIds)
Constructor.
Definition: Fem2DElementTriangle.cpp:42
std::array< double, 9 > batozDhxDxi(double xi, double neta) const
Batoz derivative dHx/dxi.
Definition: Fem2DElementTriangle.cpp:516