diff --git a/src/pcms/field/layout/omega_h_entity.cpp b/src/pcms/field/layout/omega_h_entity.cpp index 32f39043..e6a2a698 100644 --- a/src/pcms/field/layout/omega_h_entity.cpp +++ b/src/pcms/field/layout/omega_h_entity.cpp @@ -54,7 +54,9 @@ OmegaHEntityLayout::OmegaHEntityLayout(Omega_h::Mesh& mesh, int entity_dim, int num_components, CoordinateSystem coordinate_system, std::string global_id_name) - : dimension_(mesh.dim()), + // dimension_ is the first member, so this runs before the class_ids_/ + // class_dims_ initializers below read the mesh's classification tags. + : dimension_((EnsureClassification(mesh), mesh.dim())), entity_dim_(entity_dim), num_components_(num_components), num_global_dof_holder_(mesh.nglobal_ents(entity_dim)), diff --git a/src/pcms/field/layout/omega_h_lagrange.cpp b/src/pcms/field/layout/omega_h_lagrange.cpp index c9d7bdb9..8797ad91 100644 --- a/src/pcms/field/layout/omega_h_lagrange.cpp +++ b/src/pcms/field/layout/omega_h_lagrange.cpp @@ -3,7 +3,6 @@ #include "pcms/utility/mesh_geometry.h" #include "pcms/utility/omega_h_array_utils.h" #include "pcms/utility/profile.h" -#include #include namespace pcms @@ -49,35 +48,6 @@ Omega_h::Write BuildGids(Omega_h::Mesh& mesh, int entity_dim, return gids; } -// Some meshes (e.g. certain XGC meshes) are stored without any geometric -// classification (no class_id/class_dim tags). The layout and its -// discretization read these tags on every mesh dimension, so derive a default -// classification when it is missing. classify_elements + -// finalize_classification populate a geometrically meaningful class_dim on all -// dimensions but do not create class_id (that normally comes from a geometric -// model we don't have here), so fill any missing class_id with 0. -// Classification is only consulted for coupling DOF matching -// (field_exchange_planner); standalone field transfer never reads it, so a -// default id is sufficient to keep such meshes usable. -void EnsureClassification(Omega_h::Mesh& mesh) -{ - if (mesh.has_tag(mesh.dim(), "class_id") && - mesh.has_tag(mesh.dim(), "class_dim")) { - return; - } - if (!mesh.has_tag(mesh.dim(), "class_dim")) { - Omega_h::classify_elements(&mesh); - Omega_h::finalize_classification(&mesh); - } - for (int d = 0; d <= mesh.dim(); ++d) { - if (!mesh.has_tag(d, "class_id")) { - mesh.add_tag( - d, "class_id", 1, - Omega_h::Read(mesh.nents(d), 0, "class_id")); - } - } -} - Kokkos::View BuildOwned(Omega_h::Mesh& mesh, int entity_dim) { diff --git a/src/pcms/utility/mesh_geometry.h b/src/pcms/utility/mesh_geometry.h index ef40719a..4c74595f 100644 --- a/src/pcms/utility/mesh_geometry.h +++ b/src/pcms/utility/mesh_geometry.h @@ -2,6 +2,7 @@ #define PCMS_UTILITY_MESH_GEOMETRY_H #include +#include #include #include @@ -93,6 +94,35 @@ inline Omega_h::Reals get_entity_centroids(Omega_h::Mesh& mesh, return Omega_h::Reals(centroids); } +// Some meshes (e.g. certain XGC meshes) are stored without any geometric +// classification (no class_id/class_dim tags). Layouts read these tags on +// every mesh dimension, so derive a default classification when it is +// missing. classify_elements + finalize_classification populate a +// geometrically meaningful class_dim on all dimensions but do not create +// class_id (that normally comes from a geometric model we don't have here), +// so fill any missing class_id with 0. +// Classification is only consulted for coupling DOF matching +// (field_exchange_planner); standalone field transfer never reads it, so a +// default id is sufficient to keep such meshes usable. +inline void EnsureClassification(Omega_h::Mesh& mesh) +{ + if (mesh.has_tag(mesh.dim(), "class_id") && + mesh.has_tag(mesh.dim(), "class_dim")) { + return; + } + if (!mesh.has_tag(mesh.dim(), "class_dim")) { + Omega_h::classify_elements(&mesh); + Omega_h::finalize_classification(&mesh); + } + for (int d = 0; d <= mesh.dim(); ++d) { + if (!mesh.has_tag(d, "class_id")) { + mesh.add_tag( + d, "class_id", 1, + Omega_h::Read(mesh.nents(d), 0, "class_id")); + } + } +} + } // namespace pcms #endif // PCMS_UTILITY_MESH_GEOMETRY_H