Skip to content

Commit

Permalink
Merge pull request #1614 from ExtremeFLOW/clean/krylov
Browse files Browse the repository at this point in the history
Cleans the Krylov factory a bit
  • Loading branch information
timfelle authored Dec 11, 2024
2 parents 2742c88 + b3fd65e commit 24d1b22
Showing 1 changed file with 51 additions and 317 deletions.
368 changes: 51 additions & 317 deletions src/krylov/krylov_fctry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -163,329 +163,63 @@ module subroutine krylov_solver_factory(object, n, type_name, &
! issues with compilers, when it was not there. However, at some point we
! should check if we can get away with just having one obj%init statement.
! Same applies to the code in the "destroy" routine below.
if (present(abstol) .and. present(M) .and. present(monitor)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (sx_cg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (cg_cpld_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (cg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (pipecg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (sx_pipecg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (pipecg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (fusedcg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (cacg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (gmres_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (sx_gmres_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (gmres_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (bicgstab_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (cheby_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
type is (cheby_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol, monitor = monitor)
end select
else if (present(abstol) .and. present(M)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (sx_cg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (cg_cpld_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (cg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (pipecg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (sx_pipecg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (pipecg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (fusedcg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (cacg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (gmres_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (sx_gmres_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (gmres_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (bicgstab_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (cheby_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
type is (cheby_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol)
end select
else if (present(monitor) .and. present(M)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (sx_cg_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (cg_cpld_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (cg_device_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (pipecg_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (sx_pipecg_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (pipecg_device_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (fusedcg_device_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (cacg_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (gmres_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (sx_gmres_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (gmres_device_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (bicgstab_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (cheby_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
type is (cheby_device_t)
call obj%init(n, max_iter, M = M, monitor = monitor)
end select
else if (present(abstol) .and. present(monitor)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (sx_cg_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (cg_cpld_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (cg_device_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (pipecg_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (sx_pipecg_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (pipecg_device_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (fusedcg_device_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (cacg_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (gmres_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (sx_gmres_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (gmres_device_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (bicgstab_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (cheby_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
type is (cheby_device_t)
call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
end select
else if (present(abstol)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (sx_cg_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (cg_cpld_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (cg_device_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (pipecg_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (sx_pipecg_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (pipecg_device_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (fusedcg_device_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (cacg_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (gmres_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (sx_gmres_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (gmres_device_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (bicgstab_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (cheby_t)
call obj%init(n, max_iter, abs_tol = abstol)
type is (cheby_device_t)
call obj%init(n, max_iter, abs_tol = abstol)
end select
else if (present(monitor)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, monitor = monitor)
type is (sx_cg_t)
call obj%init(n, max_iter, monitor = monitor)
type is (cg_cpld_t)
call obj%init(n, max_iter, monitor = monitor)
type is (cg_device_t)
call obj%init(n, max_iter, monitor = monitor)
type is (pipecg_t)
call obj%init(n, max_iter, monitor = monitor)
type is (sx_pipecg_t)
call obj%init(n, max_iter, monitor = monitor)
type is (pipecg_device_t)
call obj%init(n, max_iter, monitor = monitor)
type is (fusedcg_device_t)
call obj%init(n, max_iter, monitor = monitor)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, monitor = monitor)
type is (cacg_t)
call obj%init(n, max_iter, monitor = monitor)
type is (gmres_t)
call obj%init(n, max_iter, monitor = monitor)
type is (sx_gmres_t)
call obj%init(n, max_iter, monitor = monitor)
type is (gmres_device_t)
call obj%init(n, max_iter, monitor = monitor)
type is (bicgstab_t)
call obj%init(n, max_iter, monitor = monitor)
type is (cheby_t)
call obj%init(n, max_iter, monitor = monitor)
type is (cheby_device_t)
call obj%init(n, max_iter, monitor = monitor)
end select
else if (present(M)) then
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, M = M)
type is (sx_cg_t)
call obj%init(n, max_iter, M = M)
type is (cg_cpld_t)
call obj%init(n, max_iter, M = M)
type is (cg_device_t)
call obj%init(n, max_iter, M = M)
type is (pipecg_t)
call obj%init(n, max_iter, M = M)
type is (sx_pipecg_t)
call obj%init(n, max_iter, M = M)
type is (pipecg_device_t)
call obj%init(n, max_iter, M = M)
type is (fusedcg_device_t)
call obj%init(n, max_iter, M = M)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, M = M)
type is (cacg_t)
call obj%init(n, max_iter, M = M)
type is (gmres_t)
call obj%init(n, max_iter, M = M)
type is (sx_gmres_t)
call obj%init(n, max_iter, M = M)
type is (gmres_device_t)
call obj%init(n, max_iter, M = M)
type is (bicgstab_t)
call obj%init(n, max_iter, M = M)
type is (cheby_t)
call obj%init(n, max_iter, M = M)
type is (cheby_device_t)
call obj%init(n, max_iter, M = M)
end select
else
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter)
type is (sx_cg_t)
call obj%init(n, max_iter)
type is (cg_cpld_t)
call obj%init(n, max_iter)
type is (cg_device_t)
call obj%init(n, max_iter)
type is (pipecg_t)
call obj%init(n, max_iter)
type is (sx_pipecg_t)
call obj%init(n, max_iter)
type is (pipecg_device_t)
call obj%init(n, max_iter)
type is (fusedcg_device_t)
call obj%init(n, max_iter)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter)
type is (cacg_t)
call obj%init(n, max_iter)
type is (gmres_t)
call obj%init(n, max_iter)
type is (sx_gmres_t)
call obj%init(n, max_iter)
type is (gmres_device_t)
call obj%init(n, max_iter)
type is (bicgstab_t)
call obj%init(n, max_iter)
type is (cheby_t)
call obj%init(n, max_iter)
type is (cheby_device_t)
call obj%init(n, max_iter)
end select
end if
select type (obj => object)
type is (cg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (sx_cg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (cg_cpld_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (cg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (pipecg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (sx_pipecg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (pipecg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (fusedcg_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (fusedcg_cpld_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (cacg_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (gmres_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (sx_gmres_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (gmres_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (bicgstab_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (cheby_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
type is (cheby_device_t)
call obj%init(n, max_iter, M = M, abs_tol = abstol,&
monitor = monitor)
end select

end subroutine krylov_solver_factory

!> Destroy an iterative Krylov type_name
module subroutine krylov_solver_destroy(object)
class(ksp_t), allocatable, intent(inout) :: object

if (allocated(object)) then
select type (obj => object)
type is (cg_t)
call obj%free()
type is (sx_cg_t)
call obj%free()
type is (cg_cpld_t)
call obj%free()
type is (cg_device_t)
call obj%free()
type is (pipecg_t)
call obj%free()
type is (sx_pipecg_t)
call obj%free()
type is (pipecg_device_t)
call obj%free()
type is (fusedcg_device_t)
call obj%free()
type is (fusedcg_cpld_device_t)
call obj%free()
type is (cacg_t)
call obj%free()
type is (gmres_t)
call obj%free()
type is (sx_gmres_t)
call obj%free()
type is (gmres_device_t)
call obj%free()
type is (bicgstab_t)
call obj%free()
type is (cheby_t)
call obj%free()
end select
end if

call object%free()
end subroutine krylov_solver_destroy

end submodule krylov_fctry
Expand Down

0 comments on commit 24d1b22

Please sign in to comment.