Skip to content

test_geometry.py::test_1D_manifold test tolerance fails on 32-bit i386 #234

Description

@drew-parsons

scifem 20.0.0 is failing test_geometry.py::test_1D_manifold on i386.
Test tolerance seems to be a little too tight for it.
https://buildd.debian.org/status/fetch.php?pkg=scifem&arch=i386&ver=0.20.0-1&stamp=1782574433&raw=0

____________________________ test_1D_manifold[2-4] _____________________________

order = 2, num_threads = 4

    @pytest.mark.parametrize("num_threads", [1, 2, 4])
    @pytest.mark.parametrize("order", [1, 2])
    def test_1D_manifold(order, num_threads):
        comm = MPI.COMM_SELF
    
        # Curved quadratic triangle in 2D (5 nodes)
        curved_nodes = np.array(
            [
                [0.0, 0.0],  # Node 0: Vertex
                [1.0, 0.0],  # Node 1: Vertex
                [0.3, 0.5],
            ]
        )
        cells = np.array([[0, 1, 2]], dtype=np.int64)  # Single curved triangle element
        if order == 1:
            curved_nodes = curved_nodes[:2]  # Use only vertices for linear case
            cells = cells[:, :2]
    
        c_el = ufl.Mesh(basix.ufl.element("Lagrange", "interval", order, shape=(2,)))
        mesh = dolfinx.mesh.create_mesh(comm, cells=cells, x=curved_nodes, e=c_el)
    
        tol_x = 5e-6
        tol_dist = 1e-7
        theta = np.linspace(0, 4 * np.pi, 3_016)
        rand = np.random.RandomState(42)
        R = rand.rand(len(theta))
        y = rand.rand(len(theta)) * 0.5  # Add some random z variation
        points = np.vstack([R * np.cos(theta), y]).T
    
        cells = np.zeros(points.shape[0], dtype=np.int32)
        (result_scipy, _ref_scipy) = scipy_project_point_to_element(mesh, cells, points, tol=tol_x**2)
    
        result, ref_coords = _closest_point_projection(
            mesh, cells, points, tol_x=tol_x, tol_dist=tol_dist, tol_grad=1e-16
        )
    
        closest_point, closest_ref = closest_point_projection(
            mesh,
            cells,
            points,
            tol_x=tol_x,
            tol_dist=tol_dist,
            tol_grad=1e-16,
            max_iter=500,
            max_ls_iter=50,
            num_threads=num_threads,
        )
    
        # Check that python and C++ implementations give the same result
>       np.testing.assert_allclose(result, closest_point, atol=tol_dist)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=1e-07
E       
E       Mismatched elements: 2 / 6032 (0.0332%)
E       Mismatch at indices:
E        [2055, 0]: 0.041665848731243064 (ACTUAL), 0.04166622248131442 (DESIRED)
E        [2055, 1]: 0.2338510914431682 (ACTUAL), 0.23385240137764757 (DESIRED)
E       Max absolute difference among violations: 1.30993448e-06
E       Max relative difference among violations: 8.97009734e-06
E        ACTUAL: array([[0.41482 , 0.477589],
E              [0.877615, 0.130511],
E              [0.852922, 0.155408],...
E        DESIRED: array([[0.41482 , 0.477589],
E              [0.877615, 0.130511],
E              [0.852922, 0.155408],...

tests/test_geometry.py:298: AssertionError
=========================== short test summary info ============================
FAILED tests/test_geometry.py::test_1D_manifold[2-1] - AssertionError: 
FAILED tests/test_geometry.py::test_1D_manifold[2-2] - AssertionError: 
FAILED tests/test_geometry.py::test_1D_manifold[2-4] - AssertionError: 
= 3 failed, 1710 passed, 3 skipped, 6 xfailed, 18413 warnings in 614.50s (0:10:14) =

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions