Skip to content

Commit f1c85fc

Browse files
committed
Add UnstructuredMesh weight-window export test
1 parent 2dedf30 commit f1c85fc

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/unit_tests/weightwindows/test_ww_list.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import h5py
2+
import numpy as np
3+
import pytest
24
import openmc
35

46

@@ -44,3 +46,26 @@ def test_export_hdf5_format(request, run_in_tmpdir):
4446
for name in m_grp:
4547
assert 'id' in m_grp[name].attrs
4648
assert 'type' in m_grp[name]
49+
50+
51+
@pytest.mark.parametrize('library', ('libmesh', 'moab'))
52+
def test_export_hdf5_unstructured_mesh(request, run_in_tmpdir, library):
53+
# UnstructuredMesh can't be serialized from pure Python; export_to_hdf5
54+
# routes it through openmc.lib.export_weight_windows (a live session).
55+
if library == 'libmesh' and not openmc.lib._libmesh_enabled():
56+
pytest.skip('LibMesh not enabled in this build.')
57+
if library == 'moab' and not openmc.lib._dagmc_enabled():
58+
pytest.skip('DAGMC (and MOAB) not enabled in this build.')
59+
60+
mesh = openmc.UnstructuredMesh(
61+
str(request.path.with_name('test_mesh_tets.exo')), library)
62+
ww = openmc.WeightWindows(mesh, np.ones((12_000,)), upper_bound_ratio=5.0)
63+
openmc.WeightWindowsList([ww]).export_to_hdf5('ww.h5')
64+
65+
with h5py.File('ww.h5') as f:
66+
assert f.attrs['filetype'] == b'weight_windows'
67+
assert list(f.attrs['version']) == [1, 0]
68+
assert int(f['weight_windows'].attrs['n_weight_windows']) == 1
69+
m_grp = f['meshes'][f'mesh {mesh.id}']
70+
assert m_grp['type'][()] == b'unstructured'
71+
assert 'filename' in m_grp

0 commit comments

Comments
 (0)