Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making h5m files with h5py #10

Open
shimwell opened this issue Oct 11, 2022 · 4 comments · May be fixed by #12
Open

making h5m files with h5py #10

shimwell opened this issue Oct 11, 2022 · 4 comments · May be fixed by #12

Comments

@shimwell
Copy link
Member

shimwell commented Oct 11, 2022

The package currently uses pymoab

However it might be possible to use h5py

This would have the advantage of being pip installable and faster.

The data structure needed for a DAGMC compatible h5m file is shown here https://sigma.mcs.anl.gov/moab/h5m-file-format/

meshio is able to make h5m files, but these have never quite worked in the simulation code we make the h5m files for (dagmc/openmc).

It would be great to add to meshio so that the h5m files produced work in neutronics simulations.
The h5m files produced by this package work in neutronics simulations so could be used to provide a simple comparison as we can make a simple set of vertices and triangles into a dagmc/openmc compatible h5m file and compare it to the output from meshio and see what is missing

@shimwell
Copy link
Member Author

shimwell commented Oct 11, 2022

Alternatively, h5py routines could be written into this package to take the vertices and triangles and write them directly to h5m files.

Perhaps something like this is a starting point

import numpy as np
import h5py

vertices = np.array(
    [
        [0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0],
        [0.0, 0.0, 1.0],
    ]
)


triangles = [
    np.array([[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]]),
]



f = h5py.File("one_volume.h5m", "w")

tstt = f.create_group("tstt")

elements = tstt.create_group("elements")

nodes = tstt.create_group("nodes")

coords = nodes.create_dataset("coordinates", data=vertices)

sets = tstt.create_group("sets")

tags = tstt.create_group("tags")

@shimwell
Copy link
Member Author

To test the resulting h5m file works in openmc I have a few test cases as part of the CI that will check that the material tags are visible to DAGMC and that neutrons can be transported through the geometry. So any solution to this issue can be tested against these test cases

@shimwell
Copy link
Member Author

h5view can be used to see the contents of the h5 file
Screenshot from 2022-10-20 16-08-40

@shimwell
Copy link
Member Author

just to note the triangle sets need tagging with a string that is encoded. here is an example of decoding https://github.com/openmc-dev/openmc/blob/dff3ad48f1e9f7f3bc9cb74675613d1ae3d8bb60/openmc/universe.py#L717-L728

@shimwell shimwell linked a pull request Oct 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant