Skip to content

Commit

Permalink
Split tests for block solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Mar 6, 2024
1 parent 4ccde7e commit 79a584c
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 106 deletions.
13 changes: 0 additions & 13 deletions test/mpi/cavity_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,4 @@ using GridapMHD: cavity
# PETSc - SNES + MUMPS
cavity(np=4,nc=(4,4,4),backend=:mpi,solver=:petsc)

# GMRES + block LU solvers
cavity(np=4,nc=(4,4,4),backend=:mpi,solver=:li2019)

# GMRES + block preconditioners
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:amg,:gmres_swartz,:amg,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
cavity(np=4,nc=(4,4,4),backend=:mpi,solver=solver)

end # module
21 changes: 21 additions & 0 deletions test/mpi/expansion_li2019_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module ExpansionLi2019TestsMPI

using GridapPETSc
using SparseMatricesCSR

using GridapMHD: cavity

# GMRES + block LU solvers
cavity(np=4,nc=(4,4,4),backend=:mpi,solver=:li2019)

# GMRES + block preconditioners
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:amg,:gmres_swartz,:amg,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
cavity(np=4,nc=(4,4,4),backend=:mpi,solver=solver)

end # module
28 changes: 28 additions & 0 deletions test/mpi/hunt_li2019_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module HuntLi2019TestsMPI

using GridapPETSc
using SparseMatricesCSR

using GridapMHD: hunt

# Li2019, MUMPS for Dj
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:mumps,:gmres_schwarz,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
hunt(
nc=(6,6),
np=(2,2),
backend=:mpi,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=solver,
)

end # module
23 changes: 1 addition & 22 deletions test/mpi/hunt_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ using SparseMatricesCSR

using GridapMHD: hunt

# Li2019, MUMPS for Dj
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:mumps,:gmres_schwarz,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
hunt(
nc=(6,6),
np=(2,2),
backend=:mpi,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=solver,
)

"""
hunt(
nc=(4,4),
np=(2,2),
Expand All @@ -37,6 +16,6 @@ hunt(
title="hunt",
solver=:petsc,
)
"""


end
24 changes: 24 additions & 0 deletions test/seq/cavity_badia2024_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module CavityBadia2024TestsSequential

using SparseArrays
using GridapMHD: cavity

solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSC{Float64,Int64},
:vector_type => Vector{Float64},
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason",
:block_solvers => [:julia,:cg_jacobi,:cg_jacobi],
)
cavity(np=1,backend=:mpi,solver=solver,ζ=10.0)

solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSC{Float64,Int64},
:vector_type => Vector{Float64},
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason",
:block_solvers => [:gmg,:cg_jacobi,:cg_jacobi],
)
cavity(np=1,backend=:mpi,solver=solver,ζ=10.0,ranks_per_level=[1,1])

end
35 changes: 35 additions & 0 deletions test/seq/cavity_li2019_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module CavityLi2019TestsSequential

using GridapPETSc
using SparseMatricesCSR, SparseArrays
using GridapMHD: cavity

# Serial, GMRES + block LU solvers
cavity(solver=:li2019)

# Sequential, GMRES + block LU solvers
cavity(np=2,backend=:sequential,solver=:li2019)

# Sequential, GMRES + block preconditioners
petsc_options = """
-ksp_type gmres
-ksp_rtol 1.0e-5
-ksp_atol 1.0e-14
-ksp_converged_reason
-pc_type asm
-pc_asm_overlap 10
-pc_asm_type restrict
-pc_asm_blocks 32
-sub_ksp_type preonly
-sub_pc_type lu
"""
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:from_options,:gmres_schwarz,:cg_jacobi,:cg_jacobi],
:petsc_options => petsc_options
)
cavity(np=2,backend=:sequential,solver=solver)

end # module
40 changes: 1 addition & 39 deletions test/seq/cavity_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,12 @@ module CavityTestsSequential

