SOFA API  6a688117
Open source framework for multi-physics simuation
sofa::simulation::common::MechanicalOperations Class Reference

#include <MechanicalOperations.h>

Public Attributes

core::MechanicalParams mparams
 
core::ConstraintParams cparams
 
core::objectmodel::BaseContextctx
 

Protected Attributes

VisitorExecuteFunc executeVisitor
 

Public Member Functions

 MechanicalOperations (const core::MechanicalParams *mparams, core::objectmodel::BaseContext *ctx, bool precomputedTraversalOrder=false)
 
 MechanicalOperations (const core::ExecParams *params, core::objectmodel::BaseContext *ctx, bool precomputedTraversalOrder=false)
 
core::MechanicalParamsoperator-> ()
 
 operator const core::MechanicalParams * ()
 
void solveConstraint (sofa::core::MultiVecId id, core::ConstraintParams::ConstOrder order)
 
Mechanical Vector operations
void propagateDx (core::MultiVecDerivId dx, bool ignore_flag=false)
 Propagate the given displacement through all mappings. More...
 
void propagateDxAndResetDf (core::MultiVecDerivId dx, core::MultiVecDerivId df)
 Propagate the given displacement through all mappings and reset the current force delta. More...
 
void propagateX (core::MultiVecCoordId x)
 Propagate the given position through all mappings. More...
 
void propagateV (core::MultiVecDerivId v)
 Propagate the given velocity through all mappings. More...
 
void propagateXAndV (core::MultiVecCoordId x, core::MultiVecDerivId v)
 Propagate the given position and velocity through all mappings. More...
 
void propagateXAndResetF (core::MultiVecCoordId x, core::MultiVecDerivId f)
 Propagate the given position through all mappings and reset the current force delta. More...
 
void projectPosition (core::MultiVecCoordId x, SReal time=0.0)
 Apply projective constraints to the given position vector. More...
 
void projectVelocity (core::MultiVecDerivId v, SReal time=0.0)
 Apply projective constraints to the given velocity vector. More...
 
void projectResponse (core::MultiVecDerivId dx, double **W=nullptr)
 Apply projective constraints to the given vector. More...
 
void projectPositionAndVelocity (core::MultiVecCoordId x, core::MultiVecDerivId v, double time=0.0)
 Apply projective constraints to the given position and velocity vectors. More...
 
void addMdx (core::MultiVecDerivId res, core::MultiVecDerivId dx, SReal factor=1.0)
 res += factor M.dx More...
 
void integrateVelocity (core::MultiVecDerivId res, core::ConstMultiVecCoordId x, core::ConstMultiVecDerivId v, SReal dt)
 res = x + v.dt More...
 
void accFromF (core::MultiVecDerivId a, core::ConstMultiVecDerivId f)
 
void computeEnergy (SReal &kineticEnergy, SReal &potentialEnergy)
 Compute Energy. More...
 
void computeForce (core::MultiVecDerivId result, bool clear=true, bool accumulate=true, bool neglectingCompliance=true)
 Compute the current force (given the latest propagated position and velocity) More...
 
void computeDf (core::MultiVecDerivId df, bool clear=true, bool accumulate=true)
 Compute the current force delta (given the latest propagated displacement) More...
 
void computeDfV (core::MultiVecDerivId df, bool clear=true, bool accumulate=true)
 Compute the current force delta (given the latest propagated velocity) More...
 
void addMBKdx (core::MultiVecDerivId df, SReal m, SReal b, SReal k, bool clear=true, bool accumulate=true)
 accumulate $ df += (m M + b B + k K) dx $ (given the latest propagated displacement) More...
 
void addMBKv (core::MultiVecDerivId df, SReal m, SReal b, SReal k, bool clear=true, bool accumulate=true)
 accumulate $ df += (m M + b B + k K) velocity $ More...
 
void addSeparateGravity (SReal dt, core::MultiVecDerivId result=core::VecDerivId::velocity())
 Add dt*Gravity to the velocity. More...
 
void computeContactForce (core::MultiVecDerivId result)
 
void computeContactDf (core::MultiVecDerivId df)
 
