Skip to content

Commit

Permalink
Making z-grid relative to the mesh origin in from_domain. (#2710)
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Sep 27, 2023
1 parent d4b989a commit f7bb27e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions openmc/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ def from_domain(
num=dimension[2]+1
)
origin = (cached_bb.center[0], cached_bb.center[1], z_grid[0])

# make z-grid relative to the origin
z_grid -= origin[2]

mesh = cls(
r_grid=r_grid,
z_grid=z_grid,
Expand Down
5 changes: 3 additions & 2 deletions tests/unit_tests/test_mesh_from_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_cylindrical_mesh_from_cell():
assert np.array_equal(mesh.dimension, (2, 4, 3))
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, [10., 20., 30., 40.])
assert np.array_equal(mesh.z_grid, [0., 10., 20., 30.])
assert np.array_equal(mesh.origin, [0., 0., 10.])

# Cell is not centralized on Z or X axis
Expand Down Expand Up @@ -83,7 +83,8 @@ def test_cylindrical_mesh_from_region():
assert np.array_equal(mesh.dimension, (6, 2, 3))
assert np.array_equal(mesh.r_grid, [0., 1., 2., 3., 4., 5., 6.])
assert np.array_equal(mesh.phi_grid, [0., 0.5*np.pi, np.pi])
assert np.array_equal(mesh.z_grid, [-30., -10., 10., 30.])
assert np.array_equal(mesh.z_grid, [0.0, 20., 40., 60])
assert np.array_equal(mesh.origin, (0.0, 0.0, -30.))


def test_reg_mesh_from_universe():
Expand Down

0 comments on commit f7bb27e

Please sign in to comment.