Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
Classes | Public Types | Public Member Functions | List of all members
smith::FieldStore Struct Reference

Manages storage and metadata for fields, parameters, and weak forms. More...

#include <field_store.hpp>

Classes

struct  TimeIntegrationMapping
 Mapping between primary and history/derivative fields for time integration. More...
 

Public Types

enum class  TimeDerivative { VAL , DOT , DDOT , DDDOT }
 Enum for different types of time derivatives. More...
 

Public Member Functions

 FieldStore (std::shared_ptr< Mesh > mesh, size_t storage_size=50)
 Construct a new FieldStore object. More...
 
template<typename Space >
void addShapeDisp (FieldType< Space > type)
 Add a shape displacement field to the store. More...
 
template<typename Space >
void addParameter (FieldType< Space > type)
 Add a parameter field to the store. More...
 
template<typename Space >
std::shared_ptr< DirichletBoundaryConditionsaddIndependent (FieldType< Space > &type, std::shared_ptr< TimeIntegrationRule > time_rule)
 Add an independent field (a solver unknown) to the store. More...
 
template<typename Space >
auto addDependent (FieldType< Space > independent_field, TimeDerivative derivative, std::string name_override="")
 Add a dependent field (history value, velocity, or acceleration) to the store. More...
 
void addWeakFormUnknownArg (std::string weak_form_name, std::string argument_name, size_t argument_index)
 Register an argument to a weak form as an unknown. More...
 
void addWeakFormArg (std::string weak_form_name, std::string argument_name, size_t argument_index)
 Register an argument to a weak form. More...
 
size_t getNumUnknowns () const
 Get the number of unknowns in the field store. More...
 
void addWeakFormReaction (std::string weak_form_name, std::string field_name)
 Register the reaction (test) field for a weak form. More...
 
std::string getWeakFormReaction (const std::string &weak_form_name) const
 Get the name of the reaction (test) field for a weak form. More...
 
template<typename... FieldTypes>
std::vector< const mfem::ParFiniteElementSpace * > createSpaces (const std::string &weak_form_name, const std::string &reaction_field_name, FieldTypes... types)
 Register all input fields for a weak form and return their FE spaces. More...
 
const std::vector< std::pair< std::shared_ptr< TimeIntegrationRule >, TimeIntegrationMapping > > & getTimeIntegrationRules () const
 Get all registered time integration rules and their mappings. More...
 
void printMap ()
 Print the internal field maps for debugging.
 
std::vector< std::vector< size_t > > indexMap (const std::vector< std::string > &residual_names) const
 Generate an index map for the residuals. More...
 
std::vector< const BoundaryConditionManager * > getBoundaryConditionManagers () const
 Get the boundary condition managers for all independent fields. More...
 
std::shared_ptr< DirichletBoundaryConditionsgetBoundaryConditions (size_t unknown_index) const
 Get the Dirichlet boundary conditions for an independent field by its unknown index. More...
 
size_t getFieldIndex (const std::string &field_name) const
 Get the internal index of a field by name. More...
 
size_t getUnknownIndex (const std::string &field_name) const
 Get the unknown index of a field by name. More...
 
FieldState getField (const std::string &field_name) const
 Get a FieldState by name. More...
 
FieldState getParameter (const std::string &param_name) const
 Get a parameter field by name. More...
 
void setField (const std::string &field_name, FieldState updated_field)
 Update a field in the store by name. More...
 
void setField (size_t index, FieldState updated_field)
 Update a field in the store by index. More...
 
FieldState getShapeDisp () const
 Get the shape displacement field. More...
 
const std::vector< FieldState > & getAllFields () const
 Get all fields stored in the FieldStore. More...
 
std::vector< FieldStategetStates (const std::string &weak_form_name) const
 Get the state fields associated with a weak form. More...
 
std::vector< FieldStategetStatesFromVectors (const std::string &weak_form_name, const std::vector< FieldState > &state_fields, const std::vector< FieldState > &param_fields) const
 Extract state fields for a weak form from provided state and parameter vectors. More...
 
