9.0
general documentation
Loading...
Searching...
No Matches
cs_balance.cpp File Reference

Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a field. More...

#include "base/cs_defs.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "bft/bft_error.h"
#include "bft/bft_mem.h"
#include "bft/bft_printf.h"
#include "alge/cs_blas.h"
#include "base/cs_halo.h"
#include "base/cs_halo_perio.h"
#include "base/cs_log.h"
#include "base/cs_math.h"
#include "mesh/cs_mesh.h"
#include "alge/cs_convection_diffusion.h"
#include "base/cs_field.h"
#include "base/cs_field_operator.h"
#include "base/cs_field_pointer.h"
#include "alge/cs_gradient.h"
#include "base/cs_ext_neighborhood.h"
#include "mesh/cs_mesh_quantities.h"
#include "base/cs_parall.h"
#include "base/cs_parameters.h"
#include "base/cs_prototypes.h"
#include "base/cs_timer.h"
#include "base/cs_timer_stats.h"
#include "base/cs_velocity_pressure.h"
#include "alge/cs_balance.h"
Include dependency graph for cs_balance.cpp:

Functions

void cs_balance_initialize (void)
 Initialize balance timers.
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[], const 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 smbrp[])
 Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a scalar field $ \varia $.
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[], const 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 smbrp[], cs_real_2_t i_flux[], cs_real_t b_flux[])
 Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a scalar field $ \varia $.
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[], const cs_field_bc_coeffs_t *bc_coeffs_v, const cs_bc_coeffs_solve_t *bc_coeffs_solve_v, 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 equation of a vector field $ \vect{\varia} $.
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[], const cs_field_bc_coeffs_t *bc_coeffs_ts, const cs_bc_coeffs_solve_t *bc_coeffs_solve_ts, 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 smbrp[])
 Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a tensor field $ \tens{\varia} $.

Variables

static int _balance_stat_id = -1

Detailed Description

Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a field.

Function Documentation

◆ cs_balance_initialize()

void cs_balance_initialize ( void )

Initialize balance timers.

◆ cs_balance_scalar() [1/2]

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[],
const 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 smbrp[] )

Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a scalar field $ \varia $.

More precisely, the right hand side $ Rhs $ is updated as follows:

\[Rhs = Rhs - \sum_{\fij \in \Facei{\celli}}      \left(
       \dot{m}_\ij \left( \varia_\fij - \varia_\celli \right)
     - \mu_\fij \gradv_\fij \varia \cdot \vect{S}_\ij  \right)
\]

Warning:

  • $ Rhs $ has already been initialized before calling cs_balance_scalar!
  • mind the minus sign

Options for the convective scheme:

  • blencp = 0: upwind scheme for the advection
  • blencp = 1: no upwind scheme except in the slope test
  • ischcp = 0: SOLU
  • ischcp = 1: centered
  • ischcp = 2: SOLU with upwind gradient reconstruction
  • ischcp = 3: blending SOLU centered
  • ischcp = 4: NVD-TVD
  • imucpp = 0: do not multiply the convective part by $ C_p $
  • imucpp = 1: multiply the convective part by $ C_p $
Parameters
[in]idtvarindicator of the temporal scheme
[in]f_idfield id (or -1)
[in]imucppindicator
  • 0 do not multiply the convectiv term by Cp
  • 1 do multiply the convectiv term by Cp
[in]imasactake mass accumulation into account?
[in]incindicator
  • 0 when solving an increment
  • 1 otherwise
[in]eqppointer to a cs_equation_param_t structure which contains variable calculation options
[in]pvarsolved variable (current time step) may be nullptr if pvara != nullptr
[in]pvarasolved variable (previous time step) may be nullptr if pvar != nullptr
[in]bc_coeffsboundary condition structure for the variable
[in]i_massfluxmass flux at interior faces
[in]b_massfluxmass flux at boundary faces
[in]i_visc$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} $ at interior faces for the r.h.s.
[in]b_visc$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} $ at boundary faces for the r.h.s.
[in]viscelsymmetric cell tensor $ \tens{\mu}_\celli $
[in]xcpparray of specific heat (Cp)
[in]weighfinternal face weight between cells i j in case of tensor diffusion
[in]weighbboundary face weight for cells i in case of tensor diffusion
[in]icvflbglobal indicator of boundary convection flux
  • 0 upwind scheme at all boundary faces
  • 1 imposed flux at some boundary faces
