mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Move mesh and meshsurface filter internals to C++
This commit is contained in:
parent
7f2c2904e7
commit
5a73710110
7 changed files with 107 additions and 195 deletions
|
|
@ -53,7 +53,31 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual std::string text_label(int bin) const {};
|
||||
virtual void
|
||||
to_statepoint(hid_t filter_group) const override
|
||||
{
|
||||
write_dataset(filter_group, "type", "mesh");
|
||||
write_dataset(filter_group, "n_bins", n_bins_);
|
||||
write_dataset(filter_group, "bins", meshes[mesh_]->id_);
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
text_label(int bin) const override
|
||||
{
|
||||
auto& mesh = *meshes[mesh_];
|
||||
int n_dim = mesh.n_dimension_;
|
||||
|
||||
int ijk[n_dim];
|
||||
mesh.get_indices_from_bin(bin, ijk);
|
||||
|
||||
std::stringstream out;
|
||||
out << "Mesh Index (" << ijk[0];
|
||||
if (n_dim > 1) out << ", " << ijk[1];
|
||||
if (n_dim > 2) out << ", " << ijk[2];
|
||||
out << ")";
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
int32_t mesh_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <sstream>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/mesh.h"
|
||||
#include "openmc/tallies/tally_filter.h"
|
||||
|
|
@ -45,7 +46,62 @@ public:
|
|||
for (auto b : match.bins) match.weights.push_back(1.0);
|
||||
}
|
||||
|
||||
virtual std::string text_label(int bin) const {};
|
||||
virtual void
|
||||
to_statepoint(hid_t filter_group) const override
|
||||
{
|
||||
write_dataset(filter_group, "type", "meshsurface");
|
||||
write_dataset(filter_group, "n_bins", n_bins_);
|
||||
write_dataset(filter_group, "bins", meshes[mesh_]->id_);
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
text_label(int bin) const override
|
||||
{
|
||||
auto& mesh = *meshes[mesh_];
|
||||
int n_dim = mesh.n_dimension_;
|
||||
|
||||
// Get flattend mesh index and surface index.
|
||||
int i_mesh = (bin - 1) / (4 * n_dim) + 1;
|
||||
int i_surf = ((bin - 1) % (4 * n_dim)) + 1;
|
||||
|
||||
// Get mesh index part of label.
|
||||
int ijk[n_dim];
|
||||
mesh.get_indices_from_bin(i_mesh, ijk);
|
||||
std::stringstream out;
|
||||
out << "Mesh Index (" << ijk[0];
|
||||
if (n_dim > 1) out << ", " << ijk[1];
|
||||
if (n_dim > 2) out << ", " << ijk[2];
|
||||
out << ")";
|
||||
|
||||
// Get surface part of label.
|
||||
if (i_surf == OUT_LEFT) {
|
||||
out << " Outgoing, x-min";
|
||||
} else if (i_surf == IN_LEFT) {
|
||||
out << " Incoming, x-min";
|
||||
} else if (i_surf == OUT_RIGHT) {
|
||||
out << " Outgoing, x-max";
|
||||
} else if (i_surf == IN_RIGHT) {
|
||||
out << " Incoming, x-max";
|
||||
} else if (i_surf == OUT_BACK) {
|
||||
out << " Outgoing, y-min";
|
||||
} else if (i_surf == IN_BACK) {
|
||||
out << " Incoming, y-min";
|
||||
} else if (i_surf == OUT_FRONT) {
|
||||
out << " Outgoing, y-max";
|
||||
} else if (i_surf == IN_FRONT) {
|
||||
out << " Incoming, y-max";
|
||||
} else if (i_surf == OUT_BOTTOM) {
|
||||
out << " Outgoing, z-min";
|
||||
} else if (i_surf == IN_BOTTOM) {
|
||||
out << " Incoming, z-min";
|
||||
} else if (i_surf == OUT_TOP) {
|
||||
out << " Outgoing, z-max";
|
||||
} else if (i_surf == IN_TOP) {
|
||||
out << " Incoming, z-max";
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
int32_t mesh_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue