Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
system_base.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
12 #pragma once
13 
14 #include <string>
15 #include <vector>
16 #include <memory>
17 #include <utility>
18 #include "field_state.hpp"
19 #include "field_store.hpp"
20 #include "coupled_system_solver.hpp"
21 #include "state_advancer.hpp"
22 #include "smith/physics/common.hpp"
23 #include "mfem.hpp"
24 
25 namespace smith {
26 
27 template <typename... Args>
28 struct Parameters;
29 
33 struct ReactionInfo {
34  std::string name;
35  const mfem::ParFiniteElementSpace* space = nullptr;
36 };
37 
38 namespace detail {
39 
42 template <std::size_t, typename T>
43 using always_t = T;
44 
46 template <typename Space, typename... Tail, std::size_t... Is>
47 auto time_rule_params_impl(std::index_sequence<Is...>) -> Parameters<always_t<Is, Space>..., Tail...>;
48 
49 } // namespace detail
50 
53 template <typename Rule, typename Space, typename... Tail>
55  decltype(detail::time_rule_params_impl<Space, Tail...>(std::make_index_sequence<Rule::num_states>{}));
56 
60 struct SystemBase {
61  std::shared_ptr<FieldStore> field_store;
62  std::shared_ptr<CoupledSystemSolver> solver;
63  std::shared_ptr<StateAdvancer> advancer;
64  std::vector<FieldState> parameter_fields;
65  std::string prepend_name;
66 
71  const std::vector<FieldState>& getParameterFields() const { return parameter_fields; }
72 
78  std::string prefix(const std::string& name) const
79  {
80  if (prepend_name.empty()) {
81  return name;
82  }
83  return prepend_name + "_" + name;
84  }
85 
87  std::vector<ReactionInfo> getReactionInfos() const { return {}; }
88 };
89 
90 } // namespace smith
A file defining some enums and structs that are used by the different physics modules.
Accelerator functionality.
Definition: smith.cpp:36
decltype(detail::time_rule_params_impl< Space, Tail... >(std::make_index_sequence< Rule::num_states >{})) TimeRuleParams
Generate a Parameters<...> type with Rule::num_states copies of Space followed by additional Tail typ...
Definition: system_base.hpp:55
Interface and implementations for advancing from one step to the next. Typically these are time integ...
a struct that is used in the physics modules to clarify which template arguments are user-controlled ...
Definition: common.hpp:45
Information about a dual field.
Definition: system_base.hpp:33
std::string name
The name of the dual field.
Definition: system_base.hpp:34
const mfem::ParFiniteElementSpace * space
The finite element space of the dual field.
Definition: system_base.hpp:35
Base struct for physics systems containing common members and helper functions.
Definition: system_base.hpp:60
std::vector< FieldState > parameter_fields
Optional parameter fields.
Definition: system_base.hpp:64
std::shared_ptr< CoupledSystemSolver > solver
The solver for the system.
Definition: system_base.hpp:62
std::string prefix(const std::string &name) const
Helper function to prepend the physics name to a string.
Definition: system_base.hpp:78
std::shared_ptr< StateAdvancer > advancer
The state advancer.
Definition: system_base.hpp:63
std::shared_ptr< FieldStore > field_store
Field store managing the system's fields.
Definition: system_base.hpp:61
std::vector< ReactionInfo > getReactionInfos() const
Metadata for dual outputs exported by this system.
Definition: system_base.hpp:87
const std::vector< FieldState > & getParameterFields() const
Get the list of all parameter fields.
Definition: system_base.hpp:71
std::string prepend_name
Optional prepended name for all fields.
Definition: system_base.hpp:65
T always_t
Helper: given an index and a type, always produces the type (used to repeat a type N times via pack e...
Definition: system_base.hpp:43
auto time_rule_params_impl(std::index_sequence< Is... >) -> Parameters< always_t< Is, Space >..., Tail... >
Implementation for TimeRuleParams: repeat Space N times, then append Tail...