[in]icvfliboundary face indicator array of convection flux
  • 0 upwind scheme
  • 1 imposed flux
[in,out]smbrpright hand side $ \vect{Rhs} $

◆ cs_balance_scalar() [2/2]

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[],
const 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 smbrp[],
cs_real_2_t i_flux[],
cs_real_t b_flux[] )

Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a scalar field $ \varia $.

More precisely, the right hand side $ Rhs $ is updated as follows:

\[Rhs = Rhs - \sum_{\fij \in \Facei{\celli}}      \left(
       \dot{m}_\ij \left( \varia_\fij - \varia_\celli \right)
     - \mu_\fij \gradv_\fij \varia \cdot \vect{S}_\ij  \right)
\]

Warning:

  • $ Rhs $ has already been initialized before calling cs_balance_scalar!
  • mind the minus sign

Options for the convective scheme:

  • blencp = 0: upwind scheme for the advection
  • blencp = 1: no upwind scheme except in the slope test
  • ischcp = 0: SOLU
  • ischcp = 1: centered
  • ischcp = 2: SOLU with upwind gradient reconstruction
  • ischcp = 3: blending SOLU centered
  • ischcp = 4: NVD-TVD
  • imucpp = 0: do not multiply the convective part by $ C_p $
  • imucpp = 1: multiply the convective part by $ C_p $
Parameters
[in]idtvarindicator of the temporal scheme
[in]f_idfield id (or -1)
[in]imucppindicator
  • 0 do not multiply the convectiv term by Cp
  • 1 do multiply the convectiv term by Cp
[in]imasactake mass accumulation into account?
[in]incindicator
  • 0 when solving an increment
  • 1 otherwise
[in]eqppointer to a cs_equation_param_t structure which contains variable calculation options
[in]pvarsolved variable (current time step) may be nullptr if pvara != nullptr
[in]pvarasolved variable (previous time step) may be nullptr if pvar != nullptr
[in]bc_coeffsboundary condition structure for the variable
[in]i_massfluxmass flux at interior faces
[in]b_massfluxmass flux at boundary faces
[in]i_visc$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} $ at interior faces for the r.h.s.
[in]b_visc$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} $ at boundary faces for the r.h.s.
[in]viscelsymmetric cell tensor $ \tens{\mu}_\celli $
[in]xcpparray of specific heat (Cp)
[in]weighfinternal face weight between cells i j in case of tensor diffusion
[in]weighbboundary face weight for cells i in case of tensor diffusion
[in]icvflbglobal indicator of boundary convection flux
  • 0 upwind scheme at all boundary faces
  • 1 imposed flux at some boundary faces
[in]icvfliboundary face indicator array of convection flux
  • 0 upwind scheme
  • 1 imposed flux
[in,out]smbrpright hand side $ \vect{Rhs} $
[in,out]i_fluxinterior flux (or nullptr)
[in,out]b_fluxboundary flux (or nullptr)

◆ cs_balance_tensor()

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[],
const cs_field_bc_coeffs_t * bc_coeffs_ts,
const cs_bc_coeffs_solve_t * bc_coeffs_solve_ts,
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 smbrp[] )

Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport equation of a tensor field $ \tens{\varia} $.

More precisely, the right hand side $ \vect{Rhs} $ is updated as follows:

\[\tens{Rhs} = \tens{Rhs} - \sum_{\fij \in \Facei{\celli}}      \left(
       \dot{m}_\ij \left( \tens{\varia}_\fij - \tens{\varia}_\celli \right)
     - \mu_\fij \gradt_\fij \tens{\varia} \cdot \tens{S}_\ij  \right)
\]

Warning:

  • $ \tens{Rhs} $ has already been initialized before calling bilscts!
  • mind the sign minus

Options for the convective scheme:

  • blencp = 0: upwind scheme for the advection
  • blencp = 1: no upwind scheme except in the slope test
  • ischcp = 0: SOLU
  • ischcp = 1: centered
  • ischcp = 2: SOLU with upwind gradient reconstruction
  • ischcp = 3: blending SOLU centered
  • ischcp = 4: NVD-TVD
