Fem3DElementTetrahedron.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_FEM3DELEMENTTETRAHEDRON_H
17 #define SURGSIM_PHYSICS_FEM3DELEMENTTETRAHEDRON_H
18 
19 #include <array>
20 
21 #include "SurgSim/Math/Matrix.h"
22 #include "SurgSim/Math/Vector.h"
23 #include "SurgSim/Physics/Fem.h"
25 
26 namespace SurgSim
27 {
28 
29 namespace Physics
30 {
31 SURGSIM_STATIC_REGISTRATION(Fem3DElementTetrahedron);
32 
42 {
43 public:
46 
53  explicit Fem3DElementTetrahedron(std::array<size_t, 4> nodeIds);
54 
62  explicit Fem3DElementTetrahedron(std::shared_ptr<FemElementStructs::FemElementParameter> elementData);
63 
65 
66  void initialize(const SurgSim::Math::OdeState& state) override;
67 
68  double getVolume(const SurgSim::Math::OdeState& state) const override;
69 
71  const SurgSim::Math::Vector& naturalCoordinate) const override;
72 
74  const SurgSim::Math::Vector& cartesianCoordinate) const override;
75 
76 protected:
78  void initializeMembers();
79 
80  void doUpdateFMDK(const Math::OdeState& state, int options) override;
81 
90  double* volume,
91  std::array<double, 4>* ai,
92  std::array<double, 4>* bi,
93  std::array<double, 4>* ci,
94  std::array<double, 4>* di) const;
95 
99  void computeStiffness(const SurgSim::Math::OdeState& state,
101 
105  void computeMass(const SurgSim::Math::OdeState& state,
107 
109  double m_restVolume;
111  std::array<double, 4> m_ai, m_bi, m_ci, m_di;
112 
114  Eigen::Matrix<double, 12, 1> m_x0;
115 
117  Eigen::Matrix<double, 6, 6> m_Em;
119  Eigen::Matrix<double, 6, 12> m_strain;
121  Eigen::Matrix<double, 6, 12> m_stress;
122 };
123 
124 } // namespace Physics
125 
126 } // namespace SurgSim
127 
128 #endif // SURGSIM_PHYSICS_FEM3DELEMENTTETRAHEDRON_H
Definition: CompoundShapeToGraphics.cpp:29
Eigen::Matrix< double, 6, 12 > m_strain
Strain matrix.
Definition: Fem3DElementTetrahedron.h:119
std::array< double, 4 > m_bi
Definition: Fem3DElementTetrahedron.h:111
Class for Fem Element 3D based on a tetrahedron volume discretization.
Definition: Fem3DElementTetrahedron.h:41
std::array< double, 4 > m_ai
Shape functions coefficients Ni(x,y,z) = 1/6V ( ai + x.bi + y.ci + z.di )
Definition: Fem3DElementTetrahedron.h:111
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
Eigen::Matrix< double, 12, 1 > m_x0
The tetrahedon rest state.
Definition: Fem3DElementTetrahedron.h:114
void computeShapeFunctions(const SurgSim::Math::OdeState &state, double *volume, std::array< double, 4 > *ai, std::array< double, 4 > *bi, std::array< double, 4 > *ci, std::array< double, 4 > *di) const
Computes the tetrahedron shape functions.
Definition: Fem3DElementTetrahedron.cpp:229
void initializeMembers()
Initializes variables needed before Initialize() is called.
Definition: Fem3DElementTetrahedron.cpp:73
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
Eigen::Matrix< double, 6, 12 > m_stress
Stress matrix.
Definition: Fem3DElementTetrahedron.h:121
void computeStiffness(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *k)
Computes the tetrahedron stiffness matrix.
Definition: Fem3DElementTetrahedron.cpp:171
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: Fem3DElementTetrahedron.cpp:353
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
void computeMass(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *m)
Computes the tetrahedron mass matrix.
Definition: Fem3DElementTetrahedron.cpp:126
Eigen::Matrix< double, 6, 6 > m_Em
Elasticity material matrix (contains the elastic properties of the material)
Definition: Fem3DElementTetrahedron.h:117
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
std::array< double, 4 > m_ci
Definition: Fem3DElementTetrahedron.h:111
Definitions of small fixed-size square matrix types.
std::array< double, 4 > m_di
Definition: Fem3DElementTetrahedron.h:111
Definitions of small fixed-size vector types.
double m_restVolume
Shape functions: Tetrahedron rest volume.
Definition: Fem3DElementTetrahedron.h:109
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: Fem3DElementTetrahedron.cpp:372
void doUpdateFMDK(const Math::OdeState &state, int options) override
Update the FemElement based on the given state.
Definition: Fem3DElementTetrahedron.cpp:78
void initialize(const SurgSim::Math::OdeState &state) override
Initialize the FemElement once everything has been set.
Definition: Fem3DElementTetrahedron.cpp:92
double getVolume(const SurgSim::Math::OdeState &state) const override
Gets the element volume based on the input state (in m-3)
Definition: Fem3DElementTetrahedron.cpp:210
Fem3DElementTetrahedron()
Constructor.
Definition: Fem3DElementTetrahedron.cpp:50