sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes > Class Template Reference

Component computing forces between a pair of simulated body. More...

#include <PairInteractionForceField.h>

Inheritance diagram for sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >:

Inheritance graph
[legend]
Collaboration diagram for sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >:

Collaboration graph
[legend]

Public Types

typedef TDataTypes DataTypes
typedef DataTypes::VecCoord VecCoord
typedef DataTypes::VecDeriv VecDeriv
typedef DataTypes::Coord Coord
typedef DataTypes::Deriv Deriv

Public Member Functions

 PairInteractionForceField (MechanicalState< DataTypes > *mm1=NULL, MechanicalState< DataTypes > *mm2=NULL)
virtual ~PairInteractionForceField ()
virtual void init ()
 Initialization method called at graph modification, during bottom-up traversal.
MechanicalState< DataTypes > * getMState1 ()
 Retrieve the associated MechanicalState.
BaseMechanicalState * getMechModel1 ()
 Get the first MechanicalState.
MechanicalState< DataTypes > * getMState2 ()
 Retrieve the associated MechanicalState.
BaseMechanicalState * getMechModel2 ()
 Get the first MechanicalState.
BaseMechanicalState * getMState (sofa::core::objectmodel::BaseContext *context, std::string path)
 Retrieve the associated MechanicalState given the path.
virtual std::string getTemplateName () const
 Get the template type names (if any) used to instantiate this object.
Vector operations
virtual void addForce ()
 Given the current position and velocity states, update the current force vector by computing and adding the forces associated with this ForceField.
virtual void addDForce (double kFactor, double bFactor)
 Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().
virtual void addDForceV (double kFactor, double bFactor)
 Same as addDForce(), except the velocity vector should be used instead of dx.
virtual double getPotentialEnergy ()
 Get the potential energy associated to this ForceField.
virtual void addForce (VecDeriv &f1, VecDeriv &f2, const VecCoord &x1, const VecCoord &x2, const VecDeriv &v1, const VecDeriv &v2)=0
 Given the current position and velocity states, update the current force vector by computing and adding the forces associated with this ForceField.
virtual void addDForce (VecDeriv &df1, VecDeriv &df2, const VecDeriv &dx1, const VecDeriv &dx2)
 Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().
virtual void addDForce (VecDeriv &df1, VecDeriv &df2, const VecDeriv &dx1, const VecDeriv &dx2, double kFactor, double bFactor)
 Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().
virtual double getPotentialEnergy (const VecCoord &x1, const VecCoord &x2)=0
 Get the potential energy associated to this ForceField.

Static Public Member Functions

template<class T >
static bool canCreate (T *&obj, objectmodel::BaseContext *context, objectmodel::BaseObjectDescription *arg)
 Pre-construction check method called by ObjectFactory.
template<class T >
static void create (T *&obj, core::objectmodel::BaseContext *context, core::objectmodel::BaseObjectDescription *arg)
 Construction method called by ObjectFactory.
static std::string templateName (const PairInteractionForceField< DataTypes > *=NULL)

Protected Attributes

sofa::core::objectmodel::Data
< std::string > 
_object1
sofa::core::objectmodel::Data
< std::string > 
_object2
MechanicalState< DataTypes > * mstate1
MechanicalState< DataTypes > * mstate2

Detailed Description

template<class TDataTypes>
class sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >

Component computing forces between a pair of simulated body.

This class define the abstract API common to interaction force fields between a pair of bodies using a given type of DOFs.

Definition at line 55 of file PairInteractionForceField.h.


Member Typedef Documentation

template<class TDataTypes >
typedef DataTypes::Coord sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::Coord

template<class TDataTypes >
typedef TDataTypes sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::DataTypes

template<class TDataTypes >
typedef DataTypes::Deriv sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::Deriv

template<class TDataTypes >
typedef DataTypes::VecCoord sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::VecCoord

template<class TDataTypes >
typedef DataTypes::VecDeriv sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::VecDeriv


Constructor & Destructor Documentation

Definition at line 51 of file PairInteractionForceField.inl.

Definition at line 59 of file PairInteractionForceField.inl.


Member Function Documentation

