33 submodule(
krylov) krylov_fctry
57 character(len=20) :: KSP_KNOWN_TYPES(8) = [character(len=20) :: &
77 module subroutine krylov_solver_factory(object, n, type_name, &
78 max_iter, abstol, m, monitor)
79 class(ksp_t),
allocatable,
target,
intent(inout) :: object
80 integer,
intent(in),
value :: n
81 character(len=*),
intent(in) :: type_name
82 integer,
intent(in) :: max_iter
83 real(kind=
rp),
optional :: abstol
84 class(pc_t),
optional,
intent(inout),
target :: M
85 logical,
optional,
intent(in) :: monitor
86 character(len=:),
allocatable :: type_string
88 if (
allocated(object))
then
89 call krylov_solver_destroy(object)
93 if (trim(type_name) .eq.
'cg')
then
96 else if (neko_bcknd_device .eq. 1)
then
99 allocate(
cg_t::object)
101 else if (trim(type_name) .eq.
'cpldcg')
then
103 if (neko_bcknd_device .eq. 1)
then
104 call neko_error(
'Coupled CG only supported for CPU')
106 else if (trim(type_name) .eq.
'pipecg')
then
109 else if (neko_bcknd_device .eq. 1)
then
111 call neko_error(
'PipeCG not supported for OpenCL')
117 else if (trim(type_name) .eq.
'fusedcg')
then
118 if (neko_bcknd_device .eq. 1)
then
120 call neko_error(
'FusedCG not supported for OpenCL')
124 call neko_error(
'FusedCG only supported for CUDA/HIP')
126 else if (trim(type_name) .eq.
'fcpldcg')
then
127 if (neko_bcknd_device .eq. 1)
then
129 call neko_error(
'Coupled FusedCG not supported for OpenCL')
133 call neko_error(
'Coupled FusedCG only supported for CUDA/HIP')
135 else if (trim(type_name) .eq.
'cacg')
then
137 else if (trim(type_name) .eq.
'gmres')
then
140 else if (neko_bcknd_device .eq. 1)
then
145 else if (trim(type_name) .eq.
'cheby')
then
146 if (neko_bcknd_device .eq. 1)
then
151 else if (trim(type_name) .eq.
'bicgstab')
then
155 new_line(
'A') //
"- ", .true.)
156 call neko_error(
"Unknown Krylov solver type: " &
157 // trim(type_name) //
". Known types are: " &
165 if (
present(abstol) .and.
present(m) .and.
present(monitor))
then
166 select type (obj => object)
168 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
170 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
172 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
174 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
176 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
178 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
180 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
182 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
184 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
186 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
188 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
190 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
192 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
194 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
196 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
198 call obj%init(n, max_iter, m = m, abs_tol = abstol, monitor = monitor)
200 else if (
present(abstol) .and.
present(m))
then
201 select type (obj => object)
203 call obj%init(n, max_iter, m = m, abs_tol = abstol)
205 call obj%init(n, max_iter, m = m, abs_tol = abstol)
207 call obj%init(n, max_iter, m = m, abs_tol = abstol)
209 call obj%init(n, max_iter, m = m, abs_tol = abstol)
211 call obj%init(n, max_iter, m = m, abs_tol = abstol)
213 call obj%init(n, max_iter, m = m, abs_tol = abstol)
215 call obj%init(n, max_iter, m = m, abs_tol = abstol)
217 call obj%init(n, max_iter, m = m, abs_tol = abstol)
219 call obj%init(n, max_iter, m = m, abs_tol = abstol)
221 call obj%init(n, max_iter, m = m, abs_tol = abstol)
223 call obj%init(n, max_iter, m = m, abs_tol = abstol)
225 call obj%init(n, max_iter, m = m, abs_tol = abstol)
227 call obj%init(n, max_iter, m = m, abs_tol = abstol)
229 call obj%init(n, max_iter, m = m, abs_tol = abstol)
231 call obj%init(n, max_iter, m = m, abs_tol = abstol)
233 call obj%init(n, max_iter, m = m, abs_tol = abstol)
235 else if (
present(monitor) .and.
present(m))
then
236 select type (obj => object)
238 call obj%init(n, max_iter, m = m, monitor = monitor)
240 call obj%init(n, max_iter, m = m, monitor = monitor)
242 call obj%init(n, max_iter, m = m, monitor = monitor)
244 call obj%init(n, max_iter, m = m, monitor = monitor)
246 call obj%init(n, max_iter, m = m, monitor = monitor)
248 call obj%init(n, max_iter, m = m, monitor = monitor)
250 call obj%init(n, max_iter, m = m, monitor = monitor)
252 call obj%init(n, max_iter, m = m, monitor = monitor)
254 call obj%init(n, max_iter, m = m, monitor = monitor)
256 call obj%init(n, max_iter, m = m, monitor = monitor)
258 call obj%init(n, max_iter, m = m, monitor = monitor)
260 call obj%init(n, max_iter, m = m, monitor = monitor)
262 call obj%init(n, max_iter, m = m, monitor = monitor)
264 call obj%init(n, max_iter, m = m, monitor = monitor)
266 call obj%init(n, max_iter, m = m, monitor = monitor)
268 call obj%init(n, max_iter, m = m, monitor = monitor)
270 else if (
present(abstol) .and.
present(monitor))
then
271 select type (obj => object)
273 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
275 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
277 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
279 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
281 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
283 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
285 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
287 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
289 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
291 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
293 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
295 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
297 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
299 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
301 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
303 call obj%init(n, max_iter, monitor = monitor, abs_tol = abstol)
305 else if (
present(abstol))
then
306 select type (obj => object)
308 call obj%init(n, max_iter, abs_tol = abstol)
310 call obj%init(n, max_iter, abs_tol = abstol)
312 call obj%init(n, max_iter, abs_tol = abstol)
314 call obj%init(n, max_iter, abs_tol = abstol)
316 call obj%init(n, max_iter, abs_tol = abstol)
318 call obj%init(n, max_iter, abs_tol = abstol)
320 call obj%init(n, max_iter, abs_tol = abstol)
322 call obj%init(n, max_iter, abs_tol = abstol)
324 call obj%init(n, max_iter, abs_tol = abstol)
326 call obj%init(n, max_iter, abs_tol = abstol)
328 call obj%init(n, max_iter, abs_tol = abstol)
330 call obj%init(n, max_iter, abs_tol = abstol)
332 call obj%init(n, max_iter, abs_tol = abstol)
334 call obj%init(n, max_iter, abs_tol = abstol)
336 call obj%init(n, max_iter, abs_tol = abstol)
338 call obj%init(n, max_iter, abs_tol = abstol)
340 else if (
present(monitor))
then
341 select type (obj => object)
343 call obj%init(n, max_iter, monitor = monitor)
345 call obj%init(n, max_iter, monitor = monitor)
347 call obj%init(n, max_iter, monitor = monitor)
349 call obj%init(n, max_iter, monitor = monitor)
351 call obj%init(n, max_iter, monitor = monitor)
353 call obj%init(n, max_iter, monitor = monitor)
355 call obj%init(n, max_iter, monitor = monitor)
357 call obj%init(n, max_iter, monitor = monitor)
359 call obj%init(n, max_iter, monitor = monitor)
361 call obj%init(n, max_iter, monitor = monitor)
363 call obj%init(n, max_iter, monitor = monitor)
365 call obj%init(n, max_iter, monitor = monitor)
367 call obj%init(n, max_iter, monitor = monitor)
369 call obj%init(n, max_iter, monitor = monitor)
371 call obj%init(n, max_iter, monitor = monitor)
373 call obj%init(n, max_iter, monitor = monitor)
375 else if (
present(m))
then
376 select type (obj => object)
378 call obj%init(n, max_iter, m = m)
380 call obj%init(n, max_iter, m = m)
382 call obj%init(n, max_iter, m = m)
384 call obj%init(n, max_iter, m = m)
386 call obj%init(n, max_iter, m = m)
388 call obj%init(n, max_iter, m = m)
390 call obj%init(n, max_iter, m = m)
392 call obj%init(n, max_iter, m = m)
394 call obj%init(n, max_iter, m = m)
396 call obj%init(n, max_iter, m = m)
398 call obj%init(n, max_iter, m = m)
400 call obj%init(n, max_iter, m = m)
402 call obj%init(n, max_iter, m = m)
404 call obj%init(n, max_iter, m = m)
406 call obj%init(n, max_iter, m = m)
408 call obj%init(n, max_iter, m = m)
411 select type (obj => object)
413 call obj%init(n, max_iter)
415 call obj%init(n, max_iter)
417 call obj%init(n, max_iter)
419 call obj%init(n, max_iter)
421 call obj%init(n, max_iter)
423 call obj%init(n, max_iter)
425 call obj%init(n, max_iter)
427 call obj%init(n, max_iter)
429 call obj%init(n, max_iter)
431 call obj%init(n, max_iter)
433 call obj%init(n, max_iter)
435 call obj%init(n, max_iter)
437 call obj%init(n, max_iter)
439 call obj%init(n, max_iter)
441 call obj%init(n, max_iter)
443 call obj%init(n, max_iter)
447 end subroutine krylov_solver_factory
450 module subroutine krylov_solver_destroy(object)
451 class(ksp_t),
allocatable,
intent(inout) :: object
453 if (
allocated(object))
then
454 select type (obj => object)
488 end subroutine krylov_solver_destroy
490 end submodule krylov_fctry
Defines various Bi-Conjugate Gradient Stabilized methods.
Defines a communication avoiding Conjugate Gradient method.
Defines a coupled Conjugate Gradient methods.
Defines various Conjugate Gradient methods for accelerators.
Defines various Conjugate Gradient methods.
Defines various Conjugate Gradient methods.
Chebyshev preconditioner.
Chebyshev preconditioner.
Defines a fused Conjugate Gradient method for accelerators.
Defines a fused Conjugate Gradient method for accelerators.
Defines various GMRES methods.
Defines various GMRES methods.
Defines various GMRES methods.
Implements the base abstract type for Krylov solvers plus helper types.
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_opencl
integer, parameter, public rp
Global precision used in computations.
Defines a pipelined Conjugate Gradient methods.
Defines a pipelined Conjugate Gradient methods SX-Aurora backend.
Defines a pipelined Conjugate Gradient methods.
character(:) function, allocatable, public concat_string_array(array, sep, prepend)
Concatenate an array of strings into one string with array items separated by spaces.
Standard preconditioned Bi-Conjugate Gradient Stabilized method.
S-step communication avoiding preconditioned conjugate gradient method.
Standard preconditioned conjugate gradient method.
Coupled preconditioned conjugate gradient method.
Device based preconditioned conjugate gradient method.
Standard preconditioned conjugate gradient method (SX version)
Defines a Chebyshev preconditioner.
Defines a Chebyshev preconditioner.
Fused preconditioned conjugate gradient method.
Fused preconditioned conjugate gradient method.
Standard preconditioned generalized minimal residual method.
Standard preconditioned generalized minimal residual method.
Standard preconditioned generalized minimal residual method (SX version)
Pipelined preconditioned conjugate gradient method.
Pipelined preconditioned conjugate gradient method.
Pipelined preconditioned conjugate gradient method for SX-Aurora.
Defines a canonical Krylov preconditioner.