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
Switching to enclose_domain
  • Loading branch information
pshriwise committed Jun 6, 2025
commit e12ca216d875a87c9f4bfa818943dedece21f559
30 changes: 14 additions & 16 deletions openmc/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ def from_domain(
mesh_id: int | None = None,
phi_grid_bounds: Sequence[float] = (0.0, 2*pi),
name: str = '',
inscribe: bool = True
enclose_domain: bool = False
):
"""Creates a regular CylindricalMesh from an existing openmc domain.

Expand All @@ -1812,10 +1812,9 @@ def from_domain(
is (0, 2π), i.e., the full phi range.
name : str
Name of the mesh
inscribe : bool
If True, the mesh will be inscribed within the bounding box of the
domain, meaning that the r_grid will be adjusted to fit within
the bounding box.
enclose_domain : bool
If True, the mesh will encompass the bounding box of the domain. If
False, the mesh will be inscribed within the domain's bounding box.

Returns
-------
Expand All @@ -1832,10 +1831,10 @@ def from_domain(
# loaded once to avoid recalculating bounding box
cached_bb = domain.bounding_box

if inscribe:
outer_radius = 0.5 * min(cached_bb.width[:2])
else:
if enclose_domain:
outer_radius = 0.5 * np.linalg.norm(cached_bb.width[:2])
else:
outer_radius = 0.5 * min(cached_bb.width[:2])

r_grid = np.linspace(
0,
Expand Down Expand Up @@ -2179,7 +2178,7 @@ def from_domain(
phi_grid_bounds: Sequence[float] = (0.0, 2*pi),
theta_grid_bounds: Sequence[float] = (0.0, pi),
name: str = '',
inscribe: bool = True
enclose_domain: bool = False
):
"""Creates a regular SphericalMesh from an existing openmc domain.

Expand All @@ -2203,10 +2202,9 @@ def from_domain(
is (0, π), i.e., the full theta range.
name : str
Name of the mesh
inscribe : bool
If True, the mesh will be inscribed within the bounding box of the
domain, meaning that the r_grid will be adjusted to fit within
the bounding box.
enclose_domain : bool
If True, the mesh will encompass the bounding box of the domain. If
False, the mesh will be inscribed within the domain's bounding box.

Returns
-------
Expand All @@ -2223,10 +2221,10 @@ def from_domain(
# loaded once to avoid recalculating bounding box
cached_bb = domain.bounding_box

if inscribe:
outer_radius = 0.5 * min(cached_bb.width)
else:
if enclose_domain:
outer_radius = 0.5 * np.linalg.norm(cached_bb.width)
else:
outer_radius = 0.5 * min(cached_bb.width)

r_grid = np.linspace(
0,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_mesh_from_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_spherical_mesh_from_domain():
geometry = openmc.Geometry(openmc.Universe(cells=[openmc.Cell(region=region)]))

region_mesh = openmc.SphericalMesh.from_domain(
domain=region, dimension=(4, 3, 4), inscribe=True)
domain=region, dimension=(4, 3, 4))
universe_mesh = openmc.SphericalMesh.from_domain(
domain=geometry.root_universe, dimension=(4, 3, 4))
geometry_mesh = openmc.SphericalMesh.from_domain(
Expand Down