From e32f4c3cc1eb99f073db70e940d865083da34bb1 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 1 Apr 2020 09:19:23 -0500 Subject: [PATCH] Changes in mesh.py from PullRequest Inc. review --- openmc/mesh.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/openmc/mesh.py b/openmc/mesh.py index c490f604a..d2a93676f 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -10,6 +10,7 @@ import openmc.checkvalue as cv import openmc from openmc._xml import get_text from openmc.mixin import IDManagerMixin +from openmc.surface import _BOUNDARY_TYPES class MeshBase(IDManagerMixin, metaclass=ABCMeta): @@ -322,7 +323,7 @@ class RegularMesh(MeshBase): return mesh - def build_cells(self, bc=['reflective'] * 6): + def build_cells(self, bc=None): """Generates a lattice of universes with the same dimensionality as the mesh object. The individual cells/universes produced will not have material definitions applied and so downstream code @@ -330,12 +331,13 @@ class RegularMesh(MeshBase): Parameters ---------- - bc : iterable of {'reflective', 'periodic', 'transmission', or 'vacuum'} + bc : iterable of {'reflective', 'periodic', 'transmission', 'vacuum', or 'white'} Boundary conditions for each of the four faces of a rectangle - (if aplying to a 2D mesh) or six faces of a parallelepiped + (if applying to a 2D mesh) or six faces of a parallelepiped (if applying to a 3D mesh) provided in the following order: [x min, x max, y min, y max, z min, z max]. 2-D cells do not - contain the z min and z max entries. + contain the z min and z max entries. Defaults to 'reflective' for + all faces. Returns ------- @@ -349,11 +351,12 @@ class RegularMesh(MeshBase): geometry. """ - - cv.check_length('bc', bc, length_min=4, length_max=6) + if bc is None: + bc = ['reflective'] * 6 + if len(bc) not in (4, 6): + raise ValueError('Boundary condition must be of length 4 or 6') for entry in bc: - cv.check_value('bc', entry, ['transmission', 'vacuum', - 'reflective', 'periodic']) + cv.check_value('bc', entry, _BOUNDARY_TYPES) n_dim = len(self.dimension) @@ -390,7 +393,7 @@ class RegularMesh(MeshBase): # We will concurrently build cells to assign to these universes cells = [] universes = [] - for index in self.indices: + for _ in self.indices: cells.append(openmc.Cell()) universes.append(openmc.Universe()) universes[-1].add_cell(cells[-1])