Skip to content

Commit

Permalink
example004 with petsc amg
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Feb 9, 2024
1 parent 99dc6cb commit bd6a326
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/GalerkinToolkitExamples/src/example004.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function nlsolve_solver(;linear_solver=Example001.lu_solver(),timer=TimerOutput(
error("todo")
end
function finalize!(setup)
setup.linear_solver.finalize!(setup)
setup.linear_solver.finalize!(setup.ls_setup)
end
(;setup,solve!,setup!,finalize!)
end
Expand Down
29 changes: 26 additions & 3 deletions extensions/GalerkinToolkitExamples/test/example004_defs.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

import GalerkinToolkit as gk
using GalerkinToolkitExamples: Example004
using GalerkinToolkitExamples: Example004, Example002
using Test
using PartitionedArrays
using PetscCall
using TimerOutputs

function example004_tests_np_4(distribute)
tol = 1.0e-8
Expand All @@ -22,8 +23,8 @@ function example004_tests_np_4(distribute)

params = Dict{Symbol,Any}()
domain = (0,10,0,10,0,10)
cells_per_dir = (20,20,20)
parts_per_dir = (2,2,2)
cells_per_dir = (10,10,10)
parts_per_dir = (2,2,1)
np = prod(parts_per_dir)
parts = distribute(LinearIndices((np,)))
ghost_layers = 0
Expand All @@ -33,4 +34,26 @@ function example004_tests_np_4(distribute)
@test results[:eh1] < tol
@test results[:el2] < tol


params = Dict{Symbol,Any}()
domain = (0,10,0,10,0,10)
cells_per_dir = (50,50,50)
parts_per_dir = (2,2,1)
np = prod(parts_per_dir)
parts = distribute(LinearIndices((np,)))
ghost_layers = 0
mesh = gk.cartesian_mesh(domain,cells_per_dir,parts_per_dir;parts,ghost_layers)
params[:mesh] = mesh
params[:export_vtu] = false
options = "-pc_type gamg -ksp_type cg -ksp_error_if_not_converged true -ksp_converged_reason -ksp_rtol 1.0e-6"
PetscCall.init(args=split(options))
# TODO a more comfortable way of passing a timer?
linear_solver = Example002.ksp_solver()
timer = TimerOutput()
params[:solver] = Example004.nlsolve_solver(;timer,linear_solver,method=:newton,show_trace=true)
params[:timer] = timer
results = Example004.main(params)
@test results[:eh1] < tol
@test results[:el2] < tol

end

0 comments on commit bd6a326

Please sign in to comment.