const std::shared_ptr< smith::Mesh > & getMesh () const
 Get the associated mesh. More...
 
const std::shared_ptr< gretl::DataStore > & graph () const
 Get the associated data store graph. More...
 

Detailed Description

Manages storage and metadata for fields, parameters, and weak forms.

Definition at line 44 of file field_store.hpp.

Member Enumeration Documentation

◆ TimeDerivative

Enum for different types of time derivatives.

Enumerator
DOT 

The first time derivative.

DDOT 

The second time derivative.

DDDOT 

The third time derivative.

Definition at line 55 of file field_store.hpp.

Constructor & Destructor Documentation

◆ FieldStore()

smith::FieldStore::FieldStore ( std::shared_ptr< Mesh mesh,
size_t  storage_size = 50 
)

Construct a new FieldStore object.

Parameters
meshThe mesh associated with the fields.
storage_sizeInitial storage size for fields (default: 50).

Definition at line 14 of file field_store.cpp.

Member Function Documentation

◆ addDependent()

template<typename Space >
auto smith::FieldStore::addDependent ( FieldType< Space >  independent_field,
TimeDerivative  derivative,
std::string  name_override = "" 
)
inline

Add a dependent field (history value, velocity, or acceleration) to the store.

Creates and registers a new field that carries the previous time-step value of a particular time derivative of an independent field. The relationship is recorded in the TimeIntegrationMapping for the parent independent field so that, at evaluation time, the time integration rule can reconstruct the current rate from the pair (predicted_value, stored_old_value).

Return value: a FieldType<Space> whose name is the name of the newly registered field. This object is intentionally returned (rather than discarded) so that callers can pass it directly to createSpaces when assembling the weak-form argument list. The position at which a FieldType appears in that argument list determines which slot of the lambda the field occupies at quadrature-point evaluation time, which is how the time integration rules reconstruct quantities such as \( \dot{\alpha} = (\alpha_\text{predicted} - \alpha_\text{old}) / \Delta t \).

The field name is derived automatically from the independent field's name plus a suffix that reflects the derivative level (_old for VALUE, _dot_old for DOT, _ddot_old for DDOT), unless name_override is supplied.

Template Parameters
SpaceThe finite element space type (must match the independent field).
Parameters
independent_fieldThe FieldType of the independent (predicted) field.
derivativeWhich time-derivative level this history field stores.
name_overrideIf non-empty, use this as the field name instead of the auto-generated one.
Returns
FieldType<Space> Type descriptor for the newly created dependent field; pass this to createSpaces to register it as a weak-form argument.

Definition at line 154 of file field_store.hpp.

◆ addIndependent()

template<typename Space >
std::shared_ptr<DirichletBoundaryConditions> smith::FieldStore::addIndependent ( FieldType< Space > &  type,
std::shared_ptr< TimeIntegrationRule time_rule 
)
inline

Add an independent field (a solver unknown) to the store.

Registers the field as an unknown and assigns it an index in the solver's block structure. The type argument is mutated in-place: its unknown_index is set to the assigned index, so the same FieldType<Space> object can later be passed to createSpaces to tell the weak form that this argument is an active unknown (i.e. the Jacobian should be computed with respect to it).

Template Parameters
SpaceThe finite element space type.
Parameters
typeThe field type specification; type.unknown_index is set on return.
time_ruleThe time integration rule governing how this unknown and its dependents are related across time steps.
Returns
std::shared_ptr<DirichletBoundaryConditions> The boundary conditions for this field.

Definition at line 102 of file field_store.hpp.

◆ addParameter()

template<typename Space >
void smith::FieldStore::addParameter ( FieldType< Space >  type)
inline

Add a parameter field to the store.

Template Parameters
SpaceThe finite element space type.
Parameters
typeThe field type specification.

Definition at line 80 of file field_store.hpp.

◆ addShapeDisp()

template<typename Space >
void smith::FieldStore::addShapeDisp ( FieldType< Space >  type)
inline

Add a shape displacement field to the store.

