Go to the documentation of this file.
16 #ifndef SURGSIM_PHYSICS_FEMREPRESENTATION_H
17 #define SURGSIM_PHYSICS_FEMREPRESENTATION_H
35 class FemPlyReaderDelegate;
58 virtual void loadFem(
const std::string& filename) = 0;
70 void addFemElement(
const std::shared_ptr<FemElement> element);
81 std::shared_ptr<FemElement>
getFemElement(
size_t femElementId);
112 void update(
double dt)
override;
147 bool useGlobalMassMatrix =
false,
bool useGlobalStiffnessMatrix =
false,
230 #endif // SURGSIM_PHYSICS_FEMREPRESENTATION_H
std::shared_ptr< FemElement > getFemElement(size_t femElementId)
Retrieves a given FemElement from its id.
Definition: FemRepresentation.cpp:170
void updateComplianceMatrix(const SurgSim::Math::OdeState &state)
Updates the compliance matrix using nodes transformation (useful for compliance warping)
Definition: FemRepresentation.cpp:312
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
void computeFMDK(const SurgSim::Math::OdeState &state) override
Evaluation of , , and .
Definition: FemRepresentation.cpp:411
void addGravityForce(SurgSim::Math::Vector *f, const SurgSim::Math::OdeState &state, double scale=1.0)
Adds the gravity force to f (given a state)
Definition: FemRepresentation.cpp:537
void setRayleighDampingMass(double massCoef)
Sets the Rayleigh mass parameter.
Definition: FemRepresentation.cpp:207
double massCoefficient
Definition: FemRepresentation.h:213
virtual void loadFem(const std::string &filename)=0
Loads the FEM file into an Fem class data structure.
void addRayleighDampingForce(SurgSim::Math::Vector *f, const SurgSim::Math::OdeState &state, bool useGlobalMassMatrix=false, bool useGlobalStiffnessMatrix=false, double scale=1.0)
Adds the Rayleigh damping forces.
Definition: FemRepresentation.cpp:479
void beforeUpdate(double dt) override
Preprocessing done before the update call.
Definition: FemRepresentation.cpp:212
void computeF(const SurgSim::Math::OdeState &state) override
Evaluation of the RHS function for a given state.
Definition: FemRepresentation.cpp:328
virtual void setFemElementType(const std::string &type)
Sets the FemElement type pulled from the object factory.
Definition: FemRepresentation.cpp:64
double getRayleighDampingStiffness() const
Gets the Rayleigh stiffness parameter.
Definition: FemRepresentation.cpp:192
FemRepresentation(const std::string &name)
Constructor.
Definition: FemRepresentation.cpp:39
double stiffnessCoefficient
Definition: FemRepresentation.h:214
Finite Element Model (a.k.a FEM) is a deformable model (a set of nodes connected by FemElement).
Definition: FemRepresentation.h:46
void updateFMDK(const SurgSim::Math::OdeState &state, int options) override
Update the OdeEquation (and support data) based on the given state.
Definition: FemRepresentation.cpp:467
void setIsInitialComplianceMatrixComputed(bool flag)
Sets the flag keeping track of the initial compliance matrix calculation (compliance warping case)
Definition: FemRepresentation.cpp:565
bool getComplianceWarping() const
Get the compliance warping flag (default = false)
Definition: FemRepresentation.cpp:275
struct SurgSim::Physics::FemRepresentation::@3 m_rayleighDamping
Rayleigh damping parameters (massCoefficient and stiffnessCoefficient) D = massCoefficient....
const std::string & getFemElementType() const
Gets the FemElement type pulled from the object factory.
Definition: FemRepresentation.cpp:70
bool m_useComplianceWarping
Are we using Compliance Warping or not ?
Definition: FemRepresentation.h:217
void addFemElement(const std::shared_ptr< FemElement > element)
Adds a FemElement.
Definition: FemRepresentation.cpp:160
Definition: CompoundShapeToGraphics.cpp:29
void computeK(const SurgSim::Math::OdeState &state) override
Evaluation of for a given state.
Definition: FemRepresentation.cpp:394
void addFemElementsForce(SurgSim::Math::Vector *f, const SurgSim::Math::OdeState &state, double scale=1.0)
Adds the FemElements forces to f (given a state)
Definition: FemRepresentation.cpp:527
virtual ~FemRepresentation()
Destructor.
Definition: FemRepresentation.cpp:60
A generic (size_t index, Vector coordinate) pair.
Definition: IndexedLocalCoordinate.h:29
void setRayleighDampingStiffness(double stiffnessCoef)
Sets the Rayleigh stiffness parameter.
Definition: FemRepresentation.cpp:202
const SurgSim::Math::Matrix & getComplianceMatrix() const override
Gets the compliance matrix associated with motion.
Definition: FemRepresentation.cpp:293
size_t getNumFemElements() const
Gets the number of FemElement.
Definition: FemRepresentation.cpp:165
bool isInitialComplianceMatrixComputed() const
Gets the flag keeping track of the initial compliance matrix calculation (compliance warping case)
Definition: FemRepresentation.cpp:560
std::vector< std::shared_ptr< FemElement > > m_femElements
FemElements.
Definition: FemRepresentation.h:199
void computeM(const SurgSim::Math::OdeState &state) override
Evaluation of the LHS matrix for a given state.
Definition: FemRepresentation.cpp:344
void update(double dt) override
Update the representation state to the current time step.
Definition: FemRepresentation.cpp:222
virtual SurgSim::Math::Matrix getNodeTransformation(const SurgSim::Math::OdeState &state, size_t nodeId)
Retrieves a specific node transformation (useful for compliance warping)
Definition: FemRepresentation.cpp:304
void computeD(const SurgSim::Math::OdeState &state) override
Evaluation of for a given state.
Definition: FemRepresentation.cpp:355
Math::Matrix applyCompliance(const Math::OdeState &state, const Math::Matrix &b) override
Calculate the product C.b where C is the compliance matrix with boundary conditions.
Definition: FemRepresentation.cpp:280
double getRayleighDampingMass() const
Gets the Rayleigh mass parameter.
Definition: FemRepresentation.cpp:197
std::vector< double > m_massPerNode
Useful information per node.
Definition: FemRepresentation.h:196
void setComplianceWarping(bool useComplianceWarping)
Set the compliance warping flag.
Definition: FemRepresentation.cpp:268
SurgSim::Math::Matrix m_complianceWarpingMatrix
The compliance warping matrix if compliance warping in use.
Definition: FemRepresentation.h:221
bool m_isInitialComplianceMatrixComputed
For compliance warping: Is the initial compliance matrix computed ?
Definition: FemRepresentation.h:219
bool isValidCoordinate(const SurgSim::DataStructures::IndexedLocalCoordinate &coordinate) const
Determines whether the associated coordinate is valid.
Definition: FemRepresentation.cpp:176
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
std::string m_femElementType
The FemElement factory parameter invoked in doInitialize() when using a MeshAsset either with LoadFem...
Definition: FemRepresentation.h:205
double getTotalMass() const
Gets the total mass of the fem.
Definition: FemRepresentation.cpp:182
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: FemRepresentation.cpp:75
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
Eigen::SparseMatrix< double > m_complianceWarpingTransformation
The system-size transformation matrix. It contains nodes transformation on the diagonal blocks.
Definition: FemRepresentation.h:224