AnimaL |
Tutorial |
Documentation |
#include <massspringsolver.h>
Inheritance diagram for animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >:
A spring is modeled using:
An isotropy coefficient is used to bias the product of the stiffness with a vector when performing implicit integration. This enhances the stability of the system. Reasonable values for anistropy are experimentally around 0.03 or 0.05.
Definition at line 45 of file massspringsolver.h.
Public Types | |
typedef t_Positions | Positions |
Positions of the particles. | |
typedef container_traits< Positions >::value_type | Position |
Position of a particle. | |
typedef t_Vector | Vector |
Velocities, forces, etc. | |
typedef container_traits< Vector >::value_type | Vec |
typedef t_VecReal | VecReal |
Vector of real numbers. | |
typedef value_type< VecReal >::type | Real |
Real numbers. | |
typedef t_VecIndex | VecIndex |
Vector of indices. | |
typedef value_type< VecIndex >::type | Index |
Index of a particle. | |
typedef PhysicalSolver< t_Positions, t_Vector, t_InvMasses, typename value_type< t_VecReal >::type > | _PhysicalSolver |
Parent class. | |
typedef OdeImplicitSolver< t_Positions, t_Vector, typename value_type< t_VecReal >::type > | _OdeImplicitSolver |
Convenience for disambiguating multiple inheritance. | |
Public Member Functions | |
MassSpringSolver () | |
~MassSpringSolver () | |
void | create_rest_lengths (const Positions &p) |
Set the rest lengths of the springs according to the current particle positions. | |
void | set_rest_lengths (VecReal *r) |
Set the given rest lengths. | |
VecReal * | get_rest_lengths () |
rest lengths | |
bool | get_debugInfo () const |
Get debug info boolean. | |
void | set_debugInfo (bool b) |
set debug info boolean | |
virtual void | solveODE (Positions &pos, Vector &vel, Real dt) |
Solve the ODE then applies exponential damping. | |
virtual void | computeForces (Vector &f, const Positions &p, const Vector &v) |
Compute the elastic forces given particle positions and velocities. | |
virtual void | computeAccelerations (Vector &acc, const Positions &pos, const Vector &vel) |
Compute the accelerations given particle positions and velocities. | |
virtual void | computeAccelerationsAndStiffness (Vector &acc, const Positions &pos, const Vector &vel) |
Compute the accelerations given particle positions and velocities, and computes [df/dx]. | |
virtual void | applyForces (Vector &a, const Vector &f) |
Compute the acceleration of the particles when given forces are applied. | |
virtual void | v_eq_h_dfdx_x (Vector &v, Real h, const Vector &x) |
Compute ![]() | |
virtual void | v_peq_h_dfdx_x (Vector &v, Real h, const Vector &x) |
Compute ![]() | |
numerical settings | |
virtual void | setMethod (int) |
Set the integration method. | |
virtual int | getMethod () const |
Get the integration method. | |
void | setIsotropy (Real iso) |
Set the isotropy coefficient. | |
Real | getIsotropy () const |
Get the isotropy coefficient. | |
physical settings | |
virtual void | set_common_damping_ratio (const Real &_newVal) |
Write property of Real _common_damping_ratio. | |
virtual const Real & | get_common_damping_ratio () |
Read property of Real _common_damping_ratio. | |
connections | |
virtual void | set_spring_indices (VecIndex *_newVal) |
Set the pointer to the spring indices. | |
virtual void | set_stiffnesses (VecReal *_newVal) |
Set the pointer to the stiffness values. | |
Static Public Member Functions | |
Real | get_thresholdDistance () |
return the threshold value | |
void | set_thresholdDistance (Real threshold) |
set the threshold value | |
void | accumulateSpringForce (Vec &fa, Vec &fb, const Vec &pa, const Vec &pb, const Vec &va, const Vec &vb, const Real &stiffness, const Real &dampingRatio, const Real &restLength) |
Accumulate spring force, given particle states and spring constants. | |
void | accumulateSpringForceAndGradientMatrix (Vec &fa, Vec &fb, Vec &grad, const Vec &pa, const Vec &pb, const Vec &va, const Vec &vb, const Real &stiffness, const Real &dampingRatio, const Real &restLength) |
Accumulate spring force, given particle states and spring constants. | |
bool | computeDistanceAndDirection (Real &d, Vec &u, const Vec &pa, const Vec &pb) |
Compute the distance and direction between two given points. | |
Public Attributes | |
VecIndex * | _links |
The set of indices modeling spring topology. | |
VecReal * | _stiffnesses |
the set of stiffnesses | |
VecReal * | _restLengths |
The rest lengths of the springs. | |
bool | _own_restLengths |
true iff the rest lengths have been built locally and must be deleted by the destructor | |
animal::vector< Vec > | _directions |
Unit vectors modeling spring directions. | |
Real | _isotropy |
Fraction of the force gradient applied independently of the spring direction; used to enhance stability; 0.03 is a reasonable value. | |
Static Public Attributes | |
Real | _thresholdDistance = 1.e-12 |
the minimum threshold distance between two points authorized | |
bool | _debug = false |
print computation detail |
|
Convenience for disambiguating multiple inheritance.
Definition at line 63 of file massspringsolver.h. |
|
Parent class.
Definition at line 62 of file massspringsolver.h. |
|
|
Position of a particle.
Definition at line 52 of file massspringsolver.h. |
|
Positions of the particles.
Reimplemented from animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >. Definition at line 51 of file massspringsolver.h. |
|
|
Reimplemented from animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >. Definition at line 54 of file massspringsolver.h. |
|
Vector of indices.
Definition at line 57 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::set_spring_indices(). |
|
Vector of real numbers.
Definition at line 55 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::set_stiffnesses(). |
|
|
Definition at line 34 of file massspringsolver.inl. |
|
|
Accumulate spring force, given particle states and spring constants.
Definition at line 139 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::_debug, animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeDistanceAndDirection(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real, animal::v_dot(), animal::v_meq(), animal::v_peq(), and animal::v_teq(). Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeForces(). |
|
Accumulate spring force, given particle states and spring constants. On output, force is accumulated and grad is a unit vector along spring direction Definition at line 170 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real, animal::v_dot(), animal::v_meq(), animal::v_peq(), and animal::v_teq(). Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(). |
|
Compute the acceleration of the particles when given forces are applied.
Implements animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >. Definition at line 322 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Vector. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(). |
|
Compute the accelerations given particle positions and velocities.
Implements animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >. Definition at line 227 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Vector. |
|
|
Compute the distance and direction between two given points. Return false iff the distance is below a security threshold. Definition at line 195 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::get_thresholdDistance(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real, animal::v_norm(), and animal::v_teq(). Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::accumulateSpringForce(). |
|
|
Set the rest lengths of the springs according to the current particle positions.
Definition at line 98 of file massspringsolver.h. |
|
Read property of Real _common_damping_ratio.
Definition at line 89 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real. |
|
Get debug info boolean.
Definition at line 142 of file massspringsolver.h. |
|
rest lengths
Definition at line 130 of file massspringsolver.h. |
|
return the threshold value
Definition at line 133 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeDistanceAndDirection(). |
|
Get the isotropy coefficient.
Definition at line 84 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::_isotropy, and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real. |
|
Get the integration method.
Definition at line 74 of file massspringsolver.inl. |
|
Write property of Real _common_damping_ratio.
Definition at line 94 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real. |
|
set debug info boolean
Definition at line 145 of file massspringsolver.h. |
|
Set the given rest lengths.
Definition at line 119 of file massspringsolver.h. |
|
Set the pointer to the spring indices.
Definition at line 100 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::_links, and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::VecIndex. |
|
Set the pointer to the stiffness values.
Definition at line 104 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::_stiffnesses, and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::VecReal. |
|
set the threshold value
Definition at line 137 of file massspringsolver.h. |
|
Set the isotropy coefficient.
Definition at line 79 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::_isotropy, and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real. |
|
Set the integration method.
Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >. Definition at line 69 of file massspringsolver.inl. |
|
Solve the ODE then applies exponential damping.
Reimplemented from animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >. Definition at line 45 of file massspringsolver.inl. References animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::applyExponentialDamping(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real, and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Vector. |
|
Compute
Implements animal::OdeImplicitSolver< t_Positions, t_Vector, t_Real >. Definition at line 396 of file massspringsolver.inl. References animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Real, animal::v_assign(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::v_peq_h_dfdx_x(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::Vector, and animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::zero(). |
|
|
print computation detail
Definition at line 30 of file massspringsolver.inl. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::accumulateSpringForce(), and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeForces(). |
|
Unit vectors modeling spring directions.
Definition at line 154 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(), and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::v_peq_h_dfdx_x(). |
|
Fraction of the force gradient applied independently of the spring direction; used to enhance stability; 0.03 is a reasonable value.
Definition at line 155 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::getIsotropy(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::setIsotropy(), and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::v_peq_h_dfdx_x(). |
|
The set of indices modeling spring topology.
Definition at line 149 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeForces(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::set_spring_indices(), and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::v_peq_h_dfdx_x(). |
|
true iff the rest lengths have been built locally and must be deleted by the destructor
Definition at line 152 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::~MassSpringSolver(). |
|
The rest lengths of the springs.
Definition at line 151 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeForces(), and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::~MassSpringSolver(). |
|
the set of stiffnesses
Definition at line 150 of file massspringsolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeForces(), animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::set_stiffnesses(), and animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::v_peq_h_dfdx_x(). |
|
the minimum threshold distance between two points authorized
Definition at line 27 of file massspringsolver.inl. |