void computeAcc (SReal t, core::MultiVecDerivId a, core::MultiVecCoordId x, core::MultiVecDerivId v)
 Compute a(x,v) at time t. Parameters x and v not const due to propagation through mappings. More...
 
void computeForce (SReal t, core::MultiVecDerivId f, core::MultiVecCoordId x, core::MultiVecDerivId v, bool neglectingCompliance=true)
 Compute f(x,v) at time t. Parameters x and v not const due to propagation through mappings. More...
 
void computeContactAcc (SReal t, core::MultiVecDerivId a, core::MultiVecCoordId x, core::MultiVecDerivId v)
 
Matrix operations using LinearSolver components
void m_resetSystem ()
 
void m_setSystemMBKMatrix (SReal mFact, SReal bFact, SReal kFact)
 
void m_setSystemRHVector (core::MultiVecDerivId v)
 
void m_setSystemLHVector (core::MultiVecDerivId v)
 
void m_solveSystem ()
 
void m_print (std::ostream &out)
 
Matrix operations
void getMatrixDimension (std::size_t *const, std::size_t *const, sofa::core::behavior::MultiMatrixAccessor *matrix=nullptr)
 
void getMatrixDimension (sofa::core::behavior::MultiMatrixAccessor *matrix)
 
void addMBK_ToMatrix (const sofa::core::behavior::MultiMatrixAccessor *matrix, SReal mFact, SReal bFact, SReal kFact)
 
void addSubMBK_ToMatrix (const sofa::core::behavior::MultiMatrixAccessor *matrix, const helper::vector< unsigned > &subMatrixIndex, SReal mFact, SReal bFact, SReal kFact)
 
void multiVector2BaseVector (core::ConstMultiVecId src, defaulttype::BaseVector *dest, const sofa::core::behavior::MultiMatrixAccessor *matrix)
 
void baseVector2MultiVector (const defaulttype::BaseVector *src, core::MultiVecId dest, const sofa::core::behavior::MultiMatrixAccessor *matrix)
 
void multiVectorPeqBaseVector (core::MultiVecDerivId dest, const defaulttype::BaseVector *src, const sofa::core::behavior::MultiMatrixAccessor *matrix)
 
Debug operations
void print (core::ConstMultiVecId v, std::ostream &out)
 Dump the content of the given vector. More...
 
void printWithElapsedTime (core::ConstMultiVecId v, unsigned time, std::ostream &out=std::cerr)
 

Protected Member Functions

void setX (core::MultiVecCoordId &v)
 
void setX (core::ConstMultiVecCoordId &v)
 
void setV (core::MultiVecDerivId &v)
 
void setV (core::ConstMultiVecDerivId &v)
 
void setF (core::MultiVecDerivId &v)
 
void setF (core::ConstMultiVecDerivId &v)
 
void setDx (core::MultiVecDerivId &v)
 
void setDx (core::ConstMultiVecDerivId &v)
 
void setDf (core::MultiVecDerivId &v)
 
void setDf (core::ConstMultiVecDerivId &v)
 

Attribute details

core::ConstraintParams sofa::simulation::common::MechanicalOperations::cparams
core::objectmodel::BaseContext* sofa::simulation::common::MechanicalOperations::ctx
VisitorExecuteFunc sofa::simulation::common::MechanicalOperations::executeVisitor
protected
core::MechanicalParams sofa::simulation::common::MechanicalOperations::mparams

Constructor details

sofa::simulation::common::MechanicalOperations::MechanicalOperations ( const core::MechanicalParams mparams,
core::objectmodel::BaseContext ctx,
bool  precomputedTraversalOrder = false 
)
sofa::simulation::common::MechanicalOperations::MechanicalOperations ( const core::ExecParams params,
core::objectmodel::BaseContext ctx,
bool  precomputedTraversalOrder = false 
)

Function details

void sofa::simulation::common::MechanicalOperations::accFromF ( core::MultiVecDerivId  a,
core::ConstMultiVecDerivId  f 
)

a = M^-1 . f

Parameters
fa = M^-1 . f
void sofa::simulation::common::MechanicalOperations::addMBK_ToMatrix ( const sofa::core::behavior::MultiMatrixAccessor matrix,
SReal  mFact,
SReal  bFact,
SReal  kFact 
)
void sofa::simulation::common::MechanicalOperations::addMBKdx ( core::MultiVecDerivId  df,
SReal  m,
SReal  b,
SReal  k,
bool  clear = true,
bool  accumulate = true 
)

