iMSTK
Interactive Medical Simulation Toolkit
Public Types | Public Member Functions | Public Attributes | Protected Attributes | Friends | List of all members
imstk::PbdModelConfig Class Reference

Gives parameters for PBD simulation. More...

#include <imstkPbdModelConfig.h>

Public Types

enum  ConstraintGenType {
  Custom, Distance, FemTet, Volume,
  Area, Bend, Dihedral, ConstantDensity
}
 Gives the set of standard pbd constraint generation schemes/functors provided by iMSTK. Note, these do not correspond to constraint types as there may be multiple schemes for one constraint or even multiple constraints per scheme.
 

Public Member Functions

void enableConstraint (ConstraintGenType type, const double stiffness, const int bodyId=2)
 Enables a constraint of type defined by ConstraintGenType with given stiffness. If constraint of that type already exists, sets the stiffness on it. More...
 
void enableDistanceConstraint (const double stiffness, const double stretch, const int bodyId)
 Enables a Distance constraint on the body Will remove an existing distance constraint on the same body. More...
 
void enableBendConstraint (const double stiffness, const int stride, const bool restLength0=true, const int bodyId=2)
 Enables a bend constraint with given stiffness, stride, and flag for 0 rest length You may enable multiple with differing strides If constraint with same stride already exists, updates the stiffness and restLength0 on it. More...
 
void enableConstantDensityConstraint (const double stiffness, const double particleRadius, const double restDensity=6378.0, const int bodyId=2)
 Enables constant density constraint given the stiffness and particleSize. More...
 
void enableFemConstraint (PbdFemConstraint::MaterialType material, const int bodyId=2)
 Enable a Fem constraint with the material provided. More...
 
void enableFemConstraint (PbdFemConstraint::MaterialType material, double youngsModulus, double poissonRatio, const int bodyId)
 Enable a Fem constraint with the material provided and parameters. More...
 
void computeElasticConstants ()
 If lame parameters (mu+lambda) are given in femParams, then youngs modulus and poissons ratio are computed Conversely if youngs and poissons are given, lame parameters are computed.
 
void addPbdConstraintFunctor (std::shared_ptr< PbdConstraintFunctor > functor)
 Adds a functor to generate constraints. More...
 
void addPbdConstraintFunctor (std::function< void(PbdConstraintContainer &)> functor)
 
std::unordered_map< ConstraintGenType, std::vector< std::shared_ptr< PbdConstraintFunctor > > > & getFunctors ()
 
void setBodyDamping (const int bodyId, const double linearDampCoeff, const double angularDampCoeff=0.01)
 Set damping for a specific body 1.0 is fully damped/all velocity removed, 0.0 is no damping. More...
 
double getLinearDamping (const int bodyId)
 Returns global and per body damping multiplied together for a body 1.0 is fully damped/all velocity removed, 0.0 is no damping. More...
 
double getAngularDamping (const int bodyId)
 

Public Attributes

double m_linearDampingCoeff = 0.01
 Damping coefficient applied to linear velocity [0, 1].
 
double m_angularDampingCoeff = 0.01
 Damping coefficient applied to angular velcoity [0, 1].
 
unsigned int m_iterations = 10
 Internal constraints pbd solver iterations.
 
double m_dt = 0.01
 Time step size.
 
bool m_doPartitioning = true
 Does graph coloring to solve in parallel.
 
Vec3d m_gravity = Vec3d(0.0, -9.81, 0.0)
 Gravity acceleration.
 
std::shared_ptr< PbdFemConstraintConfigm_femParams
 
PbdConstraint::SolverType m_solverType = PbdConstraint::SolverType::xPBD
 
std::unordered_map< int, double > m_bodyLinearDampingCoeff
 Per body linear damping, Body id -> linear damping for given body [0, 1].
 
std::unordered_map< int, double > m_bodyAngularDampingCoeff
 Per body angular damping, Body id -> angular damping for given body [0, 1].
 
std::shared_ptr< DataTrackerm_dataTracker
 

Protected Attributes

std::unordered_map< ConstraintGenType, std::vector< std::shared_ptr< PbdConstraintFunctor > > > m_functors
 

Friends

class PbdModel
 

Detailed Description

Gives parameters for PBD simulation.

Definition at line 24 of file imstkPbdModelConfig.h.

Member Function Documentation

◆ addPbdConstraintFunctor()

void imstk::PbdModelConfig::addPbdConstraintFunctor ( std::shared_ptr< PbdConstraintFunctor functor)
inline

Adds a functor to generate constraints.

Template Parameters
Mustcontain operator(PbdConstraintContainer&), could be a PbdConstraintFunctor or std::function<void(PbdConstraintContainer&)>

