8.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-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 
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
121  * extra_diag_block_size block sizes for extra diagonal
122  * da diagonal values (NULL if zero)
123  * xa extradiagonal values (NULL if zero)
124  * conv_diff convection-diffusion mode
125  */
126 /*----------------------------------------------------------------------------*/
127 
128 void
130  const char *name,
131  const cs_lnum_t diag_block_size,
132  const cs_lnum_t extra_diag_block_size,
133  const cs_real_t *da,
134  const cs_real_t *xa,
135  bool conv_diff);
136 
137 /*----------------------------------------------------------------------------
138  * Call sparse linear equation solver using native matrix arrays.
139  *
140  * parameters:
141  * f_id <-- associated field id, or < 0
142  * name <-- associated name if f_id < 0, or NULL
143  * symmetric <-- indicates if matrix coefficients are symmetric
144  * diag_block_size <-- block sizes for diagonal
145  * extra_diag_block_size <-- block sizes for extra diagonal
146  * da <-- diagonal values (NULL if zero)
147  * xa <-- extradiagonal values (NULL if zero)
148  * r_epsilon <-- precision
149  * r_norm <-- residual normalization
150  * n_iter --> number of iterations
151  * residual --> residual
152  * rhs <-- right hand side
153  * vx <-> system solution
154  *
155  * returns:
156  * convergence state
157  *----------------------------------------------------------------------------*/
158 
160 cs_sles_solve_native(int f_id,
161  const char *name,
162  bool symmetric,
163  cs_lnum_t diag_block_size,
164  cs_lnum_t extra_diag_block_size,
165  const cs_real_t *da,
166  const cs_real_t *xa,
167  double precision,
168  double r_norm,
169  int *n_iter,
170  double *residual,
171  const cs_real_t *rhs,
172  cs_real_t *vx);
173 
174 /*----------------------------------------------------------------------------
175  * Free sparse linear equation solver setup using native matrix arrays.
176  *
177  * parameters:
178  * f_id <-- associated field id, or < 0
179  * name <-- associated name if f_id < 0, or NULL
180  *----------------------------------------------------------------------------*/
181 
182 void
183 cs_sles_free_native(int f_id,
184  const char *name);
185 
186 /*----------------------------------------------------------------------------
187  * Error handler attempting fallback to alternative solution procedure for
188  * sparse linear equation solver.
189  *
190  * In case of divergence with an iterative solver, this error handler
191  * switches to a default preconditioner, then resets the solution vector.
192  *
193  * The default error for the solver type handler is then set, in case
194  * the solution fails again.
195  *
196  * Note that this error handler may rebuild solver contexts, so should not
197  * be used in conjunction with shared contexts (such as multigrid
198  * ascent/descent contexts), but only for "outer" solvers.
199  *
200  * parameters:
201  * sles <-> pointer to solver object
202  * state <-- convergence status
203  * a <-- matrix
204  * rhs <-- right hand side
205  * vx <-> system solution
206  *
207  * returns:
208  * true if fallback solution is possible, false otherwise
209  *----------------------------------------------------------------------------*/
210 
211 bool
214  const cs_matrix_t *a,
215  const cs_real_t rhs[],
216  cs_real_t vx[]);
217 
218 /*----------------------------------------------------------------------------*/
219 
221 
222 #endif /* __CS_SLES_DEFAULT_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:110
cs_sles_convergence_state_t
Definition: cs_sles.h:56
struct _cs_sles_t cs_sles_t
Definition: cs_sles.h:68
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:887
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, bool conv_diff)
Call sparse linear equation solver setup for convection-diffusion systems.
Definition: cs_sles_default.c:638
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:592
cs_sles_convergence_state_t cs_sles_solve_native(int f_id, const char *name, bool symmetric, cs_lnum_t diag_block_size, 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 *residual, const cs_real_t *rhs, cs_real_t *vx)
Call sparse linear equation solver using native matrix arrays.
Definition: cs_sles_default.c:738
void cs_sles_default_setup(void)
Default setup for sparse linear equation solver API.
Definition: cs_sles_default.c:514
void cs_sles_default_log_setup(void)
void cs_sles_default_finalize(void)
Default finalization for sparse linear equation solver API.
Definition: cs_sles_default.c:572
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:946
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:495