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 axom::fmt::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));
80 const std::vector<ConstFieldPtr>& fields)
const override
83 return evaluateObjective(std::make_integer_sequence<
int,
sizeof...(parameter_indices)>{}, time, shape_disp, fields);
88 const std::vector<ConstFieldPtr>& fields,
int field_ordinal)
const override
92 gradientEvaluators(std::make_integer_sequence<
int,
sizeof...(parameter_indices)>{}, time, shape_disp, fields);
93 auto g = smith::get<DERIVATIVE>(grads[
static_cast<size_t>(field_ordinal)](time, shape_disp, fields));
99 const std::vector<ConstFieldPtr>& fields)
const override
103 smith::get<DERIVATIVE>((*objective_)(
DifferentiateWRT<0>{}, time, *shape_disp, *fields[parameter_indices]...));
110 auto evaluateObjective(std::integer_sequence<int, i...>,
double time,
ConstFieldPtr shape_disp,
111 const std::vector<ConstFieldPtr>& fs)
const
113 return (*objective_)(time, *shape_disp, *fs[i]...);
118 auto gradientEvaluators(std::integer_sequence<int, i...>,
double time,
ConstFieldPtr shape_disp,
119 const std::vector<ConstFieldPtr>& fs)
const
121 using JacFuncType = std::function<decltype((*objective_)(DifferentiateWRT<1>{}, time, *shape_disp, *fs[i]...))(
123 return std::array<JacFuncType,
sizeof...(i)>{
124 [=](
double _time,
ConstFieldPtr _shape_disp,
const std::vector<ConstFieldPtr>& _fs) {
125 return (*objective_)(DifferentiateWRT<i + 1>{}, _time, *_shape_disp, *_fs[i]...);
133 std::shared_ptr<Mesh> mesh_;
136 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.
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 ...