Exemple #1
0
def test_Schur_Sp_solve(load_nse_step_matrix, initialize_petsc_options):
    """Tests a KSP solve using the Sp Schur complement approximation.
       For this test, the global matrix does not have a null space."""
    mat_A = load_nse_step_matrix
    b, x = create_petsc_vecs(mat_A)

    solver_info = LS.ModelInfo(3, 'interlaced')
    schur_approx = LS.Schur_Sp(mat_A, '', solver_info=solver_info)
    ksp_obj = initialize_schur_ksp_obj(mat_A, schur_approx)
    ksp_obj.solve(b, x)

    assert ksp_obj.converged == True
    assert ksp_obj.its == 45
    assert np.allclose(ksp_obj.norm, 394.7036050627)
    assert ksp_obj.reason == 2
Exemple #2
0
def test_Schur_Sp_solve_global_null_space(load_nse_cavity_matrix,
                                          initialize_petsc_options):
    """Tests a KSP solve using the Sp Schur complement approximation.
    For this test, the global matrix has a null space because the
    boundary conditions are pure Dirichlet. """
    mat_A = load_nse_cavity_matrix
    b, x = create_petsc_vecs(mat_A)

    solver_info = LS.ModelInfo('interlaced', 3, bdy_null_space=True)
    schur_approx = LS.Schur_Sp(L=mat_A, prefix='', solver_info=solver_info)
    petsc_options = initialize_petsc_options
    ksp_obj = initialize_schur_ksp_obj(mat_A, schur_approx)
    ksp_obj.solve(b, x)

    assert ksp_obj.converged == True
    assert ksp_obj.its == 89
    assert ksp_obj.norm < np.linalg.norm(b) * 1.0e-9 + 1.0e-16
    assert ksp_obj.reason == 2
Exemple #3
0
def test_Schur_Sp_solve_global_null_space(load_nse_cavity_matrix,
                                          initialize_petsc_options):
    """Tests a KSP solve using the Sp Schur complement approximation.
    For this test, the global matrix has a null space because the
    boundary conditions are pure Dirichlet. """
    mat_A = load_nse_cavity_matrix
    b, x = create_petsc_vecs(mat_A)
    petsc_options = initialize_petsc_options

    solver_info = LS.ModelInfo(3, 'interlaced')
    schur_approx = LS.Schur_Sp(mat_A, '', True, solver_info=solver_info)
    ksp_obj = initialize_schur_ksp_obj(mat_A, schur_approx)
    ksp_obj.solve(b, x)

    assert ksp_obj.converged == True
    assert ksp_obj.its == 35
    assert np.allclose(ksp_obj.norm, 0.0007464632)
    assert ksp_obj.reason == 2
def test_Schur_Sp_solve():
    """Tests a KSP solve using the Sp Schur complement approximation.
       For this test, the global matrix does not have a null space."""
    mat_A = load_matrix_step_noslip()
    petsc_options = initialize_petsc_options()
    b, x = create_petsc_vecs(mat_A)

    solver_info = LS.ModelInfo('interlaced', 3)
    schur_approx = LS.Schur_Sp(mat_A,
                               '',
                               solver_info=solver_info)
    ksp_obj = initialize_schur_ksp_obj(mat_A, schur_approx)
    ksp_obj.solve(b,x)

    assert ksp_obj.converged == True
    assert ksp_obj.reason == 2
    assert float(ksp_obj.norm) < 1.0e-5
    assert ksp_obj.its == 63