Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fluid_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 fluid_step_info(time, ksp_results, full_stress_formulation, &
53 strict_convergence, allow_stabilization)
54 type(ksp_monitor_t), dimension(:), intent(in) :: ksp_results
55 type(time_state_t), intent(in) :: time
56 logical, intent(in) :: full_stress_formulation
57 logical, intent(in), optional :: strict_convergence
58 logical, intent(in), optional :: allow_stabilization
59 logical :: converged, strict_conv, allow_stab
60 character(len=LOG_SIZE) :: log_buf
61 integer :: i, n
62
63 n = size(ksp_results)
64 if (full_stress_formulation) n = 2
65
66 if (present(strict_convergence)) then
67 strict_conv = strict_convergence
68 else
69 strict_conv = .false.
70 end if
71
72 if (present(allow_stabilization)) then
73 allow_stab = allow_stabilization
74 else
75 allow_stab = .false.
76 end if
77
78 ! Do the printing
79 call ksp_results(1)%print_header()
80 do i = 1, n
81 call ksp_results(i)%print_result(time%tstep)
82 end do
83
84 ! Check for convergence
85 converged = .true.
86 do i = 1, n
87 if (ieee_is_nan(ksp_results(i)%res_final)) then
88 call neko_error("Fluid solver diverged for " // &
89 trim(ksp_results(i)%name))
90 end if
91
92 if (.not. ksp_results(i)%converged) then
93 converged = .false.
94 log_buf = 'Fluid solver did not converge for ' &
95 // trim(ksp_results(i)%name)
96
97 if (.not. stabilized .and. allow_stab) then
98 continue
99 else if (strict_conv) then
100 call neko_error(log_buf)
101 else
102 call neko_log%message(log_buf)
103 end if
104 end if
105 end do
106
107 ! Update stabilized status
108 if (.not. stabilized) stabilized = converged
109
110 end subroutine fluid_step_info
111
116
117end module fluid_aux
Auxiliary routines for fluid solvers.
Definition fluid_aux.f90:34
subroutine, public fluid_step_info_reset_stabilized()
Resets the stabilized flag to false.
subroutine, public fluid_step_info(time, ksp_results, full_stress_formulation, strict_convergence, allow_stabilization)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
Definition fluid_aux.f90:54
logical, public, protected stabilized
To track if the solver is stabilized.
Definition fluid_aux.f90:46
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
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.