Skip to content

Commit

Permalink
Better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Feb 15, 2024
1 parent bcd6821 commit 9213a39
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 108 deletions.
34 changes: 34 additions & 0 deletions test/seq/expansion_badia2024_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

using GridapMHD: expansion
using GridapPETSc, SparseMatricesCSR
cw = 0.028
Re = 1.0
Ha = 100.0
N = Ha^2/Re

mesh = Dict(
:mesher => :MG,
:base_mesh => "coarse",
:num_refs_coarse => 0,
:ranks_per_level => [1,1],
)
solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:block_solvers => [:julia,:cg_jacobi,:cg_jacobi],
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason"
)
expansion(np=1,backend=:mpi,mesh=mesh,solver=solver,order=2=10000.0,N=N,Ha=Ha,cw=cw,title="ExpansionGMG")

# ReferenceSolution
expansion(np=1,backend=:mpi,solver=:julia,order=2=0.0,N=N,Ha=Ha,cw=cw,title="ExpansionRef")

expansion(np=1,backend=:mpi,solver=:julia,order=2=0.0,N=N,Ha=Ha,cw=cw,title="ExpansionRefBis",mesh=mesh)

meshbis = Dict(
:mesher => :SG,
:base_mesh => "coarse",
:num_refs => 1
)
expansion(np=1,backend=:mpi,solver=:julia,order=2=0.0,N=N,Ha=Ha,cw=cw,title="ExpansionRefBis",mesh=meshbis)
16 changes: 0 additions & 16 deletions test/seq/gmg_tests.jl

This file was deleted.

49 changes: 49 additions & 0 deletions test/seq/hunt_badia2024_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module HuntBadia2024SequentialTests

using GridapMHD: hunt
using GridapPETSc, SparseMatricesCSR

# Badia2024, with LU factorisation for u-j sub-block
solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason",
:block_solvers => [:julia,:cg_jacobi,:cg_jacobi],
)
hunt(
nc=(6,6),
np=(1,1),
backend=:mpi,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=solver,
ζ=10.0,
)

# Badia2024, with GMG solver for u-j sub-block
solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason",
:block_solvers => [:gmg,:cg_jacobi,:cg_jacobi],
)
hunt(
nc=(4,4),
np=(1,1),
backend=:mpi,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=solver,
ζ=10.0,
ranks_per_level=[1,1]
)

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

using GridapMHD: hunt
using GridapPETSc, SparseMatricesCSR

hunt(
nc=(4,4),
np=(2,2),
backend=:sequential,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=:li2019,
)

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

# Li2019, GMRES + Overlapping Additive Schwarz preconditioner 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 => [:petsc_from_options,:petsc_gmres_schwarz,:petsc_cg_jacobi,:petsc_cg_jacobi],
:petsc_options => petsc_options
)
hunt(
nc=(4,4),
np=(2,2),
backend=:sequential,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=solver,
)

end # module
98 changes: 6 additions & 92 deletions test/seq/hunt_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module HuntTestsSequential

using GridapMHD: hunt
using GridapPETSc, SparseMatricesCSR
"""

hunt(
nc=(4,4),
L=1.0,
Expand All @@ -11,17 +11,17 @@ hunt(
vtk=true,
title="hunt",
solver=:julia,
)
)

hunt(
nc=(4,4),
nc=(10,10),
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=:julia,
)
)

hunt(
nc=(4,4),
Expand All @@ -33,34 +33,8 @@ hunt(
vtk=true,
title="hunt",
solver=:julia,
)
hunt(
nc=(4,4),
np=(2,2),
backend=:sequential,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=:julia,
)
hunt(
nc=(4,4),
np=(2,2),
backend=:sequential,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=:petsc,
)
"""

"""
hunt(
nc=(4,4),
np=(2,2),
Expand All @@ -70,69 +44,9 @@ hunt(
debug=false,
vtk=true,
title="hunt",
solver=:li2019,
)
"""

solver = Dict(
:solver => :badia2024,
:matrix_type => SparseMatrixCSR{0,PetscScalar,PetscInt},
:vector_type => Vector{PetscScalar},
:petsc_options => "-ksp_error_if_not_converged true -ksp_converged_reason",
:block_solvers => [:petsc_gmres_schwarz,:petsc_cg_jacobi,:petsc_cg_jacobi],
)
hunt(
nc=(4,4),
np=(2,2),
backend=:sequential,
L=1.0,
B=(0.,50.,0.),
debug=false,
vtk=true,
title="hunt",
solver=solver,
)

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

# Li2019, GMRES + Overlapping Additive Schwarz preconditioner 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 => [:petsc_from_options,:petsc_gmres_schwarz,:petsc_cg_jacobi,:petsc_cg_jacobi],
:petsc_options => petsc_options
)
hunt(
nc=(4,4),
np=(2,2),
Expand All @@ -142,7 +56,7 @@ hunt(
debug=false,
vtk=true,
title="hunt",
solver=solver,
solver=:petsc,
)

end # module

0 comments on commit 9213a39

Please sign in to comment.