Skip to content

Commit 7f01e4e

Browse files
committed
use find_point_to_point_mapping instead of find_point_permutation
1 parent 26a5991 commit 7f01e4e

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

meshmode/discretization/connection/direct.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,17 @@ def _resample_point_pick_indices(self, to_group_index: int, ibatch_index: int,
422422
ibatch = self.groups[to_group_index].batches[ibatch_index]
423423
from_grp = self.from_discr.groups[ibatch.from_group_index]
424424

425-
from meshmode.mesh.tools import find_point_permutation
426-
return find_point_permutation(
427-
targets=ibatch.result_unit_nodes,
428-
permutees=from_grp.unit_nodes,
425+
from meshmode.mesh.tools import find_point_to_point_mapping
426+
src_idx_to_tgt_idx = find_point_to_point_mapping(
427+
src_points=ibatch.result_unit_nodes,
428+
tgt_points=from_grp.unit_nodes,
429429
tol_multiplier=tol_multiplier)
430430

431+
return (
432+
src_idx_to_tgt_idx
433+
if np.all(src_idx_to_tgt_idx >= 0)
434+
else None)
435+
431436
@keyed_memoize_method(lambda actx, to_group_index, ibatch_index,
432437
tol_multiplier=None: (to_group_index, ibatch_index, tol_multiplier))
433438
def _frozen_resample_point_pick_indices(self, actx: ArrayContext,

meshmode/mesh/processing.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
_FaceIDs,
4747
make_mesh,
4848
)
49-
from meshmode.mesh.tools import AffineMap, find_point_permutation
49+
from meshmode.mesh.tools import AffineMap, find_point_to_point_mapping
5050

5151

5252
__doc__ = """
@@ -589,18 +589,18 @@ def evec(i: int) -> np.ndarray:
589589
result[i] = 1
590590
return result
591591

592-
def unpack_single(ary: np.ndarray | None) -> np.ndarray:
592+
def unpack_single(ary: np.ndarray | None) -> int:
593593
assert ary is not None
594594
item, = ary
595595
return item
596596

597-
base_vertex_index = unpack_single(find_point_permutation(
598-
targets=-np.ones(grp.dim),
599-
permutees=grp.vertex_unit_coordinates().T))
597+
base_vertex_index = unpack_single(find_point_to_point_mapping(
598+
src_points=-np.ones(grp.dim).reshape(-1, 1),
599+
tgt_points=grp.vertex_unit_coordinates().T))
600600
spanning_vertex_indices = [
601-
unpack_single(find_point_permutation(
602-
targets=-np.ones(grp.dim) + 2 * evec(i),
603-
permutees=grp.vertex_unit_coordinates().T))
601+
unpack_single(find_point_to_point_mapping(
602+
src_points=(-np.ones(grp.dim) + 2 * evec(i)).reshape(-1, 1),
603+
tgt_points=grp.vertex_unit_coordinates().T))
604604
for i in range(grp.dim)
605605
]
606606

@@ -748,11 +748,10 @@ def _get_tensor_product_element_flip_matrix_and_vertex_permutation(
748748
unit_flip_matrix,
749749
grp.vertex_unit_coordinates().T)
750750

751-
vertex_permutation_to = find_point_permutation(
752-
targets=flipped_vertices,
753-
permutees=grp.vertex_unit_coordinates().T,
754-
)
755-
if vertex_permutation_to is None:
751+
vertex_permutation_to = find_point_to_point_mapping(
752+
src_points=flipped_vertices,
753+
tgt_points=grp.vertex_unit_coordinates().T)
754+
if np.any(vertex_permutation_to < 0):
756755
raise RuntimeError("flip permutation was not found")
757756

758757
flipped_unit_nodes = np.einsum("ij,jn->in", unit_flip_matrix, grp.unit_nodes)
@@ -1140,7 +1139,6 @@ def _match_boundary_faces(
11401139
bdry_m_vertices = mesh.vertices[:, bdry_m_vertex_indices]
11411140
bdry_n_vertices = mesh.vertices[:, bdry_n_vertex_indices]
11421141

1143-
from meshmode.mesh.tools import find_point_to_point_mapping
11441142
m_idx_to_n_idx = find_point_to_point_mapping(
11451143
bdry_pair_mapping.aff_map(bdry_m_vertices),
11461144
bdry_n_vertices)

test/test_mesh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ def test_point_matching():
931931
# Perturbed too far
932932
unmatchable_point = points[:, 0] + 2*tol
933933
unmatchable_point_to_point = find_point_to_point_mapping(
934-
src_points=unmatchable_point,
934+
src_points=unmatchable_point.reshape(-1, 1),
935935
tgt_points=points,
936936
tol=tol)
937937

0 commit comments

Comments
 (0)