mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
added get_surfaces_by_name method
This commit is contained in:
parent
ee0fcd3bc0
commit
a0afa5de44
2 changed files with 33 additions and 4 deletions
|
|
@ -525,6 +525,27 @@ class Geometry:
|
|||
"""
|
||||
return self._get_domains_by_name(name, case_sensitive, matching, 'cell')
|
||||
|
||||
def get_surfaces_by_name(self, name, case_sensitive=False, matching=False):
|
||||
"""Return a list of surfaces with matching names.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name : str
|
||||
The name to search match
|
||||
case_sensitive : bool
|
||||
Whether to distinguish upper and lower case letters in each
|
||||
surface's name (default is False)
|
||||
matching : bool
|
||||
Whether the names must match completely (default is False)
|
||||
|
||||
Returns
|
||||
-------
|
||||
list of openmc.Surface
|
||||
Surfaces matching the queried name
|
||||
|
||||
"""
|
||||
return self._get_domains_by_name(name, case_sensitive, matching, 'surface')
|
||||
|
||||
def get_cells_by_fill_name(self, name, case_sensitive=False, matching=False):
|
||||
"""Return a list of cells with fills with matching names.
|
||||
|
||||
|
|
|
|||
|
|
@ -159,12 +159,13 @@ def test_get_by_name():
|
|||
m2 = openmc.Material(name='Zirconium')
|
||||
m2.add_element('Zr', 1.0)
|
||||
|
||||
c1 = openmc.Cell(fill=m1, name='cell1')
|
||||
s1 = openmc.Sphere(name='surface1')
|
||||
c1 = openmc.Cell(fill=m1, region=-s1, name='cell1')
|
||||
u1 = openmc.Universe(name='Zircaloy universe', cells=[c1])
|
||||
|
||||
cyl = openmc.ZCylinder()
|
||||
c2 = openmc.Cell(fill=u1, region=-cyl, name='cell2')
|
||||
c3 = openmc.Cell(fill=m2, region=+cyl, name='Cell3')
|
||||
s2 = openmc.ZCylinder(name='surface2')
|
||||
c2 = openmc.Cell(fill=u1, region=-s2, name='cell2')
|
||||
c3 = openmc.Cell(fill=m2, region=+s2, name='Cell3')
|
||||
root = openmc.Universe(name='root Universe', cells=[c2, c3])
|
||||
geom = openmc.Geometry(root)
|
||||
|
||||
|
|
@ -177,6 +178,13 @@ def test_get_by_name():
|
|||
mats = geom.get_materials_by_name('zirconium', True, True)
|
||||
assert not mats
|
||||
|
||||
surfaces = set(geom.get_surfaces_by_name('surface'))
|
||||
assert not surfaces ^ {s1, s2}
|
||||
surfaces = set(geom.get_surfaces_by_name('Surface2', False, True))
|
||||
assert not surfaces ^ {s2}
|
||||
surfaces = geom.get_surfaces_by_name('Surface2', True, True)
|
||||
assert not surfaces
|
||||
|
||||
cells = set(geom.get_cells_by_name('cell'))
|
||||
assert not cells ^ {c1, c2, c3}
|
||||
cells = set(geom.get_cells_by_name('cell', True))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue