19 #include "field_store.hpp"
20 #include "system_solver.hpp"
27 template <
typename... Args>
34 template <std::
size_t,
typename T>
38 template <
typename Space,
typename... Tail, std::size_t... Is>
45 template <
typename Rule,
typename Space,
typename... Tail>
47 decltype(detail::time_rule_params_impl<Space, Tail...>(std::make_index_sequence<Rule::num_states>{}));
58 std::shared_ptr<SystemSolver>
solver;
59 std::vector<std::shared_ptr<SystemBase>>
63 std::vector<std::string>
65 std::vector<std::vector<std::string>>
76 explicit SystemBase(std::shared_ptr<FieldStore> fs, std::shared_ptr<SystemSolver> sol =
nullptr,
77 std::vector<std::shared_ptr<WeakForm>> wfs = {})
88 virtual std::vector<FieldState>
solve(
const TimeInfo& time_info)
const;
96 virtual std::vector<ReactionState>
computeReactions(
const TimeInfo& time_info,
97 const std::vector<FieldState>& states_for_reactions)
const;
103 inline std::shared_ptr<SystemBase>
makeSystem(std::shared_ptr<FieldStore> field_store,
104 std::shared_ptr<SystemSolver> solver,
105 std::vector<std::shared_ptr<WeakForm>> weak_forms)
107 return std::make_shared<SystemBase>(std::move(field_store), std::move(solver), std::move(weak_forms));
116 template <
typename WeakFormT,
typename FieldStorePtr,
typename... Args, std::size_t... Is>
118 const std::string& unknown_field_name,
const std::tuple<Args...>& args_tuple,
119 std::index_sequence<Is...>)
121 auto coupling_fields_tuple =
std::get<
sizeof...(Args) - 1>(args_tuple);
123 [&](
const auto&... coupling_fields) {
124 return std::make_shared<WeakFormT>(weak_form_name, field_store->getMesh(),
125 field_store->getField(unknown_field_name).get()->space(),
126 field_store->createSpaces(weak_form_name, unknown_field_name,
127 std::get<Is>(args_tuple)..., coupling_fields...));
129 coupling_fields_tuple);
133 template <
typename WeakFormT,
typename FieldStorePtr,
typename... Args>
135 const std::string& unknown_field_name,
const Args&... args)
137 return buildWeakFormWithCouplingImpl<WeakFormT>(field_store, weak_form_name, unknown_field_name, std::tie(args...),
138 std::make_index_sequence<
sizeof...(Args) - 1>{});
A file defining some enums and structs that are used by the different physics modules.
T always_t
Helper: given an index and a type, always produces the type (used to repeat a type N times via pack e...
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...
auto buildWeakFormWithCouplingImpl(const FieldStorePtr &field_store, const std::string &weak_form_name, const std::string &unknown_field_name, const std::tuple< Args... > &args_tuple, std::index_sequence< Is... >)
Expands coupling tuple into trailing weak-form space arguments.
auto buildWeakFormWithCoupling(const FieldStorePtr &field_store, const std::string &weak_form_name, const std::string &unknown_field_name, const Args &... args)
Builds weak form using regular args plus final coupling pack argument.
Accelerator functionality.
std::shared_ptr< SystemBase > makeSystem(std::shared_ptr< FieldStore > field_store, std::shared_ptr< SystemSolver > solver, std::vector< std::shared_ptr< WeakForm >> weak_forms)
Convenience factory for a plain SystemBase.
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...
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 ...
Base struct for physics systems containing common members and helper functions.
std::vector< std::shared_ptr< SystemBase > > cycle_zero_systems
std::vector< std::shared_ptr< WeakForm > > weak_forms
Weak forms solved together by this system.
std::vector< std::shared_ptr< SystemBase > > post_solve_systems
Optional systems solved after main state update.
std::shared_ptr< FieldStore > field_store
Field store managing the system's fields.
virtual std::vector< ReactionState > computeReactions(const TimeInfo &time_info, const std::vector< FieldState > &states_for_reactions) const
Compute reactions after solving the main state.
SystemBase()=default
Construct an empty system shell.
virtual std::vector< FieldState > solve(const TimeInfo &time_info) const
Solve the system using the internal weak_forms and solver.
std::shared_ptr< SystemSolver > solver
The solver for the system.
std::vector< std::string > solve_result_field_names
Optional per-weak-form fields to solve/update instead of reaction fields.
SystemBase(std::shared_ptr< FieldStore > fs, std::shared_ptr< SystemSolver > sol=nullptr, std::vector< std::shared_ptr< WeakForm >> wfs={})
Construct a system from a field store, solver, and weak forms.
std::vector< std::vector< std::string > > solve_input_field_names
Optional per-weak-form input field ordering used during solve.