sofa::component::forcefield::SpringForceField< DataTypes > Class Template Reference

Define a set of springs between particles. More...

#include <SpringForceField.h>

Inheritance diagram for sofa::component::forcefield::SpringForceField< DataTypes >:

Inheritance graph
[legend]
Collaboration diagram for sofa::component::forcefield::SpringForceField< DataTypes >:

Collaboration graph
[legend]

Data Structures

class  Loader
class  Spring

Public Types

typedef
core::componentmodel::behavior::PairInteractionForceField
< DataTypes > 
Inherit
typedef DataTypes::VecCoord VecCoord
typedef DataTypes::VecDeriv VecDeriv
typedef DataTypes::Coord Coord
typedef DataTypes::Deriv Deriv
typedef Coord::value_type Real
typedef
core::componentmodel::behavior::MechanicalState
< DataTypes > 
MechanicalState

Public Member Functions

 SpringForceField (MechanicalState *object1, MechanicalState *object2, SReal _ks=100.0, SReal _kd=5.0)
 SpringForceField (SReal _ks=100.0, SReal _kd=5.0)
virtual void parse (core::objectmodel::BaseObjectDescription *arg)
 Parse the given description to assign values to this object's fields and potentially other parameters.
bool load (const char *filename)
core::componentmodel::behavior::MechanicalState
< DataTypes > * 
getObject1 ()
core::componentmodel::behavior::MechanicalState
< DataTypes > * 
getObject2 ()
virtual void init ()
 Initialization method called at graph modification, during bottom-up traversal.
virtual void addForce (VecDeriv &f1, VecDeriv &f2, const VecCoord &x1, const VecCoord &x2, const VecDeriv &v1, const VecDeriv &v2)
 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 double getPotentialEnergy (const VecCoord &, const VecCoord &)
 Get the potential energy associated to this ForceField.
SReal getStiffness ()
SReal getDamping ()
void setStiffness (SReal _ks)
void setDamping (SReal _kd)
void draw ()
 Render internal data of this object, for debugging purposes.
void clear (int reserve=0)
void addSpring (int m1, int m2, SReal ks, SReal kd, SReal initlen)

Protected Member Functions

void addSpringForce (SReal &potentialEnergy, VecDeriv &f1, const VecCoord &p1, const VecDeriv &v1, VecDeriv &f2, const VecCoord &p2, const VecDeriv &v2, int i, const Spring &spring)

Protected Attributes

SReal m_potentialEnergy
Data< SReal > ks
Data< SReal > kd
Data< sofa::helper::vector
< Spring > > 
springs
SpringForceFieldInternalData
< DataTypes > 
data

Friends

class SpringForceFieldInternalData< DataTypes >

Detailed Description

template<class DataTypes>
class sofa::component::forcefield::SpringForceField< DataTypes >

Define a set of springs between particles.

Definition at line 57 of file SpringForceField.h.


Member Typedef Documentation

template<class DataTypes >
typedef DataTypes::Coord sofa::component::forcefield::SpringForceField< DataTypes >::Coord

template<class DataTypes >
typedef DataTypes::Deriv sofa::component::forcefield::SpringForceField< DataTypes >::Deriv

template<class DataTypes >
typedef Coord::value_type sofa::component::forcefield::SpringForceField< DataTypes >::Real

template<class DataTypes >
typedef DataTypes::VecCoord sofa::component::forcefield::SpringForceField< DataTypes >::VecCoord

template<class DataTypes >
typedef DataTypes::VecDeriv sofa::component::forcefield::SpringForceField< DataTypes >::VecDeriv


Constructor & Destructor Documentation

template<class DataTypes >
sofa::component::forcefield::SpringForceField< DataTypes >::SpringForceField ( MechanicalState *  object1,
MechanicalState *  object2,
SReal  _ks = 100.0,
SReal  _kd = 5.0 
) [inline]

Definition at line 53 of file SpringForceField.inl.

template<class DataTypes >
sofa::component::forcefield::SpringForceField< DataTypes >::SpringForceField ( SReal  _ks = 100.0,
SReal  _kd = 5.0 
) [inline]

Definition at line 62 of file SpringForceField.inl.


Member Function Documentation

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< 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 from sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >.

Definition at line 145 of file SpringForceField.inl.

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::addForce ( VecDeriv &  f1,
VecDeriv &  f2,
const VecCoord &  x1,
const VecCoord &  x2,
const VecDeriv &  v1,
const VecDeriv &  v2 
) [inline, virtual]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::addSpring ( int  m1,
int  m2,
SReal  ks,
SReal  kd,
SReal  initlen 
) [inline]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::addSpringForce ( SReal &  potentialEnergy,
VecDeriv &  f1,
const VecCoord &  p1,
const VecDeriv &  v1,
VecDeriv &  f2,
const VecCoord &  p2,
const VecDeriv &  v2,
int  i,
const Spring &  spring 
) [inline, protected]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::clear ( int  reserve = 0  )  [inline]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::draw (  )  [inline, virtual]

template<class DataTypes >
SReal sofa::component::forcefield::SpringForceField< DataTypes >::getDamping (  )  [inline]

template<class DataTypes >
virtual double sofa::component::forcefield::SpringForceField< DataTypes >::getPotentialEnergy ( const VecCoord &  x1,
const VecCoord &  x2 
) [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 must be implemented by the component, and is usually called by the generic ForceField::getPotentialEnergy() method.

Implements sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >.

Definition at line 120 of file SpringForceField.h.

References sofa::component::forcefield::SpringForceField< DataTypes >::m_potentialEnergy.

template<class DataTypes >
SReal sofa::component::forcefield::SpringForceField< DataTypes >::getStiffness (  )  [inline]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::init ( void   )  [inline, virtual]

template<class DataTypes >
bool sofa::component::forcefield::SpringForceField< DataTypes >::load ( const char *  filename  )  [inline]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::parse ( core::objectmodel::BaseObjectDescription *  arg  )  [inline, virtual]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::setDamping ( SReal  _kd  )  [inline]

template<class DataTypes >
void sofa::component::forcefield::SpringForceField< DataTypes >::setStiffness ( SReal  _ks  )  [inline]


Friends And Related Function Documentation

template<class DataTypes >
friend class SpringForceFieldInternalData< DataTypes > [friend]

Definition at line 101 of file SpringForceField.h.


Field Documentation

Definition at line 98 of file SpringForceField.h.

template<class DataTypes >
Data<SReal> sofa::component::forcefield::SpringForceField< DataTypes >::kd [protected]

template<class DataTypes >
Data<SReal> sofa::component::forcefield::SpringForceField< DataTypes >::ks [protected]


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

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