mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Releasing ID after creating dummy universe for cell plotting (#2663)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
1cae2f712a
commit
27540c5b8a
2 changed files with 22 additions and 1 deletions
|
|
@ -618,7 +618,10 @@ class Cell(IDManagerMixin):
|
|||
Axes containing resulting image
|
||||
|
||||
"""
|
||||
return openmc.Universe(cells=[self]).plot(*args, **kwargs)
|
||||
# Create dummy universe but preserve used_ids
|
||||
u = openmc.Universe(cells=[self], universe_id=openmc.Universe.next_id + 1)
|
||||
openmc.Universe.used_ids.remove(u.id)
|
||||
return u.plot(*args, **kwargs)
|
||||
|
||||
def create_xml_subelement(self, xml_element, memo=None):
|
||||
"""Add the cell's xml representation to an incoming xml element
|
||||
|
|
|
|||
|
|
@ -345,3 +345,21 @@ def test_rotation_from_xml(rotation):
|
|||
elem, {s.id: s}, {'void': None}, openmc.Universe
|
||||
)
|
||||
np.testing.assert_allclose(new_cell.rotation, cell.rotation)
|
||||
|
||||
|
||||
def test_plot(run_in_tmpdir):
|
||||
zcyl = openmc.ZCylinder()
|
||||
c = openmc.Cell(region=-zcyl)
|
||||
|
||||
# create a universe before the plot
|
||||
u_before = openmc.Universe()
|
||||
|
||||
# create a plot of the cell
|
||||
c.plot()
|
||||
|
||||
# create a universe after the plot
|
||||
u_after = openmc.Universe()
|
||||
|
||||
# ensure that calling the plot method doesn't
|
||||
# affect the universe ID space
|
||||
assert u_before.id + 1 == u_after.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue