Skip to content

Commit efdfb90

Browse files
author
Lachlan Grose
committed
test: updating test for unstructured
1 parent cb38a5a commit efdfb90

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

tests/unit_tests/interpolator/test_unstructured_supports.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,37 @@ def test_get_elements():
1515

1616
vertices = nodes[elements,:]
1717
pos = points[:,:]
18-
vap = pos[None,:, :] - vertices[:, None, 0, :]
19-
vbp = pos[None,:, :] - vertices[:, None, 1, :]
20-
21-
vab = vertices[:, None, 1, :] - vertices[:,None, 0, :]
22-
vac = vertices[:, None, 2, :] - vertices[:,None, 0, :]
23-
vad = vertices[:, None, 3, :] - vertices[:,None, 0, :]
24-
vbc = vertices[:, None, 2, :] - vertices[:,None, 1, :]
25-
vbd = vertices[:, None, 3, :] - vertices[:, None, 1, :]
18+
vap = pos[:,None, :] - vertices[None, :, 0, :]
19+
vbp = pos[:,None, :] - vertices[None, :, 1, :]
20+
# # vcp = p - points[:, 2, :]
21+
# # vdp = p - points[:, 3, :]
22+
vab = vertices[None, :, 1, :] - vertices[None, :, 0, :]
23+
vac = vertices[None, :, 2, :] - vertices[None, :, 0, :]
24+
vad = vertices[None, :, 3, :] - vertices[None, :, 0, :]
25+
vbc = vertices[None, :, 2, :] - vertices[None, :, 1, :]
26+
vbd = vertices[None, :, 3, :] - vertices[None, :, 1, :]
2627

2728
va = np.einsum('ikj, ikj->ik', vbp, np.cross(vbd, vbc, axisa=2, axisb=2)) / 6.
2829
vb = np.einsum('ikj, ikj->ik', vap, np.cross(vac, vad, axisa=2, axisb=2)) / 6.
2930
vc = np.einsum('ikj, ikj->ik', vap, np.cross(vad, vab, axisa=2, axisb=2)) / 6.
3031
vd = np.einsum('ikj, ikj->ik', vap, np.cross(vab, vac, axisa=2, axisb=2)) / 6.
3132
v = np.einsum('ikj, ikj->ik', vab, np.cross(vac, vad, axisa=2, axisb=2)) / 6.
32-
33-
c = np.zeros((va.shape[0], pos.shape[0], 4))
33+
# c = np.zeros((va.shape[0], 4))
34+
# c[:, 0] = va / v
35+
# c[:, 1] = vb / v
36+
# c[:, 2] = vc / v
37+
# c[:, 3] = vd / v
38+
c = np.zeros((pos.shape[0],va.shape[1], 4))
3439
c[:,:, 0] = va / v
3540
c[:,:, 1] = vb / v
3641
c[:,:, 2] = vc / v
42+
3743
c[:,:, 3] = vd / v
3844
row,col = np.where(np.all(c>=0,axis=2))
39-
tetra_idx = np.sort(row)
4045

41-
assert np.all(elements[tetra_idx]-tetra == 0)
46+
tetra_idx = col
47+
48+
# check if the calculated tetra from the mesh method using aabb
49+
# is the same as using the barycentric coordinates on all elelemts for
50+
# all points
51+
assert np.all(elements[tetra_idx]-tetra==0)

0 commit comments

Comments
 (0)