7.0
general documentation
cs_sles_default.h
Go to the documentation of this file.
1 #ifndef __CS_SLES_DEFAULT_H__
2 #define __CS_SLES_DEFAULT_H__
3 
4 /*============================================================================
5  * Sparse Linear Equation Solvers
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2021 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 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 #include "cs_halo_perio.h"
36 #include "cs_matrix.h"
37 #include "cs_sles.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
47 /*============================================================================
48  * Type definitions
49  *============================================================================*/
50 
51 /*============================================================================
52  * Global variables
53  *============================================================================*/
54 
55 /*=============================================================================
56  * Public function prototypes
57  *============================================================================*/
58 
59 /*----------------------------------------------------------------------------
60  * Default initializations for sparse linear equation solver API.
61  *----------------------------------------------------------------------------*/
62 
63 void
65 
66 /*----------------------------------------------------------------------------
67  * Default definition of a sparse linear equation solver
68  *
69  * parameters:
70  * f_id <-- associated field id, or < 0
71  * name <-- associated name if f_id < 0, or NULL
72  * a <-- matrix
73  *----------------------------------------------------------------------------*/
74 
75 void
76 cs_sles_default(int f_id,
77  const char *name,
78  const cs_matrix_t *a);
79 
80 /*----------------------------------------------------------------------------
81  * Default setup setup for sparse linear equation solver API.
82  *
83  * This includes setup logging.
84  *----------------------------------------------------------------------------*/
85 
86 void
88 
89 /*----------------------------------------------------------------------------
90  * Return default verbosity associated to a field id, name couple.
91  *
92  * parameters:
93  * f_id <-- associated field id, or < 0
94  * name <-- associated name if f_id < 0, or NULL
95  *
96  * returns:
97  * verbosity associated with field or name
98  *----------------------------------------------------------------------------*/
99 
100 int
102  const char *name);
103 
104 /*----------------------------------------------------------------------------
105  * Default finalization for sparse linear equation solver API.
106  *
107  * This includes performance data logging output.
108  *----------------------------------------------------------------------------*/
109 
110 void
112 
113 /*----------------------------------------------------------------------------
114  * Call sparse linear equation solver setup for convection-diffusion
115  * systems
116  *
117  * parameters:
118  * f_id associated field id, or < 0
119  * name associated name if f_id < 0, or NULL
120  * diag_block_size block sizes for diagonal, or NULL
121  * extra_diag_block_size block sizes for extra diagonal, or NULL
122  * da diagonal values (NULL if zero)
123  * xa extradiagonal values (NULL if zero)
124  * da_conv diagonal values (NULL if zero)
125  * xa_conv extradiagonal values (NULL if zero)
126  * da_diff diagonal values (NULL if zero)
127  * xa_diff extradiagonal values (NULL if zero)
128  */
129 /*----------------------------------------------------------------------------*/
130 
131 void
133  const char *name,
134  const cs_lnum_t *diag_block_size,
135  const cs_lnum_t *extra_diag_block_size,
136  const cs_real_t *da,
137  const cs_real_t *xa,
138  const cs_real_t *da_conv,
139  const cs_real_t *xa_conv,
140  const cs_real_t *da_diff,
141  const cs_real_t *xa_diff);
142 
143 /*----------------------------------------------------------------------------
144  * Call sparse linear equation solver using native matrix arrays.
145  *
146  * parameters:
147  * f_id <-- associated field id, or < 0
148  * name <-- associated name if f_id < 0, or NULL
149  * symmetric <-- indicates if matrix coefficients are symmetric
150  * diag_block_size <-- block sizes for diagonal, or NULL
151  * extra_diag_block_size <-- block sizes for extra diagonal, or NULL
152  * da <-- diagonal values (NULL if zero)
153  * xa <-- extradiagonal values (NULL if zero)
154  * rotation_mode <-- halo update option for rotational periodicity
155  * r_epsilon <-- precision
156  * r_norm <-- residue normalization
157  * n_iter --> number of iterations
158  * residue --> residue
159  * rhs <-- right hand side
160  * vx <-> system solution
161  *
162  * returns:
163  * convergence state
164  *----------------------------------------------------------------------------*/
165 
167 cs_sles_solve_native(int f_id,
168  const char *name,
169  bool symmetric,
170  const cs_lnum_t *diag_block_size,
171  const cs_lnum_t *extra_diag_block_size,
172  const cs_real_t *da,
173  const cs_real_t *xa,
174  cs_halo_rotation_t rotation_mode,
175  double precision,
176  double r_norm,
177  int *n_iter,
178  double *residue,
179  const cs_real_t *rhs,
180  cs_real_t *vx);
181 
182 /*----------------------------------------------------------------------------
183  * Free sparse linear equation solver setup using native matrix arrays.
184  *
185  * parameters:
186  * f_id <-- associated field id, or < 0
187  * name <-- associated name if f_id < 0, or NULL
188  *----------------------------------------------------------------------------*/
189 
190 void
191 cs_sles_free_native(int f_id,
192  const char *name);
193 
194 /*----------------------------------------------------------------------------
195  * Error handler attempting fallback to alternative solution procedure for
196  * sparse linear equation solver.
197  *
198  * In case of divergence with an iterative solver, this error handler
199  * switches to a default preconditioner, then resets the solution vector.
200  *
201  * The default error for the solver type handler is then set, in case
202  * the solution fails again.
203  *
204  * Note that this error handler may rebuild solver contexts, so should not
205  * be used in conjunction with shared contexts (such as multigrid
206  * ascent/descent contexts), but only for "outer" solvers.
207  *
208  * parameters:
209  * sles <-> pointer to solver object
210  * state <-- convergence status
211  * a <-- matrix
212  * rotation_mode <-- halo update option for rotational periodicity
213  * rhs <-- right hand side
214  * vx <-> system solution
215  *
216  * returns:
217  * true if fallback solution is possible, false otherwise
218  *----------------------------------------------------------------------------*/
219 
220 bool
223  const cs_matrix_t *a,
224  cs_halo_rotation_t rotation_mode,
225  const cs_real_t rhs[],
226  cs_real_t vx[]);
227 
228 /*----------------------------------------------------------------------------*/
229 
231 
232 #endif /* __CS_SLES_DEFAULT_H__ */
void cs_sles_setup_native_conv_diff(int f_id, const char *name, const cs_lnum_t *diag_block_size, const cs_lnum_t *extra_diag_block_size, const cs_real_t *da, const cs_real_t *xa, const cs_real_t *da_conv, const cs_real_t *xa_conv, const cs_real_t *da_diff, const cs_real_t *xa_diff)
Call sparse linear equation solver setup for convection-diffusion systems.
Definition: cs_sles_default.c:582
cs_halo_rotation_t
Definition: cs_halo.h:60
void cs_sles_default(int f_id, const char *name, const cs_matrix_t *a)
Default definition of a sparse linear equation solver.
Definition: cs_sles_default.c:439
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
cs_sles_convergence_state_t cs_sles_solve_native(int f_id, const char *name, bool symmetric, const cs_lnum_t *diag_block_size, const cs_lnum_t *extra_diag_block_size, const cs_real_t *da, const cs_real_t *xa, cs_halo_rotation_t rotation_mode, double precision, double r_norm, int *n_iter, double *residue, const cs_real_t *rhs, cs_real_t *vx)
Call sparse linear equation solver using native matrix arrays.
Definition: cs_sles_default.c:728
double cs_real_t
Floating-point value.
Definition: cs_defs.h:307
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:94
cs_sles_convergence_state_t
Convergence status indicator.
Definition: cs_sles.h:56
struct _cs_sles_t cs_sles_t
Definition: cs_sles.h:68
void cs_sles_default_setup(void)
Default setup for sparse linear equation solver API.
Definition: cs_sles_default.c:458
double precision, save a
Definition: cs_fuel_incl.f90:146
void cs_sles_default_finalize(void)
Default finalization for sparse linear equation solver API.
Definition: cs_sles_default.c:513
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
int cs_sles_default_get_verbosity(int f_id, const char *name)
Return default verbosity associated to a field id, name couple.
Definition: cs_sles_default.c:533
#define END_C_DECLS
Definition: cs_defs.h:496
void cs_sles_free_native(int f_id, const char *name)
Free sparse linear equation solver setup using native matrix arrays.
Definition: cs_sles_default.c:885
bool cs_sles_default_error(cs_sles_t *sles, cs_sles_convergence_state_t state, const cs_matrix_t *a, cs_halo_rotation_t rotation_mode, const cs_real_t rhs[], cs_real_t vx[])
Error handler attempting fallback to alternative solution procedure for sparse linear equation solver...
Definition: cs_sles_default.c:946
void cs_sles_default_log_setup(void)