mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Open dagmc model file within a context manager (#3706)
This commit is contained in:
parent
9c91bddf04
commit
60ddafa9b3
1 changed files with 12 additions and 14 deletions
|
|
@ -223,21 +223,19 @@ class DAGMCUniverse(openmc.UniverseBase):
|
|||
|
||||
@property
|
||||
def material_names(self):
|
||||
dagmc_file_contents = h5py.File(self.filename)
|
||||
material_tags_hex = dagmc_file_contents['/tstt/tags/NAME'].get(
|
||||
'values')
|
||||
material_tags_ascii = []
|
||||
for tag in material_tags_hex:
|
||||
candidate_tag = tag.tobytes().decode().replace('\x00', '')
|
||||
# tags might be for temperature or reflective surfaces
|
||||
if candidate_tag.startswith('mat:'):
|
||||
# if name ends with _comp remove it, it is not parsed
|
||||
if candidate_tag.endswith('_comp'):
|
||||
candidate_tag = candidate_tag[:-5]
|
||||
# removes first 4 characters as openmc.Material name should be
|
||||
# set without the 'mat:' part of the tag
|
||||
material_tags_ascii.append(candidate_tag[4:])
|
||||
|
||||
with h5py.File(self.filename) as dagmc_file_contents:
|
||||
material_tags_hex = dagmc_file_contents['/tstt/tags/NAME'].get('values')
|
||||
for tag in material_tags_hex:
|
||||
candidate_tag = tag.tobytes().decode().replace('\x00', '')
|
||||
# tags might be for temperature or reflective surfaces
|
||||
if candidate_tag.startswith('mat:'):
|
||||
# if name ends with _comp remove it, it is not parsed
|
||||
if candidate_tag.endswith('_comp'):
|
||||
candidate_tag = candidate_tag[:-5]
|
||||
# removes first 4 characters as openmc.Material name should be
|
||||
# set without the 'mat:' part of the tag
|
||||
material_tags_ascii.append(candidate_tag[4:])
|
||||
return sorted(set(material_tags_ascii))
|
||||
|
||||
def _n_geom_elements(self, geom_type):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue