38 type(hecmwST_saamg_hier),
save :: g_dh
39 type(hecmwST_saamg_comm),
save :: g_cmt
40 logical,
save :: INITIALIZED = .false.
41 integer(kind=kint),
save :: g_n = 0
42 integer(kind=kint),
save :: g_id = 0
54 integer(kind=kint),
save :: g_sig(4) = 0
62 integer(kind=kint),
intent(in) :: sym
63 type(hecmwst_saamg_bcsr) :: a
64 type(hecmwst_saamg_params) :: prm
65 real(kind=
kreal),
allocatable :: b(:,:)
66 integer(kind=kint) :: ndof, nint, iopt(10), m, astat, myrank, sig_bad
67 real(kind=
kreal) :: ropt(10)
68 logical :: will_use_mumps
75 '#### SA-AMG (PRECOND=22) requires a LAPACK-enabled build. Rebuild with '// &
76 '--with-lapack (setup.sh) or -DWITH_LAPACK=ON (cmake), or select another preconditioner.'
86 if (initialized .and. hecmat%Iarray(98) == 0)
then
88 if (.not. sig_sizes_match(hecmat)) sig_bad = 1
92 '#### SA-AMG: matrix structure changed under a values-only recycle flag -- full rebuild'
93 else if (hecmat%Iarray(97) == 0)
then
95 call saamg_register_mat(hecmat, hecmesh)
100 call saamg_register_mat(hecmat, hecmesh)
104 hecmat%Iarray(97) = 0
111 call saamg_register_mat(hecmat, hecmesh)
121 write(*,
'(a)')
'#### SA-AMG (PRECOND=22): only NDOF=1 (heat) / 2 (plane) / 3 (solid) / 6 (shell) supported'
161 select case (iopt(1))
162 case (0, 1, 2, 3) ; prm%coarsest_solver = iopt(1)
163 case default ;
if (myrank == 0)
write(*,
'(a,i0,a)') &
164 '#### SA-AMG: invalid coarse solver ', iopt(1),
' (ignored) -- using auto'
167 select case (iopt(2))
169 case default ;
if (myrank == 0)
write(*,
'(a,i0,a)') &
170 '#### SA-AMG: smoother type ', iopt(2),
' not supported -- using Chebyshev'
175 select case (iopt(3))
177 case (1) ; prm%ncycle = 1
178 case (2) ; prm%ncycle = 2
179 case (3) ; prm%ncycle = 2 ;
if (myrank == 0)
write(*,
'(a)') &
180 '#### SA-AMG: Full-V cycle not supported -- using W-cycle'
181 case default ;
if (myrank == 0)
write(*,
'(a,i0,a)') &
182 '#### SA-AMG: invalid cycle ', iopt(3),
' (ignored) -- using default (W)'
184 if (iopt(4) > 0) prm%max_level = iopt(4)
189 if (iopt(5) /= 0 .and. myrank == 0)
then
190 write(*,
'(a,i0,a)')
'#### SA-AMG: int slot5 (ML CoarsenScheme) = ', iopt(5), &
191 ' is ignored -- SA-AMG always uses uncoupled aggregation'
192 write(*,
'(a)')
'#### (max aggregate size is int slot8)'
194 if (iopt(6) > 0) prm%cheb_deg = iopt(6)
195 if (iopt(7) > 0) prm%coarse_size = iopt(7)
196 if (iopt(8) > 0) prm%max_size = iopt(8)
197 if (iopt(9) > 0) prm%galerkin_lowmem = .true.
201 prm%verbose = (prm%loglevel >= 1)
204 if (ropt(1) > 0.0d0) prm%theta = ropt(1)
205 if (ropt(2) > 0.0d0) prm%cheb_alpha = ropt(2)
206 if (ropt(3) > 0.0d0) prm%safety = ropt(3)
212 if (ropt(4) > 0.0d0) prm%taper_k = int(ropt(4) + 0.5d0, kind=
kint)
213 if (ropt(4) < 0.0d0) prm%taper_k = 0
216 if (ropt(5) > 0.0d0 .and. ropt(5) < 4.5d0) prm%agg_order = int(ropt(5) + 0.5d0, kind=
kint)
217 if (ropt(5) < 0.0d0) prm%agg_order = 0
220 if (ropt(6) > 0.0d0) prm%min_size = int(ropt(6) + 0.5d0, kind=
kint)
222 prm%verify = (ropt(7) > 0.0d0)
223 prm%dump_vtk = (ropt(8) > 0.0d0)
226 prm%symmetric = (sym == 1)
232 if (iopt(7) == 0)
then
233 will_use_mumps = (prm%coarsest_solver == 3) .or. &
235 if (will_use_mumps) prm%coarse_size = 50000
251 allocate(b(nint*ndof, m), stat=astat)
257 move_in=(.not. prm%verify))
261 if (prm%dump_vtk)
call dump_agg_vtk(g_dh, hecmesh, ndof, nint)
266 g_sig = (/ hecmat%N, hecmat%NP, hecmat%NPL, hecmat%NPU /)
268 hecmat%Iarray(98) = 0
269 hecmat%Iarray(97) = 0
273 logical function sig_sizes_match(hecMAT)
result(ok)
276 ok = (g_sig(1) == hecmat%N .and. g_sig(2) == hecmat%NP .and. &
277 g_sig(3) == hecmat%NPL .and. g_sig(4) == hecmat%NPU)
278 end function sig_sizes_match
285 subroutine dump_agg_vtk(dh, hecMESH, ndof, nint)
287 type(hecmwst_saamg_hier),
intent(in) :: dh
289 integer(kind=kint),
intent(in) :: ndof, nint
290 character(len=128) :: fname
291 integer(kind=kint) :: rank, idummy
293 if (.not.
allocated(dh%aggr_fine))
return
295 write(fname,
'(a,i0,a)')
'saamg_agg.', rank,
'.vtk'
298 if (rank == 0)
write(*,
'(a)') &
299 '#### SA-AMG: wrote finest aggregation to saamg_agg.<rank>.vtk (ParaView)'
300 end subroutine dump_agg_vtk
304 real(kind=
kreal),
intent(inout) :: zp(:)
305 integer(kind=kint),
intent(in) :: ndof
306 real(kind=
kreal),
allocatable :: r(:), z(:)
307 allocate(r(g_n), z(g_n))
317 integer(kind=kint),
intent(in) :: ndof
318 if (initialized)
then
321 initialized = .false.
331 subroutine saamg_register_mat(hecMAT, hecMESH)
337 end subroutine saamg_register_mat
343 subroutine saamg_fine_matvec(x, y)
345 real(kind=
kreal),
intent(inout) :: x(:)
346 real(kind=
kreal),
intent(out) :: y(:)
351 end subroutine saamg_fine_matvec
subroutine, public hecmw_mat_id_set(hecMAT, hecMESH, id)
subroutine, public hecmw_mat_id_get(id, hecMAT, hecMESH)
subroutine, public hecmw_mat_id_clear(id)
subroutine, public hecmw_mat_get_solver_opt(hecMAT, solver_opt)
integer(kind=kint) function, public hecmw_mat_get_timelog(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_loglevel(hecMAT)
subroutine, public hecmw_mat_get_solver_ropt(hecMAT, solver_ropt)
Rigid-body / near-kernel modes from mesh coordinates.
subroutine, public hecmw_precond_rbm_from_mesh(hecMESH, ndof, rbm)
Smoothed Aggregation AMG preconditioner : FrontISTR adapter.
subroutine, public hecmw_saamg_from_hecmat(hecMAT, A, include_halo)
Convert hecmwST_matrix (FrontISTR block storage) -> internal block-CSR. Rows are always internal only...
subroutine, public hecmw_saamg_comm_from_mesh(hecMESH, ndof, cmt)
Build the finest-level communication table from the FrontISTR mesh. Copies the node-based halo descri...
Smoothed Aggregation AMG preconditioner : node graph + aggregation.
subroutine, public hecmw_saamg_write_vtk(fname, coord, nnode, aggr)
Write a legacy-VTK point cloud colored by aggregate id (ParaView diagnostic). coord is (x,...
Smoothed Aggregation AMG preconditioner : distributed MUMPS coarsest solver.
logical function, public hecmw_saamg_cmumps_available()
.true. only when compiled with MUMPS; the caller uses the dense coarsest else.
Smoothed Aggregation AMG preconditioner : lightweight comm table.
logical function, public hecmw_saamg_lapack_available()
Whether this build links LAPACK (SA-AMG's setup needs it: dense coarsest factorization,...
subroutine, public hecmw_saamg_check_alloc(ier, what)
Report a failed allocation (stat /= 0) with a clear message and a collective abort,...
subroutine, public hecmw_saamg_comm_allreduce_sum_r(cmt, s)
Global sum-reduction of a scalar over the communicator (no-op when serial).
subroutine, public hecmw_saamg_comm_allreduce_sum_int(cmt, n)
Global sum-reduction of an integer over the communicator (no-op when serial).
subroutine, public hecmw_saamg_comm_free(cmt)
Smoothed Aggregation AMG preconditioner : distributed coarsening.
subroutine, public hecmw_saamg_free(dh)
subroutine, public hecmw_saamg_setup(A, cmt, bfine_int, m, prm, dh, fine_matvec, move_in)
Build a fully-distributed multilevel SA-AMG hierarchy. bfine_int is the near-kernel on internal nodes...
subroutine, public hecmw_saamg_refresh(dh, A_new)
Numeric-only refresh (Newton): reuse each level's aggregation / comm table / tentative P-hat AND the ...
subroutine, public hecmw_saamg_apply(dh, r, z)
Apply one distributed multilevel V-cycle: z = M^{-1} r (internal, length nint*nb).
Smoothed Aggregation AMG preconditioner : internal block-CSR matrix.
subroutine, public hecmw_saamg_bcsr_free(A)
Release the storage held by a hecmwST_saamg_bcsr.
Smoothed Aggregation AMG preconditioner : tunable parameters.
Smoothed Aggregation AMG preconditioner : distributed self-checks.
subroutine, public hecmw_saamg_verify_coarsen(hecMAT, cmt, m, prm)
F4b self-check: build the uncoupled aggregation and the coarse comm table on the distributed finest o...
subroutine, public hecmw_saamg_verify_prolong(hecMAT, hecMESH, cmt, ndof, m, prm)
F4b-2 self-check: build the halo-extended tentative prolongator P-hat_ext on the distributed operator...
subroutine, public hecmw_saamg_verify_refresh(dh, A, cmt, B, m, prm, n)
Verify the distributed numeric refresh: refreshing with the SAME operator A must reproduce the freshl...
subroutine, public hecmw_saamg_verify_matvec(hecMAT, hecMESH, cmt, ndof)
F4a self-check: the distributed (halo-aware) matvec applied to a globally consistent vector x (define...
subroutine, public hecmw_saamg_verify_smoothp(hecMAT, hecMESH, cmt, ndof, m, prm)
F4c-1 self-check: build the distributed SMOOTHED prolongator P and confirm the global near-kernel res...
Smoothed Aggregation AMG preconditioner : FrontISTR backend (id 22)
subroutine, public hecmw_precond_saamg_setup(hecMAT, hecMESH, sym)
subroutine, public hecmw_precond_saamg_apply(ZP, NDOF)
subroutine, public hecmw_precond_saamg_clear(NDOF)
subroutine, public hecmw_matvec(hecMESH, hecMAT, X, Y, COMMtime)
subroutine hecmw_abort(comm, code)
integer(kind=4), parameter kint
integer(kind=kint) function hecmw_comm_get_comm()
integer(kind=4), parameter kreal
integer(kind=kint) function hecmw_comm_get_rank()