Template Parameters
SpaceThe finite element space type.
Parameters
typeThe field type specification.

Definition at line 69 of file field_store.hpp.

◆ addWeakFormArg()

void smith::FieldStore::addWeakFormArg ( std::string  weak_form_name,
std::string  argument_name,
size_t  argument_index 
)

Register an argument to a weak form.

Parameters
weak_form_nameName of the weak form.
argument_nameName of the argument field.
argument_indexIndex of the argument in the weak form's argument list.

Definition at line 36 of file field_store.cpp.

◆ addWeakFormReaction()

void smith::FieldStore::addWeakFormReaction ( std::string  weak_form_name,
std::string  field_name 
)

Register the reaction (test) field for a weak form.

The reaction field is the field whose test function space the weak form integrates against. It determines which field's degrees of freedom the assembled residual is "returned to" (i.e. the field whose force/flux vector is populated).

Parameters
weak_form_nameName of the weak form.
field_nameName of the reaction field.

Definition at line 214 of file field_store.cpp.

◆ addWeakFormUnknownArg()

void smith::FieldStore::addWeakFormUnknownArg ( std::string  weak_form_name,
std::string  argument_name,
size_t  argument_index 
)

Register an argument to a weak form as an unknown.

Parameters
weak_form_nameName of the weak form.
argument_nameName of the argument field.
argument_indexIndex of the argument in the weak form's argument list.

Definition at line 26 of file field_store.cpp.

◆ createSpaces()

template<typename... FieldTypes>
std::vector<const mfem::ParFiniteElementSpace*> smith::FieldStore::createSpaces ( const std::string &  weak_form_name,
const std::string &  reaction_field_name,
FieldTypes...  types 
)
inline

Register all input fields for a weak form and return their FE spaces.

This is the primary setup method for constructing a weak form. It:

  1. Registers reaction_field_name as the reaction/test field via addWeakFormReaction.
  2. Iterates over every FieldType in types (in order), registering each as an input argument to the weak form and recording whether it is an active unknown.
  3. Returns the ordered vector of finite element spaces, which can be passed directly to the TimeDiscretizedWeakForm constructor without creating a named temporary.
Parameters
weak_form_nameName of the weak form being constructed.
reaction_field_nameName of the test/reaction field (may differ from the first input).
typesOrdered list of FieldType descriptors for every input argument.
Returns
std::vector<const mfem::ParFiniteElementSpace*> Ordered input FE spaces.

Definition at line 246 of file field_store.hpp.

◆ getAllFields()

const std::vector< FieldState > & smith::FieldStore::getAllFields ( ) const

Get all fields stored in the FieldStore.

Returns
const std::vector<FieldState>& List of all fields.

Definition at line 137 of file field_store.cpp.

◆ getBoundaryConditionManagers()

std::vector< const BoundaryConditionManager * > smith::FieldStore::getBoundaryConditionManagers ( ) const

Get the boundary condition managers for all independent fields.

Returns
std::vector<const BoundaryConditionManager*> List of boundary condition managers.

Definition at line 80 of file field_store.cpp.

◆ getBoundaryConditions()

std::shared_ptr< DirichletBoundaryConditions > smith::FieldStore::getBoundaryConditions ( size_t  unknown_index) const

Get the Dirichlet boundary conditions for an independent field by its unknown index.

Parameters
unknown_indexThe unknown index of the independent field.
Returns
std::shared_ptr<DirichletBoundaryConditions> The boundary conditions.

Definition at line 89 of file field_store.cpp.

◆ getField()

FieldState smith::FieldStore::getField ( const std::string &  field_name) const

Get a FieldState by name.

Parameters
field_nameName of the field.
Returns
FieldState The field state.

Definition at line 107 of file field_store.cpp.

◆ getFieldIndex()

size_t smith::FieldStore::getFieldIndex ( const std::string &  field_name) const

Get the internal index of a field by name.

Parameters
field_nameName of the field.
Returns
size_t Index of the field.

Definition at line 95 of file field_store.cpp.

◆ getMesh()

