7.1
general documentation
Turbulence model source terms.

Additional right_hand side source terms for turbulence models

Turbulence source terms may be modified using the cs_user_source_terms user-defined function.

Local variables

/* mesh quantities */
const cs_lnum_t n_cells = cs_glob_mesh->n_cells;

Remaining initialization

Get the density array in cpro_rom

const cs_real_t *cpro_rom = CS_F_(rho)->val;

Get the array of the current turbulent variable and its name

/* Define pointer f to the current turbulent variable field */
const cs_field_t *f = cs_field_by_id(f_id);

Example

Example of arbitrary additional source term for turbulence models (Source term on the TKE "k" here).

Source term for $\varia:$

\[ \rho \norm{\vol{\celli}} \frac{d(\varia)}{dt} = ... - \rho \norm{\vol{\celli}} \cdot ff - \rho \frac{ \varia}{\tau}\]

with $ ff $ = 3.0 an $ \tau $ = 4.0

Body

Note
The turbulence variable names are:
  • 'k' and 'epsilon' for the k-epsilon models
  • 'rij' and 'epsilon' for the Rij-epsilon LRR and S SG
  • 'rij', 'epsilon' and 'alpha' for the EBRSM
  • 'k', 'epsilon', 'phi' and 'f_bar' for the phi-model
  • 'k', 'epsilon', 'phi' and 'alpha' for the Bl-v2-k model
  • 'k' and 'omega' for the k-omega turbulence model
  • 'nu_tilda' for the Spalart Allmaras model

Calculation of the explicit and implicit source terms

if (f == CS_F_(k)) {
if (eqp->verbosity >= 1)
bft_printf(" User source terms for turbulence variable %s\n",
const cs_real_t ff = 3.0;
const cs_real_t tau = 4.0;
for (cs_lnum_t i = 0; i < n_cells; i++) {
/* explicit source terms */
st_exp[i] = -cpro_rom[i] * cell_f_vol[i] * ff;
/* implicit source terms */
st_imp[i] = -cpro_rom[i] * cell_f_vol[i] / tau;
}
}