using GridapPETSc
using SparseMatricesCSR, SparseArrays

using GridapMHD: cavity

# Serial, LUSolver
cavity(np=1,backend=:mpi,solver=:julia)

solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSC{Float64,Int64},
:vector_type => Vector{Float64},
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason",
:block_solvers => [:gmg,:cg_jacobi,:cg_jacobi],
)
cavity(np=1,backend=:mpi,solver=solver,ζ=10.0,ranks_per_level=[1,1])

# Serial, GMRES + block LU solvers
cavity(solver=:li2019)
cavity()

# Sequential, PETSc - SNES + MUMPS
cavity(np=2,backend=:sequential,solver=:petsc)

# Sequential, GMRES + block LU solvers
cavity(np=2,backend=:sequential,solver=:li2019)

# Sequential, GMRES + block preconditioners
petsc_options = """
-ksp_type gmres
-ksp_rtol 1.0e-5
-ksp_atol 1.0e-14
-ksp_converged_reason
-pc_type asm
-pc_asm_overlap 10
-pc_asm_type restrict
-pc_asm_blocks 32
-sub_ksp_type preonly
-sub_pc_type lu
"""
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:from_options,:gmres_schwarz,:cg_jacobi,:cg_jacobi],
:petsc_options => petsc_options
)
cavity(np=2,backend=:sequential,solver=solver)

end # module
4 changes: 4 additions & 0 deletions test/seq/expansion_badia2024_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module ExpansionBadia2024TestsSequential

using GridapMHD: expansion
using SparseArrays

cw = 0.028
Re = 1.0
Ha = 100.0
Expand Down Expand Up @@ -32,3 +34,5 @@ meshbis = Dict(
:num_refs => 1
)
expansion(np=1,backend=:mpi,solver=:julia,order=2=0.0,N=N,Ha=Ha,cw=cw,title="ExpansionRefBis",mesh=meshbis)

end # module
40 changes: 40 additions & 0 deletions test/seq/expansion_li2019_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

module ExpansionLi2019TestsSequential

using GridapMHD: expansion
using GridapPETSc, SparseMatricesCSR

# Li2019, with MUMPS solver for Dj
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:mumps,:gmres_schwarz,:gmres_amg,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
expansion(np=2,backend=:sequential,solver=solver)

# Li2019, with Schwarz solver for Dj
petsc_options = """
-ksp_type gmres
-ksp_rtol 1.0e-5
-ksp_atol 1.0e-14
-ksp_converged_reason
-pc_type asm
-pc_asm_overlap 10
-pc_asm_type restrict
-pc_asm_blocks 32
-sub_ksp_type preonly
-sub_pc_type lu
"""
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:from_options,:gmres_schwarz,:cg_jacobi,:cg_jacobi],
:petsc_options => petsc_options
)
expansion(np=2,backend=:sequential,solver=solver)

end # module

32 changes: 0 additions & 32 deletions test/seq/expansion_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,4 @@ expansion()
expansion(np=2,backend=:sequential)
expansion(np=1,backend=:mpi)

# Li2019, with MUMPS solver for Dj
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:mumps,:gmres_schwarz,:gmres_amg,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
expansion(np=2,backend=:sequential,solver=solver)

# Li2019, with Schwarz solver for Dj
petsc_options = """
-ksp_type gmres
-ksp_rtol 1.0e-5
-ksp_atol 1.0e-14
-ksp_converged_reason
-pc_type asm
-pc_asm_overlap 10
-pc_asm_type restrict
-pc_asm_blocks 32
-sub_ksp_type preonly
-sub_pc_type lu
"""
solver = Dict(
:solver => :li2019,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:from_options,:gmres_schwarz,:cg_jacobi,:cg_jacobi],
:petsc_options => petsc_options
)
expansion(np=2,backend=:sequential,solver=solver)

end # module

0 comments on commit 79a584c

Please sign in to comment.