template<class DataTypes >
void sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::addDForce ( VecDeriv &  df1,
VecDeriv &  df2,
const VecDeriv &  dx1,
const VecDeriv &  dx2,
double  kFactor,
double  bFactor 
) [inline, virtual]

Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().

The derivative should be directly derived from the computations done by addForce. Any forces neglected in addDForce will be integrated explicitly (i.e. using its value at the beginning of the timestep).

If the ForceField can be represented as a matrix, this method computes $ df += kFactor K dx + bFactor B dx $

This method must be implemented by the component, and is usually called by the generic PairInteractionForceField::addDForce() method.

To support old components that implement the deprecated addForce method without scalar coefficients, it defaults to using a temporaty vector to compute $ K dx $ and then manually scaling all values by kFactor.

: Add a better way to get the current VecId of dx

: Add a better way to get the current VecId of dx

Reimplemented in sofa::component::forcefield::PenalityContactForceField< DataTypes >, sofa::component::forcefield::RegularGridSpringForceField< DataTypes >, sofa::component::forcefield::SparseGridSpringForceField< DataTypes >, sofa::component::forcefield::StiffSpringForceField< DataTypes >, sofa::component::forcefield::VectorSpringForceField< DataTypes >, sofa::component::forcefield::PenalityContactForceField< CudaVec3fTypes >, and sofa::component::forcefield::StiffSpringForceField< sofa::defaulttype::StdVectorTypes >.

Definition at line 202 of file PairInteractionForceField.inl.

References sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::addDForce(), sofa::core::componentmodel::behavior::MechanicalState< TDataTypes >::getVecDeriv(), sofa::core::componentmodel::behavior::BaseMechanicalState::VecId::index, sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::mstate1, sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::mstate2, sofa::core::componentmodel::behavior::BaseMechanicalState::VecId::null(), sofa::core::componentmodel::behavior::BaseMechanicalState::VecId::V_DERIV, sofa::core::componentmodel::behavior::BaseMechanicalState::VecId::V_FIRST_DYNAMIC_INDEX, sofa::core::componentmodel::behavior::BaseMechanicalState::vAlloc(), sofa::core::componentmodel::behavior::BaseMechanicalState::vAvail(), sofa::core::componentmodel::behavior::BaseMechanicalState::vFree(), and sofa::core::componentmodel::behavior::BaseMechanicalState::vOp().

template<class DataTypes >
void sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::addDForce ( VecDeriv &  df1,
VecDeriv &  df2,
const VecDeriv &  dx1,
const VecDeriv &  dx2 
) [inline, virtual]

Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().

The derivative should be directly derived from the computations done by addForce. Any forces neglected in addDForce will be integrated explicitly (i.e. using its value at the beginning of the timestep).

If the ForceField can be represented as a matrix, this method computes $ df += K dx $

This method must be implemented by the component, and is usually called by the generic PairInteractionForceField::addDForce() method.

Deprecated:
to more efficiently accumulate contributions from all terms of the system equation, a new addDForce method allowing to pass two coefficients for the stiffness and damping terms should now be used.

Reimplemented in sofa::component::forcefield::FrameSpringForceField< DataTypes >, sofa::component::forcefield::JointSpringForceField< DataTypes >, and sofa::component::forcefield::SpringForceField< DataTypes >.

Definition at line 196 of file PairInteractionForceField.inl.

template<class DataTypes >
void sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::addDForce ( double  kFactor,
double  bFactor 
) [inline, virtual]

Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().

The derivative should be directly derived from the computations done by addForce. Any forces neglected in addDForce will be integrated explicitly (i.e. using its value at the beginning of the timestep).

If the ForceField can be represented as a matrix, this method computes $ df += kFactor K dx + bFactor B dx $

This method retrieves the force and dx vector from the two MechanicalState and call the internal addDForce(VecDeriv&,VecDeriv&,const VecDeriv&,const VecDeriv&,double,double) method implemented by the component.

Implements sofa::core::componentmodel::behavior::BaseForceField.

Definition at line 178 of file PairInteractionForceField.inl.

Referenced by sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::addDForce(), and sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::addDForceV().

template<class DataTypes >
void sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::addDForceV ( double  kFactor,
double  bFactor 
) [inline, virtual]

