Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
scalar_aux.f90
Go to the documentation of this file.
1! Copyright (c) 2025, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32
35 use, intrinsic :: ieee_arithmetic, only: ieee_is_nan
36 use krylov, only : ksp_monitor_t
37 use logger, only : neko_log, log_size
38 use utils, only : neko_error, neko_warning
39 use time_state, only : time_state_t
40 implicit none
41 private
42
44
46 logical, public, protected :: stabilized = .false.
47
48contains
49
52 subroutine scalar_step_info(time, ksp_results, strict_convergence, &
53 allow_stabilization)
54 type(ksp_monitor_t), intent(in) :: ksp_results
55 type(time_state_t), intent(in) :: time
56 logical, intent(in), optional :: strict_convergence
57 logical, intent(in), optional :: allow_stabilization
58 logical :: converged, strict_conv, allow_stab
59 character(len=LOG_SIZE) :: log_buf
60 integer :: i
61
62 if (present(strict_convergence)) then
63 strict_conv = strict_convergence
64 else
65 strict_conv = .false.
66 end if
67
68 if (present(allow_stabilization)) then
69 allow_stab = allow_stabilization
70 else
71 allow_stab = .false.
72 end if
73
74 ! Do the printing
75 call ksp_results%print_result(time%tstep)
76
77 ! Check for convergence
78 converged = .true.
79 if (ieee_is_nan(ksp_results%res_final)) then
80 call neko_error("Scalar solver diverged for " // trim(ksp_results%name))
81 end if
82
83 if (.not. ksp_results%converged) then
84 converged = .false.
85 log_buf = 'Scalar solver did not converge for ' // trim(ksp_results%name)
86
87 if (.not. stabilized .and. allow_stab) then
88 continue
89 else if (strict_conv) then
90 call neko_error(log_buf)
91 else
92 call neko_log%message(log_buf)
93 end if
94 end if
95
96 ! Update stabilized status
97 if (.not. stabilized) stabilized = converged
98
99 end subroutine scalar_step_info
100
105
106end module scalar_aux
Implements the base abstract type for Krylov solvers plus helper types.
Definition krylov.f90:34
Logging routines.
Definition log.f90:34
type(log_t), public neko_log
Global log stream.
Definition log.f90:76
integer, parameter, public log_size
Definition log.f90:46
Auxiliary routines for fluid solvers.
subroutine, public scalar_step_info(time, ksp_results, strict_convergence, allow_stabilization)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
logical, public, protected stabilized
To track if the solver is stabilized.
subroutine, public scalar_step_info_reset_stabilized()
Resets the stabilized flag to false.
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:346
Type for storing initial and final residuals in a Krylov solver.
Definition krylov.f90:56
A struct that contains all info about the time, expand as needed.