SurgSim::Physics::Spring Class Referenceabstract

Base class for all springs It handles the node ids to which it is connected and requires all derived classes to compute the force and its derivatives (the stiffness and damping matrices) A extra method also exist to compute all of them at once for performance purposes. More...

`#include <SurgSim/Physics/Spring.h>`

Inheritance diagram for SurgSim::Physics::Spring:

## Public Member Functions

virtual | ~Spring ()
| Virtual destructor. More...
virtual void | initialize (const SurgSim::Math::OdeState &state)
| Initialize the Spring once everything has been set. More...
size_t | getNumNodes () const
| Gets the number of nodes the spring is connecting. More...
size_t | getNodeId (size_t springNodeId) const
| Gets the springNodeId-th node id. More...
const std::vector< size_t > & | getNodeIds () const
| Gets the node ids for this spring. More...
virtual void | addForce (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, double scale=1.0)=0
| Adds the spring force (computed for a given state) to a complete system force vector F (assembly) More...
virtual void | addDamping (const SurgSim::Math::OdeState &state, SurgSim::Math::SparseMatrix *D, double scale=1.0)=0
| Adds the spring damping matrix D (= -df/dv) (computed for a given state) to a complete system damping matrix D (assembly) More...
virtual void | addStiffness (const SurgSim::Math::OdeState &state, SurgSim::Math::SparseMatrix *K, double scale=1.0)=0
| Adds the spring stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly) More...
virtual void | addFDK (const SurgSim::Math::OdeState &state, SurgSim::Math::Vector *F, SurgSim::Math::SparseMatrix *D, SurgSim::Math::SparseMatrix *K)=0
| Adds the spring force vector, mass, stiffness and damping matrices (computed for a given state) into a complete system data structure F, D, K (assembly) More...
virtual void | addMatVec (const SurgSim::Math::OdeState &state, double alphaD, double alphaK, const SurgSim::Math::Vector &x, SurgSim::Math::Vector *F)=0
| Adds the spring matrix-vector contribution F += (alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly) More...

## Protected Attributes

std::vector< size_t > | m_nodeIds
| Node ids connected by this spring. More...

## Detailed Description

Base class for all springs It handles the node ids to which it is connected and requires all derived classes to compute the force and its derivatives (the stiffness and damping matrices) A extra method also exist to compute all of them at once for performance purposes.

It holds on to the actual computed values (m_f, m_K, m_D) as its size is not predefined from outside and would requires intensive (de)allocation or a temporary variable anyway

## Constructor & Destructor Documentation

## ~Spring()

SurgSim::Physics::Spring::~Spring | ( |  | ) |

virtual

Virtual destructor.

## Member Function Documentation

## addDamping()

virtual void SurgSim::Physics::Spring::addDamping | ( | const SurgSim::Math::OdeState & | state,
|  | SurgSim::Math::SparseMatrix * | D,
|  | double | scale = `1.0`
| ) |  |

pure virtual

Adds the spring damping matrix D (= -df/dv) (computed for a given state) to a complete system damping matrix D (assembly)

Parameters

  | state | The state to compute the damping matrix with
  [in,out] | D | The complete system damping matrix to add the spring damping matrix into
  | scale | A factor to scale the added damping matrix with

Implemented in SurgSim::Physics::LinearSpring.

## addFDK()

virtual void SurgSim::Physics::Spring::addFDK | ( | const SurgSim::Math::OdeState & | state,
|  | SurgSim::Math::Vector * | F,
|  | SurgSim::Math::SparseMatrix * | D,
|  | SurgSim::Math::SparseMatrix * | K
| ) |  |

pure virtual

Adds the spring force vector, mass, stiffness and damping matrices (computed for a given state) into a complete system data structure F, D, K (assembly)

Parameters

  | state | The state to compute everything with
  [in,out] | F | The complete system force vector to add the spring force into
  [in,out] | D | The complete system damping matrix to add the spring damping matrix into
  [in,out] | K | The complete system stiffness matrix to add the spring stiffness matrix into

Implemented in SurgSim::Physics::LinearSpring.

## addForce()

virtual void SurgSim::Physics::Spring::addForce | ( | const SurgSim::Math::OdeState & | state,
|  | SurgSim::Math::Vector * | F,
|  | double | scale = `1.0`
| ) |  |

pure virtual

Adds the spring force (computed for a given state) to a complete system force vector F (assembly)

Parameters

  | state | The state to compute the force with
  [in,out] | F | The complete system force vector to add the spring force into
  | scale | A factor to scale the added force with

Implemented in SurgSim::Physics::LinearSpring.

## addMatVec()

virtual void SurgSim::Physics::Spring::addMatVec | ( | const SurgSim::Math::OdeState & | state,
|  | double | alphaD,
|  | double | alphaK,
|  | const SurgSim::Math::Vector & | x,
|  | SurgSim::Math::Vector * | F
| ) |  |

pure virtual

Adds the spring matrix-vector contribution F += (alphaD.D + alphaK.K).x (computed for a given state) into a complete system data structure F (assembly)

Parameters

  | state | The state to compute everything with
  | alphaD | The scaling factor for the damping contribution
  | alphaK | The scaling factor for the stiffness contribution
  | x | A complete system vector to use as the vector in the matrix-vector multiplication
  [in,out] | F | The complete system force vector to add the element matrix-vector contribution into

Implemented in SurgSim::Physics::LinearSpring.

## addStiffness()

virtual void SurgSim::Physics::Spring::addStiffness | ( | const SurgSim::Math::OdeState & | state,
|  | SurgSim::Math::SparseMatrix * | K,
|  | double | scale = `1.0`
| ) |  |

pure virtual

Adds the spring stiffness matrix K (= -df/dx) (computed for a given state) to a complete system stiffness matrix K (assembly)

Parameters

  | state | The state to compute the stiffness matrix with
  [in,out] | K | The complete system stiffness matrix to add the spring stiffness matrix into
  | scale | A factor to scale the added stiffness matrix with

Implemented in SurgSim::Physics::LinearSpring.

## getNodeId()

size_t SurgSim::Physics::Spring::getNodeId | ( | size_t | springNodeId | ) | const

Gets the springNodeId-th node id.

Returns
  The requested node id

## getNodeIds()

const std::vector< size_t > & SurgSim::Physics::Spring::getNodeIds | ( |  | ) | const

Gets the node ids for this spring.

Returns
  A vector containing the node ids on which the spring is attached

## getNumNodes()

size_t SurgSim::Physics::Spring::getNumNodes | ( |  | ) | const

Gets the number of nodes the spring is connecting.

Returns
  The number of nodes

## initialize()

void SurgSim::Physics::Spring::initialize | ( | const SurgSim::Math::OdeState & | state | ) |

virtual

Initialize the Spring once everything has been set.

Parameters

  state | The state to initialize the Spring with

Reimplemented in SurgSim::Physics::LinearSpring.

## Member Data Documentation

## m_nodeIds

std::vector<size_t> SurgSim::Physics::Spring::m_nodeIds

protected

Node ids connected by this spring.

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

- SurgSim/Physics/Spring.h
- SurgSim/Physics/Spring.cpp