iMSTK
Interactive Medical Simulation Toolkit
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
imstk::PbdConstraint Class Referenceabstract

Base Constraint class for Position based dynamics constraints. More...

#include <imstkPbdConstraint.h>

Inheritance diagram for imstk::PbdConstraint:
Inheritance graph
[legend]

Public Types

enum  SolverType { xPBD = 0, PBD }
 Type of solvers.
 

Public Member Functions

virtual const std::string getTypeName () const =0
 
virtual bool computeValueAndGradient (PbdState &bodies, double &c, std::vector< Vec3d > &dcdx)=0
 Compute value and gradient of the constraint. More...
 
std::vector< PbdParticleId > & getParticles ()
 Get the vertex indices of the constraint.
 
bool getCorrectVelocity () const
 Get/Set whether velocity should be corrected for this constraint.
 
void setCorrectVelocity (const bool correctVelocity)
 
const Vec3d & getGradient (const int i) const
 Get gradient given the particle index in constraint.
 
double getForce (const double dt) const
 Get the force magnitude, valid after solving lambda Only valid with xpbd.
 
double getConstraintC () const
 Get constraint value C (how much the constraint is violated)
 
double getLambda () const
 Get constraint value C (how much the constraint is violated)
 
virtual double getRestValue () const
 Get reference constraint value. This value will have different context depending on the constraint being used.
 
void zeroOutLambda ()
 Zero's out the lagrange multplier before integration only used for xpbd, must be called before solving.
 
virtual void projectConstraint (PbdState &bodies, const double dt, const SolverType &type)
 Update positions by projecting constraints.
 
virtual void correctVelocity (PbdState &bodies, const double dt)
 Correct velocities according to friction and restitution Corrects according to the gradient direction.
 
double computeGeneralizedInvMass (const PbdState &bodies, const size_t particleIndex) const
 Compute generalized inverse mass of the particle. Note perf sensitive function. It has been intentionally inlined. More...
 
double computeGeneralizedInvMass (const PbdState &bodies, const size_t particleIndex, const Vec3d &r) const
 Compute generalized inverse mass of the particle. More...
 
double getRestitution () const
 Get/Set restitution.
 
void setRestitution (const double restitution)
 
double getFriction () const
 Get/Set friction.
 
void setFriction (const double friction)
 
double getStiffness () const
 Get/Set the stiffness.
 
void setStiffness (const double stiffness)
 
double getCompliance () const
 Get/Set the compliance This function is also provided in case users need 0 compliance.
 
void setCompliance (const double compliance)
 

Protected Member Functions

 PbdConstraint (const size_t numParticles)
 

Protected Attributes

std::vector< PbdParticleIdm_particles
 body, particle index
 
std::vector< Vec3d > m_dcdx
 Normalized constraint gradients (per particle)
 
double m_stiffness = 1.0
 used in PBD, [0, 1]
 
double m_compliance = 1e-7
 used in xPBD, inverse of Stiffness
 
double m_lambda = 0.0
 Lagrange multiplier.
 
double m_C = 0.0
 Constraint Value.
 
double m_friction = 0.0
 
double m_restitution = 0.0
 
bool m_correctVelocity = false
 

Detailed Description

Base Constraint class for Position based dynamics constraints.

Definition at line 24 of file imstkPbdConstraint.h.

Member Function Documentation

◆ computeGeneralizedInvMass() [1/2]

double imstk::PbdConstraint::computeGeneralizedInvMass ( const PbdState bodies,
const size_t  particleIndex 
) const
inline

Compute generalized inverse mass of the particle. Note perf sensitive function. It has been intentionally inlined.

Parameters
bodiesof the system
particleIndexIndex of the particle in the constraint to compute from

Definition at line 155 of file imstkPbdConstraint.h.

Here is the caller graph for this function:

◆ computeGeneralizedInvMass() [2/2]

double imstk::PbdConstraint::computeGeneralizedInvMass ( const PbdState bodies,
const size_t  particleIndex,
const Vec3d &  r 
) const
inline

Compute generalized inverse mass of the particle.

Parameters
bodiesof the system
particleIndexIndex of the particle in the constraint to compute from
rOptional local support point for which to cross when particle is oriented

Definition at line 167 of file imstkPbdConstraint.h.

◆ computeValueAndGradient()

virtual bool imstk::PbdConstraint::computeValueAndGradient ( PbdState bodies,
double &  c,
std::vector< Vec3d > &  dcdx 
)
pure virtual

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