Skip to content

Commit 5fb81de

Browse files
committed
Added test for get_side_set_node_list method
1 parent 299a233 commit 5fb81de

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = 'poetry.core.masonry.api'
44

55
[tool.poetry]
66
name = 'exodus_helper'
7-
version = '1.4.0'
7+
version = '1.4.1'
88
description = 'A package for manipulating ExodusII databases'
99
license = 'BSD-3-Clause'
1010
authors = ['Coleman Alleman <callema@sandia.gov>']

tests/test_exodus_helper.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def test_get_all_side_set_params():
267267

268268
def test_get_coord(mesh):
269269
# Assert correct return type
270+
coords = mesh.get_coords()
270271
coord = mesh.get_coord(1)
271272
for c in coord:
272273
assert isinstance(c, np.ndarray)
@@ -276,18 +277,33 @@ def test_get_coord(mesh):
276277
mesh.put_coords(coord_vals, coord_vals, coord_vals)
277278
for i, v in enumerate(coord_vals):
278279
assert np.all(np.stack(mesh.get_coord(i + 1)) == float(v))
280+
mesh.put_coords(*coords)
279281

280282

281283
def test_get_coords(mesh):
282284
# Assert correct return type
283-
coords = np.stack(mesh.get_coords()).T
285+
coords = mesh.get_coords()
284286
for coord in coords:
285287
assert isinstance(coord, np.ndarray)
286288

287289
# Assert that the correct values are fetched
288-
coord_vals = np.arange(mesh.get_num_nodes())
289-
for i, v in enumerate(coord_vals):
290-
assert np.all(coords[i] == float(v))
290+
num_nodes_x = mesh.shape[0] + 1
291+
num_nodes_y = mesh.shape[1] + 1
292+
num_nodes_z = mesh.shape[2] + 1
293+
294+
idxs_x = np.arange(num_nodes_x)
295+
idxs_y = np.arange(num_nodes_y)
296+
idxs_z = np.arange(num_nodes_z)
297+
298+
idxs = np.meshgrid(idxs_y, idxs_z, idxs_x)
299+
300+
idxs_yg = idxs[0].flatten()
301+
idxs_zg = idxs[1].flatten()
302+
idxs_xg = idxs[2].flatten()
303+
304+
assert np.allclose(coords[0], mesh.resolution[0] * idxs_xg)
305+
assert np.allclose(coords[1], mesh.resolution[1] * idxs_yg)
306+
assert np.allclose(coords[2], mesh.resolution[2] * idxs_zg)
291307

292308

293309
def test_get_coord_names(mesh):
@@ -980,9 +996,11 @@ def test_get_side_set_names(mesh):
980996
assert names[i - 1] == f'test_ss_name{i}'
981997

982998

983-
@pytest.mark.unwritten
984-
def test_get_side_set_node_list():
985-
assert False
999+
def test_get_side_set_node_list(mesh):
1000+
num_nodes, nodes = mesh.get_side_set_node_list(1)
1001+
assert num_nodes == len(nodes)
1002+
nodes_check = mesh.get_nodes_on_surface(1)
1003+
assert set(nodes) == set(nodes_check)
9861004

9871005

9881006
def test_get_side_set_params(mesh, dir_test_file):
@@ -1153,14 +1171,16 @@ def test_put_coord_names(mesh):
11531171

11541172

11551173
def test_put_coords(mesh):
1174+
coords = mesh.get_coords()
11561175
coordx = np.arange(12)
11571176
coordy = 10 * coordx
11581177
coordz = 100 * coordx
11591178
mesh.put_coords(coordx, coordy, coordz)
1160-
coords = mesh.get_coords()
1161-
assert np.allclose(coordx, coords[0])
1162-
assert np.allclose(coordy, coords[1])
1163-
assert np.allclose(coordz, coords[2])
1179+
coords_new = mesh.get_coords()
1180+
assert np.allclose(coordx, coords_new[0])
1181+
assert np.allclose(coordy, coords_new[1])
1182+
assert np.allclose(coordz, coords_new[2])
1183+
mesh.put_coords(*coords)
11641184

11651185

11661186
# put_elem ------------------------------------------------------------------ #

0 commit comments

Comments
 (0)