23 template <
int spatial_dim,
typename parameters = Parameters<>,
24 typename parameter_indices = std::make_
integer_sequence<
int, parameters::n>>
30 template <
int spatial_dim,
typename... InputSpaces,
int... parameter_indices>
34 using SpacesT = std::vector<const mfem::ParFiniteElementSpace*>;
46 std::array<
const mfem::ParFiniteElementSpace*,
sizeof...(InputSpaces)> mfem_spaces;
49 sizeof...(InputSpaces) != input_mfem_spaces.size(),
50 std::format(
"{} parameter spaces given in the template argument but {} parameter names were supplied.",
51 sizeof...(InputSpaces), input_mfem_spaces.size()));
53 if constexpr (
sizeof...(InputSpaces) > 0) {
54 for_constexpr<
sizeof...(InputSpaces)>([&](
auto i) { mfem_spaces[i] = input_mfem_spaces[i]; });
57 const auto& shape_disp_space = mesh_->shapeDisplacementSpace();
60 std::make_unique<ShapeAwareFunctional<
ShapeDispSpace, double(InputSpaces...)>>(&shape_disp_space, mfem_spaces);
70 template <
int... active_parameters,
typename FuncOfTimeSpaceAndParams>
72 const FuncOfTimeSpaceAndParams& qfunction)
75 mesh_->domain(body_name));
85 template <
int... active_parameters,
typename FuncOfTimeSpaceAndParams>
87 const FuncOfTimeSpaceAndParams& qfunction)
90 qfunction, mesh_->domain(boundary_name));
95 const std::vector<ConstFieldPtr>& fields)
const override
98 cycle_ = time_info.
cycle();
100 return evaluateObjective(std::make_integer_sequence<
int,
sizeof...(parameter_indices)>{}, time_info.
time(),
106 size_t field_ordinal)
const override
108 dt_ = time_info.
dt();
109 cycle_ = time_info.
cycle();
111 auto grads = gradientEvaluators(std::make_integer_sequence<
int,
sizeof...(parameter_indices)>{}, time_info.
time(),
113 auto g = smith::get<DERIVATIVE>(grads[field_ordinal](time_info.
time(), shape_disp, fields));
119 const std::vector<ConstFieldPtr>& fields)
const override
121 dt_ = time_info.
dt();
122 cycle_ = time_info.
cycle();
124 auto g = smith::get<DERIVATIVE>(
133 const std::vector<ConstFieldPtr>& fs)
const
135 return (*objective_)(time, *shape_disp, *fs[i]...);
140 auto gradientEvaluators(std::integer_sequence<int, i...>,
double time,
ConstFieldPtr shape_disp,
141 const std::vector<ConstFieldPtr>& fs)
const
143 using JacFuncType = std::function<decltype((*objective_)(DifferentiateWRT<1>{}, time, *shape_disp, *fs[i]...))(
145 return std::array<JacFuncType,
sizeof...(i)>{
146 [
this](
double _time,
ConstFieldPtr _shape_disp,
const std::vector<ConstFieldPtr>& _fs) {
147 return (*objective_)(DifferentiateWRT<i + 1>{}, _time, *_shape_disp, *_fs[i]...);
155 mutable size_t cycle_ = 0;
158 std::shared_ptr<Mesh> mesh_;
161 std::unique_ptr<ShapeAwareFunctional<ShapeDispSpace, double(InputSpaces...)>> objective_;
This contains a class that represents the dual of a finite element vector space, i....
This file contains the declaration of structure that manages the MFEM objects that make up the state ...
Smith mesh class which assists in constructing the appropriate parallel mfem meshes and registering a...
Accelerator functionality.
DoubleState evaluateObjective(const ScalarObjective &objective, const FieldState &shape_disp, const std::vector< FieldState > &inputs, const TimeInfo &time_info)
Evaluates a DoubleState using a provided ScalarObjective reference, and the input arguments to that o...
SMITH_HOST_DEVICE auto max(dual< gradient_type > a, double b)
Implementation of max for dual numbers.
FiniteElementState const * ConstFieldPtr
using
Specifies interface for evaluating scalar objective from fields and their field gradients.
Wrapper of smith::Functional for evaluating integrals and derivatives of quantities with shape displa...
Compile-time alias for a dimension.
a struct that is used in the physics modules to clarify which template arguments are user-controlled ...
struct storing time and timestep information
double dt() const
accessor for dt
size_t cycle() const
accessor for cycle
double time() const
accessor for the current time