Exemple #1
0

@pytest.mark.parametrize(
    "problem, max_k",
    [
        (Square(), 6),
        (Disk(), 4),
        (Cube(), 4),
        # Disable Ball() to avoid broken gmsh on gh-actions TODO enable
        # (Ball(), 3)
    ],
)
def test(problem, max_k):
    H, error_norm_1, error_norm_inf, order_1, order_inf = solve(problem, max_k)
    expected_order = 2
    tol = 5.0e-2
    assert order_1[-1] > expected_order - tol
    assert order_inf[-1] > expected_order - tol


if __name__ == "__main__":
    # problem = Square()
    problem = Disk()
    # problem = Cube()
    # problem = Ball()
    max_k = 6
    H, error_norm_1, error_norm_inf, order_1, order_inf = solve(problem,
                                                                max_k,
                                                                verbose=True)
    helpers.show_error_data(H, error_norm_1, error_norm_inf)
Exemple #2
0
        def jacobian_solver(u0, rhs):
            from scipy.sparse import linalg

            jac = jacobian.get_linear_operator(u0)
            return linalg.spsolve(jac, rhs)

        u0 = numpy.zeros(len(mesh.node_coords))
        u = pyfvm.newton(f.eval, jacobian_solver, u0, verbose=False)
        return u

    return helpers.perform_convergence_tests(
        solver, problem.exact_sol, problem.get_mesh, range(max_k), verbose=verbose
    )


@pytest.mark.parametrize(
    "problem, max_k", [(Square(), 6), (Circle(), 4), (Cube(), 4), (Ball(), 3)]
)
def test(problem, max_k):
    H, error_norm_1, error_norm_inf, order_1, order_inf = solve(problem, max_k)
    expected_order = 2
    tol = 5.0e-2
    assert order_1[-1] > expected_order - tol
    assert order_inf[-1] > expected_order - tol
    return


if __name__ == "__main__":
    H, error_norm_1, error_norm_inf, order_1, order_inf = solve(verbose=True)
    helpers.show_error_data(H, error_norm_1, error_norm_inf)