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

#include <VectorSpringForceField.h>

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

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

Collaboration graph
[legend]

Data Structures

class  Loader
struct  Spring

Public Types

enum  { N = Coord::static_size }
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

 VectorSpringForceField (MechanicalState *_object=NULL)
 VectorSpringForceField (MechanicalState *_object1, MechanicalState *_object2)
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.
void createDefaultSprings ()
virtual void handleEvent (Event *e)
 Handle an event.
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, 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 &, const VecCoord &)
 Get the potential energy associated to this ForceField.
Real getStiffness () const
const Real getViscosity () const
const topology::EdgeData
< Spring > & 
getSpringArray () const
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, Coord restVector)

Data Fields

sofa::core::componentmodel::topology::BaseMeshTopology * _topology
sofa::component::topology::EdgeSetTopologyContainer * edgeCont
sofa::component::topology::EdgeSetGeometryAlgorithms
< DataTypes > * 
edgeGeo
sofa::component::topology::EdgeSetTopologyModifier * edgeMod

Protected Member Functions

void resizeArray (unsigned int n)

Static Protected Member Functions

static void springCreationFunction (int, void *param, Spring &t, const topology::Edge &e, const sofa::helper::vector< unsigned int > &ancestors, const sofa::helper::vector< double > &coefs)

Protected Attributes

double m_potentialEnergy
bool useTopology
 true if the springs are initialized from the topology
sofa::helper::vector
< topology::Edge > 
edgeArray
 indices in case we don't use the topology
sofa::component::topology::EdgeData
< Spring > 
springArray
 where the springs information are stored
Data< std::string > m_filename
 the filename where to load the spring information
Data< double > m_stiffness
 By default, assume that all edges have the same stiffness.
Data< double > m_viscosity
 By default, assume that all edges have the same viscosity.

Friends

class Loader

Detailed Description

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

Definition at line 53 of file VectorSpringForceField.h.


Member Typedef Documentation

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

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

Definition at line 58 of file VectorSpringForceField.h.

Definition at line 64 of file VectorSpringForceField.h.

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

Definition at line 63 of file VectorSpringForceField.h.

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

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


Member Enumeration Documentation

template<class DataTypes >
anonymous enum

Enumerator:
N 

Definition at line 65 of file VectorSpringForceField.h.


Constructor & Destructor Documentation

template<class DataTypes >
sofa::component::forcefield::VectorSpringForceField< DataTypes >::VectorSpringForceField ( MechanicalState *  _object = NULL  )  [inline]

template<class DataTypes >
sofa::component::forcefield::VectorSpringForceField< DataTypes >::VectorSpringForceField ( MechanicalState *  _object1,
MechanicalState *  _object2 
) [inline]


Member Function Documentation

template<class DataTypes >
void sofa::component::forcefield::VectorSpringForceField< 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.

Reimplemented from sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >.

Definition at line 293 of file VectorSpringForceField.inl.

References sofa::component::forcefield::VectorSpringForceField< DataTypes >::_topology, sofa::component::forcefield::VectorSpringForceField< DataTypes >::edgeArray, sofa::core::componentmodel::topology::BaseMeshTopology::getEdge(), sofa::core::componentmodel::topology::BaseMeshTopology::getNbEdges(), sofa::component::forcefield::VectorSpringForceField< DataTypes >::Spring::ks, sofa::component::forcefield::VectorSpringForceField< DataTypes >::springArray, and sofa::component::forcefield::VectorSpringForceField< DataTypes >::useTopology.

template<class DataTypes >
void sofa::component::forcefield::VectorSpringForceField< 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::VectorSpringForceField< DataTypes >::addSpring ( int  m1,
int  m2,
SReal  ks,
SReal  kd,
Coord  restVector 
) [inline]

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

template<class DataTypes >
void sofa::component::forcefield::VectorSpringForceField< DataTypes >::createDefaultSprings (  )  [inline]

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

template<class DataTypes >
virtual double sofa::component::forcefield::VectorSpringForceField< 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 135 of file VectorSpringForceField.h.

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

template<class DataTypes >
const topology::EdgeData<Spring>& sofa::component::forcefield::VectorSpringForceField< DataTypes >::getSpringArray (  )  const [inline]

template<class DataTypes >
Real sofa::component::forcefield::VectorSpringForceField< DataTypes >::getStiffness (  )  const [inline]

template<class DataTypes >
const Real sofa::component::forcefield::VectorSpringForceField< DataTypes >::getViscosity (  )  const [inline]

template<class DataTypes >
void sofa::component::forcefield::VectorSpringForceField< DataTypes >::handleEvent ( Event *  e  )  [inline, virtual]

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

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

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

Definition at line 156 of file VectorSpringForceField.inl.

References sofa::component::forcefield::VectorSpringForceField< DataTypes >::_topology, sofa::component::forcefield::VectorSpringForceField< DataTypes >::createDefaultSprings(), sofa::component::forcefield::VectorSpringForceField< DataTypes >::edgeArray, sofa::component::forcefield::VectorSpringForceField< DataTypes >::edgeGeo, sofa::component::forcefield::VectorSpringForceField< DataTypes >::edgeMod, sofa::core::objectmodel::BaseObject::f_listening, sofa::core::objectmodel::BaseContext::get(), sofa::core::objectmodel::BaseObject::getContext(), sofa::core::objectmodel::BaseContext::getMeshTopology(), sofa::core::componentmodel::behavior::BaseMechanicalState::getSize(), sofa::core::objectmodel::Data< T >::getValue(), sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::init(), sofa::component::forcefield::VectorSpringForceField< DataTypes >::load(), sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_filename, sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_stiffness, sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_viscosity, sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >::mstate1, sofa::core::objectmodel::Data< T >::setValue(), sofa::component::forcefield::VectorSpringForceField< DataTypes >::springArray, and sofa::component::forcefield::VectorSpringForceField< DataTypes >::useTopology.

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

template<class DataTypes >
void sofa::component::forcefield::VectorSpringForceField< DataTypes >::resizeArray ( unsigned int  n  )  [inline, protected]

template<class DataTypes >
void sofa::component::forcefield::VectorSpringForceField< DataTypes >::springCreationFunction ( int  ,
void *  param,
Spring &  t,
const topology::Edge &  e,
const sofa::helper::vector< unsigned int > &  ancestors,
const sofa::helper::vector< double > &  coefs 
) [inline, static, protected]


Friends And Related Function Documentation

template<class DataTypes >
friend class Loader [friend]

Definition at line 164 of file VectorSpringForceField.h.


Field Documentation

Definition at line 109 of file VectorSpringForceField.h.

template<class DataTypes >
Data<std::string> sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_filename [protected]

the filename where to load the spring information

Definition at line 92 of file VectorSpringForceField.h.

Referenced by sofa::component::forcefield::VectorSpringForceField< DataTypes >::init().

template<class DataTypes >
double sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_potentialEnergy [protected]

template<class DataTypes >
Data<double> sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_stiffness [protected]

template<class DataTypes >
Data<double> sofa::component::forcefield::VectorSpringForceField< DataTypes >::m_viscosity [protected]


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

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