9.2
general documentation
cs_equation_iterative_solve.h
Go to the documentation of this file.
1#ifndef CS_EQUATION_ITERATIVE_SOLVE_H
2#define CS_EQUATION_ITERATIVE_SOLVE_H
3
4/*============================================================================
5 * Scalar convection diffusion equation solver.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 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 "base/cs_defs.h"
35#include "base/cs_dispatch.h"
36#include "base/cs_parameters.h"
37
38/*=============================================================================
39 * Public function prototypes
40 *============================================================================*/
41
42/*----------------------------------------------------------------------------*/
48/*----------------------------------------------------------------------------*/
49
50/*----------------------------------------------------------------------------*/
51/*
52 * \brief Solve an advection diffusion equation with source
53 * terms for one time step for the variable \f$ a \f$.
54 *
55 * The equation reads:
56 *
57 * \f[
58 * f_s^{imp}(a^{n+1}-a^n)
59 * + \divs \left( a^{n+1} \rho \vect{u} - \mu \grad a^{n+1} \right)
60 * = Rhs
61 * \f]
62 *
63 * This equation is rewritten as:
64 *
65 * \f[
66 * f_s^{imp} \delta a
67 * + \divs \left( \delta a \rho \vect{u} - \mu \grad \delta a \right)
68 * = Rhs^1
69 * \f]
70 *
71 * where \f$ \delta a = a^{n+1} - a^n\f$ and
72 * \f$ Rhs^1 = Rhs - \divs( a^n \rho \vect{u} - \mu \grad a^n)\f$
73 *
74 *
75 * It is in fact solved with the following iterative process:
76 *
77 * \f[
78 * f_s^{imp} \delta a^k
79 * + \divs \left(\delta a^k \rho \vect{u}-\mu\grad\delta a^k \right)
80 * = Rhs^k
81 * \f]
82 *
83 * where \f$Rhs^k=Rhs-f_s^{imp}(a^k-a^n)
84 * - \divs \left( a^k\rho\vect{u}-\mu\grad a^k \right)\f$
85 *
86 * Be careful, it is forbidden to modify \f$ f_s^{imp} \f$ here!
87 *
88 * Please refer to the
89 * <a href="../../theory.pdf#codits"><b>codits</b></a> section of the
90 * theory guide for more informations.
91 *
92 * \param[in] idtvar indicator of the temporal scheme
93 * \param[in] iterns external sub-iteration number
94 * \param[in] f_id field id (or -1)
95 * \param[in] name associated name if f_id < 0, or NULL
96 * \param[in] iescap compute the predictor indicator if 1
97 * \param[in] imucpp indicator
98 * - 0 do not multiply the convectiv term by Cp
99 * - 1 do multiply the convectiv term by Cp
100 * \param[in] normp Reference norm to solve the system (optional)
101 * if negative: recomputed here
102 * \param[in] eqp pointer to a cs_equation_param_t structure which
103 * contains variable calculation options
104 * \param[in] pvara variable at the previous time step
105 * \f$ a^n \f$
106 * \param[in] pvark variable at the previous sub-iteration
107 * \f$ a^k \f$.
108 * If you sub-iter on Navier-Stokes, then
109 * it allows to initialize by something else than
110 * pvara (usually pvar=pvara)
111 * \param[in] bc_coeffs boundary condition structure for the variable
112 * \param[in] i_massflux mass flux at interior faces
113 * \param[in] b_massflux mass flux at boundary faces
114 * \param[in] i_viscm \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
115 * at interior faces for the matrix
116 * \param[in] b_viscm \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
117 * at boundary faces for the matrix
118 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
119 * at interior faces for the r.h.s.
120 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
121 * at boundary faces for the r.h.s.
122 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
123 * \param[in] weighf internal face weight between cells i j in case
124 * of tensor diffusion
125 * \param[in] weighb boundary face weight for cells i in case
126 * of tensor diffusion
127 * \param[in] icvflb global indicator of boundary convection flux
128 * - 0 upwind scheme at all boundary faces
129 * - 1 imposed flux at some boundary faces
130 * \param[in] icvfli boundary face indicator array of convection flux
131 * - 0 upwind scheme
132 * - 1 imposed flux
133 * \param[in] rovsdt \f$ f_s^{imp} \f$
134 * \param[in,out] rhs Right hand side \f$ Rhs^k \f$
135 * \param[in,out] pvar current variable
136 * \param[out] dpvar last variable increment
137 * \param[in] xcpp array of specific heat (Cp)
138 * \param[out] eswork prediction-stage error estimator
139 * (if iescap > 0)
140 */
141/*----------------------------------------------------------------------------*/
142
143void
145 int iterns,
146 int f_id,
147 const char *name,
148 int iescap,
149 int imucpp,
150 cs_real_t normp,
152 const cs_real_t pvara[],
153 const cs_real_t pvark[],
154 cs_field_bc_coeffs_t *bc_coeffs,
155 const cs_real_t i_massflux[],
156 const cs_real_t b_massflux[],
157 const cs_real_t i_viscm[],
158 const cs_real_t b_viscm[],
159 const cs_real_t i_visc[],
160 const cs_real_t b_visc[],
161 cs_real_6_t viscel[],
162 const cs_real_2_t weighf[],
163 const cs_real_t weighb[],
164 int icvflb,
165 const int icvfli[],
166 const cs_real_t rovsdt[],
167 cs_real_t rhs[],
168 cs_real_t pvar[],
169 cs_real_t dpvar[],
170 const cs_real_t xcpp[],
171 cs_real_t eswork[]);
172
173/*----------------------------------------------------------------------------*/
174/*
175 * \brief This function solves an advection diffusion equation with source terms
176 * for one time step for the vector variable \f$ \vect{a} \f$.
177 *
178 * The equation reads:
179 *
180 * \f[
181 * \tens{f_s}^{imp}(\vect{a}^{n+1}-\vect{a}^n)
182 * + \divv \left( \vect{a}^{n+1} \otimes \rho \vect {u}
183 * - \mu \gradt \vect{a}^{n+1}\right)
184 * = \vect{Rhs}
185 * \f]
186 *
187 * This equation is rewritten as:
188 *
189 * \f[
190 * \tens{f_s}^{imp} \delta \vect{a}
191 * + \divv \left( \delta \vect{a} \otimes \rho \vect{u}
192 * - \mu \gradt \delta \vect{a} \right)
193 * = \vect{Rhs}^1
194 * \f]
195 *
196 * where \f$ \delta \vect{a} = \vect{a}^{n+1} - \vect{a}^n\f$ and
197 * \f$ \vect{Rhs}^1 = \vect{Rhs}
198 * - \divv \left( \vect{a}^n \otimes \rho \vect{u}
199 * - \mu \gradt \vect{a}^n \right)\f$
200 *
201 *
202 * It is in fact solved with the following iterative process:
203 *
204 * \f[
205 * \tens{f_s}^{imp} \delta \vect{a}^k
206 * + \divv \left( \delta \vect{a}^k \otimes \rho \vect{u}
207 * - \mu \gradt \delta \vect{a}^k \right)
208 * = \vect{Rhs}^k
209 * \f]
210 *
211 * where \f$ \vect{Rhs}^k = \vect{Rhs}
212 * - \tens{f_s}^{imp} \left(\vect{a}^k-\vect{a}^n \right)
213 * - \divv \left( \vect{a}^k \otimes \rho \vect{u}
214 * - \mu \gradt \vect{a}^k \right)\f$
215 *
216 * Be careful, it is forbidden to modify \f$ \tens{f_s}^{imp} \f$ here!
217 *
218 * \param[in] idtvar indicator of the temporal scheme
219 * \param[in] iterns external sub-iteration number
220 * \param[in] f_id field id (or -1)
221 * \param[in] name associated name if f_id < 0, or NULL
222 * \param[in] ivisep indicator to take \f$ \divv
223 * \left(\mu \gradt \transpose{\vect{a}} \right)
224 * -2/3 \grad\left( \mu \dive \vect{a} \right)\f$
225 * - 1 take into account,
226 * - 0 otherwise
227 * \param[in] iescap compute the predictor indicator if >= 1
228 * \param[in] eqp pointer to a cs_equation_param_t structure which
229 * contains variable calculation options
230 * \param[in] pvara variable at the previous time step
231 * \f$ \vect{a}^n \f$
232 * \param[in] pvark variable at the previous sub-iteration
233 * \f$ \vect{a}^k \f$.
234 * If you sub-iter on Navier-Stokes, then
235 * it allows to initialize by something else than
236 * \c pvara (usually \c pvar= \c pvara)
237 * \param[in, out] bc_coeffs_v boundary condition structure for the variable
238 * \param[in] i_massflux mass flux at interior faces
239 * \param[in] b_massflux mass flux at boundary faces
240 * \param[in] i_viscm \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
241 * at interior faces for the matrix
242 * \param[in] b_viscm \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
243 * at boundary faces for the matrix
244 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
245 * at interior faces for the r.h.s.
246 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
247 * at boundary faces for the r.h.s.
248 * \param[in] i_secvis secondary viscosity at interior faces
249 * \param[in] b_secvis secondary viscosity at boundary faces
250 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
251 * \param[in] weighf internal face weight between cells i j in case
252 * of tensor diffusion
253 * \param[in] weighb boundary face weight for cells i in case
254 * of tensor diffusion
255 * \param[in] icvflb global indicator of boundary convection flux
256 * - 0 upwind scheme at all boundary faces
257 * - 1 imposed flux at some boundary faces
258 * \param[in] icvfli boundary face indicator array of convection flux
259 * - 0 upwind scheme
260 * - 1 imposed flux
261 * \param[in, out] fimp \f$ \tens{f_s}^{imp} \f$
262 * \param[in,out] rhs Right hand side \f$ \vect{Rhs}^k \f$
263 * \param[in, out] pvar current variable
264 * \param[out] eswork prediction-stage error estimator
265 * (if iescap >= 0)
266 */
267/*----------------------------------------------------------------------------*/
268
269void
271 int iterns,
272 int f_id,
273 const char *name,
274 int ivisep,
275 int iescap,
277 const cs_real_t pvara[][3],
278 const cs_real_t pvark[][3],
279 cs_field_bc_coeffs_t *bc_coeffs_v,
280 const cs_real_t i_massflux[],
281 const cs_real_t b_massflux[],
282 const cs_real_t i_viscm[],
283 const cs_real_t b_viscm[],
284 const cs_real_t i_visc[],
285 const cs_real_t b_visc[],
286 const cs_real_t i_secvis[],
287 const cs_real_t b_secvis[],
288 cs_real_t viscel[][6],
289 const cs_real_2_t weighf[],
290 const cs_real_t weighb[],
291 int icvflb,
292 const int icvfli[],
293 cs_real_t fimp[][3][3],
294 cs_real_t rhs[][3],
295 cs_real_t pvar[][3],
296 cs_real_t eswork[][3]);
297
298/*----------------------------------------------------------------------------*/
299/*
300 * \brief This function solves an advection diffusion equation with source
301 * terms for one time step for the symmetric tensor variable
302 * \f$ \tens{\variat} \f$.
303 *
304 * The equation reads:
305 *
306 * \f[
307 * \tens{f_s}^{imp}(\tens{\variat}^{n+1}-\tens{\variat}^n)
308 * + \divt \left( \tens{\variat}^{n+1} \otimes \rho \vect {u}
309 * - \mu \gradtt \tens{\variat}^{n+1}\right)
310 * = \tens{Rhs}
311 * \f]
312 *
313 * This equation is rewritten as:
314 *
315 * \f[
316 * \tens{f_s}^{imp} \delta \tens{\variat}
317 * + \divt \left( \delta \tens{\variat} \otimes \rho \vect{u}
318 * - \mu \gradtt \delta \tens{\variat} \right)
319 * = \tens{Rhs}^1
320 * \f]
321 *
322 * where \f$ \delta \tens{\variat} = \tens{\variat}^{n+1} - \tens{\variat}^n\f$
323 * and \f$ \tens{Rhs}^1 = \tens{Rhs}
324 * - \divt \left( \tens{\variat}^n \otimes \rho \vect{u}
325 * - \mu \gradtt \tens{\variat}^n \right)\f$
326 *
327 *
328 * It is in fact solved with the following iterative process:
329 *
330 * \f[
331 * \tens{f_s}^{imp} \delta \tens{\variat}^k
332 * + \divt \left( \delta \tens{\variat}^k \otimes \rho \vect{u}
333 * - \mu \gradtt \delta \tens{\variat}^k \right)
334 * = \tens{Rhs}^k
335 * \f]
336 *
337 * where \f$ \tens{Rhs}^k = \tens{Rhs}
338 * - \tens{f_s}^{imp} \left(\tens{\variat}^k-\tens{\variat}^n \right)
339 * - \divt \left( \tens{\variat}^k \otimes \rho \vect{u}
340 * - \mu \gradtt \tens{\variat}^k \right)\f$
341 *
342 * Be careful, it is forbidden to modify \f$ \tens{f_s}^{imp} \f$ here!
343 *
344 * \param[in] idtvar indicator of the temporal scheme
345 * \param[in] f_id field id (or -1)
346 * \param[in] name associated name if f_id < 0, or NULL
347 * \param[in] eqp pointer to a cs_equation_param_t structure which
348 * contains variable calculation options
349 * \param[in] pvara variable at the previous time step
350 * \f$ \vect{a}^n \f$
351 * \param[in] pvark variable at the previous sub-iteration
352 * \f$ \vect{a}^k \f$.
353 * If you sub-iter on Navier-Stokes, then
354 * it allows to initialize by something else than
355 * pvara (usually pvar=pvara)
356 * \param[in,out] bc_coeffs_ts boundary condition structure for the variable
357 * \param[in] i_massflux mass flux at interior faces
358 * \param[in] b_massflux mass flux at boundary faces
359 * \param[in] i_viscm \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
360 * at interior faces for the matrix
361 * \param[in] b_viscm \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
362 * at boundary faces for the matrix
363 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
364 * at interior faces for the r.h.s.
365 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
366 * at boundary faces for the r.h.s.
367 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
368 * \param[in] weighf internal face weight between cells i j in case
369 * of tensor diffusion
370 * \param[in] weighb boundary face weight for cells i in case
371 * of tensor diffusion
372 * \param[in] icvflb global indicator of boundary convection flux
373 * - 0 upwind scheme at all boundary faces
374 * - 1 imposed flux at some boundary faces
375 * \param[in] icvfli boundary face indicator array of convection flux
376 * - 0 upwind scheme
377 * - 1 imposed flux
378 * \param[in,out] fimp \f$ \tens{f_s}^{imp} \f$
379 * \param[in,out] rhs Right hand side \f$ \vect{Rhs}^k \f$
380 * \param[in,out] pvar current variable
381 */
382/*----------------------------------------------------------------------------*/
383
384void
386 int f_id,
387 const char *name,
389 const cs_real_t pvara[][6],
390 const cs_real_t pvark[][6],
391 cs_field_bc_coeffs_t *bc_coeffs_ts,
392 const cs_real_t i_massflux[],
393 const cs_real_t b_massflux[],
394 const cs_real_t i_viscm[],
395 const cs_real_t b_viscm[],
396 const cs_real_t i_visc[],
397 const cs_real_t b_visc[],
398 cs_real_t viscel[][6],
399 const cs_real_2_t weighf[],
400 const cs_real_t weighb[],
401 int icvflb,
402 const int icvfli[],
403 cs_real_t fimp[][6][6],
404 cs_real_t rhs[][6],
405 cs_real_t pvar[][6]);
406
407/*----------------------------------------------------------------------------*/
408
409#endif /* CS_EQUATION_ITERATIVE_SOLVE_H */
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:348
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:351
void cs_equation_iterative_solve_tensor(int idtvar, int f_id, const char *name, cs_equation_param_t *eqp, const cs_real_t pvara[][6], const cs_real_t pvark[][6], cs_field_bc_coeffs_t *bc_coeffs_ts, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_viscm[], const cs_real_t b_viscm[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t viscel[][6], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_t fimp[][6][6], cs_real_t rhs[][6], cs_real_t pvar[][6])
This function solves an advection diffusion equation with source terms for one time step for the symm...
Definition: cs_equation_iterative_solve.cpp:2530
void cs_equation_iterative_solve_scalar(int idtvar, int iterns, int f_id, const char *name, int iescap, int imucpp, cs_real_t normp, cs_equation_param_t *eqp, const cs_real_t pvara[], const cs_real_t pvark[], cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_viscm[], const cs_real_t b_viscm[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t viscel[], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], const cs_real_t rovsdt[], cs_real_t rhs[], cs_real_t pvar[], cs_real_t dpvar[], const cs_real_t xcpp[], cs_real_t eswork[])
Solve an advection diffusion equation with source terms for one time step for the variable .
Definition: cs_equation_iterative_solve.cpp:1391
void cs_equation_iterative_solve_vector(int idtvar, int iterns, int f_id, const char *name, int ivisep, int iescap, cs_equation_param_t *eqp, const cs_real_t pvara[][3], const cs_real_t pvark[][3], cs_field_bc_coeffs_t *bc_coeffs_v, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_viscm[], const cs_real_t b_viscm[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t i_secvis[], const cs_real_t b_secvis[], cs_real_t viscel[][6], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_t fimp[][3][3], cs_real_t rhs[][3], cs_real_t pvar[][3], cs_real_t eswork[][3])
This function solves an advection diffusion equation with source terms for one time step for the vect...
Definition: cs_equation_iterative_solve.cpp:2386
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:70
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190