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

cy mesh origin from start of z_grid and _r_grid #2680

Merged
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
4 changes: 2 additions & 2 deletions openmc/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ def from_domain(
(openmc.Cell, openmc.Region, openmc.Universe, openmc.Geometry),
)

# loaded once to avoid reading h5m file repeatedly
# loaded once to avoid recalculating bounding box
cached_bb = domain.bounding_box
max_bounding_box_radius = max(
[
Expand All @@ -1438,7 +1438,7 @@ def from_domain(
cached_bb[1][2],
num=dimension[2]+1
)
origin = cached_bb.center
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., 15.])
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