mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Add bin label unit test
This commit is contained in:
parent
5f78fd9594
commit
a9c046cdeb
1 changed files with 40 additions and 0 deletions
|
|
@ -267,6 +267,46 @@ def test_centroids():
|
|||
np.testing.assert_array_almost_equal(mesh.centroids[0, 0, 0], [x-5.0, y-5.0, z+5.0])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mesh_type', ('regular', 'rectilinear', 'cylindrical', 'spherical'))
|
||||
def test_axis_labels(mesh_type):
|
||||
if mesh_type == 'regular':
|
||||
mesh = openmc.RegularMesh()
|
||||
mesh.lower_left = np.asarray([0.0]*3]
|
||||
mesh.width = np.asarray([0.0]*3]
|
||||
mesh.dimension = (1, 1, 1)
|
||||
elif mesh_type == 'rectilinear':
|
||||
mesh = openmc.RectilinearMesh()
|
||||
mesh.x_grid = np.asarray([0.0, 1.0])
|
||||
mesh.y_grid = np.asarray([0.0, 1.0])
|
||||
mesh.z_grid = np.asarray([0.0, 1.0])
|
||||
elif mesh_type == 'cylindrical':
|
||||
r_grid = np.asarray([0.0, 1.0])
|
||||
z_grid = np.asarray([0.0, 1.0])
|
||||
p_grid = np.asarray([0.0, 1.0])
|
||||
mesh = openmc.CylindricalMesh(r_grid=r_grid, z_grid=z_grid, phi_grid=p_grid)
|
||||
elif mesh_type == 'spherical':
|
||||
r_grid = np.asarray([0.0, 1.0])
|
||||
t_grid = np.asarray([0.0, 1.0])
|
||||
p_grid = np.asarray([0.0, 1.0])
|
||||
mesh = openmc.SphericalMesh(r_grid=r_grid, theta_grid=t_grid, phi_grid=p_grid)
|
||||
else:
|
||||
raise ValueError(mesh_type)
|
||||
|
||||
filt = openmc.MeshSurfaceFilter(mesh)
|
||||
assert len(filt.bins) == 12
|
||||
bin_names = [b[3] for b in filt.bins]
|
||||
if mesh_type in {'regular', 'rectilinear'}:
|
||||
assert bin_names[:8] == ['x-min out', 'x-min in', 'x-max out', 'x-max in',
|
||||
'y-min out', 'y-min in', 'y-max out', 'y-max in']
|
||||
if mesh_type in {'regular', 'rectilinear', 'cylindrical'}:
|
||||
assert bin_names[8:] == ['z-min out', 'z-min in', 'z-max out', 'z-max in']
|
||||
if mesh_type in {'cylindrical', 'spherical'}:
|
||||
assert bin_names[:4] == ['r-min out', 'r-min in', 'r-max out', 'r-max in']
|
||||
assert bin_names[4:8] == ['phi-min out', 'phi-min in', 'phi-max out', 'phi-max in']
|
||||
if mesh_type == 'spherical':
|
||||
assert bin_names[8:] == ['theta-min out', 'theta-min in', 'theta-max out', 'theta-max in']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mesh_type', ('regular', 'rectilinear', 'cylindrical', 'spherical'))
|
||||
def test_mesh_vertices(mesh_type):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue