#pragma once #include #include #include #include #include #include "mfem/fem/gridfunc.hpp" #include "serif/backend/mfem/mapping/domain_mapper.hpp" #include "serif/utils/dependencies/dependency_context.hpp" #include "serif/utils/dependencies/key_list_operations.hpp" namespace serif::discretization::backend::mfem { /** @brief Own meshes and finite-element resources in reverse dependency order, for creation and archive restoration. */ struct Resources { std::vector> meshes; std::vector> collections; std::vector> spaces; std::unique_ptr<::mfem::GridFunction> compactification; std::unique_ptr mapper; }; template struct OwnedBindings; /** @brief Keep typed bindings alive beside the resources they borrow; neither copying a configuration nor restoring it copies these resources. */ template struct OwnedBindings> { template using Binding = std::remove_cvref_t().template get())>; Resources resources; std::tuple>...> bindings; /** @brief Borrow each stable binding through the existing computational-graph input vocabulary. */ [[nodiscard]] auto context() const { using namespace utils::dependencies; return make_dependency_context(borrow(*std::get>()>(bindings))...); } }; }