9.2
general documentation
cs_balance.h
Go to the documentation of this file.
1#ifndef CS_BALANCE_H
2#define CS_BALANCE_H
3
4/*============================================================================
5 * Building of the right hand side for a transport of a field.
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#include "base/cs_defs.h"
31
32/*----------------------------------------------------------------------------
33 * Standard C library headers
34 *----------------------------------------------------------------------------*/
35
36/*----------------------------------------------------------------------------
37 * Local headers
38 *----------------------------------------------------------------------------*/
39
40#include "base/cs_parameters.h"
41
42/*=============================================================================
43 * Public function prototypes
44 *============================================================================*/
45
46/*----------------------------------------------------------------------------*/
50/*----------------------------------------------------------------------------*/
51
52void
54
55/*----------------------------------------------------------------------------*/
56/*
57 * \brief Wrapper to the function which adds the explicit part of the
58 * convection/diffusion terms of a transport equation of
59 * a scalar field \f$ \varia \f$.
60 *
61 * More precisely, the right hand side \f$ Rhs \f$ is updated as
62 * follows:
63 * \f[
64 * Rhs = Rhs - \sum_{\fij \in \Facei{\celli}} \left(
65 * \dot{m}_\ij \left( \varia_\fij - \varia_\celli \right)
66 * - \mu_\fij \gradv_\fij \varia \cdot \vect{S}_\ij \right)
67 * \f]
68 *
69 * Warning:
70 * - \f$ Rhs \f$ has already been initialized
71 * before calling cs_balance_scalar!
72 * - mind the minus sign
73 *
74 * Options for the convective scheme:
75 * - blencp = 0: upwind scheme for the advection
76 * - blencp = 1: no upwind scheme except in the slope test
77 * - ischcp = 0: SOLU
78 * - ischcp = 1: centered
79 * - ischcp = 2: SOLU with upwind gradient reconstruction
80 * - ischcp = 3: blending SOLU centered
81 * - ischcp = 4: NVD-TVD
82 * - imucpp = 0: do not multiply the convective part by \f$ C_p \f$
83 * - imucpp = 1: multiply the convective part by \f$ C_p \f$
84 *
85 * \param[in] idtvar indicator of the temporal scheme
86 * \param[in] f_id field id (or -1)
87 * \param[in] imucpp indicator
88 * - 0 do not multiply the convectiv term by Cp
89 * - 1 do multiply the convectiv term by Cp
90 * \param[in] imasac take mass accumulation into account?
91 * \param[in] inc indicator
92 * - 0 when solving an increment
93 * - 1 otherwise
94 * \param[in] eqp pointer to a cs_equation_param_t structure which
95 * contains variable calculation options
96 * \param[in] pvar solved variable (current time step)
97 * may be NULL if pvara != NULL
98 * \param[in] pvara solved variable (previous time step)
99 * may be NULL if pvar != NULL
100 * \param[in] bc_coeffs boundary condition structure for the variable
101 * \param[in] i_massflux mass flux at interior faces
102 * \param[in] b_massflux mass flux at boundary faces
103 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
104 * at interior faces for the r.h.s.
105 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
106 * at boundary faces for the r.h.s.
107 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
108 * \param[in] xcpp array of specific heat (Cp)
109 * \param[in] weighf internal face weight between cells i j in case
110 * of tensor diffusion
111 * \param[in] weighb boundary face weight for cells i in case
112 * of tensor diffusion
113 * \param[in] icvflb global indicator of boundary convection flux
114 * - 0 upwind scheme at all boundary faces
115 * - 1 imposed flux at some boundary faces
116 * \param[in] icvfli boundary face indicator array of convection flux
117 * - 0 upwind scheme
118 * - 1 imposed flux
119 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
120 */
121/*----------------------------------------------------------------------------*/
122
123void
125 int f_id,
126 int imucpp,
127 int imasac,
128 int inc,
130 cs_real_t pvar[],
131 const cs_real_t pvara[],
132 cs_field_bc_coeffs_t *bc_coeffs,
133 const cs_real_t i_massflux[],
134 const cs_real_t b_massflux[],
135 const cs_real_t i_visc[],
136 const cs_real_t b_visc[],
137 cs_real_6_t viscel[],
138 const cs_real_t xcpp[],
139 const cs_real_2_t weighf[],
140 const cs_real_t weighb[],
141 int icvflb,
142 const int icvfli[],
143 cs_real_t rhs[]);
144
145/*----------------------------------------------------------------------------*/
146/*
147 * \brief Wrapper to the function which adds the explicit part of the
148 * convection/diffusion terms of a transport equation of
149 * a scalar field \f$ \varia \f$.
150 *
151 * More precisely, the right hand side \f$ Rhs \f$ is updated as
152 * follows:
153 * \f[
154 * Rhs = Rhs - \sum_{\fij \in \Facei{\celli}} \left(
155 * \dot{m}_\ij \left( \varia_\fij - \varia_\celli \right)
156 * - \mu_\fij \gradv_\fij \varia \cdot \vect{S}_\ij \right)
157 * \f]
158 *
159 * Warning:
160 * - \f$ Rhs \f$ has already been initialized
161 * before calling cs_balance_scalar!
162 * - mind the minus sign
163 *
164 * Options for the convective scheme:
165 * - blencp = 0: upwind scheme for the advection
166 * - blencp = 1: no upwind scheme except in the slope test
167 * - ischcp = 0: SOLU
168 * - ischcp = 1: centered
169 * - ischcp = 2: SOLU with upwind gradient reconstruction
170 * - ischcp = 3: blending SOLU centered
171 * - ischcp = 4: NVD-TVD
172 * - imucpp = 0: do not multiply the convective part by \f$ C_p \f$
173 * - imucpp = 1: multiply the convective part by \f$ C_p \f$
174 *
175 * \param[in] idtvar indicator of the temporal scheme
176 * \param[in] f_id field id (or -1)
177 * \param[in] imucpp indicator
178 * - 0 do not multiply the convectiv term by Cp
179 * - 1 do multiply the convectiv term by Cp
180 * \param[in] imasac take mass accumulation into account?
181 * \param[in] inc indicator
182 * - 0 when solving an increment
183 * - 1 otherwise
184 * \param[in] eqp pointer to a cs_equation_param_t structure which
185 * contains variable calculation options
186 * \param[in] pvar solved variable (current time step)
187 * may be NULL if pvara != NULL
188 * \param[in] pvara solved variable (previous time step)
189 * may be NULL if pvar != NULL
190 * \param[in] bc_coeffs boundary condition structure for the variable
191 * \param[in] i_massflux mass flux at interior faces
192 * \param[in] b_massflux mass flux at boundary faces
193 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
194 * at interior faces for the r.h.s.
195 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
196 * at boundary faces for the r.h.s.
197 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
198 * \param[in] xcpp array of specific heat (Cp)
199 * \param[in] weighf internal face weight between cells i j in case
200 * of tensor diffusion
201 * \param[in] weighb boundary face weight for cells i in case
202 * of tensor diffusion
203 * \param[in] icvflb global indicator of boundary convection flux
204 * - 0 upwind scheme at all boundary faces
205 * - 1 imposed flux at some boundary faces
206 * \param[in] icvfli boundary face indicator array of convection flux
207 * - 0 upwind scheme
208 * - 1 imposed flux
209 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
210 * \param[in,out] i_flux interior flux (or nullptr)
211 * \param[in,out] b_flux boundary flux (or nullptr)
212 */
213/*----------------------------------------------------------------------------*/
214
215void
217 int f_id,
218 int imucpp,
219 int imasac,
220 int inc,
222 cs_real_t pvar[],
223 const cs_real_t pvara[],
224 cs_field_bc_coeffs_t *bc_coeffs,
225 const cs_real_t i_massflux[],
226 const cs_real_t b_massflux[],
227 const cs_real_t i_visc[],
228 const cs_real_t b_visc[],
229 cs_real_6_t viscel[],
230 const cs_real_t xcpp[],
231 const cs_real_2_t weighf[],
232 const cs_real_t weighb[],
233 int icvflb,
234 const int icvfli[],
235 cs_real_t rhs[],
236 cs_real_2_t i_flux[],
237 cs_real_t b_flux[]);
238
239/*----------------------------------------------------------------------------*/
240/*
241 * \brief Wrapper to the function which adds the explicit part of the
242 * convection/diffusion
243 * terms of a transport equation of a vector field \f$ \vect{\varia} \f$.
244 *
245 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as
246 * follows:
247 * \f[
248 * \vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}} \left(
249 * \dot{m}_\ij \left( \vect{\varia}_\fij - \vect{\varia}_\celli \right)
250 * - \mu_\fij \gradt_\fij \vect{\varia} \cdot \vect{S}_\ij \right)
251 * \f]
252 *
253 * Remark:
254 * if ivisep = 1, then we also take \f$ \mu \transpose{\gradt\vect{\varia}}
255 * + \lambda \trace{\gradt\vect{\varia}} \f$, where \f$ \lambda \f$ is
256 * the secondary viscosity, i.e. usually \f$ -\frac{2}{3} \mu \f$.
257 *
258 * Warning:
259 * - \f$ \vect{Rhs} \f$ has already been initialized
260 * before calling cs_balance_vector!
261 * - mind the sign minus
262 *
263 * Options for the convective scheme:
264 * - blencp = 0: upwind scheme for the advection
265 * - blencp = 1: no upwind scheme except in the slope test
266 * - ischcp = 0: SOLU
267 * - ischcp = 1: centered
268 * - ischcp = 2: SOLU with upwind gradient reconstruction
269 * - ischcp = 3: blending SOLU centered
270 * - ischcp = 4: NVD-TVD
271 *
272 * \param[in] idtvar indicator of the temporal scheme
273 * \param[in] f_id field id (or -1)
274 * \param[in] imasac take mass accumulation into account?
275 * \param[in] inc indicator
276 * - 0 when solving an increment
277 * - 1 otherwise
278 * \param[in] ivisep indicator to take \f$ \divv
279 * \left(\mu \gradt \transpose{\vect{a}} \right)
280 * -2/3 \grad\left( \mu \dive \vect{a} \right)\f$
281 * - 1 take into account,
282 * - 0 otherwise
283 * \param[in] eqp pointer to a cs_equation_param_t structure which
284 * contains variable calculation options
285 * \param[in] pvar solved velocity (current time step)
286 * \param[in] pvara solved velocity (previous time step)
287 * \param[in] bc_coeffs boundary condition structure for the variable
288 * \param[in] i_massflux mass flux at interior faces
289 * \param[in] b_massflux mass flux at boundary faces
290 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
291 * at interior faces for the r.h.s.
292 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
293 * at boundary faces for the r.h.s.
294 * \param[in] secvif secondary viscosity at interior faces
295 * \param[in] secvib secondary viscosity at boundary faces
296 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
297 * \param[in] weighf internal face weight between cells i j in case
298 * of tensor diffusion
299 * \param[in] weighb boundary face weight for cells i in case
300 * of tensor diffusion
301 * \param[in] icvflb global indicator of boundary convection flux
302 * - 0 upwind scheme at all boundary faces
303 * - 1 imposed flux at some boundary faces
304 * \param[in] icvfli boundary face indicator array of convection flux
305 * - 0 upwind scheme
306 * - 1 imposed flux
307 * \param[in,out] smbr right hand side \f$ \vect{Rhs} \f$
308 */
309/*----------------------------------------------------------------------------*/
310
311void
313 int f_id,
314 int imasac,
315 int inc,
316 int ivisep,
318 cs_real_3_t pvar[],
319 const cs_real_3_t pvara[],
320 cs_field_bc_coeffs_t *bc_coeffs,
321 const cs_real_t i_massflux[],
322 const cs_real_t b_massflux[],
323 const cs_real_t i_visc[],
324 const cs_real_t b_visc[],
325 const cs_real_t secvif[],
326 const cs_real_t secvib[],
327 cs_real_6_t viscel[],
328 const cs_real_2_t weighf[],
329 const cs_real_t weighb[],
330 int icvflb,
331 const int icvfli[],
332 cs_real_3_t i_pvar[],
333 cs_real_3_t b_pvar[],
334 cs_real_3_t smbr[]);
335
336/*----------------------------------------------------------------------------*/
337/*
338 * \brief Wrapper to the function which adds the explicit part of the
339 * convection/diffusion
340 * terms of a transport equation of a tensor field \f$ \tens{\varia} \f$.
341 *
342 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as
343 * follows:
344 * \f[
345 * \tens{Rhs} = \tens{Rhs} - \sum_{\fij \in \Facei{\celli}} \left(
346 * \dot{m}_\ij \left( \tens{\varia}_\fij - \tens{\varia}_\celli \right)
347 * - \mu_\fij \gradt_\fij \tens{\varia} \cdot \tens{S}_\ij \right)
348 * \f]
349 *
350 * Warning:
351 * - \f$ \tens{Rhs} \f$ has already been initialized before calling bilscts!
352 * - mind the sign minus
353 *
354 * Options for the convective scheme:
355 * - blencp = 0: upwind scheme for the advection
356 * - blencp = 1: no upwind scheme except in the slope test
357 * - ischcp = 0: SOLU
358 * - ischcp = 1: centered
359 * - ischcp = 2: SOLU with upwind gradient reconstruction
360 * - ischcp = 3: blending SOLU centered
361 * - ischcp = 4: NVD-TVD
362 *
363 * \param[in] idtvar indicator of the temporal scheme
364 * \param[in] f_id field id (or -1)
365 * \param[in] imasac take mass accumulation into account?
366 * \param[in] inc indicator
367 * \param[in] eqp pointer to a cs_equation_param_t structure which
368 * contains variable calculation options
369 * \param[in] pvar solved velocity (current time step)
370 * \param[in] pvara solved velocity (previous time step)
371 * \param[in] bc_coeffs boundary condition structure for the variable
372 * \param[in] i_massflux mass flux at interior faces
373 * \param[in] b_massflux mass flux at boundary faces
374 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
375 * at interior faces for the r.h.s.
376 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
377 * at boundary faces for the r.h.s.
378 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
379 * \param[in] weighf internal face weight between cells i j in case
380 * of tensor diffusion
381 * \param[in] weighb boundary face weight for cells i in case
382 * of tensor diffusion
383 * \param[in] icvflb global indicator of boundary convection flux
384 * - 0 upwind scheme at all boundary faces
385 * - 1 imposed flux at some boundary faces
386 * \param[in] icvfli boundary face indicator array of convection flux
387 * - 0 upwind scheme
388 * - 1 imposed flux
389 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
390 */
391/*----------------------------------------------------------------------------*/
392
393void
395 int f_id,
396 int imasac,
397 int inc,
399 cs_real_6_t pvar[],
400 const cs_real_6_t pvara[],
401 cs_field_bc_coeffs_t *bc_coeffs,
402 const cs_real_t i_massflux[],
403 const cs_real_t b_massflux[],
404 const cs_real_t i_visc[],
405 const cs_real_t b_visc[],
406 cs_real_6_t viscel[],
407 const cs_real_2_t weighf[],
408 const cs_real_t weighb[],
409 int icvflb,
410 const int icvfli[],
411 cs_real_6_t rhs[]);
412
413/*----------------------------------------------------------------------------*/
414
415#endif /* CS_BALANCE_H */
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
void cs_balance_initialize(void)
Initialize balance timers.
Definition: cs_balance.cpp:245
void cs_balance_scalar(int idtvar, int f_id, int imucpp, int imasac, int inc, cs_equation_param_t *eqp, cs_real_t pvar[], const cs_real_t pvara[], cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t viscel[], const cs_real_t xcpp[], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_t rhs[])
Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport...
Definition: cs_balance.cpp:326
void cs_balance_tensor(int idtvar, int f_id, int imasac, int inc, cs_equation_param_t *eqp, cs_real_6_t pvar[], const cs_real_6_t pvara[], cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], 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[], cs_real_6_t rhs[])
Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport...
Definition: cs_balance.cpp:889
void cs_balance_vector(int idtvar, int f_id, int imasac, int inc, int ivisep, cs_equation_param_t *eqp, cs_real_3_t pvar[], const cs_real_3_t pvara[], cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t secvif[], const cs_real_t secvib[], cs_real_6_t viscel[], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_3_t i_pvar[], cs_real_3_t b_pvar[], cs_real_3_t smbr[])
Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport...
Definition: cs_balance.cpp:690
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
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
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