Closed RemDelaporteMathurin closed 10 months ago
This package was made before CylindricalMesh exited so it doesn't support it.
CylindricalMesh could be added, I guess we should rename it openmc-mesh-plotter at that point but perhaps best to add the feature first and see how it goes.
def reshape_values_to_mesh_shape(tally, values):
mesh_filter = tally.find_filter(filter_type=openmc.MeshFilter)
# shape = mesh_filter.mesh.dimension.tolist()
shape = [
len(mesh_filter.mesh.r_grid) - 1,
len(mesh_filter.mesh.phi_grid) - 1,
len(mesh_filter.mesh.z_grid) - 1,
]
# 2d mesh has a shape in the form [1, 400, 400]
if 1 in shape:
shape.remove(1)
return values.reshape(shape)
def get_tally_extent(tally):
for filter in tally.filters:
if isinstance(filter, openmc.MeshFilter):
mesh_filter = filter
extent_x = (
min(mesh_filter.mesh.r_grid),
max(mesh_filter.mesh.r_grid),
)
extent_y = (
min(mesh_filter.mesh.phi_grid),
max(mesh_filter.mesh.phi_grid),
)
extent_z = (
min(mesh_filter.mesh.z_grid),
max(mesh_filter.mesh.z_grid),
)
shape = [
len(mesh_filter.mesh.r_grid) - 1,
len(mesh_filter.mesh.phi_grid) - 1,
len(mesh_filter.mesh.z_grid) - 1,
]
if 1 in shape:
print("2d mesh tally")
index_of_1d = shape.index(1)
print("index", index_of_1d)
if index_of_1d == 0:
return extent_y + extent_z
if index_of_1d == 1:
return extent_x + extent_z
if index_of_1d == 2:
return extent_x + extent_y
return None
@shimwell when dealing with a CylindricalMesh instead of a RegularMesh, these two functions need to be updated in order for the plot to work (tested locally)
there is another package openmc-cylinderical-mesh-plotter that solves this
Please... Please...
Don't tell me we need a package called
cylindrical_mesh_plotter
ðŸ˜