allowing geometry to be fully made via constructor (#2602)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Jonathan Shimwell 2023-07-23 23:26:13 +01:00 committed by GitHub
parent afa6ceb7d7
commit d47e9a1092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -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

View file

@ -362,8 +362,13 @@ def test_remove_redundant_surfaces():
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]))