20 #include "smith/numerics/functional/differentiate_wrt.hpp"
22 #include "smith/numerics/functional/function_signature.hpp"
23 #include "smith/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 smith::Functional<output_space(output_space)> phi_phi(&fitted_field.space(), {&fitted_field.space()});
44 phi_phi.AddDomainIntegral(
45 Dimension<dim>{}, DependsOn<0>{}, [](
double ,
auto ,
auto u) {
return tuple{get<0>(u), zero{}}; },
47 auto M = get<1>(phi_phi(DifferentiateWRT<0>{}, 0.0 , fitted_field));
50 std::array<
const mfem::ParFiniteElementSpace*,
sizeof...(T)> trial_spaces = {&solution_fields.space()...};
51 smith::Functional<signature> phi_f(&fitted_field.space(), trial_spaces);
52 phi_f.AddDomainIntegral(Dimension<dim>{}, DependsOn<i...>{}, f, whole_domain);
53 mfem::Vector b = phi_f(0.0, solution_fields...);
55 mfem::CGSolver cg(MPI_COMM_WORLD);
60 cg.Mult(b, fitted_field);
75 template <
int dim,
typename signature,
int... n,
typename func,
typename... T>
78 auto iseq = std::make_integer_sequence<int,
sizeof...(T)>{};
79 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.
tuple(T...) -> tuple< T... >
Class template argument deduction rule for tuples.
FiniteElementState fit(func f, mfem::ParMesh &pmesh, const T &... solution_fields)
determine field parameters to approximate the output of a user-provided q-function
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.