Parameters
[in]idtvarindicator of the temporal scheme
[in]f_idfield id (or -1)
[in]imasactake mass accumulation into account?
[in]incindicator
[in]eqppointer to a cs_equation_param_t structure which contains variable calculation options
[in]pvarsolved velocity (current time step)
[in]pvarasolved velocity (previous time step)
[in]bc_coeffs_tsboundary condition structure for the variable
[in]bc_coeffs_solve_tssweep loop boundary conditions structure
[in]i_massfluxmass flux at interior faces
[in]b_massfluxmass flux at boundary faces
[in]i_visc$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} $ at interior faces for the r.h.s.
[in]b_visc$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} $ at boundary faces for the r.h.s.
[in]viscelsymmetric cell tensor $ \tens{\mu}_\celli $
[in]weighfinternal face weight between cells i j in case of tensor diffusion
[in]weighbboundary face weight for cells i in case of tensor diffusion
[in]icvflbglobal indicator of boundary convection flux
  • 0 upwind scheme at all boundary faces
  • 1 imposed flux at some boundary faces
[in]icvfliboundary face indicator array of convection flux
  • 0 upwind scheme
  • 1 imposed flux
[in,out]smbrpright hand side $ \vect{Rhs} $

◆ cs_balance_vector()

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[],
const cs_field_bc_coeffs_t * bc_coeffs_v,
const cs_bc_coeffs_solve_t * bc_coeffs_solve_v,
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 equation of a vector field $ \vect{\varia} $.

More precisely, the right hand side $ \vect{Rhs} $ is updated as follows:

\[\vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}}      \left(
       \dot{m}_\ij \left( \vect{\varia}_\fij - \vect{\varia}_\celli \right)
     - \mu_\fij \gradt_\fij \vect{\varia} \cdot \vect{S}_\ij  \right)
\]

Remark: if ivisep = 1, then we also take $ \mu \transpose{\gradt\vect{\varia}}
+ \lambda \trace{\gradt\vect{\varia}} $, where $ \lambda $ is the secondary viscosity, i.e. usually $ -\frac{2}{3} \mu $.

Warning:

  • $ \vect{Rhs} $ has already been initialized before calling cs_balance_vector!
  • mind the sign minus

Options for the convective scheme:

  • blencp = 0: upwind scheme for the advection
  • blencp = 1: no upwind scheme except in the slope test
  • ischcp = 0: SOLU
  • ischcp = 1: centered
  • ischcp = 2: SOLU with upwind gradient reconstruction
  • ischcp = 3: blending SOLU centered
  • ischcp = 4: NVD-TVD
Parameters
[in]idtvarindicator of the temporal scheme
[in]f_idfield id (or -1)
[in]imasactake mass accumulation into account?
[in]incindicator
  • 0 when solving an increment
  • 1 otherwise
[in]ivisepindicator to take $ \divv
                              \left(\mu \gradt \transpose{\vect{a}} \right)
                              -2/3 \grad\left( \mu \dive \vect{a} \right)$
  • 1 take into account,
  • 0 otherwise
[in]eqppointer to a cs_equation_param_t structure which contains variable calculation options
[in]pvarsolved velocity (current time step)
[in]pvarasolved velocity (previous time step)
[in]bc_coeffs_vboundary condition structure for the variable
[in]bc_coeffs_solve_vboundary conditions structure when solving
[in]i_massfluxmass flux at interior faces
[in]b_massfluxmass flux at boundary faces
[in]i_visc$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} $ at interior faces for the r.h.s.
[in]b_visc$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} $ at boundary faces for the r.h.s.
[in]secvifsecondary viscosity at interior faces
[in]secvibsecondary viscosity at boundary faces
[in]viscelsymmetric cell tensor $ \tens{\mu}_\celli $
[in]weighfinternal face weight between cells i j in case of tensor diffusion
[in]weighbboundary face weight for cells i in case of tensor diffusion
[in]icvflbglobal indicator of boundary convection flux
  • 0 upwind scheme at all boundary faces
  • 1 imposed flux at some boundary faces
[in]icvfliboundary face indicator array of convection flux
  • 0 upwind scheme
  • 1 imposed flux
[in,out]smbrright hand side $ \vect{Rhs} $

Variable Documentation

◆ _balance_stat_id

int _balance_stat_id = -1
static