mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
switch universe deepcopying for a fresh instance on clones
This commit is contained in:
parent
3f8f8f6701
commit
e799346502
2 changed files with 16 additions and 3 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable
|
||||
from copy import deepcopy
|
||||
from numbers import Integral, Real
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
|
@ -138,8 +137,14 @@ class UniverseBase(ABC, IDManagerMixin):
|
|||
|
||||
# If no memoize'd clone exists, instantiate one
|
||||
if self not in memo:
|
||||
clone = deepcopy(self)
|
||||
clone.id = None
|
||||
clone = openmc.Universe(name=self.name)
|
||||
clone.volume = self.volume
|
||||
# Try to set DAGMCUniverse-specific attributes on the clone
|
||||
try:
|
||||
clone.auto_geom_ids = self.auto_geom_ids
|
||||
clone.auto_mat_ids = self.auto_mat_ids
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# Clone all cells for the universe clone
|
||||
clone._cells = OrderedDict()
|
||||
|
|
|
|||
|
|
@ -120,6 +120,14 @@ def test_clone():
|
|||
assert next(iter(u3.cells.values())).region ==\
|
||||
next(iter(u1.cells.values())).region
|
||||
|
||||
dagmc_u = openmc.DAGMCUniverse(filename="")
|
||||
dagmc_u.auto_geom_ids = True
|
||||
dagmc_u.auto_mat_ids = True
|
||||
dagmc_u1 = dagmc_u.clone()
|
||||
assert dagmc_u1.name == dagmc_u.name
|
||||
assert dagmc_u1.auto_geom_ids == dagmc_u.auto_geom_ids
|
||||
assert dagmc_u1.auto_mat_ids == dagmc_u.auto_mat_ids
|
||||
|
||||
|
||||
def test_create_xml(cell_with_lattice):
|
||||
cells = [openmc.Cell() for i in range(5)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue