Implement get_bin and get_bin_index for MeshSurfaceFilter

This commit is contained in:
Paul Romano 2018-03-16 14:38:37 -05:00
parent 22429dd389
commit d393a74906
2 changed files with 18 additions and 2 deletions

View file

@ -109,6 +109,7 @@ Constructing Tallies
openmc.CellbornFilter
openmc.SurfaceFilter
openmc.MeshFilter
openmc.MeshSurfaceFilter
openmc.EnergyFilter
openmc.EnergyoutFilter
openmc.MuFilter

View file

@ -865,10 +865,25 @@ class MeshSurfaceFilter(MeshFilter):
return 4*n_dim*reduce(operator.mul, self.mesh.dimension)
def get_bin_index(self, filter_bin):
raise NotImplementedError
# Split bin into mesh/surface parts
*mesh_tuple, surf = filter_bin
# Get index for mesh alone
mesh_index = super().get_bin_index(mesh_tuple)
# Combine surface and mesh index
n_dim = len(self.mesh.dimension)
for surf_index, name in _CURRENT_NAMES.items():
if surf == name:
return 4*n_dim*mesh_index + surf_index - 1
else:
raise ValueError("'{}' is not a valid mesh surface.".format(surf))
def get_bin(self, bin_index):
raise NotImplementedError
n_dim = len(self.mesh.dimension)
mesh_index, surf_index = divmod(bin_index, 4*n_dim)
mesh_bin = super().get_bin(mesh_index)
return mesh_bin + (_CURRENT_NAMES[surf_index + 1],)
def get_pandas_dataframe(self, data_size, stride, **kwargs):
"""Builds a Pandas DataFrame for the Filter's bins.