Skip to content

Commit 775539f

Browse files
shimwellpaulromano
authored andcommitted
Adding missing origin to CylindricalMesh.from_domain (openmc-dev#2676)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent eafbdd6 commit 775539f

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎openmc/mesh.py‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,8 @@ class CylindricalMesh(StructuredMesh):
11881188
1-D array of mesh boundary points along the r-axis.
11891189
Requirement is r >= 0.
11901190
z_grid : numpy.ndarray
1191-
1-D array of mesh boundary points along the z-axis.
1191+
1-D array of mesh boundary points along the z-axis relative to the
1192+
origin.
11921193
phi_grid : numpy.ndarray
11931194
1-D array of mesh boundary points along the phi-axis in radians.
11941195
The default value is [0, 2π], i.e. the full phi range.
@@ -1207,8 +1208,7 @@ class CylindricalMesh(StructuredMesh):
12071208
name : str
12081209
Name of the mesh
12091210
dimension : Iterable of int
1210-
The number of mesh cells in each direction (r_grid,
1211-
phi_grid, z_grid).
1211+
The number of mesh cells in each direction (r_grid, phi_grid, z_grid).
12121212
n_dimension : int
12131213
Number of mesh dimensions (always 3 for a CylindricalMesh).
12141214
r_grid : numpy.ndarray
@@ -1218,7 +1218,8 @@ class CylindricalMesh(StructuredMesh):
12181218
1-D array of mesh boundary points along the phi-axis in radians.
12191219
The default value is [0, 2π], i.e. the full phi range.
12201220
z_grid : numpy.ndarray
1221-
1-D array of mesh boundary points along the z-axis.
1221+
1-D array of mesh boundary points along the z-axis relative to the
1222+
origin.
12221223
origin : numpy.ndarray
12231224
1-D array of length 3 the (x,y,z) origin of the mesh in
12241225
cartesian coordinates
@@ -1314,7 +1315,6 @@ def indices(self):
13141315
for p in range(1, np + 1)
13151316
for r in range(1, nr + 1))
13161317

1317-
13181318
@property
13191319
def lower_left(self):
13201320
return np.array((
@@ -1413,7 +1413,6 @@ def from_domain(
14131413
(openmc.Cell, openmc.Region, openmc.Universe, openmc.Geometry),
14141414
)
14151415

1416-
14171416
# loaded once to avoid reading h5m file repeatedly
14181417
cached_bb = domain.bounding_box
14191418
max_bounding_box_radius = max(
@@ -1439,8 +1438,14 @@ def from_domain(
14391438
cached_bb[1][2],
14401439
num=dimension[2]+1
14411440
)
1441+
origin = cached_bb.center
14421442
mesh = cls(
1443-
r_grid=r_grid, z_grid=z_grid, phi_grid=phi_grid, mesh_id=mesh_id, name=name
1443+
r_grid=r_grid,
1444+
z_grid=z_grid,
1445+
phi_grid=phi_grid,
1446+
mesh_id=mesh_id,
1447+
name=name,
1448+
origin=origin
14441449
)
14451450

14461451
return mesh

‎tests/unit_tests/test_mesh_from_domain.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_cylindrical_mesh_from_cell():
3030
assert np.array_equal(mesh.r_grid, [0., 25., 50.])
3131
assert np.array_equal(mesh.phi_grid, [0., 0.5*np.pi, np.pi, 1.5*np.pi, 2.*np.pi])
3232
assert np.array_equal(mesh.z_grid, [0., 10., 20., 30.])
33+
assert np.array_equal(mesh.origin, [0., 0., 15.])
3334

3435

3536
def test_reg_mesh_from_region():

0 commit comments

Comments
 (0)