added ability to find material names in DAG
As discussed in issue #2229 this PR is an attempt to allow users to easily find the DAGMC material tags present in a DAGMCUniverse.
This is useful as the tags are needed when naming openmc.Material() objects used in the simulation and there is not an easy way of finding tags from a material file otherwise. openmc.Materials with the same names as the tags must exist for each tag otherwise the simulation fails.
There is this handy micro package I made a while back that uses MOAB to find tag names but no one wants to have to install another package for such a task and it would be much more convenient to have the material tags where they are needed.
Also the method is proposed in the PR is nicer than the dagmc_h5m_file_inspector package as it makes use of h5py which is a openmc dependency already.
This PR is moving functionality from another one of my mico packages and improving it along the way.
I like that these DAGMC universes are gaining more of the capabilities our other geometry classes have! It would be nice to somehow name this method get_all_materials like other classes have, but I don't know how we'd return a similar data structure here as we don't have any openmc.Material objects to return.
Thanks for the review @pshriwise , I just keep them as draft till I've seen that they pass the tests. Many thanks for improving the hex to ascii conversion part
get_all_materials
Yep I noticed those classes have a get_all_materials method. How about we return a list of openmc.Material() which are mainly blank but the name attribute has been set
returning a list of openmc.Materials could be used by the user like this
my_universe = DAGMCUniverse("dagmc.h5m")
mat1, mat2 = my_universe.get_all_materials
print(mat1.name)
>>> m1
print(mat2.name)
>>> m2
mat1.add_element() ...
or we could add material_names to the Universe class which return a list of names in the materials. I guess users don't often set the names for CSG geometry but it would mirror this functionality
Just putting this PR on hold as we have a regular DAGMC meeting on Thursday and wanted to invite the DAGMC community to comment
Discussed at the recent DAGMC meeting https://github.com/svalinn/DAGMC/discussions/833#discussion-4432125 ✔️
I'll merge tomorrow morning unless @paulromano has additional comments.