accumulate $ df += (m M + b B + k K) dx $ (given the latest propagated displacement)

void sofa::simulation::common::MechanicalOperations::addMBKv ( core::MultiVecDerivId  df,
SReal  m,
SReal  b,
SReal  k,
bool  clear = true,
bool  accumulate = true 
)

accumulate $ df += (m M + b B + k K) velocity $

void sofa::simulation::common::MechanicalOperations::addMdx ( core::MultiVecDerivId  res,
core::MultiVecDerivId  dx,
SReal  factor = 1.0 
)

res += factor M.dx

void sofa::simulation::common::MechanicalOperations::addSeparateGravity ( SReal  dt,
core::MultiVecDerivId  result = core::VecDerivId::velocity() 
)

Add dt*Gravity to the velocity.

void sofa::simulation::common::MechanicalOperations::addSubMBK_ToMatrix ( const sofa::core::behavior::MultiMatrixAccessor matrix,
const helper::vector< unsigned > &  subMatrixIndex,
SReal  mFact,
SReal  bFact,
SReal  kFact 
)
void sofa::simulation::common::MechanicalOperations::baseVector2MultiVector ( const defaulttype::BaseVector src,
core::MultiVecId  dest,
const sofa::core::behavior::MultiMatrixAccessor matrix 
)
void sofa::simulation::common::MechanicalOperations::computeAcc ( SReal  t,
core::MultiVecDerivId  a,
core::MultiVecCoordId  x,
core::MultiVecDerivId  v 
)

Compute a(x,v) at time t. Parameters x and v not const due to propagation through mappings.

void sofa::simulation::common::MechanicalOperations::computeContactAcc ( SReal  t,
core::MultiVecDerivId  a,
core::MultiVecCoordId  x,
core::MultiVecDerivId  v 
)
void sofa::simulation::common::MechanicalOperations::computeContactDf ( core::MultiVecDerivId  df)
void sofa::simulation::common::MechanicalOperations::computeContactForce ( core::MultiVecDerivId  result)
void sofa::simulation::common::MechanicalOperations::computeDf ( core::MultiVecDerivId  df,
bool  clear = true,
bool  accumulate = true 
)

Compute the current force delta (given the latest propagated displacement)

void sofa::simulation::common::MechanicalOperations::computeDfV ( core::MultiVecDerivId  df,
bool  clear = true,
bool  accumulate = true 
)

Compute the current force delta (given the latest propagated velocity)

void sofa::simulation::common::MechanicalOperations::computeEnergy ( SReal &  kineticEnergy,
SReal &  potentialEnergy 
)

Compute Energy.

Apply projective constraints to the given velocity vector.

void sofa::simulation::common::MechanicalOperations::computeForce ( core::MultiVecDerivId  result,
bool  clear = true,
bool  accumulate = true,
bool  neglectingCompliance = true 
)

Compute the current force (given the latest propagated position and velocity)

void sofa::simulation::common::MechanicalOperations::computeForce ( SReal  t,
core::MultiVecDerivId  f,
core::MultiVecCoordId  x,
core::MultiVecDerivId  v,
bool  neglectingCompliance = true 
)

Compute f(x,v) at time t. Parameters x and v not const due to propagation through mappings.

void sofa::simulation::common::MechanicalOperations::getMatrixDimension ( std::size_t * const  nbRow,
std::size_t * const  nbCol,
sofa::core::behavior::MultiMatrixAccessor matrix = nullptr 
)
void sofa::simulation::common::MechanicalOperations::getMatrixDimension ( sofa::core::behavior::MultiMatrixAccessor matrix)
inline
void sofa::simulation::common::MechanicalOperations::integrateVelocity ( core::MultiVecDerivId  res,
core::ConstMultiVecCoordId  x,
core::ConstMultiVecDerivId  v,
SReal  dt 
)

res = x + v.dt

void sofa::simulation::common::MechanicalOperations::m_print ( std::ostream &  out)
void sofa::simulation::common::MechanicalOperations::m_resetSystem ( )
void sofa::simulation::common::MechanicalOperations::m_setSystemLHVector ( core::MultiVecDerivId  v)
void sofa::simulation::common::MechanicalOperations::m_setSystemMBKMatrix ( SReal  mFact,
SReal  bFact,
SReal  kFact 
)
void sofa::simulation::common::MechanicalOperations::m_setSystemRHVector ( core::MultiVecDerivId  v)
void sofa::simulation::common::MechanicalOperations::m_solveSystem ( )
void sofa::simulation::common::MechanicalOperations::multiVector2BaseVector ( core::ConstMultiVecId  src,
defaulttype::BaseVector dest,
const sofa::core::behavior::MultiMatrixAccessor matrix 
)
void sofa::simulation::common::MechanicalOperations::multiVectorPeqBaseVector ( core::MultiVecDerivId  dest,
const defaulttype::BaseVector src,
const sofa::core::behavior::MultiMatrixAccessor matrix 
)
sofa::simulation::common::MechanicalOperations::operator const core::MechanicalParams * ( )
inline
core::MechanicalParams* sofa::simulation::common::MechanicalOperations::operator-> ( )
inline
void sofa::simulation::common::MechanicalOperations::print ( core::ConstMultiVecId  v,
std::ostream &  out 
)

Dump the content of the given vector.

void sofa::simulation::common::MechanicalOperations::printWithElapsedTime ( core::ConstMultiVecId  v,
unsigned  time,
std::ostream &  out = std::cerr 
)
void sofa::simulation::common::MechanicalOperations::projectPosition ( core::MultiVecCoordId  x,
SReal  time = 0.0 
)

Apply projective constraints to the given position vector.

void sofa::simulation::common::MechanicalOperations::projectPositionAndVelocity ( core::MultiVecCoordId  x,
core::MultiVecDerivId  v,
double  time = 0.0 
)

Apply projective constraints to the given position and velocity vectors.

void sofa::simulation::common::MechanicalOperations::projectResponse ( core::MultiVecDerivId  dx,
double **  W = nullptr 
)

Apply projective constraints to the given vector.

void sofa::simulation::common::MechanicalOperations::projectVelocity ( core::MultiVecDerivId  v,
SReal  time = 0.0 
)

Apply projective constraints to the given velocity vector.

void sofa::simulation::common::MechanicalOperations::propagateDx ( core::MultiVecDerivId  dx,
bool  ignore_flag = false 
)

Propagate the given displacement through all mappings.

void sofa::simulation::common::MechanicalOperations::propagateDxAndResetDf ( core::MultiVecDerivId  dx,
core::MultiVecDerivId  df 
)

Propagate the given displacement through all mappings and reset the current force delta.

void sofa::simulation::common::MechanicalOperations::propagateV ( core::MultiVecDerivId  v)

Propagate the given velocity through all mappings.

void sofa::simulation::common::MechanicalOperations::propagateX ( core::MultiVecCoordId  x)

Propagate the given position through all mappings.

void sofa::simulation::common::MechanicalOperations::propagateXAndResetF ( core::MultiVecCoordId  x,
core::MultiVecDerivId  f 
)

Propagate the given position through all mappings and reset the current force delta.

void sofa::simulation::common::MechanicalOperations::propagateXAndV ( core::MultiVecCoordId  x,
core::MultiVecDerivId  v 
)

Propagate the given position and velocity through all mappings.

void sofa::simulation::common::MechanicalOperations::setDf ( core::MultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setDf ( core::ConstMultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setDx ( core::MultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setDx ( core::ConstMultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setF ( core::MultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setF ( core::ConstMultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setV ( core::MultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setV ( core::ConstMultiVecDerivId v)
protected
void sofa::simulation::common::MechanicalOperations::setX ( core::MultiVecCoordId v)
protected
void sofa::simulation::common::MechanicalOperations::setX ( core::ConstMultiVecCoordId v)
protected
void sofa::simulation::common::MechanicalOperations::solveConstraint ( sofa::core::MultiVecId  id,
core::ConstraintParams::ConstOrder  order 
)

Find all the Constraint present in the scene graph, build the constraint equation system, solve and apply the correction