SOFA API  1a4bb3e7
Open source framework for multi-physics simuation
sofa::core::behavior::TMultiVec< vtype > Class Template Reference

#include <MultiVec.h>

Inheritance diagram for sofa::core::behavior::TMultiVec< vtype >:

Detailed Description

template<VecType vtype>
class sofa::core::behavior::TMultiVec< vtype >

Helper class providing a high-level view of underlying state vectors.

It is used to convert math-like operations to call to computation methods.

Protected Attributes

BaseVectorOperationsvop
 Solver who is using this vector. More...
 
MyMultiVecId v
 Identifier of this vector. More...
 
bool dynamic
 Flag indicating if this vector was dynamically allocated. More...
 

Public Member Functions

 TMultiVec (BaseVectorOperations *vop, MyMultiVecId v)
 Refers to a state vector with the given ID (VecId::position(), VecId::velocity(), etc). More...
 
 TMultiVec ()
 Refers to a not yet allocated state vector. More...
 
 TMultiVec (BaseVectorOperations *vop, bool dynamic=true, const VecIdProperties &properties={})
 Allocate a new temporary vector with the given type (sofa::core::V_COORD or sofa::core::V_DERIV). More...
 
 ~TMultiVec ()
 
 operator MyMultiVecId ()
 Automatic conversion to the underlying VecId. More...
 
 operator ConstMyMultiVecId ()
 
 operator AllMultiVecId ()
 
 operator ConstAllMultiVecId ()
 
const MyMultiVecIdid () const
 
MyMultiVecIdid ()
 
BaseVectorOperationsops ()
 
void setOps (BaseVectorOperations *op)
 
void realloc (BaseVectorOperations *_vop, bool interactionForceField=false, bool propagate=false, const VecIdProperties &properties={})
 
void clear ()
 v = 0 More...
 
void eq (MyMultiVecId a)
 v = a More...
 
void eq (MyMultiVecId a, SReal f)
 v = a*f More...
 
void peq (AllMultiVecId a, SReal f=1.0)
 v += a*f More...
 
void teq (SReal f)
 v *= f More...
 
void eq (AllMultiVecId a, AllMultiVecId b, SReal f=1.0)
 v = a+b*f More...
 
SReal dot (MyMultiVecId a)
 
void threshold (SReal threshold)
 nullify values below given threshold More...
 
SReal norm ()
 
SReal norm (unsigned l)
 
void operator= (MyMultiVecId a)
 v = a More...
 
void operator= (const TMultiVec< vtype > &a)
 v = a More...
 
void operator+= (MyMultiVecId a)
 v += a More...
 
void operator-= (MyMultiVecId a)
 v -= a More...
 
void operator*= (SReal f)
 v *= f More...
 
void operator/= (SReal f)
 v /= f More...
 
SReal operator* (MyMultiVecId a)
 return the scalar product dot(v,a) More...
 
size_t size () const
 

Friends

std::ostream & operator<< (std::ostream &out, const TMultiVec< vtype > &mv)
 

Attribute details

◆ dynamic

template<VecType vtype>
bool sofa::core::behavior::TMultiVec< vtype >::dynamic
protected

Flag indicating if this vector was dynamically allocated.

◆ v

template<VecType vtype>
MyMultiVecId sofa::core::behavior::TMultiVec< vtype >::v
protected

Identifier of this vector.

◆ vop

template<VecType vtype>
BaseVectorOperations* sofa::core::behavior::TMultiVec< vtype >::vop
protected

Solver who is using this vector.

Constructor details

◆ TMultiVec() [1/3]

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::TMultiVec ( BaseVectorOperations vop,
MyMultiVecId  v 
)
inline

Refers to a state vector with the given ID (VecId::position(), VecId::velocity(), etc).

◆ TMultiVec() [2/3]

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::TMultiVec ( )
inline

Refers to a not yet allocated state vector.

◆ TMultiVec() [3/3]

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::TMultiVec ( BaseVectorOperations vop,
bool  dynamic = true,
const VecIdProperties properties = {} 
)
inline

Allocate a new temporary vector with the given type (sofa::core::V_COORD or sofa::core::V_DERIV).

