reference_tracking.cpp serif/backend/mfem/shared/reference_tracking.hpp mfem/fem/fespace.hpp serif serif::backend serif::backend::mfem serif::backend::mfem::shared #include"serif/backend/mfem/shared/reference_tracking.hpp" #include"mfem/fem/fespace.hpp" namespaceserif::backend::mfem::shared{ [[nodiscard]]ReferenceMeshSnapshotmesh_snapshot(const::mfem::Mesh*mesh,boolcoordinates,boolmaterials){ if(!mesh){ return{}; } ReferenceMeshSnapshotresult{ .identity=mesh, .sequence=mesh->GetSequence(), .nodes_sequence=coordinates?mesh->GetNodesSequence():-1, .vertices=mesh->GetNV(), .elements=mesh->GetNE(), .element_attributes=std::vector<int>(materials?mesh->GetNE():0), .boundary_attributes=std::vector<int>(mesh->GetNBE())}; for(std::size_telement=0;element<result.element_attributes.size();++element){ result.element_attributes[element]=mesh->GetAttribute(element); } for(intboundary=0;boundary<mesh->GetNBE();++boundary){ result.boundary_attributes[boundary]=mesh->GetBdrAttribute(boundary); } returnresult; } [[nodiscard]]ReferenceSpaceSnapshotspace_snapshot(const::mfem::FiniteElementSpace&space){ return{ .identity=&space, .mesh=space.GetMesh(), .collection=space.FEColl(), .sequence=space.GetSequence(), .size=space.GetVSize(), .vector_dimension=space.GetVDim(), .ordering=static_cast<int>(space.GetOrdering())}; } [[nodiscard]]boolmesh_matches(constReferenceMeshSnapshot&snapshot,const::mfem::Mesh*mesh){ if(snapshot.identity!=mesh){ returnfalse; } if(!mesh){ returntrue; } if(snapshot.sequence!=mesh->GetSequence()||(snapshot.nodes_sequence>=0&&snapshot.nodes_sequence!=mesh->GetNodesSequence())||snapshot.vertices!=mesh->GetNV()||snapshot.elements!=mesh->GetNE()||snapshot.boundary_attributes.size()!=static_cast<std::size_t>(mesh->GetNBE())){ returnfalse; } for(std::size_telement=0;element<snapshot.element_attributes.size();++element){ if(snapshot.element_attributes[element]!=mesh->GetAttribute(element)){ returnfalse; } } for(intboundary=0;boundary<mesh->GetNBE();++boundary){ if(snapshot.boundary_attributes[boundary]!=mesh->GetBdrAttribute(boundary)){ returnfalse; } } returntrue; } }