60 real(kind=
rp) :: res_start
62 real(kind=
rp) :: res_final
67 class(
pc_t),
pointer :: m => null()
68 real(kind=
rp) :: rel_tol
69 real(kind=
rp) :: abs_tol
71 class(
pc_t),
allocatable :: m_ident
105 function ksp_method(this, Ax, x, f, n, coef, blst, gs_h, niter) &
116 class(
ksp_t),
intent(inout) :: this
117 class(
ax_t),
intent(inout) :: ax
118 type(
field_t),
intent(inout) :: x
119 integer,
intent(in) :: n
120 real(kind=
rp),
dimension(n),
intent(inout) :: f
121 type(
coef_t),
intent(inout) :: coef
123 type(
gs_t),
intent(inout) :: gs_h
124 integer,
optional,
intent(in) :: niter
144 n, coef, blstx, blsty, blstz, gs_h, niter)
result(ksp_results)
154 class(
ksp_t),
intent(inout) :: this
155 class(
ax_t),
intent(inout) :: ax
156 type(
field_t),
intent(inout) :: x
157 type(
field_t),
intent(inout) :: y
158 type(
field_t),
intent(inout) :: z
159 integer,
intent(in) :: n
160 real(kind=
rp),
dimension(n),
intent(inout) :: fx
161 real(kind=
rp),
dimension(n),
intent(inout) :: fy
162 real(kind=
rp),
dimension(n),
intent(inout) :: fz
163 type(
coef_t),
intent(inout) :: coef
167 type(
gs_t),
intent(inout) :: gs_h
168 integer,
optional,
intent(in) :: niter
177 class(
ksp_t),
intent(inout) :: this
190 module subroutine krylov_solver_factory(object, n, type_name, &
191 max_iter, abstol, m, monitor)
192 class(ksp_t),
allocatable,
target,
intent(inout) :: object
193 integer,
intent(in),
value :: n
194 character(len=*),
intent(in) :: type_name
195 integer,
intent(in) :: max_iter
196 real(kind=
rp),
optional :: abstol
197 class(
pc_t),
optional,
intent(inout),
target :: m
198 logical,
optional,
intent(in) :: monitor
199 end subroutine krylov_solver_factory
202 module subroutine krylov_solver_destroy(object)
203 class(ksp_t),
allocatable,
intent(inout) :: object
204 end subroutine krylov_solver_destroy
207 public :: krylov_solver_factory, krylov_solver_destroy
215 subroutine krylov_init(this, max_iter, rel_tol, abs_tol, M, monitor)
216 class(ksp_t),
target,
intent(inout) :: this
217 integer,
intent(in) :: max_iter
218 real(kind=
rp),
optional,
intent(in) :: rel_tol
219 real(kind=
rp),
optional,
intent(in) :: abs_tol
220 class(
pc_t),
optional,
target,
intent(in) :: m
221 logical,
optional,
intent(in) :: monitor
223 call krylov_free(this)
225 if (
present(rel_tol))
then
226 this%rel_tol = rel_tol
228 this%rel_tol = ksp_rel_tol
231 if (
present(abs_tol))
then
232 this%abs_tol = abs_tol
234 this%abs_tol = ksp_abs_tol
237 this%max_iter = max_iter
242 if (.not.
associated(this%M))
then
246 allocate(
ident_t::this%M_ident)
248 this%M => this%M_ident
252 if (
present(monitor))
then
253 this%monitor = monitor
255 this%monitor = .false.
258 end subroutine krylov_init
261 subroutine krylov_free(this)
262 class(ksp_t),
intent(inout) :: this
266 end subroutine krylov_free
270 subroutine krylov_set_pc(this, M)
271 class(ksp_t),
intent(inout) :: this
272 class(
pc_t),
target,
intent(in) :: M
274 if (
associated(this%M))
then
275 select type (pc => this%M)
279 call neko_error(
'Preconditioner already defined')
285 end subroutine krylov_set_pc
288 subroutine krylov_monitor_start(this, name)
289 class(ksp_t),
intent(in) :: this
290 character(len=*) :: name
291 character(len=LOG_SIZE) :: log_buf
293 if (this%monitor)
then
294 write(log_buf,
'(A)')
'Krylov monitor (' // trim(name) //
')'
295 call neko_log%section(trim(log_buf))
298 write(log_buf,
'(A)')
' Iter. Residual'
300 write(log_buf,
'(A)')
'---------------------'
303 end subroutine krylov_monitor_start
306 subroutine krylov_monitor_stop(this)
307 class(ksp_t),
intent(in) :: this
309 if (this%monitor)
then
314 end subroutine krylov_monitor_stop
318 subroutine krylov_monitor_iter(this, iter, rnorm)
319 class(ksp_t),
intent(in) :: this
320 integer,
intent(in) :: iter
321 real(kind=
rp),
intent(in) :: rnorm
322 character(len=LOG_SIZE) :: log_buf
324 if (this%monitor)
then
325 write(log_buf,
'(I6,E15.7)') iter, rnorm
329 end subroutine krylov_monitor_iter
Abstract interface for a Krylov method's coupled solve routine.
Abstract interface for a Krylov method's solve routine.
Abstract interface for deallocating a Krylov method.
Defines a Matrix-vector product.
Defines a boundary condition.
Identity Krylov preconditioner for accelerators.
Krylov preconditioner (identity)
Implements the base abstract type for Krylov solvers plus helper types.
real(kind=rp), parameter, public ksp_rel_tol
Relative tolerance.
real(kind=rp), parameter, public ksp_abs_tol
Absolut tolerance.
subroutine krylov_free(this)
Deallocate a Krylov solver.
integer, parameter, public ksp_max_iter
Maximum number of iters.
subroutine krylov_monitor_iter(this, iter, rnorm)
Monitor iteration.
subroutine krylov_monitor_start(this, name)
Monitor start.
subroutine krylov_init(this, max_iter, rel_tol, abs_tol, M, monitor)
Factory for Krylov solvers. Both creates and initializes the object.
subroutine krylov_set_pc(this, M)
Setup a Krylov solver's preconditioner.
subroutine krylov_monitor_stop(this)
Monitor stop.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter neko_bcknd_device
integer, parameter, public c_rp
integer, parameter, public rp
Global precision used in computations.
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Base type for a matrix-vector product providing .
A list of boundary conditions.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Defines a canonical Krylov preconditioner for accelerators.
Defines a canonical Krylov preconditioner.
Type for storing initial and final residuals in a Krylov solver.
Base abstract type for a canonical Krylov method, solving .
Defines a canonical Krylov preconditioner.