sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 > Class Template Reference

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

#include <MixedInteractionForceField.h>

Inheritance diagram for sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >:

Inheritance graph
[legend]
Collaboration diagram for sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >:

Collaboration graph
[legend]

Public Types

typedef TDataTypes1 DataTypes1
typedef DataTypes1::VecCoord VecCoord1
typedef DataTypes1::VecDeriv VecDeriv1
typedef DataTypes1::Coord Coord1
typedef DataTypes1::Deriv Deriv1
typedef TDataTypes2 DataTypes2
typedef DataTypes2::VecCoord VecCoord2
typedef DataTypes2::VecDeriv VecDeriv2
typedef DataTypes2::Coord Coord2
typedef DataTypes2::Deriv Deriv2

Public Member Functions

 MixedInteractionForceField (MechanicalState< DataTypes1 > *mm1=NULL, MechanicalState< DataTypes2 > *mm2=NULL)
virtual ~MixedInteractionForceField ()
virtual void init ()
 Initialization method called at graph modification, during bottom-up traversal.
MechanicalState< DataTypes1 > * getMState1 ()
 Retrieve the associated MechanicalState.
BaseMechanicalState * getMechModel1 ()
 Get the first MechanicalState.
MechanicalState< DataTypes2 > * getMState2 ()
 Retrieve the associated MechanicalState.
BaseMechanicalState * getMechModel2 ()
 Get the first MechanicalState.
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 (VecDeriv1 &f1, VecDeriv2 &f2, const VecCoord1 &x1, const VecCoord2 &x2, const VecDeriv1 &v1, const VecDeriv2 &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 (VecDeriv1 &df1, VecDeriv2 &df2, const VecDeriv1 &dx1, const VecDeriv2 &dx2)
 Compute the force derivative given a small displacement from the position and velocity used in the previous call to addForce().
virtual void addDForce (VecDeriv1 &df1, VecDeriv2 &df2, const VecDeriv1 &dx1, const VecDeriv2 &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 VecCoord1 &x1, const VecCoord2 &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 MixedInteractionForceField< DataTypes1, DataTypes2 > *=NULL)

Protected Attributes

MechanicalState< DataTypes1 > * mstate1
MechanicalState< DataTypes2 > * mstate2

Detailed Description

template<class TDataTypes1, class TDataTypes2>
class sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >

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 53 of file MixedInteractionForceField.h.


Member Typedef Documentation

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes1::Coord sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::Coord1

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes2::Coord sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::Coord2

template<class TDataTypes1 , class TDataTypes2 >
typedef TDataTypes1 sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::DataTypes1

Definition at line 56 of file MixedInteractionForceField.h.

template<class TDataTypes1 , class TDataTypes2 >
typedef TDataTypes2 sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::DataTypes2

Definition at line 61 of file MixedInteractionForceField.h.

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes1::Deriv sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::Deriv1

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes2::Deriv sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::Deriv2

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes1::VecCoord sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::VecCoord1

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes2::VecCoord sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::VecCoord2

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes1::VecDeriv sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::VecDeriv1

template<class TDataTypes1 , class TDataTypes2 >
typedef DataTypes2::VecDeriv sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::VecDeriv2


Constructor & Destructor Documentation

template<class DataTypes1 , class DataTypes2 >
sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::MixedInteractionForceField ( MechanicalState< DataTypes1 > *  mm1 = NULL,
MechanicalState< DataTypes2 > *  mm2 = NULL 
) [inline]

Definition at line 46 of file MixedInteractionForceField.inl.

template<class DataTypes1 , class DataTypes2 >
sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::~MixedInteractionForceField (  )  [inline, virtual]

Definition at line 52 of file MixedInteractionForceField.inl.


Member Function Documentation

template<class DataTypes1 , class DataTypes2 >
void sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::addDForce ( VecDeriv1 &  df1,
VecDeriv2 &  df2,
const VecDeriv1 &  dx1,
const VecDeriv2 &  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 MixedInteractionForceField::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

Definition at line 96 of file MixedInteractionForceField.inl.

References sofa::core::componentmodel::behavior::BaseMechanicalState::VecId::index.

template<class DataTypes1 , class DataTypes2 >
void sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::addDForce ( VecDeriv1 &  df1,
VecDeriv2 &  df2,
const VecDeriv1 &  dx1,
const VecDeriv2 &  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 MixedInteractionForceField::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::interactionforcefield::InteractionEllipsoidForceField< DataTypes1, DataTypes2 >.

Definition at line 90 of file MixedInteractionForceField.inl.

References sofa::core::objectmodel::Base::getClassName().

template<class DataTypes1 , class DataTypes2 >
void sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::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(VecDeriv1&,VecDeriv2&,const VecDeriv1&,const VecDeriv2&,double,double) method implemented by the component.

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

Definition at line 72 of file MixedInteractionForceField.inl.

References sofa::core::componentmodel::behavior::MechanicalState< TDataTypes >::getDx(), sofa::core::componentmodel::behavior::MechanicalState< TDataTypes >::getF(), sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::mstate1, and sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::mstate2.

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

Same as addDForce(), except the velocity vector should be used instead of dx.

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

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

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

Definition at line 81 of file MixedInteractionForceField.inl.

template<class TDataTypes1 , class TDataTypes2 >
virtual void sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::addForce ( VecDeriv1 &  f1,
VecDeriv2 &  f2,
const VecCoord1 &  x1,
const VecCoord2 &  x2,
const VecDeriv1 &  v1,
const VecDeriv2 &  v2 
) [pure virtual]

Given the current position and velocity states, update the current force vector by computing and adding the forces associated with this ForceField.

If the ForceField can be represented as a matrix, this method computes $ f += B v + K x $

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

Implemented in sofa::component::interactionforcefield::InteractionEllipsoidForceField< DataTypes1, DataTypes2 >.

template<class DataTypes1 , class DataTypes2 >
void sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::addForce (  )  [inline, virtual]

Given the current position and velocity states, update the current force vector by computing and adding the forces associated with this ForceField.

If the ForceField can be represented as a matrix, this method computes $ f += B v + K x $

This method retrieves the force, x and v vector from the two MechanicalState and call the internal addForce(VecDeriv&,VecDeriv&,const VecCoord&,const VecCoord&,const VecDeriv&,const VecDeriv&) method implemented by the component.

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

Definition at line 63 of file MixedInteractionForceField.inl.

template<class TDataTypes1 , class TDataTypes2 >
template<class T >
static bool sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::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 191 of file MixedInteractionForceField.h.

Referenced by sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::canCreate().

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

template<class TDataTypes1 , class TDataTypes2 >
BaseMechanicalState* sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::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 75 of file MixedInteractionForceField.h.

template<class TDataTypes1 , class TDataTypes2 >
BaseMechanicalState* sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::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 78 of file MixedInteractionForceField.h.

template<class TDataTypes1 , class TDataTypes2 >
MechanicalState<DataTypes1>* sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::getMState1 (  )  [inline]

Retrieve the associated MechanicalState.

Definition at line 74 of file MixedInteractionForceField.h.

template<class TDataTypes1 , class TDataTypes2 >
MechanicalState<DataTypes2>* sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::getMState2 (  )  [inline]

Retrieve the associated MechanicalState.

Definition at line 77 of file MixedInteractionForceField.h.

template<class TDataTypes1 , class TDataTypes2 >
virtual double sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::getPotentialEnergy ( const VecCoord1 &  x1,
const VecCoord2 &  x2 
) [pure 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 must be implemented by the component, and is usually called by the generic ForceField::getPotentialEnergy() method.

Implemented in sofa::component::interactionforcefield::InteractionEllipsoidForceField< DataTypes1, DataTypes2 >.

template<class DataTypes1 , class DataTypes2 >
double sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::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.

Definition at line 130 of file MixedInteractionForceField.inl.

References sofa::core::componentmodel::behavior::MechanicalState< TDataTypes >::getX(), sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::mstate1, and sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::mstate2.

template<class TDataTypes1 , class TDataTypes2 >
virtual std::string sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::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 215 of file MixedInteractionForceField.h.

template<class DataTypes1 , class DataTypes2 >
void sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >::init (  )  [inline, virtual]

Initialization method called at graph modification, during bottom-up traversal.

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

Definition at line 57 of file MixedInteractionForceField.inl.

template<class TDataTypes1 , class TDataTypes2 >
static std::string sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::templateName ( const MixedInteractionForceField< DataTypes1, DataTypes2 > *  = NULL  )  [inline, static]


Field Documentation

template<class TDataTypes1 , class TDataTypes2 >
MechanicalState<DataTypes1>* sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::mstate1 [protected]

template<class TDataTypes1 , class TDataTypes2 >
MechanicalState<DataTypes2>* sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >::mstate2 [protected]


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

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