opensurgsim
Fem1DElementBeam.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_FEM1DELEMENTBEAM_H
17 #define SURGSIM_PHYSICS_FEM1DELEMENTBEAM_H
18 
19 #include <array>
20 
21 #include "SurgSim/Physics/FemElement.h"
22 
23 namespace SurgSim
24 {
25 
26 namespace Physics
27 {
28 
29 SURGSIM_STATIC_REGISTRATION(Fem1DElementBeam);
30 
38 {
39 public:
42 
46  explicit Fem1DElementBeam(std::array<size_t, 2> nodeIds);
47 
52  explicit Fem1DElementBeam(std::shared_ptr<FemElementStructs::FemElementParameter> elementData);
53 
54  SURGSIM_CLASSNAME(SurgSim::Physics::Fem1DElementBeam)
55 
56 
57  void setRadius(double radius);
59 
62  double getRadius() const;
63 
64  void initialize(const SurgSim::Math::OdeState& state) override;
65 
66  double getVolume(const SurgSim::Math::OdeState& state) const override;
67 
70  bool getShearingEnabled() const;
71 
76  void setShearingEnabled(bool enabled);
77 
79  const SurgSim::Math::OdeState& state,
80  const SurgSim::Math::Vector& naturalCoordinate) const override;
81 
83  const SurgSim::Math::OdeState& state,
84  const SurgSim::Math::Vector& cartesianCoordinate) const override;
85 
88 
89 protected:
91  void initializeMembers();
92 
97 
100  void computeStiffness(const SurgSim::Math::OdeState& state);
101 
104  void computeMass(const SurgSim::Math::OdeState& state);
105 
106  void doUpdateFMDK(const Math::OdeState& state, int options) override;
107 
109  Eigen::Matrix<double, 12, 1> m_x0;
110 
113 
115  Eigen::Matrix<double, 12, 12> m_MLocal;
117  Eigen::Matrix<double, 12, 12> m_KLocal;
118 
120  double m_restLength;
122  double m_radius;
124  double m_A;
130  double m_J;
131 };
132 
133 } // namespace Physics
134 
135 } // namespace SurgSim
136 
137 #endif // SURGSIM_PHYSICS_FEM1DELEMENTBEAM_H
void initializeMembers()
Initializes variables needed before Initialize() is called.
Definition: Fem1DElementBeam.cpp:91
void computeMass(const SurgSim::Math::OdeState &state)
Computes the beam&#39;s mass matrix.
Definition: Fem1DElementBeam.cpp:134
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
double m_J
Polar moment of inertia.
Definition: Fem1DElementBeam.h:130
const SurgSim::Math::Matrix33d & getInitialRotation() const
Definition: Fem1DElementBeam.cpp:129
void setRadius(double radius)
Sets the beam&#39;s circular cross-section radius.
Definition: Fem1DElementBeam.cpp:60
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::Matrix33d m_R0
Initial rotation matrix for the element.
Definition: Fem1DElementBeam.h:112
bool m_haveShear
Does this beam element have shear.
Definition: Fem1DElementBeam.h:126
double m_restLength
Rest length.
Definition: Fem1DElementBeam.h:120
void computeStiffness(const SurgSim::Math::OdeState &state)
Computes the beam&#39;s stiffness matrix.
Definition: Fem1DElementBeam.cpp:209
Eigen::Matrix< double, 12, 12 > m_KLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem1DElementBeam.h:117
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: Fem1DElementBeam.cpp:341
Fem1DElementBeam()
Constructor.
Definition: Fem1DElementBeam.cpp:35
1D FemElement based on a beam volume discretization with a fixed cross section
Definition: Fem1DElementBeam.h:37
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
double m_shearFactor
Shear factor (usually 5/8)
Definition: Fem1DElementBeam.h:128
double getRadius() const
Gets the beam&#39;s circular cross-section radius.
Definition: Fem1DElementBeam.cpp:68
void initialize(const SurgSim::Math::OdeState &state) override
Initialize the FemElement once everything has been set.
Definition: Fem1DElementBeam.cpp:104
double m_radius
radius for a circular Beam
Definition: Fem1DElementBeam.h:122
void setShearingEnabled(bool enabled)
Enables or disables shearing for the element.
Definition: Fem1DElementBeam.cpp:78
bool getShearingEnabled() const
Gets whether shearing is enabled for the element.
Definition: Fem1DElementBeam.cpp:73
void computeInitialRotation(const SurgSim::Math::OdeState &state)
Computes the beam element&#39;s initial rotation.
Definition: Fem1DElementBeam.cpp:301
Eigen::Matrix< double, 12, 12 > m_MLocal
Stiffness matrix (in local coordinate frame)
Definition: Fem1DElementBeam.h:115
double getVolume(const SurgSim::Math::OdeState &state) const override
Gets the element volume based on the input state (in m-3)
Definition: Fem1DElementBeam.cpp:83
Eigen::Matrix< double, 12, 1 > m_x0
The element&#39;s rest state.
Definition: Fem1DElementBeam.h:109
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
void doUpdateFMDK(const Math::OdeState &state, int options) override
Update the FemElement based on the given state.
Definition: Fem1DElementBeam.cpp:327
double m_A
Cross sectional area = PI.radius.radius if circular.
Definition: Fem1DElementBeam.h:124
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: Fem1DElementBeam.cpp:317