8.0
general documentation
Loading...
Searching...
No Matches
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 * Set of functions to manage high-level iterative algorithms
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2023 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------
29 * Local headers
30 *----------------------------------------------------------------------------*/
31
32#include "cs_cdo_blas.h"
33#include "cs_math.h"
34#include "cs_param_sles.h"
35#include "cs_param_types.h"
36#include "cs_sles.h"
37
38/*----------------------------------------------------------------------------*/
39
41
42/*============================================================================
43 * Macro definitions
44 *============================================================================*/
45
46/*============================================================================
47 * Type definitions
48 *============================================================================*/
49
59
133
139
168
174
175typedef struct _cs_iter_algo_aa_t cs_iter_algo_aa_t;
176
177/*============================================================================
178 * Inline static public function prototypes
179 *============================================================================*/
180
181/*----------------------------------------------------------------------------*/
187/*----------------------------------------------------------------------------*/
188
189static inline void
191{
192 if (algo == NULL)
193 return;
194
196 algo->res0 = cs_math_big_r;
197 algo->prev_res = cs_math_big_r;
198 algo->res = cs_math_big_r;
199 algo->n_algo_iter = 0;
200 algo->n_inner_iter = 0;
201 algo->last_inner_iter = 0;
202}
203
204/*============================================================================
205 * Public function prototypes
206 *============================================================================*/
207
208/*----------------------------------------------------------------------------*/
218/*----------------------------------------------------------------------------*/
219
221cs_iter_algo_create(int verbosity,
222 cs_param_sles_cvg_t cvg_param);
223
224/*----------------------------------------------------------------------------*/
234/*----------------------------------------------------------------------------*/
235
236void
237cs_iter_algo_post_check(const char *func_name,
238 const char *eq_name,
239 const char *algo_name,
240 cs_iter_algo_t *algo);
241
242/*----------------------------------------------------------------------------*/
250/*----------------------------------------------------------------------------*/
251
252void
254
255/*----------------------------------------------------------------------------*/
264/*----------------------------------------------------------------------------*/
265
266void
268
269/*----------------------------------------------------------------------------*/
276/*----------------------------------------------------------------------------*/
277
278void
280 cs_iter_algo_t *algo);
281
282/*----------------------------------------------------------------------------*/
291/*----------------------------------------------------------------------------*/
292
295 cs_lnum_t n_elts);
296
297/*----------------------------------------------------------------------------*/
305/*----------------------------------------------------------------------------*/
306
309
310/*----------------------------------------------------------------------------*/
316/*----------------------------------------------------------------------------*/
317
318void
320
321/*----------------------------------------------------------------------------*/
327/*----------------------------------------------------------------------------*/
328
329void
331
332/*----------------------------------------------------------------------------*/
339/*----------------------------------------------------------------------------*/
340
341void
343
344/*----------------------------------------------------------------------------*/
354/*----------------------------------------------------------------------------*/
355
356void
358 cs_real_t *cur_iterate,
359 const cs_real_t *pre_iterate,
360 cs_cdo_blas_dotprod_t *dotprod,
362
363/*----------------------------------------------------------------------------*/
364
366
367#endif /* __CS_ITER_ALGO_H__ */
cs_real_t cs_cdo_blas_square_norm_t(const cs_real_t *array)
Generic function pointer for computing a square norm. Parallel synchronization is performed.
Definition cs_cdo_blas.h:79
cs_real_t cs_cdo_blas_dotprod_t(const cs_real_t *a, const cs_real_t *b)
Generic function pointer for computing a dot product. Parallel synchronization is performed.
Definition cs_cdo_blas.h:64
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
static void cs_iter_algo_reset(cs_iter_algo_t *algo)
Reset a cs_iter_algo_t structure.
Definition cs_iter_algo.h:190
cs_iter_algo_param_aa_t cs_iter_algo_get_anderson_param(cs_iter_algo_t *algo)
Retrieve the set of parameters for an Anderson algorithm.
Definition cs_iter_algo.c:594
void cs_iter_algo_post_check(const char *func_name, const char *eq_name, const char *algo_name, cs_iter_algo_t *algo)
Check if something wrong happens during the iterative process after one new iteration.
Definition cs_iter_algo.c:409
cs_iter_algo_aa_t * cs_iter_algo_aa_create(cs_iter_algo_param_aa_t aap, cs_lnum_t n_elts)
Create a new cs_iter_algo_aa_t structure for Anderson acceleration.
Definition cs_iter_algo.c:550
void cs_iter_algo_aa_free_arrays(cs_iter_algo_aa_t *aa)
Free arrays used during the Anderson acceleration.
Definition cs_iter_algo.c:664
void cs_iter_algo_aa_update(cs_iter_algo_t *algo, cs_real_t *cur_iterate, const cs_real_t *pre_iterate, cs_cdo_blas_dotprod_t *dotprod, cs_cdo_blas_square_norm_t *sqnorm)
Apply one more iteration of the Anderson acceleration.
Definition cs_iter_algo.c:719
void cs_iter_algo_aa_free(cs_iter_algo_t *algo)
Free a cs_iter_algo_aa_t structure inside a cs_iter_algo_t structure This structure is used to manage...
Definition cs_iter_algo.c:691
void cs_iter_algo_aa_allocate_arrays(cs_iter_algo_aa_t *aa)
Allocate arrays needed by the "Anderson acceleration" algorithm.
Definition cs_iter_algo.c:626
void cs_iter_algo_reset_nl(cs_param_nl_algo_t nl_algo_type, cs_iter_algo_t *algo)
Reset a cs_iter_algo_t structure in case of a non-linear algorothm.
Definition cs_iter_algo.c:521
void cs_iter_algo_update_cvg(cs_iter_algo_t *algo)
Update the convergence status and the number of iterations. The tolerance threshold has to be compute...
Definition cs_iter_algo.c:449
cs_iter_algo_t * cs_iter_algo_create(int verbosity, cs_param_sles_cvg_t cvg_param)
Create and initialize a new cs_iter_algo_t structure.
Definition cs_iter_algo.c:375
void cs_iter_algo_update_cvg_default(cs_iter_algo_t *algo)
Update the convergence status and the number of iterations. The tolerance threshold is computed by a ...
Definition cs_iter_algo.c:483
const cs_real_t cs_math_big_r
Structure and routines handling the SLES settings stored inside a cs_param_sles_t structure.
cs_param_nl_algo_t
Class of non-linear iterative algorithm.
Definition cs_param_types.h:551
cs_param_dotprod_type_t
Definition cs_param_types.h:1093
cs_sles_convergence_state_t
Definition cs_sles.h:56
@ CS_SLES_ITERATING
Definition cs_sles.h:61
Context structure for the algorithm called Anderson acceleration.
Structure storing all the parameters to drive the algorithm called Anderson acceleration.
Definition cs_iter_algo.h:140
double max_cond
Definition cs_iter_algo.h:163
int n_max_dir
Definition cs_iter_algo.h:161
cs_param_dotprod_type_t dp_type
Definition cs_iter_algo.h:165
double beta
Definition cs_iter_algo.h:164
int starting_iter
Definition cs_iter_algo.h:162
Structure to handle the convergence of an iterative algorithm.
Definition cs_iter_algo.h:60
cs_sles_convergence_state_t cvg_status
Definition cs_iter_algo.h:120
double res
Definition cs_iter_algo.h:125
int verbosity
Definition cs_iter_algo.h:115
double tol
Definition cs_iter_algo.h:122
int last_inner_iter
Definition cs_iter_algo.h:130
cs_param_sles_cvg_t cvg_param
Definition cs_iter_algo.h:116
double prev_res
Definition cs_iter_algo.h:124
double res0
Definition cs_iter_algo.h:126
int n_algo_iter
Definition cs_iter_algo.h:128
void * context
Definition cs_iter_algo.h:118
int n_inner_iter
Definition cs_iter_algo.h:129
double normalization
Definition cs_iter_algo.h:121
Set of parameters to check the convergence (or the divergence) of an iterative process (tolerances or...
Definition cs_param_sles.h:61