Skip to content

Commit

Permalink
tamg: allow for abritrary number of levels
Browse files Browse the repository at this point in the history
  • Loading branch information
pohm01 committed Dec 19, 2024
1 parent b3247e0 commit e6c01e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/.depends
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ multigrid/tree_amg.lo : multigrid/tree_amg.f90 gs/gather_scatter.lo bc/bc_list.l
multigrid/tree_amg_utils.lo : multigrid/tree_amg_utils.f90 gs/gather_scatter.lo multigrid/tree_amg.lo math/math.lo common/utils.lo config/num_types.lo
multigrid/tree_amg_aggregate.lo : multigrid/tree_amg_aggregate.f90 common/log.lo mesh/mesh.lo comm/comm.lo config/num_types.lo common/utils.lo multigrid/tree_amg.lo
multigrid/tree_amg_multigrid.lo : multigrid/tree_amg_multigrid.f90 common/log.lo multigrid/tree_amg_smoother.lo multigrid/tree_amg_aggregate.lo multigrid/tree_amg.lo gs/gather_scatter.lo bc/bc_list.lo math/ax.lo sem/space.lo mesh/mesh.lo sem/coef.lo comm/comm.lo math/math.lo common/utils.lo config/num_types.lo
multigrid/tree_amg_smoother.lo : multigrid/tree_amg_smoother.f90 gs/gather_scatter.lo bc/bc_list.lo krylov/krylov.lo math/math.lo common/utils.lo config/num_types.lo multigrid/tree_amg_utils.lo multigrid/tree_amg.lo
multigrid/tree_amg_smoother.lo : multigrid/tree_amg_smoother.f90 common/log.lo gs/gather_scatter.lo bc/bc_list.lo krylov/krylov.lo math/math.lo common/utils.lo config/num_types.lo multigrid/tree_amg_utils.lo multigrid/tree_amg.lo
multigrid/phmg.lo : multigrid/phmg.f90 krylov/krylov.lo math/math.lo sem/interpolation.lo multigrid/tree_amg_multigrid.lo math/ax.lo krylov/bcknd/cpu/pc_jacobi.lo krylov/bcknd/cpu/cheby.lo common/utils.lo bc/dirichlet.lo bc/bc_list.lo bc/bc.lo mesh/mesh.lo sem/coef.lo field/field.lo sem/dofmap.lo sem/space.lo gs/gather_scatter.lo krylov/precon.lo config/num_types.lo
common/checkpoint.lo : common/checkpoint.f90 mesh/mesh.lo common/utils.lo field/field.lo device/device.lo sem/space.lo field/field_series.lo config/num_types.lo config/neko_config.lo
io/generic_file.lo : io/generic_file.f90 comm/comm.lo common/utils.lo config/num_types.lo
Expand Down
29 changes: 15 additions & 14 deletions src/multigrid/tree_amg_multigrid.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ subroutine tamg_mg_init(this, ax, Xh, coef, msh, gs_h, nlvls_in, blst, max_iter)
type(bc_list_t), target, intent(in) :: blst
integer, intent(in) :: nlvls_in
integer, intent(in) :: max_iter
integer :: nlvls, lvl, n, cheby_degree, env_len, mlvl
integer :: nlvls, lvl, n, cheby_degree, env_len, mlvl, target_num_aggs
integer, allocatable :: agg_nhbr(:,:), asdf(:,:)
character(len=255) :: env_cheby_degree, env_mlvl
character(len=LOG_SIZE) :: log_buf
Expand All @@ -112,26 +112,27 @@ subroutine tamg_mg_init(this, ax, Xh, coef, msh, gs_h, nlvls_in, blst, max_iter)
write(log_buf, '(A28,I2,A8)') 'Creating AMG hierarchy with', nlvls, 'levels.'
call neko_log%message(log_buf)

if (nlvls .gt. 4) then
call neko_error("Can not do more than four levels right now. I recommend two or three.")
end if

allocate( this%amg )
call this%amg%init(ax, Xh, coef, msh, gs_h, nlvls, blst)

!> Create level 1 (neko elements are level 0)
call aggregate_finest_level(this%amg, Xh%lx, Xh%ly, Xh%lz, msh%nelv)

if (nlvls .gt. 2) then
call print_preagg_info(2,(msh%nelv/8))
call aggregate_greedy(this%amg, 2, (msh%nelv/8), msh%facet_neigh, agg_nhbr)
end if

if (nlvls .gt. 3) then
call print_preagg_info(3,(this%amg%lvl(2)%nnodes/8))
call aggregate_greedy(this%amg, 3, (this%amg%lvl(2)%nnodes/8), agg_nhbr, asdf)
end if
!> Create the remaining levels
allocate( agg_nhbr, SOURCE=msh%facet_neigh )
do mlvl = 2, nlvls-1
target_num_aggs = this%amg%lvl(mlvl-1)%nnodes / 8
call print_preagg_info( mlvl, target_num_aggs)
if ( target_num_aggs .lt. 4 ) then
call neko_error("TAMG: Too many levels. Not enough DOFs for coarsest grid.")
end if
call aggregate_greedy( this%amg, mlvl, target_num_aggs, agg_nhbr, asdf)
agg_nhbr = asdf
deallocate( asdf )
end do
deallocate( agg_nhbr )

!> Create the end point
call aggregate_end(this%amg, nlvls)

this%max_iter = max_iter
Expand Down

0 comments on commit e6c01e0

Please sign in to comment.