◆ ~TMultiVec()

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::~TMultiVec ( )
inline

Function details

◆ clear()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::clear ( )
inline

v = 0

◆ dot()

template<VecType vtype>
SReal sofa::core::behavior::TMultiVec< vtype >::dot ( MyMultiVecId  a)
inline
Returns
v.a

◆ eq() [1/3]

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::eq ( AllMultiVecId  a,
AllMultiVecId  b,
SReal  f = 1.0 
)
inline

v = a+b*f

◆ eq() [2/3]

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::eq ( MyMultiVecId  a)
inline

v = a

◆ eq() [3/3]

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::eq ( MyMultiVecId  a,
SReal  f 
)
inline

v = a*f

◆ id() [1/2]

template<VecType vtype>
MyMultiVecId& sofa::core::behavior::TMultiVec< vtype >::id ( )
inline

◆ id() [2/2]

template<VecType vtype>
const MyMultiVecId& sofa::core::behavior::TMultiVec< vtype >::id ( ) const
inline

◆ norm() [1/2]

template<VecType vtype>
SReal sofa::core::behavior::TMultiVec< vtype >::norm ( )
inline
Returns
sqrt(v.v)

◆ norm() [2/2]

template<VecType vtype>
SReal sofa::core::behavior::TMultiVec< vtype >::norm ( unsigned  l)
inline

Compute the norm of a vector. The type of norm is set by parameter l. Use 0 for the infinite norm. Note that the 2-norm is more efficiently computed using the square root of the dot product.

◆ operator AllMultiVecId()

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::operator AllMultiVecId ( )
inline

◆ operator ConstAllMultiVecId()

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::operator ConstAllMultiVecId ( )
inline

◆ operator ConstMyMultiVecId()

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::operator ConstMyMultiVecId ( )
inline

◆ operator MyMultiVecId()

template<VecType vtype>
sofa::core::behavior::TMultiVec< vtype >::operator MyMultiVecId ( )
inline

Automatic conversion to the underlying VecId.

◆ operator*()

template<VecType vtype>
SReal sofa::core::behavior::TMultiVec< vtype >::operator* ( MyMultiVecId  a)
inline

return the scalar product dot(v,a)

◆ operator*=()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::operator*= ( SReal  f)
inline

v *= f

◆ operator+=()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::operator+= ( MyMultiVecId  a)
inline

v += a

◆ operator-=()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::operator-= ( MyMultiVecId  a)
inline

v -= a

◆ operator/=()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::operator/= ( SReal  f)
inline

v /= f

◆ operator=() [1/2]

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::operator= ( const TMultiVec< vtype > &  a)
inline

v = a

◆ operator=() [2/2]

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::operator= ( MyMultiVecId  a)
inline

v = a

◆ ops()

template<VecType vtype>
BaseVectorOperations* sofa::core::behavior::TMultiVec< vtype >::ops ( )
inline

◆ peq()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::peq ( AllMultiVecId  a,
SReal  f = 1.0 
)
inline

v += a*f

◆ realloc()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::realloc ( BaseVectorOperations _vop,
bool  interactionForceField = false,
bool  propagate = false,
const VecIdProperties properties = {} 
)
inline

allocates vector for every newly appeared mechanical states (initializing them to 0 and does not modify already allocated mechanical states)

Parameters
interactionForceFieldset to true, also allocate external mechanical states linked by an InteractionForceField (TODO remove this option by seeing external mmstates as abstract null vectors)

◆ setOps()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::setOps ( BaseVectorOperations op)
inline

◆ size()

template<VecType vtype>
size_t sofa::core::behavior::TMultiVec< vtype >::size ( ) const
inline

◆ teq()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::teq ( SReal  f)
inline

v *= f

◆ threshold()

template<VecType vtype>
void sofa::core::behavior::TMultiVec< vtype >::threshold ( SReal  threshold)
inline

nullify values below given threshold

Related details

◆ operator<<

template<VecType vtype>
std::ostream& operator<< ( std::ostream &  out,
const TMultiVec< vtype > &  mv 
)
friend