|
Smith
0.1
Smith is an implicit thermal structural mechanics simulation code.
|
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, std::string prepend_name="") | |
| Construct a new FieldStore object. More... | |
| std::string | prefix (const std::string &base) const |
| Apply this store's namespace prefix to a base name. 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< DirichletBoundaryConditions > | addIndependent (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... | |
| void | addWeakFormReaction (std::string weak_form_name, std::string field_name) |
| Register the reaction (test) field for a weak form. More... | |
| void | markWeakFormInternal (const std::string &weak_form_name) |
| Mark a weak form as internal so it is excluded from getReactionInfos(). 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 std::vector< std::string > &weak_form_names) const |
| Get the boundary condition managers for the given weak forms, one per residual row. More... | |
| std::vector< const BoundaryConditionManager * > | getBoundaryConditionManagersForFields (const std::vector< std::string > &field_names) const |
| Get ordered boundary condition managers corresponding to an ordered list of fields. | |
| bool | hasField (const std::string &field_name) const |
| Check whether a field exists. More... | |
| size_t | getFieldIndex (const std::string &field_name) const |
| Get the internal 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 ¶m_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< FieldState > | getStates (const std::string &weak_form_name) const |
| Get the state fields associated with a weak form. More... | |
| std::vector< FieldState > | getStatesFromVectors (const std::string &weak_form_name, const std::vector< FieldState > &state_fields, const std::vector< FieldState > ¶m_fields) const |
| Extract state fields for a weak form from provided state and parameter vectors. More... | |
| const std::vector< FieldState > & | getParameterFields () const |
| Get the list of all parameter fields. | |
| const std::vector< FieldState > & | getStateFields () const |
| Get the list of all state fields. | |
| std::vector< FieldState > | getOutputFieldStates () const |
| Get the list of physical, non-solve state fields suitable for output. | |
| std::vector< ReactionInfo > | getReactionInfos () const |
| Get information about reaction fields. | |
| const std::shared_ptr< smith::Mesh > & | getMesh () const |
| Get associated mesh shared by all registered fields. | |
| std::shared_ptr< DirichletBoundaryConditions > | getBoundaryConditions (const std::string &field_name) const |
| Get the boundary conditions for a given field name. | |
| const std::shared_ptr< gretl::DataStore > & | graph () const |
| Get the associated data store graph. More... | |
Manages storage and metadata for fields, parameters, and weak forms.
Definition at line 63 of file field_store.hpp.
|
strong |
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 84 of file field_store.hpp.
| smith::FieldStore::FieldStore | ( | std::shared_ptr< Mesh > | mesh, |
| size_t | storage_size = 50, |
||
| std::string | prepend_name = "" |
||
| ) |
Construct a new FieldStore object.
| mesh | The mesh associated with the fields. |
| storage_size | Initial storage size for fields (default: 50). |
| prepend_name | Namespace prefix applied by prefix(). Empty means no prefix. |
Definition at line 14 of file field_store.cpp.
|
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 and is_unknown is false. This object is intentionally returned (rather than discarded) so that callers can pass it directly to createSpaces when assembling the weak-form argument list. To make it the Jacobian variable for a specific weak form (e.g. the cycle-zero acceleration solve), copy the returned object and set is_unknown = true before passing to createSpaces.
| Space | The finite element space type (must match the independent field). |
| independent_field | The FieldType of the independent (predicted) field. |
| derivative | Which time-derivative level this history field stores. |
| name_override | If non-empty, use this as the field name instead of the auto-generated one. |
Definition at line 187 of file field_store.hpp.
|
inline |
Add an independent field (a solver unknown) to the store.
Registers the field as an unknown by setting type.is_unknown = true, so the same FieldType<Space> object can later be passed to createSpaces to mark this argument as an active Jacobian variable. Also creates a boundary-condition slot keyed by field name that callers can populate after this call returns.
| Space | The finite element space type. |
| type | The field type specification; type.is_unknown is set to true on return. |
| time_rule | The time integration rule governing how this unknown and its dependents are related across time steps. |
Definition at line 142 of file field_store.hpp.
|
inline |
Add a parameter field to the store.
| Space | The finite element space type. |
| type | The field type specification. |
Definition at line 110 of file field_store.hpp.
|
inline |
Add a shape displacement field to the store.
| Space | The finite element space type. |
| type | The field type specification. |
Definition at line 98 of file field_store.hpp.
| void smith::FieldStore::addWeakFormArg | ( | std::string | weak_form_name, |
| std::string | argument_name, | ||
| size_t | argument_index | ||
| ) |
Register an argument to a weak form.
| weak_form_name | Name of the weak form. |
| argument_name | Name of the argument field. |
| argument_index | Index of the argument in the weak form's argument list. |
Definition at line 44 of file field_store.cpp.
| 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).
| weak_form_name | Name of the weak form. |
| field_name | Name of the reaction field. |
Definition at line 362 of file field_store.cpp.
| 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.
| weak_form_name | Name of the weak form. |
| argument_name | Name of the argument field. |
| argument_index | Index of the argument in the weak form's argument list. |
Definition at line 34 of file field_store.cpp.
|
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:
reaction_field_name as the reaction/test field via addWeakFormReaction.FieldType in types (in order), registering each as an input argument. If type.is_unknown is true, the field is also registered as an active Jacobian unknown for this weak form.A field may have is_unknown = true in one weak form and false in another (e.g. displacement is a Jacobian variable in the main solid solve but a fixed input in the stress projection). Callers control this by passing the FieldType returned from addIndependent (has is_unknown = true) or a plain copy constructed from the field name (has is_unknown = false). Similarly, a dependent field can be made the Jacobian variable for a specific weak form (e.g. acceleration in the cycle-zero solve) by copying the returned FieldType and setting is_unknown = true.
| weak_form_name | Name of the weak form being constructed. |
| reaction_field_name | Name of the test/reaction field (may differ from the first input). |
| types | Ordered list of FieldType descriptors for every input argument. |
Definition at line 290 of file field_store.hpp.
| const std::vector< FieldState > & smith::FieldStore::getAllFields | ( | ) | const |
Get all fields stored in the FieldStore.
Definition at line 275 of file field_store.cpp.
| std::vector< const BoundaryConditionManager * > smith::FieldStore::getBoundaryConditionManagers | ( | const std::vector< std::string > & | weak_form_names | ) | const |
Get the boundary condition managers for the given weak forms, one per residual row.
For each weak form in weak_form_names the reaction (test) field name is looked up. The returned manager is selected by consulting the registered TimeIntegrationMapping s:
nullptr (solver skips null entries)The second-derivative manager is rebuilt on each call, so late value-BC additions are reflected.
| weak_form_names | Ordered list of weak form names whose BCs are needed. |
Definition at line 129 of file field_store.cpp.
| FieldState smith::FieldStore::getField | ( | const std::string & | field_name | ) | const |
Get a FieldState by name.
| field_name | Fully-qualified or unprefixed field name. |
Definition at line 209 of file field_store.cpp.
| size_t smith::FieldStore::getFieldIndex | ( | const std::string & | field_name | ) | const |
Get the internal index of a field by name.
| field_name | Fully-qualified or unprefixed field name. |
Definition at line 196 of file field_store.cpp.
| FieldState smith::FieldStore::getParameter | ( | const std::string & | param_name | ) | const |
Get a parameter field by name.
| param_name | Fully-qualified or unprefixed parameter name. |
Definition at line 226 of file field_store.cpp.
| FieldState smith::FieldStore::getShapeDisp | ( | ) | const |
Get the shape displacement field.
Definition at line 273 of file field_store.cpp.
| std::vector< FieldState > smith::FieldStore::getStates | ( | const std::string & | weak_form_name | ) | const |
Get the state fields associated with a weak form.
| weak_form_name | Name of the weak form. |
Definition at line 277 of file field_store.cpp.
| 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.
| weak_form_name | Name of the weak form. |
| state_fields | Vector of all state fields. |
| param_fields | Vector of all parameter fields. |
Definition at line 301 of file field_store.cpp.
| const std::vector< std::pair< std::shared_ptr< TimeIntegrationRule >, FieldStore::TimeIntegrationMapping > > & smith::FieldStore::getTimeIntegrationRules | ( | ) | const |
Get all registered time integration rules and their mappings.
Definition at line 350 of file field_store.cpp.
| std::string smith::FieldStore::getWeakFormReaction | ( | const std::string & | weak_form_name | ) | const |
Get the name of the reaction (test) field for a weak form.
| weak_form_name | Name of the weak form. |
Definition at line 373 of file field_store.cpp.
| const std::shared_ptr< gretl::DataStore > & smith::FieldStore::graph | ( | ) | const |
Get the associated data store graph.
Definition at line 347 of file field_store.cpp.
| bool smith::FieldStore::hasField | ( | const std::string & | field_name | ) | const |
Check whether a field exists.
Accepts either a fully-qualified field name or an unprefixed base name.
Definition at line 187 of file field_store.cpp.
| std::vector< std::vector< size_t > > smith::FieldStore::indexMap | ( | const std::vector< std::string > & | residual_names | ) | const |
Generate an index map for the residuals.
| residual_names | Names of the residuals. |
Definition at line 67 of file field_store.cpp.
| void smith::FieldStore::markWeakFormInternal | ( | const std::string & | weak_form_name | ) |
Mark a weak form as internal so it is excluded from getReactionInfos().
Use this for subsystem forms (e.g. cycle-zero acceleration solve) that should not be exposed as user-visible reactions in DifferentiablePhysics.
Definition at line 357 of file field_store.cpp.
| std::string smith::FieldStore::prefix | ( | const std::string & | base | ) | const |
Apply this store's namespace prefix to a base name.
Returns base unchanged when the store was constructed with an empty prepend name, otherwise returns prepend_name_ + "_" + base. Factories use this to namespace weak form, field, and parameter names consistently without re-implementing the rule.
Definition at line 21 of file field_store.cpp.
| void smith::FieldStore::setField | ( | const std::string & | field_name, |
| FieldState | updated_field | ||
| ) |
Update a field in the store by name.
| field_name | Fully-qualified or unprefixed field name. |
| updated_field | The new field state. |
Definition at line 233 of file field_store.cpp.
| void smith::FieldStore::setField | ( | size_t | index, |
| FieldState | updated_field | ||
| ) |
Update a field in the store by index.
| index | Index of the field. |
| updated_field | The new field state. |
Definition at line 355 of file field_store.cpp.