Fem3DElementCube.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PHYSICS_FEM3DELEMENTCUBE_H
#define SURGSIM_PHYSICS_FEM3DELEMENTCUBE_H
#include <array>
#include "SurgSim/Physics/FemElement.h"
#include "SurgSim/Math/GaussLegendreQuadrature.h"
namespace SurgSim
{
namespace Physics
{
SURGSIM_STATIC_REGISTRATION(Fem3DElementCube);
class Fem3DElementCube : public FemElement
{
public:
Fem3DElementCube();
explicit Fem3DElementCube(std::array<size_t, 8> nodeIds);
explicit Fem3DElementCube(std::shared_ptr<FemElementStructs::FemElementParameter> elementData);
SURGSIM_CLASSNAME(SurgSim::Physics::Fem3DElementCube)
void initialize(const SurgSim::Math::OdeState& state) override;
double getVolume(const SurgSim::Math::OdeState& state) const override;
SurgSim::Math::Vector computeCartesianCoordinate(const SurgSim::Math::OdeState& state,
const SurgSim::Math::Vector& naturalCoordinate) const override;
SurgSim::Math::Vector computeNaturalCoordinate(const SurgSim::Math::OdeState& state,
const SurgSim::Math::Vector& cartesianCoordinate) const override;
protected:
void initializeMembers();
void buildConstitutiveMaterialMatrix(Eigen::Matrix<double, 6, 6>* constitutiveMatrix);
void computeStiffness(const SurgSim::Math::OdeState& state,
Eigen::Matrix<double, 6, 24>* strain,
Eigen::Matrix<double, 6, 24>* stress,
SurgSim::Math::Matrix* k);
void computeMass(const SurgSim::Math::OdeState& state, SurgSim::Math::Matrix* m);
void doUpdateFMDK(const Math::OdeState& state, int options) override;
void addStrainStressStiffnessAtPoint(const SurgSim::Math::OdeState& state,
const SurgSim::Math::gaussQuadraturePoint& epsilon,
const SurgSim::Math::gaussQuadraturePoint& eta,
const SurgSim::Math::gaussQuadraturePoint& mu,
Eigen::Matrix<double, 6, 24>* strain,
Eigen::Matrix<double, 6, 24>* stress,
SurgSim::Math::Matrix* k);
void addMassMatrixAtPoint(const SurgSim::Math::OdeState& state,
const SurgSim::Math::gaussQuadraturePoint& epsilon,
const SurgSim::Math::gaussQuadraturePoint& eta,
const SurgSim::Math::gaussQuadraturePoint& mu,
SurgSim::Math::Matrix* m);
void evaluateJ(const SurgSim::Math::OdeState& state, double epsilon, double eta, double mu,
SurgSim::Math::Matrix33d* J,
SurgSim::Math::Matrix33d* Jinv,
double* detJ) const;
void evaluateStrainDisplacement(double epsilon, double eta, double mu, const SurgSim::Math::Matrix33d& Jinv,
Eigen::Matrix<double, 6, 24>* B) const;
double m_restVolume;
std::array<double, 8> m_shapeFunctionsEpsilonSign;
std::array<double, 8> m_shapeFunctionsEtaSign;
std::array<double, 8> m_shapeFunctionsMuSign;
double shapeFunction(size_t i, double epsilon, double eta, double mu) const;
double dShapeFunctiondepsilon(size_t i, double epsilon, double eta, double mu) const;
double dShapeFunctiondeta(size_t i, double epsilon, double eta, double mu) const;
double dShapeFunctiondmu(size_t i, double epsilon, double eta, double mu) const;
Eigen::Matrix<double, 24, 1> m_elementRestPosition;
Eigen::Matrix<double, 6, 24> m_strain;
Eigen::Matrix<double, 6, 24> m_stress;
Eigen::Matrix<double, 6, 6> m_constitutiveMaterial;
};
} // namespace Physics
} // namespace SurgSim
#endif // SURGSIM_PHYSICS_FEM3DELEMENTCUBE_H
FemElement.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::Fem3DElementCube::computeStiffness
void computeStiffness(const SurgSim::Math::OdeState &state, Eigen::Matrix< double, 6, 24 > *strain, Eigen::Matrix< double, 6, 24 > *stress, SurgSim::Math::Matrix *k)
Computes the cube stiffness matrix along with the strain and stress matrices.
Definition: Fem3DElementCube.cpp:142
SurgSim::Physics::Fem3DElementCube::addStrainStressStiffnessAtPoint
void addStrainStressStiffnessAtPoint(const SurgSim::Math::OdeState &state, const SurgSim::Math::gaussQuadraturePoint &epsilon, const SurgSim::Math::gaussQuadraturePoint &eta, const SurgSim::Math::gaussQuadraturePoint &mu, Eigen::Matrix< double, 6, 24 > *strain, Eigen::Matrix< double, 6, 24 > *stress, SurgSim::Math::Matrix *k)
Helper method to evaluate strain-stress and stiffness integral terms with a discrete sum using a Gaus...
Definition: Fem3DElementCube.cpp:266
SurgSim::Physics::Fem3DElementCube::addMassMatrixAtPoint
void addMassMatrixAtPoint(const SurgSim::Math::OdeState &state, const SurgSim::Math::gaussQuadraturePoint &epsilon, const SurgSim::Math::gaussQuadraturePoint &eta, const SurgSim::Math::gaussQuadraturePoint &mu, SurgSim::Math::Matrix *m)
Helper method to evaluate mass integral terms with a discrete sum using a Gauss quadrature rule...
Definition: Fem3DElementCube.cpp:289
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
SurgSim::Physics::Fem3DElementCube::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: Fem3DElementCube.cpp:418
SurgSim::Physics::Fem3DElementCube::m_elementRestPosition
Eigen::Matrix< double, 24, 1 > m_elementRestPosition
The cube rest state (nodes ordered by m_nodeIds)
Definition: Fem3DElementCube.h:224
SurgSim::Physics::Fem3DElementCube::evaluateStrainDisplacement
void evaluateStrainDisplacement(double epsilon, double eta, double mu, const SurgSim::Math::Matrix33d &Jinv, Eigen::Matrix< double, 6, 24 > *B) const
Helper method to evaluate the strain-displacement matrix at a given 3D parametric location c...
Definition: Fem3DElementCube.cpp:212
SurgSim::Math::OdeState
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
SurgSim::Physics::Fem3DElementCube::Fem3DElementCube
Fem3DElementCube()
Constructor.
Definition: Fem3DElementCube.cpp:35
SurgSim::Physics::Fem3DElementCube::initializeMembers
void initializeMembers()
Initializes variables needed before Initialize() is called.
Definition: Fem3DElementCube.cpp:58
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::Fem3DElementCube::m_shapeFunctionsMuSign
std::array< double, 8 > m_shapeFunctionsMuSign
Definition: Fem3DElementCube.h:168
SurgSim::Physics::Fem3DElementCube::dShapeFunctiondeta
double dShapeFunctiondeta(size_t i, double epsilon, double eta, double mu) const
Shape functions derivative .
Definition: Fem3DElementCube.cpp:383
GaussLegendreQuadrature.h
Definitions of a n-point Gaussian quadrature rule (a.k.a.
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
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
SurgSim::Physics::Fem3DElementCube
Class for Fem Element 3D based on a cube volume discretization.
Definition: Fem3DElementCube.h:42
SurgSim::Physics::Fem3DElementCube::doUpdateFMDK
void doUpdateFMDK(const Math::OdeState &state, int options) override
Update the FemElement based on the given state.
Definition: Fem3DElementCube.cpp:128
SurgSim::Physics::Fem3DElementCube::shapeFunction
double shapeFunction(size_t i, double epsilon, double eta, double mu) const
Shape functions .
Definition: Fem3DElementCube.cpp:367
SurgSim::Physics::Fem3DElementCube::m_shapeFunctionsEpsilonSign
std::array< double, 8 > m_shapeFunctionsEpsilonSign
Definition: Fem3DElementCube.h:166
SurgSim::Physics::Fem3DElementCube::m_constitutiveMaterial
Eigen::Matrix< double, 6, 6 > m_constitutiveMaterial
Constitutive material matrix (Hooke&#39;s law in this case) defines the relationship between stress and s...
Definition: Fem3DElementCube.h:231
SurgSim::Physics::Fem3DElementCube::m_shapeFunctionsEtaSign
std::array< double, 8 > m_shapeFunctionsEtaSign
Definition: Fem3DElementCube.h:167
SurgSim::Physics::Fem3DElementCube::buildConstitutiveMaterialMatrix
void buildConstitutiveMaterialMatrix(Eigen::Matrix< double, 6, 6 > *constitutiveMatrix)
Build the constitutive material 6x6 matrix.
Definition: Fem3DElementCube.cpp:252
SurgSim::Physics::Fem3DElementCube::initialize
void initialize(const SurgSim::Math::OdeState &state) override
Initializes the element once everything has been set.
Definition: Fem3DElementCube.cpp:64
SurgSim::Physics::Fem3DElementCube::dShapeFunctiondepsilon
double dShapeFunctiondepsilon(size_t i, double epsilon, double eta, double mu) const
Shape functions derivative .
Definition: Fem3DElementCube.cpp:375
SurgSim::Physics::Fem3DElementCube::getVolume
double getVolume(const SurgSim::Math::OdeState &state) const override
Gets the element volume based on the input state (in m-3)
Definition: Fem3DElementCube.cpp:320
SurgSim::Physics::Fem3DElementCube::computeMass
void computeMass(const SurgSim::Math::OdeState &state, SurgSim::Math::Matrix *m)
Computes the cube mass matrix.
Definition: Fem3DElementCube.cpp:96
SurgSim::Physics::Fem3DElementCube::evaluateJ
void evaluateJ(const SurgSim::Math::OdeState &state, double epsilon, double eta, double mu, SurgSim::Math::Matrix33d *J, SurgSim::Math::Matrix33d *Jinv, double *detJ) const
Helper method to evaluate matrix J = d(x,y,z)/d(epsilon,eta,mu) at a given 3D parametric location J e...
Definition: Fem3DElementCube.cpp:168
SurgSim::Math::Matrix33d
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
SurgSim::Physics::Fem3DElementCube::dShapeFunctiondmu
double dShapeFunctiondmu(size_t i, double epsilon, double eta, double mu) const
Shape functions derivative .
Definition: Fem3DElementCube.cpp:391
SurgSim::Physics::Fem3DElementCube::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: Fem3DElementCube.cpp:399
SurgSim::Physics::Fem3DElementCube::m_restVolume
double m_restVolume
Cube rest volume.
Definition: Fem3DElementCube.h:156
SurgSim::Physics::Fem3DElementCube::m_stress
Eigen::Matrix< double, 6, 24 > m_stress
Stress matrix (usually noted )
Definition: Fem3DElementCube.h:229
SurgSim::Math::gaussQuadraturePoint
1D Gauss-Legendre quadrature
Definition: GaussLegendreQuadrature.h:32
SurgSim::Physics::Fem3DElementCube::m_strain
Eigen::Matrix< double, 6, 24 > m_strain
Strain matrix (usually noted )
Definition: Fem3DElementCube.h:227