Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added off axis tests for cy mesh origin
  • Loading branch information
shimwell committed Sep 4, 2023
commit 2281ad5e85ef43af68f6189ed7597800961bacac
2 changes: 1 addition & 1 deletion openmc/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ def from_domain(
cached_bb[1][2],
num=dimension[2]+1
)
origin = (r_grid[0], r_grid[0], z_grid[0])
origin = (cached_bb.center[0], cached_bb.center[1], z_grid[0])
mesh = cls(
r_grid=r_grid,
z_grid=z_grid,
Expand Down
30 changes: 25 additions & 5 deletions tests/unit_tests/test_mesh_from_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,39 @@ def test_reg_mesh_from_cell():

def test_cylindrical_mesh_from_cell():
"""Tests a CylindricalMesh can be made from a Cell and the specified
dimensions are propagated through. Cell is not centralized"""
dimensions are propagated through."""
# Cell is not centralized on Z axis
cy_surface = openmc.ZCylinder(r=50)
z_surface_1 = openmc.ZPlane(z0=30)
z_surface_2 = openmc.ZPlane(z0=0)
z_surface_1 = openmc.ZPlane(z0=40)
z_surface_2 = openmc.ZPlane(z0=10)
cell = openmc.Cell(region=-cy_surface & -z_surface_1 & +z_surface_2)
mesh = openmc.CylindricalMesh.from_domain(domain=cell, dimension=[2, 4, 3])

assert isinstance(mesh, openmc.CylindricalMesh)
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, [0., 10., 20., 30.])
assert np.array_equal(mesh.origin, [0., 0., 0.])
assert np.array_equal(mesh.z_grid, [10., 20., 30., 40.])
assert np.array_equal(mesh.origin, [0., 0., 10.])

# Cell is not centralized on Z or X axis
cy_surface = openmc.ZCylinder(r=50, x0=100)
cell = openmc.Cell(region=-cy_surface & -z_surface_1 & +z_surface_2)
mesh = openmc.CylindricalMesh.from_domain(domain=cell, dimension=[1, 1, 1])

assert isinstance(mesh, openmc.CylindricalMesh)
assert np.array_equal(mesh.dimension, (1, 1, 1))
assert np.array_equal(mesh.r_grid, [0., 150.])
assert np.array_equal(mesh.origin, [100., 0., 10.])

# Cell is not centralized on Z, X or Y axis
cy_surface = openmc.ZCylinder(r=50, x0=100, y0=170)
cell = openmc.Cell(region=-cy_surface & -z_surface_1 & +z_surface_2)
mesh = openmc.CylindricalMesh.from_domain(domain=cell, dimension=[1, 1, 1])

assert isinstance(mesh, openmc.CylindricalMesh)
assert np.array_equal(mesh.r_grid, [0., 220.])
assert np.array_equal(mesh.origin, [100., 170., 10.])


def test_reg_mesh_from_region():
Expand Down