mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Wrote method Geometry.get_all_surface()
A method in the vein of `Geometry.get_all_cells()`
This commit is contained in:
parent
4353e57f95
commit
9fcdd5e046
1 changed files with 42 additions and 0 deletions
|
|
@ -257,7 +257,49 @@ class Geometry(object):
|
|||
lattices[cell.fill.id] = cell.fill
|
||||
|
||||
return lattices
|
||||
|
||||
def get_all_surfaces(self):
|
||||
"""
|
||||
Return all surfaces used in the geometry
|
||||
|
||||
Returns
|
||||
-------
|
||||
collections.OrderedDict
|
||||
Dictionary mapping lattice IDs to :class:`openmc.Surface` instances
|
||||
|
||||
"""
|
||||
surfaces = OrderedDict()
|
||||
|
||||
for cell in self.get_all_cells().values():
|
||||
self.get_surfaces_from_region(surfaces, cell.region)
|
||||
return surfaces
|
||||
|
||||
def get_surfaces_from_region(self, surfaces, region):
|
||||
"""
|
||||
Recursively find all the surfaces referenced by a region and return them
|
||||
|
||||
Parameters
|
||||
----------
|
||||
surfaces: collections.OrderedDict
|
||||
Dictionary mapping lattice IDs to :class:`openmc.Surface` instances
|
||||
|
||||
region: openmc.surface.Region
|
||||
The region of space defined by Surfaces
|
||||
Returns
|
||||
-------
|
||||
collections.OrderedDict
|
||||
Dictionary mapping lattice IDs to :class:`openmc.Surface` instances
|
||||
|
||||
"""
|
||||
if isinstance(region, openmc.Halfspace):
|
||||
s = region.surface
|
||||
if s.id not in surfaces:
|
||||
surfaces[s.id] = s
|
||||
else:
|
||||
for reg in region:
|
||||
surfaces = self.get_surfaces_from_region(surfaces, reg)
|
||||
return surfaces
|
||||
|
||||
def get_materials_by_name(self, name, case_sensitive=False, matching=False):
|
||||
"""Return a list of materials with matching names.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue