7.1
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  * r_epsilon <-- precision
155  * r_norm <-- residue normalization
156  * n_iter --> number of iterations
157  * residue --> residue
158  * rhs <-- right hand side
159  * vx <-> system solution
160  *
161  * returns:
162  * convergence state
163  *----------------------------------------------------------------------------*/
164 
166 cs_sles_solve_native(int f_id,
167  const char *name,
168  bool symmetric,
169  const cs_lnum_t *diag_block_size,
170  const cs_lnum_t *extra_diag_block_size,
171  const cs_real_t *da,
172  const cs_real_t *xa,
173  double precision,
174  double r_norm,
175  int *n_iter,
176  double *residue,
177  const cs_real_t *rhs,
178  cs_real_t *vx);
179 
180 /*----------------------------------------------------------------------------
181  * Free sparse linear equation solver setup using native matrix arrays.
182  *
183  * parameters:
184  * f_id <-- associated field id, or < 0
185  * name <-- associated name if f_id < 0, or NULL
186  *----------------------------------------------------------------------------*/
187 
188 void
189 cs_sles_free_native(int f_id,
190  const char *name);
191 
192 /*----------------------------------------------------------------------------
193  * Error handler attempting fallback to alternative solution procedure for
194  * sparse linear equation solver.
195  *
196  * In case of divergence with an iterative solver, this error handler
197  * switches to a default preconditioner, then resets the solution vector.
198  *
199  * The default error for the solver type handler is then set, in case
200  * the solution fails again.
201  *
202  * Note that this error handler may rebuild solver contexts, so should not
203  * be used in conjunction with shared contexts (such as multigrid
204  * ascent/descent contexts), but only for "outer" solvers.
205  *
206  * parameters:
207  * sles <-> pointer to solver object
208  * state <-- convergence status
209  * a <-- matrix
210  * rhs <-- right hand side
211  * vx <-> system solution
212  *
213  * returns:
214  * true if fallback solution is possible, false otherwise
215  *----------------------------------------------------------------------------*/
216 
217 bool
220  const cs_matrix_t *a,
221  const cs_real_t rhs[],
222  cs_real_t vx[]);
223 
224 /*----------------------------------------------------------------------------*/
225 
227 
228 #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:606
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:463
bool cs_sles_default_error(cs_sles_t *sles, cs_sles_convergence_state_t state, const cs_matrix_t *a, 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:964
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, 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:750
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:93
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:482
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:537
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
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:557
#define END_C_DECLS
Definition: cs_defs.h:511
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:904
void cs_sles_default_log_setup(void)