20 #include "serac/numerics/functional/differentiate_wrt.hpp"
22 #include "serac/numerics/functional/function_signature.hpp"
23 #include "serac/numerics/functional/geometry.hpp"
31 template <
int dim,
typename signature,
int... i,
typename func,
typename... T>
32 FiniteElementState
fit(std::integer_sequence<int, i...>, func f, mfem::ParMesh& pmesh,
const T&... solution_fields)
38 FiniteElementState fitted_field(pmesh, output_space{});
43 serac::Functional<output_space(output_space)> phi_phi(&fitted_field.space(), {&fitted_field.space()});
44 phi_phi.AddDomainIntegral(
45 Dimension<dim>{}, DependsOn<0>{},
46 [](
double ,
auto ,
auto u) {
47 return tuple{get<0>(u), zero{}};
50 auto M = get<1>(phi_phi(DifferentiateWRT<0>{}, 0.0 , fitted_field));
53 std::array<
const mfem::ParFiniteElementSpace*,
sizeof...(T)> trial_spaces = {&solution_fields.space()...};
54 serac::Functional<signature> phi_f(&fitted_field.space(), trial_spaces);
55 phi_f.AddDomainIntegral(Dimension<dim>{}, DependsOn<i...>{}, f, whole_domain);
56 mfem::Vector b = phi_f(0.0, solution_fields...);
58 mfem::CGSolver cg(MPI_COMM_WORLD);
63 cg.Mult(b, fitted_field);
78 template <
int dim,
typename signature,
int... n,
typename func,
typename... T>
81 auto iseq = std::make_integer_sequence<int,
sizeof...(T)>{};
82 return detail::fit<dim, signature>(iseq, f, pmesh, solution_fields...);
Class for encapsulating the critical MFEM components of a primal finite element field.
many of the functions in this file amount to extracting element indices from an mesh_t like
This file contains the declaration of structure that manages the MFEM objects that make up the state ...
Implementation of the quadrature-function-based functional enabling rapid development of FEM formulat...
Accelerator functionality.
FiniteElementState fit(func f, mfem::ParMesh &pmesh, const T &... solution_fields)
determine field parameters to approximate the output of a user-provided q-function
tuple(T...) -> tuple< T... >
Class template argument deduction rule for tuples.
Domain EntireDomain(const mesh_t &mesh)
constructs a domain from all the elements in a mesh
Implementation of the tensor class used by Functional.
Implements a std::tuple-like object that works in CUDA kernels.