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.
T | The 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 | |
FemState & | operator= (const FemState &)=delete |
FemState (FemState &&)=delete | |
FemState & | operator= (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) |
|
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.
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.
const std::vector<Data>& EvalElementData | ( | const systems::CacheIndex | cache_index | ) | const |
Returns an std::vector of per-element data in this
FemState.
[in] | cache_index | The cache index of the per-element data. |
Data | the per-element data type. |
std::exception | if the per-element data value doesn't actually have type Data . |
const VectorX<T>& GetAccelerations | ( | ) | const |
const VectorX<T>& GetPositions | ( | ) | const |
const VectorX<T>& GetPreviousStepPositions | ( | ) | const |
const VectorX<T>& GetVelocities | ( | ) | const |
bool is_created_from_system | ( | const internal::FemStateSystem< T > & | system | ) | const |
Returns true if this FemState is constructed from the given system.
int num_dofs | ( | ) | const |
Returns the number of degrees of freedom in the FEM model and state.
int num_nodes | ( | ) | const |
Returns the number of nodes in the FEM model.
void SetAccelerations | ( | const Eigen::Ref< const VectorX< T >> & | a | ) |
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 | ) |