Definition at line 110 of file imstkPbdModelConfig.h.

Here is the call graph for this function:

◆ enableBendConstraint()

void imstk::PbdModelConfig::enableBendConstraint ( const double  stiffness,
const int  stride,
const bool  restLength0 = true,
const int  bodyId = 2 
)

Enables a bend constraint with given stiffness, stride, and flag for 0 rest length You may enable multiple with differing strides If constraint with same stride already exists, updates the stiffness and restLength0 on it.

Parameters
stiffnessHow much constraint is enforced
strideDistance between vertex connections
restLength0When true rest length (and angle) are constrained to 0, useful when mesh initial/resting state is not 0 angled
bodyIdBody to add the constraint throughout, -1 applies to all bodies

Definition at line 129 of file imstkPbdModelConfig.cpp.

◆ enableConstantDensityConstraint()

void imstk::PbdModelConfig::enableConstantDensityConstraint ( const double  stiffness,
const double  particleRadius,
const double  restDensity = 6378.0,
const int  bodyId = 2 
)

Enables constant density constraint given the stiffness and particleSize.

Parameters
stiffnesshow much constraint is enforced
particleRadius,radiusof particle
bodyIdBody to add the constraint throughout, -1 applies to all bodies

Definition at line 153 of file imstkPbdModelConfig.cpp.

◆ enableConstraint()

void imstk::PbdModelConfig::enableConstraint ( ConstraintGenType  type,
const double  stiffness,
const int  bodyId = 2 
)

Enables a constraint of type defined by ConstraintGenType with given stiffness. If constraint of that type already exists, sets the stiffness on it.

Parameters
typeGeneration scheme type
stiffnessHow much constraint is enforced
bodyIdBody to add the constraint throughout, -1 applies to all bodies

Definition at line 59 of file imstkPbdModelConfig.cpp.

◆ enableDistanceConstraint()

void imstk::PbdModelConfig::enableDistanceConstraint ( const double  stiffness,
const double  stretch,
const int  bodyId 
)

Enables a Distance constraint on the body Will remove an existing distance constraint on the same body.

Parameters
stiffnessHow much constraint is enforced
stretchAllows to stretch or relax the material, the constraint restlength is multiplied by the strech factor
bodyIdBody to add the constraint

Definition at line 115 of file imstkPbdModelConfig.cpp.

◆ enableFemConstraint() [1/2]

void imstk::PbdModelConfig::enableFemConstraint ( PbdFemConstraint::MaterialType  material,
const int  bodyId = 2 
)

Enable a Fem constraint with the material provided.

Parameters
materialFEM model type
bodyIdBody to add the constraint throughout, -1 applies to all bodies This function uses the global deformable parameter object, its only provided for backwards compatibility, don't use it

Definition at line 172 of file imstkPbdModelConfig.cpp.

◆ enableFemConstraint() [2/2]

void imstk::PbdModelConfig::enableFemConstraint ( PbdFemConstraint::MaterialType  material,
double  youngsModulus,
double  poissonRatio,
const int  bodyId 
)

Enable a Fem constraint with the material provided and parameters.

Parameters
materialFEM model type
youngsModulusthe youngs modulus of the material
poissonRatiothe Poisson ration of the material
bodyIdBody to add the constraint throughout

Definition at line 189 of file imstkPbdModelConfig.cpp.

◆ getLinearDamping()

double imstk::PbdModelConfig::getLinearDamping ( const int  bodyId)

Returns global and per body damping multiplied together for a body 1.0 is fully damped/all velocity removed, 0.0 is no damping.

Parameters
bodyIdBody that is damped

Definition at line 217 of file imstkPbdModelConfig.cpp.

Here is the caller graph for this function:

◆ setBodyDamping()

void imstk::PbdModelConfig::setBodyDamping ( const int  bodyId,
const double  linearDampCoeff,
const double  angularDampCoeff = 0.01 
)

Set damping for a specific body 1.0 is fully damped/all velocity removed, 0.0 is no damping.

Parameters
bodyIdBody to damp
Howmuch to damp linear velocity
Howmuch to damp angular velocity

Definition at line 209 of file imstkPbdModelConfig.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_femParams

std::shared_ptr<PbdFemConstraintConfig> imstk::PbdModelConfig::m_femParams
Initial value:
=
std::make_shared<PbdFemConstraintConfig>(PbdFemConstraintConfig
{
0.0,
0.0,
1000.0,
0.2
})

Definition at line 153 of file imstkPbdModelConfig.h.


The documentation for this class was generated from the following files: