7.0
general documentation
cs_iter_algo.h
Go to the documentation of this file.
1 #ifndef __CS_ITER_ALGO_H__
2 #define __CS_ITER_ALGO_H__
3 
4 /*============================================================================
5  * Routines to handle iterative algorithm such augmented Lagrangian, Picard or
6  * Anderson algorithms
7  *============================================================================*/
8 
9 /*
10  This file is part of Code_Saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2021 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------
30  * Local headers
31  *----------------------------------------------------------------------------*/
32 
33 #include "cs_cdo_connect.h"
34 #include "cs_cdo_quantities.h"
35 #include "cs_math.h"
36 #include "cs_sles.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /*============================================================================
47  * Type definitions
48  *============================================================================*/
49 
93 typedef struct {
94 
95  int verbosity;
96 
97  /* Set of tolerances to drive the convergence of the iterative algorithm */
98  double atol;
99  double rtol;
100  double dtol;
101 
102  /* Variable convergence indicators */
104  double res;
105  double res0;
106  double tol;
107 
112 
114 
115 /*============================================================================
116  * Inline static public function prototypes
117  *============================================================================*/
118 
119 /*----------------------------------------------------------------------------*/
125 /*----------------------------------------------------------------------------*/
126 
127 static inline void
128 cs_iter_algo_reset(cs_iter_algo_info_t *info)
129 {
130  if (info == NULL)
131  return;
132 
133  info->cvg = CS_SLES_ITERATING;
134  info->res = cs_math_big_r;
135  info->n_algo_iter = 0;
136  info->n_inner_iter = 0;
137  info->last_inner_iter = 0;
138 }
139 
140 /*----------------------------------------------------------------------------*/
147 /*----------------------------------------------------------------------------*/
148 
149 static inline void
150 cs_iter_algo_navsto_print_header(const char *algo_name)
151 {
152  assert(algo_name != NULL);
154  "%12s.It -- Algo.Res Inner Cumul ||div(u)|| Tolerance\n",
155  algo_name);
156 }
157 
158 /*----------------------------------------------------------------------------*/
167 /*----------------------------------------------------------------------------*/
168 
169 static inline void
170 cs_iter_algo_navsto_print(const char *algo_name,
171  const cs_iter_algo_info_t *info,
172  double div_l2)
173 {
174  assert(algo_name != NULL);
176  "%12s.It%02d-- %5.3e %5d %5d %6.4e %6.4e\n",
177  algo_name, info->n_algo_iter, info->res,
178  info->last_inner_iter, info->n_inner_iter, div_l2, info->tol);
180 }
181 
182 /*============================================================================
183  * Public function prototypes
184  *============================================================================*/
185 
186 /*----------------------------------------------------------------------------*/
198 /*----------------------------------------------------------------------------*/
199 
201 cs_iter_algo_define(int verbosity,
202  int n_max_iter,
203  double atol,
204  double rtol,
205  double dtol);
206 
207 /*----------------------------------------------------------------------------*/
220 /*----------------------------------------------------------------------------*/
221 
222 void
224  const cs_cdo_quantities_t *quant,
225  const cs_real_t *pre_iterate,
226  const cs_real_t *cur_iterate,
227  cs_real_t div_l2_norm,
228  cs_iter_algo_info_t *a_info);
229 
230 /*----------------------------------------------------------------------------*/
231 
233 
234 #endif /* __CS_ITER_ALGO_H__ */
int verbosity
Definition: cs_iter_algo.h:95
int cs_log_printf(cs_log_t log, const char *format,...)
Print log info to a given log type.
Definition: cs_log.c:501
const cs_real_t cs_math_big_r
double res0
Definition: cs_iter_algo.h:105
Definition: cs_sles.h:61
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
double atol
Definition: cs_iter_algo.h:98
Definition: cs_log.h:50
Definition: cs_cdo_connect.h:76
int n_algo_iter
Definition: cs_iter_algo.h:108
double res
Definition: cs_iter_algo.h:104
double cs_real_t
Floating-point value.
Definition: cs_defs.h:307
Definition: cs_cdo_quantities.h:124
int last_inner_iter
Definition: cs_iter_algo.h:111
cs_sles_convergence_state_t
Convergence status indicator.
Definition: cs_sles.h:56
cs_sles_convergence_state_t cvg
Definition: cs_iter_algo.h:103
double rtol
Definition: cs_iter_algo.h:99
int cs_log_printf_flush(cs_log_t log)
Flush output of a log file.
Definition: cs_log.c:555
double dtol
Definition: cs_iter_algo.h:100
cs_iter_algo_info_t * cs_iter_algo_define(int verbosity, int n_max_iter, double atol, double rtol, double dtol)
Create and initialize a new cs_iter_algo_info_t structure.
Definition: cs_iter_algo.c:108
#define END_C_DECLS
Definition: cs_defs.h:496
int n_max_algo_iter
Definition: cs_iter_algo.h:109
double tol
Definition: cs_iter_algo.h:106
void cs_iter_algo_navsto_fb_picard_cvg(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *pre_iterate, const cs_real_t *cur_iterate, cs_real_t div_l2_norm, cs_iter_algo_info_t *a_info)
Test if one has to do one more Picard iteration. Test if performed on the relative norm on the increm...
Definition: cs_iter_algo.c:145
Set of information related to the convergence of the iterative algorithm (Picard or Uzawa for instanc...
Definition: cs_iter_algo.h:93
int n_inner_iter
Definition: cs_iter_algo.h:110