Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pcms/field/layout/omega_h_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Comment on lines +57 to 60
num_components_(num_components),
num_global_dof_holder_(mesh.nglobal_ents(entity_dim)),
Expand Down
30 changes: 0 additions & 30 deletions src/pcms/field/layout/omega_h_lagrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "pcms/utility/mesh_geometry.h"
#include "pcms/utility/omega_h_array_utils.h"
#include "pcms/utility/profile.h"
#include <Omega_h_class.hpp>
#include <stdexcept>

namespace pcms
Expand Down Expand Up @@ -49,35 +48,6 @@ Omega_h::Write<Omega_h::GO> 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<Omega_h::ClassId>(
d, "class_id", 1,
Omega_h::Read<Omega_h::ClassId>(mesh.nents(d), 0, "class_id"));
}
}
}

Kokkos::View<bool*, DeviceMemorySpace> BuildOwned(Omega_h::Mesh& mesh,
int entity_dim)
{
Expand Down
30 changes: 30 additions & 0 deletions src/pcms/utility/mesh_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PCMS_UTILITY_MESH_GEOMETRY_H

#include <Omega_h_array.hpp>
#include <Omega_h_class.hpp>
#include <Omega_h_for.hpp>
#include <Omega_h_mesh.hpp>

Expand Down Expand Up @@ -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);
}
Comment on lines +109 to +116
for (int d = 0; d <= mesh.dim(); ++d) {
if (!mesh.has_tag(d, "class_id")) {
mesh.add_tag<Omega_h::ClassId>(
d, "class_id", 1,
Omega_h::Read<Omega_h::ClassId>(mesh.nents(d), 0, "class_id"));
}
}
}

} // namespace pcms

#endif // PCMS_UTILITY_MESH_GEOMETRY_H
Loading