From a9db87b834cb04a32e3bf817c421a365fe7ea113 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Mon, 12 Oct 2026 14:25:16 -0400 Subject: [PATCH] feat(geometry/deformation/backend/mfem/detail): added reference tracking structs Note, I say this in the todo's in the files too. This system is something of a holdover from the older MeanField system which used a bespoke (per module) caching system. We may want to consider ripping this out in favor of the more general depedencies graph system now that we have it in SERiF --- .../mfem/detail/reference_tracking.hpp | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/include/serif/geometry/deformation/backend/mfem/detail/reference_tracking.hpp diff --git a/src/include/serif/geometry/deformation/backend/mfem/detail/reference_tracking.hpp b/src/include/serif/geometry/deformation/backend/mfem/detail/reference_tracking.hpp new file mode 100644 index 00000000..dcf10da6 --- /dev/null +++ b/src/include/serif/geometry/deformation/backend/mfem/detail/reference_tracking.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include + +namespace mfem +{ + //TODO: Really we should move the forward declarations of these mfem types to some unified location so that we are + // not managing haphazardly on a per-translation unit level (its really easy to imagining how this would lead + // to an ORD violation). Further, most of the time in headers we really don't need the implementation of the type + // so this does save a lot of compile time. + // I would suggest something like a utils/types/mfem/forward.hpp module which just forward defines these + // things and then that header can be included. + + + class Mesh; ///< Forward declaration of the mfem::Mesh class to avoid including the entire mfem mesh header file. + class FiniteElementSpace; ///< Forward declaration of the mfem::FiniteElementSpace class to avoid including the entire mfem finite element space header file. + class FiniteElementCollection; ///< Forward declaration of the mfem::FiniteElementCollection class to avoid including the entire mfem finite element collection header file. +} // namespace mfem + +namespace serif::geometry::deformation::backend::mfem::detail +{ + /** + * @brief Shared mesh metadata; a negative node revision and empty material list mean those values are irrelevant. + * + * @todo This is a holdover from MeanFields bespoke reference tracking system, consider if we can remove this with SERiF's more robust + * dependencies graph + */ + struct ReferenceMeshSnapshot + { + const ::mfem::Mesh* identity{}; ///< The identity of the mesh, which is a pointer to the mfem::Mesh object representing the mesh. + long sequence{-1}; ///< The sequence number of the mesh, which is a long integer representing the version or revision of the mesh. + long nodes_sequence{-1}; ///< The sequence number of the nodes in the mesh, which is a long integer representing the version or revision of the nodes. + int vertices{}; ///< The number of vertices in the mesh, which is an integer representing the count of vertices in the mesh. + int elements{}; ///< The number of elements in the mesh, which is an integer representing the count of elements in the mesh. + std::vector element_attributes; ///< A vector of integers representing the attributes of the elements in the mesh. + std::vector boundary_attributes; ///< A vector of integers representing the attributes of the boundaries in the mesh. + }; + + /** + * @brief Reference space metadata; by that we mean that this struct contains the information needed to uniquely identify + * some finite element space so that we can determine if two finite element spaces are equivalent or not. Used for cacheing. + * Like I say in the todo, this is a hold over from the older prototype code MeanField which had this bespoke tracking + * system per module. I think that at this point these could likely be removed in favor of using MeanField's + * more robust and extensible dependencies graph system. + * + * @todo See the todo on ReferenceMeshSnapshot. Same points apply here. + */ + struct ReferenceSpaceSnapshot + { + const ::mfem::FiniteElementSpace* identity; ///< The identity of the finite element space, which is a pointer to the mfem::FiniteElementSpace object representing the space. + const ::mfem::Mesh* mesh; ///< The mesh associated with the finite element space, which is a pointer to the mfem::Mesh object representing the mesh. + const ::mfem::FiniteElementCollection* collection; ///< The finite element collection associated with the finite element space, which is a pointer to the mfem::FiniteElementCollection object representing the collection. + long sequence; ///< The sequence number of the finite element space, which is a long integer representing the version or revision of the space. + int size; ///< The size of the finite element space, which is an integer representing the number of degrees of freedom in the space. + int vector_dimension; ///< The vector dimension of the finite element space, which is an integer representing the dimension of the vector space. + int ordering; ///< The ordering of the finite element space, which is an integer representing the ordering of the degrees of freedom. + + + /** + * @brief Compare coefficient interpretations exactly. + */ + bool operator==(const ReferenceSpaceSnapshot&) const = default; + }; +} // namespace serif::geometry::deformation::backend::mfem::detail