9.1
general documentation
cs_convection_diffusion.h
Go to the documentation of this file.
1#ifndef __CS_CONVECTION_DIFFUSION_H__
2#define __CS_CONVECTION_DIFFUSION_H__
3
4/*============================================================================
5 * Convection-diffusion operators.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2025 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 * Local headers
34 *----------------------------------------------------------------------------*/
35
36#include "base/cs_base.h"
37#include "base/cs_dispatch.h"
38#include "base/cs_halo.h"
39#include "base/cs_math.h"
42
43/*----------------------------------------------------------------------------*/
44
46
47/*=============================================================================
48 * Macro definitions
49 *============================================================================*/
50
51/*============================================================================
52 * Type definition
53 *============================================================================*/
54
55/*----------------------------------------------------------------------------
56 * NVD/TVD Advection Scheme
57 *----------------------------------------------------------------------------*/
58
59typedef enum {
60
61 CS_NVD_GAMMA = 0, /* GAMMA */
62 CS_NVD_SMART = 1, /* SMART */
63 CS_NVD_CUBISTA = 2, /* CUBISTA */
64 CS_NVD_SUPERBEE = 3, /* SUPERBEE */
65 CS_NVD_MUSCL = 4, /* MUSCL */
66 CS_NVD_MINMOD = 5, /* MINMOD */
67 CS_NVD_CLAM = 6, /* CLAM */
68 CS_NVD_STOIC = 7, /* STOIC */
69 CS_NVD_OSHER = 8, /* OSHER */
70 CS_NVD_WASEB = 9, /* WASEB */
71 CS_NVD_VOF_HRIC = 10, /* M-HRIC for VOF */
72 CS_NVD_VOF_CICSAM = 11, /* M-CICSAM for VOF */
73 CS_NVD_VOF_STACS = 12, /* STACS for VOF */
74 CS_NVD_N_TYPES = 13 /* number of NVD schemes */
75
77
78/*============================================================================
79 * Global variables
80 *============================================================================*/
81
82/*============================================================================
83 * Public function prototypes for Fortran API
84 *============================================================================*/
85
86/*=============================================================================
87 * Public function prototypes
88 *============================================================================*/
89
90/*----------------------------------------------------------------------------
91 * Return pointer to slope test indicator field values if active.
92 *
93 * parameters:
94 * f_id <-- field id (or -1)
95 * eqp <-- equation parameters
96 *
97 * return:
98 * pointer to local values array, or NULL;
99 *----------------------------------------------------------------------------*/
100
101cs_real_t *
102cs_get_v_slope_test(int f_id,
103 const cs_equation_param_t eqp);
104
105/*----------------------------------------------------------------------------*/
114/*----------------------------------------------------------------------------*/
115
116void
118 int inc,
119 const cs_real_t rovsdt[]);
120
121/*----------------------------------------------------------------------------*/
170/*----------------------------------------------------------------------------*/
171
172void
174 int f_id,
175 const cs_equation_param_t eqp,
176 int icvflb,
177 int inc,
178 int imasac,
179 cs_real_t *pvar,
180 const cs_real_t *pvara,
181 const int icvfli[],
182 const cs_field_bc_coeffs_t *bc_coeffs,
183 const cs_real_t val_f[],
184 const cs_real_t flux[],
185 const cs_real_t i_massflux[],
186 const cs_real_t b_massflux[],
187 const cs_real_t i_visc[],
188 const cs_real_t b_visc[],
189 cs_real_t *rhs,
190 cs_real_2_t i_flux[],
191 cs_real_t b_flux[]);
192
193/*----------------------------------------------------------------------------*/
194/*
195 * \brief Update face flux with convection contribution of a standard transport
196 * equation of a scalar field \f$ \varia \f$.
197 *
198 * \f[
199 * C_\ij = \dot{m}_\ij \left( \varia_\fij - \varia_\celli \right)
200 * \f]
201 *
202 * \param[in] idtvar indicator of the temporal scheme
203 * \param[in] f_id field id (or -1)
204 * \param[in] eqp equation parameters
205 * \param[in] icvflb global indicator of boundary convection flux
206 * - 0 upwind scheme at all boundary faces
207 * - 1 imposed flux at some boundary faces
208 * \param[in] inc indicator
209 * - 0 when solving an increment
210 * - 1 otherwise
211 * \param[in] imasac take mass accumulation into account?
212 * \param[in] pvar solved variable (current time step)
213 * \param[in] pvara solved variable (previous time step)
214 * \param[in] icvfli boundary face indicator array of convection flux
215 * - 0 upwind scheme
216 * - 1 imposed flux
217 * \param[in] bc_coeffs boundary condition structure for the variable
218 * \param[in] val_f boundary face value for gradient
219 * \param[in] i_massflux mass flux at interior faces
220 * \param[in] b_massflux mass flux at boundary faces
221 * \param[in,out] i_conv_flux scalar convection flux at interior faces
222 * \param[in,out] b_conv_flux scalar convection flux at boundary faces
223 */
224/*----------------------------------------------------------------------------*/
225
226void
228 int f_id,
229 const cs_equation_param_t eqp,
230 int icvflb,
231 int inc,
232 int imasac,
233 cs_real_t *pvar,
234 const cs_real_t *pvara,
235 const int icvfli[],
236 const cs_field_bc_coeffs_t *bc_coeffs,
237 const cs_real_t val_f[],
238 const cs_real_t i_massflux[],
239 const cs_real_t b_massflux[],
240 cs_real_2_t i_conv_flux[],
241 cs_real_t b_conv_flux[]);
242
243/*----------------------------------------------------------------------------*/
244/*
245 * \brief Add the explicit part of the convection/diffusion terms of a transport
246 * equation of a vector field \f$ \vect{\varia} \f$.
247 *
248 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as
249 * follows:
250 * \f[
251 * \vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}} \left(
252 * \dot{m}_\ij \left( \vect{\varia}_\fij - \vect{\varia}_\celli \right)
253 * - \mu_\fij \gradt_\fij \vect{\varia} \cdot \vect{S}_\ij \right)
254 * \f]
255 *
256 * Remark:
257 * if ivisep = 1, then we also take \f$ \mu \transpose{\gradt\vect{\varia}}
258 * + \lambda \trace{\gradt\vect{\varia}} \f$, where \f$ \lambda \f$ is
259 * the secondary viscosity, i.e. usually \f$ -\frac{2}{3} \mu \f$.
260 *
261 * Warning:
262 * - \f$ \vect{Rhs} \f$ has already been initialized before calling bilsc!
263 * - mind the sign minus
264 *
265 * \param[in] idtvar indicator of the temporal scheme
266 * \param[in] f_id index of the current variable
267 * \param[in] eqp equation parameters
268 * \param[in] icvflb global indicator of boundary convection flux
269 * - 0 upwind scheme at all boundary faces
270 * - 1 imposed flux at some boundary faces
271 * \param[in] inc indicator
272 * - 0 when solving an increment
273 * - 1 otherwise
274 * \param[in] ivisep indicator to take \f$ \divv
275 * \left(\mu \gradt \transpose{\vect{a}} \right)
276 * -2/3 \grad\left( \mu \dive \vect{a} \right)\f$
277 * - 1 take into account,
278 * - 0 otherwise
279 * \param[in] imasac take mass accumulation into account?
280 * \param[in] pvar solved velocity (current time step)
281 * \param[in] pvara solved velocity (previous time step)
282 * \param[in] icvfli boundary face indicator array of convection flux
283 * - 0 upwind scheme
284 * - 1 imposed flux
285 * \param[in] bc_coeffs_v boundary conditions structure for the variable
286 * \param[in] val_f boundary face value for gradient
287 * \param[in] flux boundary flux
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 border faces for the r.h.s.
294 * \param[in] i_secvis secondary viscosity at interior faces
295 * \param[in] b_secvis secondary viscosity at boundary faces
296 * \param[in] i_pvar velocity at interior faces
297 * \param[in] b_pvar velocity at boundary faces
298 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
299 */
300/*----------------------------------------------------------------------------*/
301
302void
304 int f_id,
305 const cs_equation_param_t eqp,
306 int icvflb,
307 int inc,
308 int ivisep,
309 int imasac,
310 cs_real_3_t *pvar,
311 const cs_real_3_t *pvara,
312 const int icvfli[],
313 const cs_field_bc_coeffs_t *bc_coeffs_v,
314 const cs_real_t val_f[][3],
315 const cs_real_t flux[][3],
316 const cs_real_t i_massflux[],
317 const cs_real_t b_massflux[],
318 const cs_real_t i_visc[],
319 const cs_real_t b_visc[],
320 const cs_real_t i_secvis[],
321 const cs_real_t b_secvis[],
322 cs_real_3_t *i_pvar,
323 cs_real_3_t *b_pvar,
324 cs_real_3_t *rhs);
325
326/*----------------------------------------------------------------------------*/
366/*----------------------------------------------------------------------------*/
367
368void
370 int f_id,
371 const cs_equation_param_t eqp,
372 int icvflb,
373 int inc,
374 int imasac,
375 cs_real_6_t *pvar,
376 const cs_real_6_t *pvara,
377 const cs_field_bc_coeffs_t *bc_coeffs_ts,
378 const cs_real_t val_f[][6],
379 const cs_real_t flux[][6],
380 const cs_real_t i_massflux[],
381 const cs_real_t b_massflux[],
382 const cs_real_t i_visc[],
383 const cs_real_t b_visc[],
384 cs_real_6_t *rhs);
385
386/*----------------------------------------------------------------------------*/
423/*----------------------------------------------------------------------------*/
424
425void
427 int f_id,
428 const cs_equation_param_t eqp,
429 int inc,
430 int imasac,
431 cs_real_t * pvar,
432 const cs_real_t * pvara,
433 const cs_field_bc_coeffs_t *bc_coeffs,
434 const cs_real_t val_f[],
435 const cs_real_t flux[],
436 const cs_real_t i_massflux[],
437 const cs_real_t b_massflux[],
438 const cs_real_t i_visc[],
439 const cs_real_t b_visc[],
440 const cs_real_t xcpp[],
441 cs_real_t * rhs);
442
443/*----------------------------------------------------------------------------*/
444/*
445 * \brief Add the explicit part of the diffusion terms with a symmetric tensor
446 * diffusivity for a transport equation of a scalar field \f$ \varia \f$.
447 *
448 * More precisely, the right hand side \f$ Rhs \f$ is updated as
449 * follows:
450 * \f[
451 * Rhs = Rhs - \sum_{\fij \in \Facei{\celli}} \left(
452 * - \tens{\mu}_\fij \gradv_\fij \varia \cdot \vect{S}_\ij \right)
453 * \f]
454 *
455 * Warning:
456 * - \f$ Rhs \f$ has already been initialized before
457 * calling cs_anisotropic_diffusion_scalar!
458 * - mind the sign minus
459 *
460 * \param[in] idtvar indicator of the temporal scheme
461 * \param[in] f_id index of the current variable
462 * \param[in] eqp equation parameters
463 * \param[in] inc indicator
464 * - 0 when solving an increment
465 * - 1 otherwise
466 * \param[in] pvar solved variable (current time step)
467 * \param[in] pvara solved variable (previous time step)
468 * \param[in] bc_coeffs boundary condition structure for the variable
469 * \param[in] val_f_g boundary face value for gradient
470 * \param[in] flux_d boundary flux
471 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
472 * at interior faces for the r.h.s.
473 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
474 * at border faces for the r.h.s.
475 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
476 * \param[in] weighf internal face weight between cells i j in case
477 * of tensor diffusion
478 * \param[in] weighb boundary face weight for cells i in case
479 * of tensor diffusion
480 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
481 */
482/*----------------------------------------------------------------------------*/
483
484void
486 int f_id,
487 const cs_equation_param_t eqp,
488 int inc,
489 cs_real_t *pvar,
490 const cs_real_t *pvara,
491 const cs_field_bc_coeffs_t *bc_coeffs,
492 const cs_real_t val_f_g[],
493 const cs_real_t flux_d[],
494 const cs_real_t i_visc[],
495 const cs_real_t b_visc[],
496 cs_real_6_t *viscel,
497 const cs_real_2_t weighf[],
498 const cs_real_t weighb[],
499 cs_real_t *rhs);
500
501/*-----------------------------------------------------------------------------*/
502/*
503 * \brief Add explicit part of the terms of diffusion by a left-multiplying
504 * symmetric tensorial diffusivity for a transport equation of a vector field
505 * \f$ \vect{\varia} \f$.
506 *
507 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as
508 * follows:
509 * \f[
510 * \vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}} \left(
511 * - \gradt_\fij \vect{\varia} \tens{\mu}_\fij \cdot \vect{S}_\ij \right)
512 * \f]
513 *
514 * Remark:
515 * if ivisep = 1, then we also take \f$ \mu \transpose{\gradt\vect{\varia}}
516 * + \lambda \trace{\gradt\vect{\varia}} \f$, where \f$ \lambda \f$ is
517 * the secondary viscosity, i.e. usually \f$ -\frac{2}{3} \mu \f$.
518 *
519 * Warning:
520 * - \f$ \vect{Rhs} \f$ has already been initialized before calling the present
521 * function
522 * - mind the sign minus
523 *
524 * \param[in] idtvar indicator of the temporal scheme
525 * \param[in] f_id index of the current variable
526 * \param[in] eqp equation parameters
527 * \param[in] inc indicator
528 * - 0 when solving an increment
529 * - 1 otherwise
530 * \param[in] ivisep indicator to take \f$ \divv
531 * \left(\mu \gradt \transpose{\vect{a}} \right)
532 * -2/3 \grad\left( \mu \dive \vect{a} \right)\f$
533 * - 1 take into account,
534 * \param[in] pvar solved variable (current time step)
535 * \param[in] pvara solved variable (previous time step)
536 * \param[in] bc_coeffs_v boundary conditions structure for the variable
537 * \param[in] val_f_g boundary face value for gradient
538 * \param[in] flux_d boundary flux
539 * \param[in] i_visc \f$ \tens{\mu}_\fij \dfrac{S_\fij}{\ipf\jpf} \f$
540 * at interior faces for the r.h.s.
541 * \param[in] b_visc \f$ \dfrac{S_\fib}{\ipf \centf} \f$
542 * at border faces for the r.h.s.
543 * \param[in] i_secvis secondary viscosity at interior faces
544 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
545 */
546/*----------------------------------------------------------------------------*/
547
548void
550 int f_id,
551 const cs_equation_param_t eqp,
552 int inc,
553 int ivisep,
554 cs_real_3_t *pvar,
555 const cs_real_3_t *pvara,
556 const cs_field_bc_coeffs_t *bc_coeffs_v,
557 const cs_real_t val_f[][3],
558 const cs_real_t flux[][3],
559 const cs_real_33_t i_visc[],
560 const cs_real_t b_visc[],
561 const cs_real_t i_secvis[],
562 cs_real_3_t *rhs);
563
564/*-----------------------------------------------------------------------------*/
565/*
566 * \brief Add explicit part of the terms of diffusion by a right-multiplying
567 * symmetric tensorial diffusivity for a transport equation of a vector field
568 * \f$ \vect{\varia} \f$.
569 *
570 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as
571 * follows:
572 * \f[
573 * \vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}} \left(
574 * - \gradt_\fij \vect{\varia} \tens{\mu}_\fij \cdot \vect{S}_\ij \right)
575 * \f]
576 *
577 * Warning:
578 * - \f$ \vect{Rhs} \f$ has already been initialized before calling the present
579 * function
580 * - mind the sign minus
581 *
582 * \param[in] idtvar indicator of the temporal scheme
583 * \param[in] f_id index of the current variable
584 * \param[in] eqp equation parameters
585 * \param[in] inc indicator
586 * - 0 when solving an increment
587 * - 1 otherwise
588 * \param[in] pvar solved variable (current time step)
589 * \param[in] pvara solved variable (previous time step)
590 * \param[in] bc_coeffs_v boundary condition structure for the variable
591 * \param[in] val_f boundary face value for gradient
592 * \param[in] flux_d boundary flux
593 * \param[in] i_visc \f$ \tens{\mu}_\fij \dfrac{S_\fij}{\ipf\jpf} \f$
594 * at interior faces for the r.h.s.
595 * \param[in] b_visc \f$ \dfrac{S_\fib}{\ipf \centf} \f$
596 * at border faces for the r.h.s.
597 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
598 * \param[in] weighf internal face weight between cells i j in case
599 * of tensor diffusion
600 * \param[in] weighb boundary face weight for cells i in case
601 * of tensor diffusion
602 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
603 */
604/*----------------------------------------------------------------------------*/
605
606void
608 int f_id,
609 const cs_equation_param_t eqp,
610 int inc,
611 cs_real_3_t *pvar,
612 const cs_real_3_t *pvara,
613 const cs_field_bc_coeffs_t *bc_coeffs_v,
614 const cs_real_t val_f[][3],
615 const cs_real_t flux_d[][3],
616 const cs_real_t i_visc[],
617 const cs_real_t b_visc[],
618 cs_real_6_t *viscel,
619 const cs_real_2_t weighf[],
620 const cs_real_t weighb[],
621 cs_real_3_t *rhs);
622
623/*----------------------------------------------------------------------------*/
624/*
625 * \brief Add the explicit part of the diffusion terms with a symmetric tensor
626 * diffusivity for a transport equation of a scalar field \f$ \varia \f$.
627 *
628 * More precisely, the right hand side \f$ Rhs \f$ is updated as
629 * follows:
630 * \f[
631 * Rhs = Rhs - \sum_{\fij \in \Facei{\celli}} \left(
632 * - \tens{\mu}_\fij \gradv_\fij \varia \cdot \vect{S}_\ij \right)
633 * \f]
634 *
635 * Warning:
636 * - \f$ Rhs \f$ has already been initialized before
637 * calling cs_anisotropic_diffusion_scalar!
638 * - mind the sign minus
639 *
640 * \param[in] idtvar indicator of the temporal scheme
641 * \param[in] f_id index of the current variable
642 * \param[in] eqp equation parameters
643 * \param[in] inc indicator
644 * - 0 when solving an increment
645 * - 1 otherwise
646 * \param[in] pvar solved variable (current time step)
647 * \param[in] pvara solved variable (previous time step)
648 * \param[in] bc_coeffs_ts boundary condition structure for the variable
649 * \param[in] val_f boundary face value for gradient
650 * \param[in] flux boundary flux
651 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
652 * at interior faces for the r.h.s.
653 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
654 * at border faces for the r.h.s.
655 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
656 * \param[in] weighf internal face weight between cells i j in case
657 * of tensor diffusion
658 * \param[in] weighb boundary face weight for cells i in case
659 * of tensor diffusion
660 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
661 */
662/*----------------------------------------------------------------------------*/
663
664void
666 int f_id,
667 const cs_equation_param_t eqp,
668 int inc,
669 cs_real_6_t *pvar,
670 const cs_real_6_t *pvara,
671 const cs_field_bc_coeffs_t *bc_coeffs_ts,
672 const cs_real_t val_f[][6],
673 const cs_real_t flux[][6],
674 const cs_real_t i_visc[],
675 const cs_real_t b_visc[],
676 cs_real_6_t *viscel,
677 const cs_real_2_t weighf[],
678 const cs_real_t weighb[],
679 cs_real_6_t *rhs);
680
681/*----------------------------------------------------------------------------*/
682/*
683 * \brief Update the face mass flux with the face pressure (or pressure
684 * increment, or pressure double increment) gradient.
685 *
686 * \f[
687 * \dot{m}_\ij = \dot{m}_\ij
688 * - \Delta t \grad_\fij \delta p \cdot \vect{S}_\ij
689 * \f]
690 *
691 * Please refer to the
692 * <a href="../../theory.pdf#cs_face_diffusion_potential">
693 <b>cs_face_diffusion_potential/cs_diffusion_potential</b></a>
694 * section of the theory guide for more information.
695 *
696 * \param[in] f pointer to field or nullptr
697 * \param[in] eqp equation parameters
698 * \param[in] m pointer to mesh
699 * \param[in] fvq pointer to finite volume quantities
700 * \param[in] init indicator
701 * - 1 initialize the mass flux to 0
702 * - 0 otherwise
703 * \param[in] inc indicator
704 * - 0 when solving an increment
705 * - 1 otherwise
706 * \param[in] iphydp hydrostatic pressure indicator
707 * \param[in] frcxt body force creating the hydrostatic pressure
708 * \param[in] pvar solved variable (current time step)
709 * \param[in] bc_coeffs boundary condition structure for the variable
710 * \param[in] val_f_g boundary face value for gradient
711 * \param[in] flux_d boundary flux
712 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
713 * at interior faces for the r.h.s.
714 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
715 * at border faces for the r.h.s.
716 * \param[in] visel viscosity by cell
717 * \param[in,out] i_massflux mass flux at interior faces
718 * \param[in,out] b_massflux mass flux at boundary faces
719 */
720/*----------------------------------------------------------------------------*/
721
722void
724 const cs_equation_param_t *eqp,
725 const cs_mesh_t *m,
727 int init,
728 int inc,
729 int iphydp,
730 cs_real_3_t *frcxt,
731 cs_real_t *pvar,
732 const cs_field_bc_coeffs_t *bc_coeffs,
733 const cs_real_t val_f_g[],
734 const cs_real_t flux_d[],
735 const cs_real_t i_visc[],
736 const cs_real_t b_visc[],
737 cs_real_t *visel,
738 cs_real_t *i_massflux,
739 cs_real_t *b_massflux);
740
741/*----------------------------------------------------------------------------*/
742/*
743 * \brief Add the explicit part of the pressure gradient term to the mass flux
744 * in case of anisotropic diffusion of the pressure field \f$ P \f$.
745 *
746 * More precisely, the mass flux side \f$ \dot{m}_\fij \f$ is updated as
747 * follows:
748 * \f[
749 * \dot{m}_\fij = \dot{m}_\fij -
750 * \left( \tens{\mu}_\fij \gradv_\fij P \cdot \vect{S}_\ij \right)
751 * \f]
752 *
753 * \param[in] f pointer to field or nullptr
754 * \param[in] eqp equation parameters
755 * \param[in] m pointer to mesh
756 * \param[in] fvq pointer to finite volume quantities
757 * \param[in] init indicator
758 * - 1 initialize the mass flux to 0
759 * - 0 otherwise
760 * \param[in] inc indicator
761 * - 0 when solving an increment
762 * - 1 otherwise
763 * \param[in] iphydp indicator
764 * - 1 hydrostatic pressure taken into account
765 * - 0 otherwise
766 * \param[in] frcxt body force creating the hydrostatic pressure
767 * \param[in] pvar solved variable (pressure)
768 * \param[in] bc_coeffs boundary condition structure for the variable
769 * \param[in] val_f_g boundary face value for gradient
770 * \param[in] flux_d boundary flux
771 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
772 * at interior faces for the r.h.s.
773 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
774 * at border faces for the r.h.s.
775 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
776 * \param[in] weighf internal face weight between cells i j in case
777 * of tensor diffusion
778 * \param[in,out] i_massflux mass flux at interior faces
779 * \param[in,out] b_massflux mass flux at boundary faces
780 */
781/*----------------------------------------------------------------------------*/
782
783void
785(
786 const cs_field_t *f,
787 const cs_equation_param_t *eqp,
788 const cs_mesh_t *m,
790 int init,
791 int inc,
792 int iphydp,
793 cs_real_3_t *frcxt,
794 cs_real_t *pvar,
795 const cs_field_bc_coeffs_t *bc_coeffs,
796 const cs_real_t val_f_g[],
797 const cs_real_t flux_d[],
798 const cs_real_t i_visc[],
799 const cs_real_t b_visc[],
800 cs_real_6_t *viscel,
801 const cs_real_2_t weighf[],
802 cs_real_t *i_massflux,
803 cs_real_t *b_massflux
804);
805
806/*----------------------------------------------------------------------------*/
838/*----------------------------------------------------------------------------*/
839
840void
842 const cs_equation_param_t *eqp,
843 const cs_mesh_t *m,
845 int init,
846 int inc,
847 int iphydp,
848 cs_real_3_t *frcxt,
849 cs_real_t *pvar,
850 const cs_field_bc_coeffs_t *bc_coeffs,
851 const cs_real_t val_f_g[],
852 const cs_real_t flux_d[],
853 const cs_real_t i_visc[],
854 const cs_real_t b_visc[],
855 cs_real_t visel[],
856 cs_real_t *diverg);
857
858/*----------------------------------------------------------------------------*/
859/*
860 * \brief Add the explicit part of the divergence of the mass flux due to the
861 * pressure gradient (analog to cs_anisotropic_diffusion_scalar).
862 *
863 * More precisely, the divergence of the mass flux side
864 * \f$ \sum_{\fij \in \Facei{\celli}} \dot{m}_\fij \f$ is updated as follows:
865 * \f[
866 * \sum_{\fij \in \Facei{\celli}} \dot{m}_\fij
867 * = \sum_{\fij \in \Facei{\celli}} \dot{m}_\fij
868 * - \sum_{\fij \in \Facei{\celli}}
869 * \left( \tens{\mu}_\fij \gradv_\fij P \cdot \vect{S}_\ij \right)
870 * \f]
871 *
872 * \param[in] f pointer to field or nullptr
873 * \param[in] eqp equation parameters
874 * \param[in] fvq pointer to finite volume quantities
875 * \param[in] init indicator
876 * - 1 initialize the mass flux to 0
877 * - 0 otherwise
878 * \param[in] inc indicator
879 * - 0 when solving an increment
880 * - 1 otherwise
881 * \param[in] iphydp indicator
882 * - 1 hydrostatic pressure taken into account
883 * - 0 otherwise
884 * \param[in] frcxt body force creating the hydrostatic pressure
885 * \param[in] pvar solved variable (pressure)
886 * \param[in] bc_coeffs boundary condition structure for the variable
887 * \param[in] val_f_g boundary face value for gradient
888 * \param[in] flux_d boundary flux
889 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
890 * at interior faces for the r.h.s.
891 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$
892 * at border faces for the r.h.s.
893 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$
894 * \param[in] weighf internal face weight between cells i j in case
895 * of tensor diffusion
896 * \param[in,out] diverg divergence of the mass flux
897 */
898/*----------------------------------------------------------------------------*/
899
900void
902 const cs_equation_param_t *eqp,
903 const cs_mesh_t *m,
905 int init,
906 int inc,
907 int iphydp,
908 cs_real_3_t *restrict frcxt,
909 cs_real_t *restrict pvar,
910 const cs_field_bc_coeffs_t *bc_coeffs,
911 const cs_real_t val_f_g[],
912 const cs_real_t flux_d[],
913 const cs_real_t i_visc[],
914 const cs_real_t b_visc[],
915 cs_real_6_t *restrict viscel,
916 const cs_real_2_t weighf[],
917 cs_real_t *restrict diverg);
918
919/*----------------------------------------------------------------------------*/
920
922
923#ifdef __cplusplus
924
925/*----------------------------------------------------------------------------*/
940/*----------------------------------------------------------------------------*/
941
942void
945 const cs_real_3_t *grad,
946 cs_real_3_t *grdpa,
947 const cs_real_t *pvar,
948 const cs_real_t val_f[],
949 const cs_real_t *i_massflux);
950
951/*----------------------------------------------------------------------------*/
952/*
953 * \brief Compute the upwind gradient used in the slope tests.
954 *
955 * template parameters:
956 * stride 1 for scalars, 3 for vectors, 6 for symmetric tensors
957 *
958 * This function assumes the input gradient and pvar values have already
959 * been synchronized.
960 *
961 * \param[in] ctx Reference to dispatch context
962 * \param[in] grad standard gradient
963 * \param[out] grdpa upwind gradient
964 * \param[in] pvar values
965 * \param[in] val_f face values for gradient
966 * \param[in] i_massflux mass flux at interior faces
967 */
968/*----------------------------------------------------------------------------*/
969
970template <cs_lnum_t stride>
971void
974 const cs_real_t grad[][stride][3],
975 cs_real_t (*restrict grdpa)[stride][3],
976 const cs_real_t pvar[][stride],
977 const cs_real_t val_f[][stride],
978 const cs_real_t *i_massflux);
979
980/*----------------------------------------------------------------------------*/
981/*
982 * \brief Compute the upwind gradient used in the pure SOLU schemes
983 * (observed in the litterature).
984 *
985 * \param[in] ctx Reference to dispatch context
986 * \param[in] inc Not an increment flag
987 * \param[in] halo_type halo type
988 * \param[in] bc_coeffs boundary condition structure for the variable
989 * \param[in] i_massflux mass flux at interior faces
990 * \param[in] b_massflux mass flux at boundary faces
991 * \param[in] pvar values
992 * \param[out] grdpa upwind gradient
993 */
994/*----------------------------------------------------------------------------*/
995
996void
998 const int inc,
999 const cs_halo_type_t halo_type,
1000 const cs_field_bc_coeffs_t *bc_coeffs,
1001 const cs_real_t i_massflux[],
1002 const cs_real_t b_massflux[],
1003 const cs_real_t *pvar,
1004 cs_real_3_t *grdpa);
1005
1006/*----------------------------------------------------------------------------
1007 * Compute the local cell Courant number as the maximum of all cell face based
1008 * Courant number at each cell.
1009 *
1010 * parameters:
1011 * f <-- pointer to field
1012 * ctx <-- reference to dispatch context
1013 * courant --> cell Courant number
1014 */
1015/*----------------------------------------------------------------------------*/
1016
1017void
1020 cs_real_t *courant);
1021
1022/*----------------------------------------------------------------------------*/
1023
1024#endif /* cplusplus */
1025
1026#endif /* __CS_CONVECTION_DIFFUSION_H__ */
Definition: cs_dispatch.h:1711
void cs_face_anisotropic_diffusion_potential(const cs_field_t *f, const cs_equation_param_t *eqp, const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int iphydp, cs_real_3_t *frcxt, cs_real_t *pvar, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f_g[], const cs_real_t flux_d[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t *viscel, const cs_real_2_t weighf[], cs_real_t *i_massflux, cs_real_t *b_massflux)
void cs_convection_diffusion_tensor(int idtvar, int f_id, const cs_equation_param_t eqp, int icvflb, int inc, int imasac, cs_real_6_t *pvar, const cs_real_6_t *pvara, const cs_field_bc_coeffs_t *bc_coeffs_ts, const cs_real_t val_f[][6], const cs_real_t flux[][6], 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 *rhs)
Add the explicit part of the convection/diffusion terms of a transport equation of a tensor field .
void cs_face_convection_scalar(int idtvar, int f_id, const cs_equation_param_t eqp, int icvflb, int inc, int imasac, cs_real_t *pvar, const cs_real_t *pvara, const int icvfli[], const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], cs_real_2_t i_conv_flux[], cs_real_t b_conv_flux[])
void cs_slope_test_gradient(int f_id, cs_dispatch_context &ctx, const cs_real_3_t *grad, cs_real_3_t *grdpa, const cs_real_t *pvar, const cs_real_t val_f[], const cs_real_t *i_massflux)
Compute the upwind gradient used in the slope tests.
Definition: cs_convection_diffusion.cpp:8508
cs_real_t * cs_get_v_slope_test(int f_id, const cs_equation_param_t eqp)
Definition: cs_convection_diffusion.cpp:3973
void cs_slope_test_gradient_strided(cs_dispatch_context &ctx, const cs_real_t grad[][stride][3], cs_real_t(*restrict grdpa)[stride][3], const cs_real_t pvar[][stride], const cs_real_t val_f[][stride], const cs_real_t *i_massflux)
Compute the upwind gradient used in the slope tests.
Definition: cs_convection_diffusion.cpp:8596
void cs_upwind_gradient(cs_dispatch_context &ctx, const int inc, const cs_halo_type_t halo_type, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t *pvar, cs_real_3_t *grdpa)
void cs_convection_diffusion_vector(int idtvar, int f_id, const cs_equation_param_t eqp, int icvflb, int inc, int ivisep, int imasac, cs_real_3_t *pvar, const cs_real_3_t *pvara, const int icvfli[], const cs_field_bc_coeffs_t *bc_coeffs_v, const cs_real_t val_f[][3], const cs_real_t flux[][3], 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 i_secvis[], const cs_real_t b_secvis[], cs_real_3_t *i_pvar, cs_real_3_t *b_pvar, cs_real_3_t *rhs)
void cs_convection_diffusion_thermal(int idtvar, int f_id, const cs_equation_param_t eqp, int inc, int imasac, cs_real_t *pvar, const cs_real_t *pvara, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f[], const cs_real_t flux[], 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 xcpp[], cs_real_t *rhs)
Add the explicit part of the convection/diffusion terms of a transport equation of a scalar field su...
void cs_anisotropic_left_diffusion_vector(int idtvar, int f_id, const cs_equation_param_t eqp, int inc, int ivisep, cs_real_3_t *pvar, const cs_real_3_t *pvara, const cs_field_bc_coeffs_t *bc_coeffs_v, const cs_real_t val_f[][3], const cs_real_t flux[][3], const cs_real_33_t i_visc[], const cs_real_t b_visc[], const cs_real_t i_secvis[], cs_real_3_t *rhs)
void cs_anisotropic_diffusion_scalar(int idtvar, int f_id, const cs_equation_param_t eqp, int inc, cs_real_t *pvar, const cs_real_t *pvara, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f_g[], const cs_real_t flux_d[], 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[], cs_real_t *rhs)
cs_nvd_type_t
Definition: cs_convection_diffusion.h:59
@ CS_NVD_SUPERBEE
Definition: cs_convection_diffusion.h:64
@ CS_NVD_SMART
Definition: cs_convection_diffusion.h:62
@ CS_NVD_CUBISTA
Definition: cs_convection_diffusion.h:63
@ CS_NVD_STOIC
Definition: cs_convection_diffusion.h:68
@ CS_NVD_WASEB
Definition: cs_convection_diffusion.h:70
@ CS_NVD_CLAM
Definition: cs_convection_diffusion.h:67
@ CS_NVD_OSHER
Definition: cs_convection_diffusion.h:69
@ CS_NVD_VOF_CICSAM
Definition: cs_convection_diffusion.h:72
@ CS_NVD_VOF_STACS
Definition: cs_convection_diffusion.h:73
@ CS_NVD_GAMMA
Definition: cs_convection_diffusion.h:61
@ CS_NVD_MINMOD
Definition: cs_convection_diffusion.h:66
@ CS_NVD_VOF_HRIC
Definition: cs_convection_diffusion.h:71
@ CS_NVD_MUSCL
Definition: cs_convection_diffusion.h:65
@ CS_NVD_N_TYPES
Definition: cs_convection_diffusion.h:74
void cs_diffusion_potential(const cs_field_t *f, const cs_equation_param_t *eqp, const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int iphydp, cs_real_3_t *frcxt, cs_real_t *pvar, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f_g[], const cs_real_t flux_d[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t visel[], cs_real_t *diverg)
Update the cell mass flux divergence with the face pressure (or pressure increment,...
void cs_convection_diffusion_scalar(int idtvar, int f_id, const cs_equation_param_t eqp, int icvflb, int inc, int imasac, cs_real_t *pvar, const cs_real_t *pvara, const int icvfli[], const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f[], const cs_real_t flux[], 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_t *rhs, cs_real_2_t i_flux[], cs_real_t b_flux[])
Add the explicit part of the convection/diffusion terms of a standard transport equation of a scalar ...
void cs_anisotropic_right_diffusion_vector(int idtvar, int f_id, const cs_equation_param_t eqp, int inc, cs_real_3_t *pvar, const cs_real_3_t *pvara, const cs_field_bc_coeffs_t *bc_coeffs_v, const cs_real_t val_f[][3], const cs_real_t flux_d[][3], 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[], cs_real_3_t *rhs)
void cs_face_diffusion_potential(const cs_field_t *f, const cs_equation_param_t *eqp, const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int iphydp, cs_real_3_t *frcxt, cs_real_t *pvar, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f_g[], const cs_real_t flux_d[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t *visel, cs_real_t *i_massflux, cs_real_t *b_massflux)
void cs_anisotropic_diffusion_tensor(int idtvar, int f_id, const cs_equation_param_t eqp, int inc, cs_real_6_t *pvar, const cs_real_6_t *pvara, const cs_field_bc_coeffs_t *bc_coeffs_ts, const cs_real_t val_f[][6], const cs_real_t flux[][6], 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[], cs_real_6_t *rhs)
void cs_beta_limiter_building(int f_id, int inc, const cs_real_t rovsdt[])
Compute the beta blending coefficient of the beta limiter (ensuring preservation of a given min/max p...
Definition: cs_convection_diffusion.cpp:4022
void cs_anisotropic_diffusion_potential(const cs_field_t *f, const cs_equation_param_t *eqp, const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int iphydp, cs_real_3_t *restrict frcxt, cs_real_t *restrict pvar, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t val_f_g[], const cs_real_t flux_d[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t *restrict viscel, const cs_real_2_t weighf[], cs_real_t *restrict diverg)
Add the explicit part of the divergence of the mass flux due to the pressure gradient (analog to cs_a...
Definition: cs_convection_diffusion.cpp:8090
void cs_cell_courant_number(const cs_field_t *f, cs_dispatch_context &ctx, cs_real_t *courant)
Definition: cs_convection_diffusion.cpp:8423
#define restrict
Definition: cs_defs.h:158
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:374
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:373
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:376
#define END_C_DECLS
Definition: cs_defs.h:555
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:383
cs_halo_type_t
Definition: cs_halo.h:57
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:85
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:194
Field boundary condition descriptor (for variables)
Definition: cs_field.h:120
Field descriptor.
Definition: cs_field.h:156
Definition: cs_mesh_quantities.h:92
Definition: cs_mesh.h:85