Drake
Drake C++ Documentation
FemState< T > Class Template Reference

Detailed Description

template<typename T>
class drake::multibody::fem::FemState< T >

FemState provides access to private workspace FEM state and per-element state-dependent data.

FemState comes in two flavors, an "owned" version that owns the state and data stored in the private workspace, and a "shared" version that doesn't own them. Because the "owned" version owns the state, one can modify it (e.g. through SetPositions). On the other hand, the "shared" version only provides a window into the const state and data, so one cannot modify it. For example, calling SetPositions on a "shared" FemState throws an exception. A "shared" FemState is cheap to construct and should never persist. It is advisable to acquire it for evaluation in a limited scope (e.g., in a calc method of a cache entry) and then discard it.

Template Parameters
TThe scalar type, which must be one of the default scalars.

#include <drake/multibody/fem/fem_state.h>

Public Member Functions

 FemState (const internal::FemStateSystem< T > *system)
 Creates an "owned" version of FemState that allocates and accesses states and cached data using the provided system. More...
 
 FemState (const internal::FemStateSystem< T > *system, const systems::Context< T > *context)
 Creates a "shared" version of FemState that accesses states and cached data in the given context. More...
 
template<typename Data >
const std::vector< Data > & EvalElementData (const systems::CacheIndex cache_index) const
 Returns an std::vector of per-element data in this FemState. More...
 
int num_dofs () const
 Returns the number of degrees of freedom in the FEM model and state. More...
 
int num_nodes () const
 Returns the number of nodes in the FEM model. More...
 
bool is_created_from_system (const internal::FemStateSystem< T > &system) const
 Returns true if this FemState is constructed from the given system. More...
 
std::unique_ptr< FemState< T > > Clone () const
 Returns an identical copy of this FemState. More...
 
Does not allow copy, move, or assignment
 FemState (const FemState &)=delete
 
FemStateoperator= (const FemState &)=delete
 
 FemState (FemState &&)=delete
 
FemStateoperator= (FemState &&)=delete
 
Getters and setters for the FEM states

The FEM states include positions, time step positions (the positions at the previous time step t₀), velocities, and accelerations. Positions and velocities are actual state variables, while the accelerations are the saved result of previous calculations required by certain integrators such as NewmarkScheme.

const VectorX< T > & GetPositions () const
 
const VectorX< T > & GetPreviousStepPositions () const
 
const VectorX< T > & GetVelocities () const
 
const VectorX< T > & GetAccelerations () const
 
void SetPositions (const Eigen::Ref< const VectorX< T >> &q)
 
void SetTimeStepPositions (const Eigen::Ref< const VectorX< T >> &q0)
 
void SetVelocities (const Eigen::Ref< const VectorX< T >> &v)
 
void SetAccelerations (const Eigen::Ref< const VectorX< T >> &a)
 

Constructor & Destructor Documentation

◆ FemState() [1/4]

FemState ( const FemState< T > &  )
delete

◆ FemState() [2/4]

FemState ( FemState< T > &&  )
delete

◆ FemState() [3/4]

FemState ( const internal::FemStateSystem< T > *  system)
explicit

Creates an "owned" version of FemState that allocates and accesses states and cached data using the provided system.

The FemState created with this constructor owns the states and data.

Precondition
system != nullptr.

◆ FemState() [4/4]

FemState ( const internal::FemStateSystem< T > *  system,
const systems::Context< T > *  context 
)

Creates a "shared" version of FemState that accesses states and cached data in the given context.

The FemState created with this constructor doesn't own the states and data.

Precondition
system != nullptr.
context != nullptr.
system and context are compatible.

Member Function Documentation

◆ Clone()

std::unique_ptr<FemState<T> > Clone ( ) const

Returns an identical copy of this FemState.

◆ EvalElementData()

const std::vector<Data>& EvalElementData ( const systems::CacheIndex  cache_index) const

Returns an std::vector of per-element data in this FemState.

Parameters
[in]cache_indexThe cache index of the per-element data.
Template Parameters
Datathe per-element data type.
Exceptions
std::exceptionif the per-element data value doesn't actually have type Data.

◆ GetAccelerations()

const VectorX<T>& GetAccelerations ( ) const

◆ GetPositions()

const VectorX<T>& GetPositions ( ) const

◆ GetPreviousStepPositions()

const VectorX<T>& GetPreviousStepPositions ( ) const

◆ GetVelocities()

const VectorX<T>& GetVelocities ( ) const

◆ is_created_from_system()

bool is_created_from_system ( const internal::FemStateSystem< T > &  system) const

Returns true if this FemState is constructed from the given system.

◆ num_dofs()

int num_dofs ( ) const

Returns the number of degrees of freedom in the FEM model and state.

◆ num_nodes()

int num_nodes ( ) const

Returns the number of nodes in the FEM model.

◆ operator=() [1/2]

FemState& operator= ( FemState< T > &&  )
delete

◆ operator=() [2/2]

FemState& operator= ( const FemState< T > &  )
delete

◆ SetAccelerations()

void SetAccelerations ( const Eigen::Ref< const VectorX< T >> &  a)

◆ SetPositions()

void SetPositions ( const Eigen::Ref< const VectorX< T >> &  q)

◆ SetTimeStepPositions()

void SetTimeStepPositions ( const Eigen::Ref< const VectorX< T >> &  q0)

◆ SetVelocities()

void SetVelocities ( const Eigen::Ref< const VectorX< T >> &  v)

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