Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing origin to CylindricalMesh.from_domain #2676

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions openmc/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,8 @@ class CylindricalMesh(StructuredMesh):
1-D array of mesh boundary points along the r-axis.
Requirement is r >= 0.
z_grid : numpy.ndarray
1-D array of mesh boundary points along the z-axis.
1-D array of mesh boundary points along the z-axis relative to the
origin.
phi_grid : numpy.ndarray
1-D array of mesh boundary points along the phi-axis in radians.
The default value is [0, 2π], i.e. the full phi range.
Expand All @@ -1207,8 +1208,7 @@ class CylindricalMesh(StructuredMesh):
name : str
Name of the mesh
dimension : Iterable of int
The number of mesh cells in each direction (r_grid,
phi_grid, z_grid).
The number of mesh cells in each direction (r_grid, phi_grid, z_grid).
n_dimension : int
Number of mesh dimensions (always 3 for a CylindricalMesh).
r_grid : numpy.ndarray
Expand All @@ -1218,7 +1218,8 @@ class CylindricalMesh(StructuredMesh):
1-D array of mesh boundary points along the phi-axis in radians.
The default value is [0, 2π], i.e. the full phi range.
z_grid : numpy.ndarray
1-D array of mesh boundary points along the z-axis.
1-D array of mesh boundary points along the z-axis relative to the
origin.
origin : numpy.ndarray
1-D array of length 3 the (x,y,z) origin of the mesh in
cartesian coordinates
Expand Down Expand Up @@ -1314,7 +1315,6 @@ def indices(self):
for p in range(1, np + 1)
for r in range(1, nr + 1))


@property
def lower_left(self):
return np.array((
Expand Down Expand Up @@ -1413,7 +1413,6 @@ def from_domain(
(openmc.Cell, openmc.Region, openmc.Universe, openmc.Geometry),
)


# loaded once to avoid reading h5m file repeatedly
cached_bb = domain.bounding_box
max_bounding_box_radius = max(
Expand All @@ -1439,8 +1438,14 @@ def from_domain(
cached_bb[1][2],
num=dimension[2]+1
)
origin = cached_bb.center
mesh = cls(
r_grid=r_grid, z_grid=z_grid, phi_grid=phi_grid, mesh_id=mesh_id, name=name
r_grid=r_grid,
z_grid=z_grid,
phi_grid=phi_grid,
mesh_id=mesh_id,
name=name,
origin=origin
)

return mesh
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/test_mesh_from_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_cylindrical_mesh_from_cell():
assert np.array_equal(mesh.r_grid, [0., 25., 50.])
assert np.array_equal(mesh.phi_grid, [0., 0.5*np.pi, np.pi, 1.5*np.pi, 2.*np.pi])
assert np.array_equal(mesh.z_grid, [0., 10., 20., 30.])
assert np.array_equal(mesh.origin, [0., 0., 15.])


def test_reg_mesh_from_region():
Expand Down