Skip to content

Commit

Permalink
allowing geometry to be fully made via constructor (#2602)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Romano <[email protected]>
  • Loading branch information
shimwell and paulromano committed Jul 23, 2023
1 parent afa6ceb commit d47e9a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions openmc/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ class Geometry:
"""

def __init__(self, root=None):
def __init__(
self,
root: typing.Optional[openmc.UniverseBase] = None,
merge_surfaces: bool = False,
surface_precision: int = 10
):
self._root_universe = None
self._offsets = {}
self.merge_surfaces = False
self.surface_precision = 10
self.merge_surfaces = merge_surfaces
self.surface_precision = surface_precision
if root is not None:
if isinstance(root, openmc.UniverseBase):
self.root_universe = root
Expand Down
9 changes: 7 additions & 2 deletions tests/unit_tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,13 @@ def get_cyl_cell(r1, r2, z1, z2, fill):
clad = get_cyl_cell(r1, r2, z1, z2, m2)
water = get_cyl_cell(r2, r3, z1, z2, m3)
root = openmc.Universe(cells=[fuel, clad, water])
geom = openmc.Geometry(root)
geom.merge_surfaces=True
geom = openmc.Geometry(root=root, merge_surfaces=True, surface_precision=11)
assert geom.merge_surfaces is True
geom.merge_surfaces = False
assert geom.merge_surfaces is False
assert geom.surface_precision == 11
geom.surface_precision = 10
assert geom.surface_precision == 10
model = openmc.model.Model(geometry=geom,
materials=openmc.Materials([m1, m2, m3]))

Expand Down

0 comments on commit d47e9a1

Please sign in to comment.