diff --git a/test/test_global_qbx.py b/test/test_global_qbx.py index e7a4eaa6baa29df83e22329e4c585b7525b00b80..d0128819b8d01d3c3d6c33b84f7848f9b6a5a9a7 100644 --- a/test/test_global_qbx.py +++ b/test/test_global_qbx.py @@ -217,13 +217,7 @@ def test_source_refinement_3d(ctx_getter, surface_name, surface_f, order): @pytest.mark.parametrize(("curve_name", "curve_f", "nelements"), [ - # TODO: This used to pass for a 20-to-1 ellipse (with different center - # placement). It still produces valid output right now, but the current - # test is not smart enough to recognize it. It might be useful to fix that. - # - # See discussion at - # https://gitlab.tiker.net/inducer/pytential/merge_requests/95#note_24003 - ("18-to-1 ellipse", partial(ellipse, 18), 100), + ("20-to-1 ellipse", partial(ellipse, 20), 100), ("horseshoe", horseshoe, 64), ]) def test_target_association(ctx_getter, curve_name, curve_f, nelements, @@ -320,6 +314,8 @@ def test_target_association(ctx_getter, curve_name, curve_f, nelements, expansion_radii = lpot_source._expansion_radii("ncenters").get(queue) + surf_targets = np.array( + [axis.get(queue) for axis in lpot_source.density_discr.nodes()]) int_targets = np.array([axis.get(queue) for axis in int_targets.nodes()]) ext_targets = np.array([axis.get(queue) for axis in ext_targets.nodes()]) @@ -352,48 +348,45 @@ def test_target_association(ctx_getter, curve_name, curve_f, nelements, if visualize: visualize_curve_and_assoc() - # Checks that the sources match with their own centers. - def check_on_surface_targets(nsources, true_side, target_to_center, - target_to_side_result): - assert (target_to_center >= 0).all() - - sources = np.arange(0, nsources) - - # Centers are on alternating sides of the geometry. Dividing by - # two yields the number of the source that spawned the center. - assert (target_to_center//2 == sources).all() - - assert (target_to_side_result == true_side).all() - # Checks that the targets match with centers on the appropriate side and # within the allowable distance. def check_close_targets(centers, targets, true_side, target_to_center, target_to_side_result, tgt_slice): - assert (target_to_center >= 0).all() + targets_have_centers = (target_to_center >= 0).all() + assert targets_have_centers + assert (target_to_side_result == true_side).all() + + TOL = 1e-3 dists = la.norm((targets.T - centers.T[target_to_center]), axis=1) - assert (dists <= expansion_radii[target_to_center]).all() + assert (dists <= (1 + TOL) * expansion_radii[target_to_center]).all() # Center side order = -1, 1, -1, 1, ... target_to_center_side = 2 * (target_assoc.target_to_center % 2) - 1 - check_on_surface_targets( - nsources, -1, + # interior surface + check_close_targets( + centers, surf_targets, -1, target_assoc.target_to_center[surf_int_slice], - target_to_center_side[surf_int_slice]) + target_to_center_side[surf_int_slice], + surf_int_slice) - check_on_surface_targets( - nsources, +1, + # exterior surface + check_close_targets( + centers, surf_targets, +1, target_assoc.target_to_center[surf_ext_slice], - target_to_center_side[surf_ext_slice]) + target_to_center_side[surf_ext_slice], + surf_ext_slice) + # interior volume check_close_targets( centers, int_targets, -1, target_assoc.target_to_center[vol_int_slice], target_to_center_side[vol_int_slice], vol_int_slice) + # exterior volume check_close_targets( centers, ext_targets, +1, target_assoc.target_to_center[vol_ext_slice], diff --git a/test/test_layer_pot.py b/test/test_layer_pot.py index 3e50aa94a36d8e5710a3bd3b6b4fbaa95ba855fd..66445fee0eda170998b7be5dccd424d9154357ae 100644 --- a/test/test_layer_pot.py +++ b/test/test_layer_pot.py @@ -92,7 +92,7 @@ def test_off_surface_eval(ctx_getter, use_fmm, do_plot=False): nelements = 30 target_order = 8 qbx_order = 3 - if use_fmm is True: + if use_fmm: fmm_order = qbx_order else: fmm_order = False @@ -139,8 +139,7 @@ def test_off_surface_eval(ctx_getter, use_fmm, do_plot=False): pt.colorbar() pt.show() - # FIXME: Why does the FMM only meet this sloppy tolerance? - assert linf_err < 1e-2 + assert linf_err < 1e-3 # }}}