Add the labeling to Mesh and its subclasses

This commit is contained in:
Labossiere-Hickman, Travis James 2026-07-16 16:04:30 -06:00
parent aa24f27d4d
commit b416a938b6
2 changed files with 39 additions and 0 deletions

View file

@ -236,6 +236,12 @@ public:
//! \param[in] bin Mesh bin to generate a label for
virtual std::string bin_label(int bin) const = 0;
//! Axis names (per dimension) used when labeling surface tally bins
virtual std::array<const char*, 3> axis_labels() const;
//! Build the surface component of a mesh surface tally bin label
std::string surface_bin_label(int surf_index) const;
//! Get the volume of a mesh bin
//
//! \param[in] bin Bin to return the volume for
@ -588,6 +594,8 @@ public:
static const std::string mesh_type;
std::array<const char*, 3> axis_labels() const override;
Position sample_element(const MeshIndex& ijk, uint64_t* seed) const override;
MeshDistance distance_to_grid_boundary(const MeshIndex& ijk, int i,
@ -653,6 +661,8 @@ public:
static const std::string mesh_type;
std::array<const char*, 3> axis_labels() const override;
Position sample_element(const MeshIndex& ijk, uint64_t* seed) const override;
MeshDistance distance_to_grid_boundary(const MeshIndex& ijk, int i,

View file

@ -430,6 +430,25 @@ vector<double> Mesh::volumes() const
return volumes;
}
//! Default (Cartesian) axis labels used for surface bin labels.
std::array<const char*, 3> Mesh::axis_labels() const
{
return {"x", "y", "z"};
}
//! Build the surface component of a mesh surface tally bin label.
//! surf_index: 0=out/min, 1=in/min, 2=out/max, 3=in/max
std::string Mesh::surface_bin_label(int surf_index) const
{
auto labels = this->axis_labels();
int dim = surf_index / 4;
int code = surf_index % 4;
bool incoming = (code == 1) || (code == 3);
bool max = (code == 2) || (code == 3);
return fmt::format(" {}, {}-{}", incoming ? "Incoming" : "Outgoing",
labels[dim], max ? "max" : "min");
}
void Mesh::material_volumes(int nx, int ny, int nz, int table_size,
int32_t* materials, double* volumes) const
{
@ -1815,6 +1834,11 @@ std::string CylindricalMesh::get_mesh_type() const
return mesh_type;
}
std::array<const char*, 3> CylindricalMesh::axis_labels() const
{
return {"r", "phi", "z"};
}
StructuredMesh::MeshIndex CylindricalMesh::get_indices(
Position r, bool& in_mesh) const
{
@ -2108,6 +2132,11 @@ std::string SphericalMesh::get_mesh_type() const
return mesh_type;
}
std::array<const char*, 3> SphericalMesh::axis_labels() const
{
return {"r", "theta", "phi"};
}
StructuredMesh::MeshIndex SphericalMesh::get_indices(
Position r, bool& in_mesh) const
{