template<class TDataTypes >
virtual void sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::addForce ( VecDeriv &  f1,
VecDeriv &  f2,
const VecCoord &  x1,
const VecCoord &  x2,
const VecDeriv &  v1,
const VecDeriv &  v2 
) [pure virtual]

template<class DataTypes >
void sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::addForce (  )  [inline, virtual]

template<class TDataTypes >
template<class T >
static bool sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::canCreate ( T *&  obj,
objectmodel::BaseContext *  context,
objectmodel::BaseObjectDescription *  arg 
) [inline, static]

Pre-construction check method called by ObjectFactory.

Check that DataTypes matches the MechanicalState.

Reimplemented from sofa::core::objectmodel::BaseObject.

Definition at line 196 of file PairInteractionForceField.h.

Referenced by sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::canCreate().

template<class TDataTypes >
template<class T >
static void sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::create ( T *&  obj,
core::objectmodel::BaseContext *  context,
core::objectmodel::BaseObjectDescription *  arg 
) [inline, static]

template<class TDataTypes >
BaseMechanicalState* sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::getMechModel1 (  )  [inline, virtual]

Get the first MechanicalState.

Todo:
Rename to getMechState1()
Todo:
Replace with an accessor to a list of states, as an InteractionForceField can be applied to more than two.

Implements sofa::core::componentmodel::behavior::InteractionForceField.

Definition at line 74 of file PairInteractionForceField.h.

template<class TDataTypes >
BaseMechanicalState* sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::getMechModel2 (  )  [inline, virtual]

Get the first MechanicalState.

Todo:
Rename to getMechState2()
Todo:
Replace with an accessor to a list of states, as an InteractionForceField can be applied to more than two.

Implements sofa::core::componentmodel::behavior::InteractionForceField.

Definition at line 77 of file PairInteractionForceField.h.

template<class DataTypes >
BaseMechanicalState * sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::getMState ( sofa::core::objectmodel::BaseContext *  context,
std::string  path 
) [inline]

template<class TDataTypes >
MechanicalState<DataTypes>* sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::getMState1 (  )  [inline]

Retrieve the associated MechanicalState.

Definition at line 73 of file PairInteractionForceField.h.

template<class TDataTypes >
MechanicalState<DataTypes>* sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::getMState2 (  )  [inline]

Retrieve the associated MechanicalState.

Definition at line 76 of file PairInteractionForceField.h.

template<class TDataTypes >
virtual double sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::getPotentialEnergy ( const VecCoord &  x1,
const VecCoord &  x2 
) [pure virtual]

template<class DataTypes >
double sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::getPotentialEnergy (  )  [inline, virtual]

Get the potential energy associated to this ForceField.

Used to extimate the total energy of the system by some post-stabilization techniques.

This method retrieves the x vector from the MechanicalState and call the internal getPotentialEnergy(const VecCoord&,const VecCoord&) method implemented by the component.

Implements sofa::core::componentmodel::behavior::BaseForceField.

Reimplemented in sofa::component::forcefield::MeshSpringForceField< DataTypes >, sofa::component::interactionforcefield::RepulsiveSpringForceField< DataTypes >, and sofa::component::forcefield::MeshSpringForceField< sofa::defaulttype::StdVectorTypes >.

Definition at line 243 of file PairInteractionForceField.inl.

template<class TDataTypes >
virtual std::string sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::getTemplateName (  )  const [inline, virtual]

Get the template type names (if any) used to instantiate this object.

Reimplemented from sofa::core::objectmodel::Base.

Definition at line 243 of file PairInteractionForceField.h.

template<class DataTypes >
void sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::init (  )  [inline, virtual]

template<class TDataTypes >
static std::string sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::templateName ( const PairInteractionForceField< DataTypes > *  = NULL  )  [inline, static]


Field Documentation

template<class TDataTypes >
sofa::core::objectmodel::Data< std::string > sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::_object1 [protected]

Definition at line 254 of file PairInteractionForceField.h.

template<class TDataTypes >
sofa::core::objectmodel::Data< std::string > sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >::_object2 [protected]

Definition at line 255 of file PairInteractionForceField.h.


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

Generated on Sun Nov 23 04:23:31 2008 for Sofa by  doxygen 1.5.7.1