My Project
programmer's 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-2019 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
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 /*----------------------------------------------------------------------------*/
128 /*----------------------------------------------------------------------------*/
129 
130 void
132  const char *name,
133  bool symmetric,
134  const int *diag_block_size,
135  const int *extra_diag_block_size,
136  const cs_real_t *da,
137  const cs_real_t *xa);
138 
139 /*----------------------------------------------------------------------------
140  * Call sparse linear equation solver setup for convection-diffusion
141  * systems
142  *
143  * parameters:
144  * f_id associated field id, or < 0
145  * name associated name if f_id < 0, or NULL
146  * diag_block_size block sizes for diagonal, or NULL
147  * extra_diag_block_size block sizes for extra diagonal, or NULL
148  * da diagonal values (NULL if zero)
149  * xa extradiagonal values (NULL if zero)
150  * da_conv diagonal values (NULL if zero)
151  * xa_conv extradiagonal values (NULL if zero)
152  * da_diff diagonal values (NULL if zero)
153  * xa_diff extradiagonal values (NULL if zero)
154  */
155 /*----------------------------------------------------------------------------*/
156 
157 void
159  const char *name,
160  const int *diag_block_size,
161  const int *extra_diag_block_size,
162  const cs_real_t *da,
163  const cs_real_t *xa,
164  const cs_real_t *da_conv,
165  const cs_real_t *xa_conv,
166  const cs_real_t *da_diff,
167  const cs_real_t *xa_diff);
168 
169 /*----------------------------------------------------------------------------
170  * Call sparse linear equation solver using native matrix arrays.
171  *
172  * parameters:
173  * f_id <-- associated field id, or < 0
174  * name <-- associated name if f_id < 0, or NULL
175  * symmetric <-- indicates if matrix coefficients are symmetric
176  * diag_block_size <-- block sizes for diagonal, or NULL
177  * extra_diag_block_size <-- block sizes for extra diagonal, or NULL
178  * da <-- diagonal values (NULL if zero)
179  * xa <-- extradiagonal values (NULL if zero)
180  * rotation_mode <-- halo update option for rotational periodicity
181  * r_epsilon <-- precision
182  * r_norm <-- residue normalization
183  * n_iter --> number of iterations
184  * residue --> residue
185  * rhs <-- right hand side
186  * vx <-> system solution
187  *
188  * returns:
189  * convergence state
190  *----------------------------------------------------------------------------*/
191 
194  const char *name,
195  bool symmetric,
196  const int *diag_block_size,
197  const int *extra_diag_block_size,
198  const cs_real_t *da,
199  const cs_real_t *xa,
200  cs_halo_rotation_t rotation_mode,
201  double precision,
202  double r_norm,
203  int *n_iter,
204  double *residue,
205  const cs_real_t *rhs,
206  cs_real_t *vx);
207 
208 /*----------------------------------------------------------------------------
209  * Free sparse linear equation solver setup using native matrix arrays.
210  *
211  * parameters:
212  * f_id <-- associated field id, or < 0
213  * name <-- associated name if f_id < 0, or NULL
214  *----------------------------------------------------------------------------*/
215 
216 void
218  const char *name);
219 
220 /*----------------------------------------------------------------------------
221  * Error handler attempting fallback to alternative solution procedure for
222  * sparse linear equation solver.
223  *
224  * In case of divergence with an iterative solver, this error handler
225  * switches to a default preconditioner, then resets the solution vector.
226  *
227  * The default error for the solver type handler is then set, in case
228  * the solution fails again.
229  *
230  * Note that this error handler may rebuild solver contexts, so should not
231  * be used in conjunction with shared contexts (such as multigrid
232  * ascent/descent contexts), but only for "outer" solvers.
233  *
234  * parameters:
235  * sles <-> pointer to solver object
236  * state <-- convergence status
237  * a <-- matrix
238  * rotation_mode <-- halo update option for rotational periodicity
239  * rhs <-- right hand side
240  * vx <-> system solution
241  *
242  * returns:
243  * true if fallback solution is possible, false otherwise
244  *----------------------------------------------------------------------------*/
245 
246 bool
249  const cs_matrix_t *a,
250  cs_halo_rotation_t rotation_mode,
251  const cs_real_t rhs[],
252  cs_real_t vx[]);
253 
254 /*----------------------------------------------------------------------------*/
255 
257 
258 #endif /* __CS_SLES_DEFAULT_H__ */
f_id
void const int * f_id
Definition: cs_gui.h:292
cs_fuel_incl::a
double precision, save a
Definition: cs_fuel_incl.f90:146
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_sles_default
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:263
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_matrix_t
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
cs_sles_convergence_state_t
cs_sles_convergence_state_t
Convergence status indicator.
Definition: cs_sles.h:56
da
void const int const int const int const cs_real_t const int const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t cs_real_t da[]
Definition: cs_matrix_building.h:65
cs_sles_default_error
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:919
cs_sles_free_native
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:858
cs_sles_setup_native_conv_diff
void cs_sles_setup_native_conv_diff(int f_id, const char *name, const int *diag_block_size, const int *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:413
cs_sles_default_log_setup
void cs_sles_default_log_setup(void)
cs_halo_perio.h
cs_sles_t
struct _cs_sles_t cs_sles_t
Definition: cs_sles.h:68
cs_sles_setup_native_coupling
void cs_sles_setup_native_coupling(int f_id, const char *name, bool symmetric, const int *diag_block_size, const int *extra_diag_block_size, const cs_real_t *da, const cs_real_t *xa)
Call sparse linear equation solver setup for systems with internal coupling.
Definition: cs_sles_default.c:560
cs_sles.h
cs_matrix.h
cs_halo_rotation_t
cs_halo_rotation_t
Definition: cs_halo.h:60
cs_sles_solve_native
cs_sles_convergence_state_t cs_sles_solve_native(int f_id, const char *name, bool symmetric, const int *diag_block_size, const int *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:656
xa
void const int const int const int const cs_real_t const int const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t const cs_real_t cs_real_t cs_real_t xa[]
Definition: cs_matrix_building.h:65
cs_sles_default_setup
void cs_sles_default_setup(void)
Default setup for sparse linear equation solver API.
Definition: cs_sles_default.c:282
cs_base.h
cs_sles_default_finalize
void cs_sles_default_finalize(void)
Default finalization for sparse linear equation solver API.
Definition: cs_sles_default.c:344
cs_sles_default_get_verbosity
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:364