Skip to content

Commit aad3457

Browse files
Implemented block precond in gmg_par_dep
1 parent 4a46f30 commit aad3457

1 file changed

Lines changed: 40 additions & 10 deletions

File tree

test/dev/gmg_par_dep.jl

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ using PartitionedArrays
55
using Gridap
66
using Gridap.Helpers
77
using Gridap.Geometry
8+
using Gridap.MultiField
9+
810
using GridapDistributed
911
using GridapSolvers
12+
using GridapSolvers.BlockSolvers
1013
using GridapSolvers.MultilevelTools
1114
using GridapSolvers.PatchBasedSmoothers
1215

@@ -186,14 +189,26 @@ function gmg_hdiv(parts,t,info,β,mh)
186189
a = get_bilinear_form(model,info,β)
187190
U = get_fe_space(trials,1)
188191
V = get_fe_space(tests,1)
192+
193+
X = MultiFieldFESpace([U];style=BlockMultiFieldStyle(1,(1,),(1,)))
194+
Y = MultiFieldFESpace([V];style=BlockMultiFieldStyle(1,(1,),(1,)))
195+
189196
if info[:FESpace] == :RT
190197
Γ = Boundary(Ω) # Γ = Boundary(model) gives an error with #polytope branches
198+
191199
# Linear operator
192200
# op = AffineFEOperator(a,v->liform_dg(v,Ω,Γ,k,ue,uexBxB,get_scaling(info,β)),U,V)
193201
# Nonlinear operator
194-
res(u,v) = a(u,u,v) - liform_dg(v,Ω,Γ,k,ue,uexBxB,get_scaling(info,β))
195-
jac(u0,u,v) = a(u0,u,v)
196-
op = FEOperator(res,jac,U,V)
202+
203+
# res(u,v) = a(u,u,v) - liform_dg(v,Ω,Γ,k,ue,uexBxB,get_scaling(info,β))
204+
# jac(u0,u,v) = a(u0,u,v)
205+
# op = FEOperator(res,jac,U,V)
206+
207+
# Nonlinear block operator
208+
res(u,v) = a(u...,u...,v...) - liform_dg(v...,Ω,Γ,k,ue,uexBxB,get_scaling(info,β))
209+
jac(u0,u,v) = a(u0...,u...,v...)
210+
op = FEOperator(res,jac,X,Y)
211+
197212
elseif info[:FESpace] == :Qk
198213
op = AffineFEOperator(a,v->liform(v,Ω,k,ue,uexBxB,get_scaling(info,β)),U,V)
199214
else
@@ -210,7 +225,7 @@ function gmg_hdiv(parts,t,info,β,mh)
210225
verbose=i_am_main(parts),
211226
name = "Projection solver (CG_Jacobi)"
212227
)
213-
projection_solver.log.depth = 8
228+
projection_solver.log.depth = 12
214229
else
215230
projection_solver = LUSolver()
216231
end
@@ -243,7 +258,7 @@ function gmg_hdiv(parts,t,info,β,mh)
243258
verbose=i_am_main(parts)
244259
,is_nonlinear=true # Nonlinear solver
245260
)
246-
gmg.log.depth = 4
261+
gmg.log.depth = 8
247262

248263
atol = info[:solver_atol]
249264
rtol = info[:solver_rtol]
@@ -252,13 +267,28 @@ function gmg_hdiv(parts,t,info,β,mh)
252267
elseif info[:solver] == :FGMRES
253268
solver = FGMRESSolver(2,gmg;m_add=1,maxiter=30,atol=atol,rtol=rtol,verbose=i_am_main(parts),name="System (FGMRES_GMG)")
254269
end
270+
solver.log.depth = 4
255271
toc!(t,"setup")
256272

257-
tic!(t;barrier=true)
273+
# Block preconditioner
274+
blocks = [NonlinearSystemBlock(1);;]
275+
P = BlockTriangularSolver(blocks,[solver])
276+
l_solver = FGMRESSolver(2,P;maxiter=2,rtol=rtol,atol=atol,verbose=i_am_main(parts),name="Global System - FGMRES + Block")
277+
l_solver.log.depth = 2
278+
258279
# Nonlinear solver
259-
nl_solver = GridapSolvers.NewtonSolver(solver,maxiter=1,atol=atol,rtol=rtol,verbose=i_am_main(parts))
260-
uh = zero(U)
261-
uh, cache = solve!(uh, nl_solver,op)
280+
# nl_solver = GridapSolvers.NewtonSolver(solver,maxiter=1,atol=atol,rtol=rtol,verbose=i_am_main(parts))
281+
nl_solver = GridapSolvers.NewtonSolver(l_solver,maxiter=1,atol=atol,rtol=rtol,verbose=i_am_main(parts))
282+
283+
# Nonlinear block solve
284+
tic!(t;barrier=true)
285+
xh = zero(X)
286+
xh, cache = solve!(xh, nl_solver,op)
287+
uh = xh[1]
288+
289+
# Nonlinear solve
290+
# uh = zero(U)
291+
# uh, cache = solve!(uh, nl_solver,op)
262292

263293
# Linear solver
264294
# uh = solve(solver,op)
@@ -312,7 +342,7 @@ function gmg_par_dep(;D=2,
312342
B = VectorValue(0.0,0.0,1.0)
313343
uexBxB = x->(VectorValue(x[1],-x[2],0.)×B)×B
314344
end
315-
title = "NL_H1_BxB_$(name)_$(fe_space)$(fe_order)_scal_$(scaling)_qdeg_$(qdegree)_$(solver)_$(cycle_type)_S_$(smoother)_P_$(prolongation)_R_$(restriction)_Ps_$(projection_solver)"
345+
title = "NL_BP_H1_BxB_$(name)_$(fe_space)$(fe_order)_scal_$(scaling)_qdeg_$(qdegree)_$(solver)_$(cycle_type)_S_$(smoother)_P_$(prolongation)_R_$(restriction)_Ps_$(projection_solver)"
316346

317347
info = Dict{Symbol,Any}()
318348
info[:title] = title

0 commit comments

Comments
 (0)