195 crs_monitor, crs_tamg_lvls, crs_tamg_itrs, crs_tamg_cheby_degree)
196 class(
hsmg_t),
intent(inout),
target :: this
197 type(
coef_t),
intent(in),
target :: coef
198 type(
bc_list_t),
intent(inout),
target :: bclst
199 character(len=:),
intent(inout),
allocatable :: crs_solver, crs_pc
200 logical,
intent(inout) :: crs_monitor
201 integer,
intent(in) :: crs_tamg_lvls, crs_tamg_itrs, crs_tamg_cheby_degree
203 integer :: lx_crs, lx_mid
204 class(
bc_t),
pointer :: bc_i
206 character(len=LOG_SIZE) :: log_buf
213 if (coef%Xh%lx .lt. 5)
then
214 lx_mid =
max(coef%Xh%lx-1,3)
216 if (coef%Xh%lx .le. 2)
then
217 call neko_error(
'Polynomial order < 2 not supported for hsmg precon')
226 if (this%nlvls .lt. 1e1)
then
227 write(log_buf,
'(A,I1,A)')
'HSMG hierarchy : ', &
228 this%nlvls,
' levels'
229 else if (this%nlvls .lt. 1e2)
then
230 write(log_buf,
'(A,I2,A)')
'HSMG hierarchy : ', &
231 this%nlvls,
' levels'
232 else if (this%nlvls .lt. 1e3)
then
233 write(log_buf,
'(A,I3,A)')
'HSMG hierarchy : ', this%nlvls, &
236 write(log_buf,
'(A,I6,A)')
'HSMG hierarchy : ', this%nlvls, &
240 if (trim(crs_solver) .ne.
'tamg' .or. trim(crs_solver) .eq.
'cheby')
then
241 call neko_log%message(
'Coarse grid solver : (' // trim(crs_solver) // &
242 ', ' // trim(crs_pc) //
')')
244 if (this%niter .lt. 1e1)
then
245 write(log_buf,
'(A,I1)')
'Coarse grid iters. : ', this%niter
246 else if (this%niter .lt. 1e2)
then
247 write(log_buf,
'(A,I2)')
'Coarse grid iters. : ', this%niter
248 else if (this%niter .lt. 1e3)
then
249 write(log_buf,
'(A,I3)')
'Coarse grid iters. : ', this%niter
250 else if (this%niter .lt. 1e4)
then
251 write(log_buf,
'(A,I4)')
'Coarse grid iters. : ', this%niter
253 write(log_buf,
'(A,I6)')
'Coarse grid iters. : ', this%niter
258 call neko_log%message(
'Coarse grid solver : ' // trim(crs_solver) )
262 allocate(this%grids(this%nlvls))
263 allocate(this%w(coef%dof%size()))
264 allocate(this%r(coef%dof%size()))
268 call coef%msh%all_deformed()
271 call this%e%init(coef%dof,
'work array')
272 call this%wf%init(coef%dof,
'work 2')
274 call this%Xh_crs%init(
gll, lx_crs, lx_crs, lx_crs)
275 call this%dm_crs%init(coef%msh, this%Xh_crs)
276 call this%gs_crs%init(this%dm_crs)
277 call this%e_crs%init(this%dm_crs,
'work crs')
282 call this%Xh_mg%init(
gll, lx_mid, lx_mid, lx_mid)
283 call this%dm_mg%init(coef%msh, this%Xh_mg)
284 call this%gs_mg%init(this%dm_mg)
285 call this%e_mg%init(this%dm_mg,
'work midl')
290 if (coef%geo_compression)
then
291 call this%c_crs%enable_geo_compression(coef%geo_compression_tol)
292 call this%c_mg%enable_geo_compression(coef%geo_compression_tol)
293 call ax_helm_allocator(this%ax, type_name =
"standard_compr")
295 call ax_helm_allocator(this%ax, type_name =
"standard")
298 call this%bc_crs%init_base(this%c_crs)
299 call this%bc_mg%init_base(this%c_mg)
300 call this%bc_reg%init_base(coef)
301 if (bclst%size() .gt. 0)
then
302 do i = 1, bclst%size()
304 call this%bc_reg%mark_facets(bc_i%marked_facet)
306 call this%bc_crs%mark_facets(bc_i%marked_facet)
308 call this%bc_mg%mark_facets(bc_i%marked_facet)
311 call this%bc_reg%finalize()
312 call this%bc_crs%finalize()
313 call this%bc_mg%finalize()
315 call this%bc_projector_reg%mark(this%bc_reg)
316 call this%bc_projector_crs%mark(this%bc_crs)
317 call this%bc_projector_mg%mark(this%bc_mg)
319 call this%schwarz%init(coef%Xh, coef%dof, coef%gs_h, &
320 this%bc_projector_reg, coef%msh)
321 call this%schwarz_mg%init(this%Xh_mg, this%dm_mg, this%gs_mg,&
322 this%bc_projector_mg, coef%msh)
324 call this%interp_fine_mid%init(coef%Xh, this%Xh_mg)
325 call this%interp_mid_crs%init(this%Xh_mg, this%Xh_crs)
328 this%bc_projector_reg, this%schwarz, this%e, this%grids, 3)
329 call hsmg_fill_grid(this%dm_mg, this%gs_mg, this%Xh_mg, this%c_mg, &
330 this%bc_projector_mg, this%schwarz_mg, this%e_mg, this%grids, 2)
332 this%c_crs, this%bc_projector_crs, this%schwarz_crs, &
333 this%e_crs, this%grids, 1)
347 if (trim(crs_solver) .eq.
'tamg')
then
348 allocate(this%amg_solver)
349 call this%amg_solver%init(this%ax, this%grids(1)%e%Xh, &
350 this%grids(1)%coef, this%msh, this%grids(1)%gs_h, crs_tamg_lvls, &
351 this%grids(1)%bc_projector, crs_tamg_itrs, crs_tamg_cheby_degree)
354 call precon_allocator(this%pc_crs, crs_pc)
356 select type (pc => this%pc_crs)
358 call pc%init_from_components(this%c_crs, this%dm_crs, this%gs_crs)
360 call pc%init_from_components(this%c_crs, this%dm_crs, this%gs_crs)
362 call pc%init_from_components(this%c_crs, this%dm_crs, this%gs_crs)
367 m = this%pc_crs, monitor = crs_monitor)
490 integer,
intent(in) :: n
491 class(
hsmg_t),
intent(inout) :: this
492 real(kind=
rp),
dimension(n),
intent(inout) :: z
493 real(kind=
rp),
dimension(n),
intent(inout) :: r
494 type(c_ptr) :: z_d, r_d
496 integer :: thrdid, nthrds
504 call this%bc_projector_reg%apply(this%r, n)
508 call device_col2(this%r_d, this%grids(3)%coef%mult_d, &
509 this%grids(3)%dof%size())
511 call this%interp_fine_mid%map(this%e%x, this%r, &
512 this%msh%nelv, this%grids(2)%Xh)
513 call this%grids(2)%gs_h%op(this%e%x, &
514 this%grids(2)%dof%size(), gs_op_add, this%gs_event)
517 call this%bc_projector_reg%apply(this%r, n)
518 call device_copy(this%w_d, this%e%x_d, this%grids(2)%dof%size())
519 call this%bc_projector_mg%apply(this%w, this%grids(2)%dof%size())
521 call device_col2(this%w_d, this%grids(2)%coef%mult_d, &
522 this%grids(2)%dof%size())
524 call this%interp_mid_crs%map(this%wf%x, this%w, this%msh%nelv, &
527 call device_copy(this%w_d, this%e%x_d, this%grids(2)%dof%size())
528 call this%bc_projector_mg%apply(this%w, this%grids(2)%dof%size())
548 if (thrdid .eq. 0)
then
550 call this%grids(3)%schwarz%compute(z, this%r, this%hsmg_event)
551 call this%grids(2)%schwarz%compute(this%grids(2)%e%x, this%w, &
555 if (nthrds .eq. 1 .or. thrdid .eq. 1)
then
557 call this%grids(1)%gs_h%op(this%wf%x, &
558 this%grids(1)%dof%size(), gs_op_add, this%gs_event)
559 call this%grids(1)%bc_projector%apply(this%wf%x, &
560 this%grids(1)%dof%size())
562 if (
allocated(this%amg_solver))
then
563 call this%amg_solver%solve(this%grids(1)%e%x, this%wf%x, &
564 this%grids(1)%dof%size())
566 crs_info = this%crs_solver%solve(this%Ax, this%grids(1)%e, &
568 this%grids(1)%dof%size(), &
569 this%grids(1)%coef, &
570 this%grids(1)%bc_projector, &
571 this%grids(1)%gs_h, this%niter)
574 call this%grids(1)%bc_projector%apply(this%grids(1)%e%x,&
575 this%grids(1)%dof%size())
580 call this%interp_mid_crs%map(this%w, this%grids(1)%e%x, &
581 this%msh%nelv, this%grids(2)%Xh)
582 call device_add2(this%grids(2)%e%x_d, this%w_d, this%grids(2)%dof%size())
584 call this%interp_fine_mid%map(this%w, this%grids(2)%e%x, &
585 this%msh%nelv, this%grids(3)%Xh)
586 call device_add2(z_d, this%w_d, this%grids(3)%dof%size())
587 call this%grids(3)%gs_h%op(z, this%grids(3)%dof%size(), &
588 gs_op_add, this%gs_event)
590 this%grids(3)%dof%size())
593 call copy(this%r, r, n)
596 call this%grids(3)%schwarz%compute(z, this%r)
598 call col2(this%r, this%grids(3)%coef%mult, &
599 this%grids(3)%dof%size())
601 call this%interp_fine_mid%map(this%w, this%r, &
602 this%msh%nelv, this%grids(2)%Xh)
603 call this%grids(2)%gs_h%op(this%w, this%grids(2)%dof%size(), gs_op_add)
605 call this%grids(2)%schwarz%compute(this%grids(2)%e%x, this%w)
606 call col2(this%w, this%grids(2)%coef%mult, this%grids(2)%dof%size())
608 call this%interp_mid_crs%map(this%r, this%w, &
609 this%msh%nelv, this%grids(1)%Xh)
612 call this%grids(1)%gs_h%op(this%r, this%grids(1)%dof%size(), gs_op_add)
613 call this%grids(1)%bc_projector%apply(this%r, this%grids(1)%dof%size())
616 if (
allocated(this%amg_solver))
then
617 call this%amg_solver%solve(this%grids(1)%e%x, this%r, &
618 this%grids(1)%dof%size())
620 crs_info = this%crs_solver%solve(this%Ax, this%grids(1)%e, this%r, &
621 this%grids(1)%dof%size(), &
622 this%grids(1)%coef, &
623 this%grids(1)%bc_projector, &
624 this%grids(1)%gs_h, this%niter)
628 call this%grids(1)%bc_projector%apply(this%grids(1)%e%x, &
629 this%grids(1)%dof%size())
632 call this%interp_mid_crs%map(this%w, this%grids(1)%e%x, &
633 this%msh%nelv, this%grids(2)%Xh)
634 call add2(this%grids(2)%e%x, this%w, this%grids(2)%dof%size())
636 call this%interp_fine_mid%map(this%w, this%grids(2)%e%x, &
637 this%msh%nelv, this%grids(3)%Xh)
638 call add2(z, this%w, this%grids(3)%dof%size())
639 call this%grids(3)%gs_h%op(z, this%grids(3)%dof%size(), gs_op_add)
640 call col2(z, this%grids(3)%coef%mult, this%grids(3)%dof%size())