Neko 1.99.3
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, iteration)
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 integer, intent(in), optional :: iteration
60 logical :: converged, strict_conv, allow_stab
61 character(len=LOG_SIZE) :: log_buf
62 integer :: i, n
63
64 n = size(ksp_results)
65 if (full_stress_formulation) n = 2
66
67 if (present(strict_convergence)) then
68 strict_conv = strict_convergence
69 else
70 strict_conv = .false.
71 end if
72
73 if (present(allow_stabilization)) then
74 allow_stab = allow_stabilization
75 else
76 allow_stab = .false.
77 end if
78
79 if (present(iteration)) then
80 if (iteration .gt. 1) then
81 write(log_buf, '(A,I3)') 'Schwarz-like iteration ', iteration - 1
82 call neko_log%message(log_buf)
83 end if
84 end if
85
86 ! Do the printing
87 call ksp_results(1)%print_header()
88 do i = 1, n
89 call ksp_results(i)%print_result(time%tstep)
90 end do
91
92 ! Check for convergence
93 converged = .true.
94 do i = 1, n
95 if (ieee_is_nan(ksp_results(i)%res_final)) then
96 call neko_error("Fluid solver diverged for " // &
97 trim(ksp_results(i)%name))
98 end if
99
100 if (.not. ksp_results(i)%converged) then
101 converged = .false.
102 log_buf = 'Fluid solver did not converge for ' &
103 // trim(ksp_results(i)%name)
104
105 if (.not. stabilized .and. allow_stab) then
106 continue
107 else if (strict_conv) then
108 call neko_error(log_buf)
109 else
110 call neko_log%message(log_buf)
111 end if
112 end if
113 end do
114
115 ! Update stabilized status
116 if (.not. stabilized) stabilized = converged
117
118 end subroutine fluid_step_info
119
124
125end module fluid_aux
Auxiliary routines for fluid solvers.
Definition fluid_aux.f90:34
subroutine, public fluid_step_info(time, ksp_results, full_stress_formulation, strict_convergence, allow_stabilization, iteration)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
Definition fluid_aux.f90:54
subroutine, public fluid_step_info_reset_stabilized()
Resets the stabilized flag to false.
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:80
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:392
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.