const std::shared_ptr< smith::Mesh > & smith::FieldStore::getMesh ( ) const

Get the associated mesh.

Returns
const std::shared_ptr<smith::Mesh>& The mesh.

Definition at line 200 of file field_store.cpp.

◆ getNumUnknowns()

size_t smith::FieldStore::getNumUnknowns ( ) const
inline

Get the number of unknowns in the field store.

Returns
size_t Number of unknowns.

Definition at line 209 of file field_store.hpp.

◆ getParameter()

FieldState smith::FieldStore::getParameter ( const std::string &  param_name) const

Get a parameter field by name.

Parameters
param_nameName of the parameter.
Returns
FieldState The parameter field state.

Definition at line 123 of file field_store.cpp.

◆ getShapeDisp()

FieldState smith::FieldStore::getShapeDisp ( ) const

Get the shape displacement field.

Returns
FieldState The shape displacement field.

Definition at line 135 of file field_store.cpp.

◆ getStates()

std::vector< FieldState > smith::FieldStore::getStates ( const std::string &  weak_form_name) const

Get the state fields associated with a weak form.

Parameters
weak_form_nameName of the weak form.
Returns
std::vector<FieldState> List of state fields.

Definition at line 139 of file field_store.cpp.

◆ getStatesFromVectors()

std::vector< FieldState > smith::FieldStore::getStatesFromVectors ( const std::string &  weak_form_name,
const std::vector< FieldState > &  state_fields,
const std::vector< FieldState > &  param_fields 
) const

Extract state fields for a weak form from provided state and parameter vectors.

Parameters
weak_form_nameName of the weak form.
state_fieldsVector of all state fields.
param_fieldsVector of all parameter fields.
Returns
std::vector<FieldState> Subset of fields relevant to the weak form.

Definition at line 164 of file field_store.cpp.

◆ getTimeIntegrationRules()

const std::vector< std::pair< std::shared_ptr< TimeIntegrationRule >, FieldStore::TimeIntegrationMapping > > & smith::FieldStore::getTimeIntegrationRules ( ) const

Get all registered time integration rules and their mappings.

Returns
const std::vector<std::pair<std::shared_ptr<TimeIntegrationRule>, TimeIntegrationMapping>>& List of rules and mappings.

Definition at line 205 of file field_store.cpp.

◆ getUnknownIndex()

size_t smith::FieldStore::getUnknownIndex ( const std::string &  field_name) const

Get the unknown index of a field by name.

Parameters
field_nameName of the field.
Returns
size_t Unknown index of the field.

Definition at line 210 of file field_store.cpp.

◆ getWeakFormReaction()

std::string smith::FieldStore::getWeakFormReaction ( const std::string &  weak_form_name) const

Get the name of the reaction (test) field for a weak form.

Parameters
weak_form_nameName of the weak form.
Returns
std::string Name of the reaction field.

Definition at line 219 of file field_store.cpp.

◆ graph()

const std::shared_ptr< gretl::DataStore > & smith::FieldStore::graph ( ) const

Get the associated data store graph.

Returns
const std::shared_ptr<gretl::DataStore>& The graph.

Definition at line 202 of file field_store.cpp.

◆ indexMap()

std::vector< std::vector< size_t > > smith::FieldStore::indexMap ( const std::vector< std::string > &  residual_names) const

Generate an index map for the residuals.

Parameters
residual_namesNames of the residuals.
Returns
std::vector<std::vector<size_t>> The index map.

Definition at line 59 of file field_store.cpp.

◆ setField() [1/2]

void smith::FieldStore::setField ( const std::string &  field_name,
FieldState  updated_field 
)

Update a field in the store by name.

Parameters
field_nameName of the field.
updated_fieldThe new field state.

Definition at line 129 of file field_store.cpp.

◆ setField() [2/2]

void smith::FieldStore::setField ( size_t  index,
FieldState  updated_field 
)

Update a field in the store by index.

Parameters
indexIndex of the field.
updated_fieldThe new field state.

Definition at line 212 of file field_store.cpp.


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