mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
This belongs in test_filter_mesh
This commit is contained in:
parent
fd42b20de1
commit
60a2ff1fc1
2 changed files with 42 additions and 42 deletions
|
|
@ -410,3 +410,45 @@ def test_mesh_filter_dataframe_rectilinear():
|
|||
assert (mesh_key, 'y') in df.columns
|
||||
assert (mesh_key, 'z') in df.columns
|
||||
assert len(df) == data_size
|
||||
|
||||
|
||||
@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']
|
||||
if mesh_type == 'spherical':
|
||||
assert bin_names[4:] == ['theta-min out', 'theta-min in', 'theta-max out', 'theta-max in',
|
||||
'phi-min out', 'phi-min in', 'phi-max out', 'phi-max in']
|
||||
if mesh_type == 'cylindrical':
|
||||
assert bin_names[4:8] == ['phi-min out', 'phi-min in', 'phi-max out', 'phi-max in']
|
||||
|
|
|
|||
|
|
@ -267,48 +267,6 @@ 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']
|
||||
if mesh_type == 'spherical':
|
||||
assert bin_names[4:] == ['theta-min out', 'theta-min in', 'theta-max out', 'theta-max in',
|
||||
'phi-min out', 'phi-min in', 'phi-max out', 'phi-max in']
|
||||
if mesh_type == 'cylindrical':
|
||||
assert bin_names[4:8] == ['phi-min out', 'phi-min in', 'phi-max out', 'phi-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