My Project
programmer's documentation
For velocity components equation (Navier-Stokes)

Additional right-hand side source terms for velocity components equation (Navier-Stokes)

Local variables and initialization

/* field structure */
/* mesh quantities */
const cs_lnum_t n_cells = cs_glob_mesh->n_cells;
/* density */
const cs_real_t *cpro_rom = CS_F_(rho)->val;

Example

Example of arbitrary source term for component $\vect{u}$:

$ \vect{S} = \tens{A} \cdot \vect{u} + \vect{B} $ appearing in the equation under the form:

$ \rho \dfrac{d\vect{u}}{dt} = \vect{S} \: (+ \text{standard Navier-Stokes terms})$

In the following example:

\[ \tens{A} = -\rho \cdot \tens{CKP} \]

\[ \vect{B} = \vect{XMMT} \]

with:

  • CKP = 1.0 (in $ s^{-1}$) (return term on velocity)
  • MMT = 100.0 (in $kg \cdot m^{-2} \cdot s^{-2}$) (momentum production by volume and time unit)

which yields:

  • st_imp[i][0][0] = volume[i] * A = - volume[i]*(rho*CKP)
  • st_exp[i][0] = volume[i] * B = volume[i]*(XMMT)

Body

if (f == CS_F_(vel)) { /* velocity */
/* cast to 3D vectors for readability */
cs_real_3_t *_st_exp = (cs_real_3_t *)st_exp;
cs_real_33_t *_st_imp = (cs_real_33_t *)st_imp;
/* Density */
const cs_real_t ckp = 10.0;
const cs_real_t xmmt = 100.0;
for (cs_lnum_t i = 0; i < n_cells; i++) {
_st_imp[i][0][0] = - cell_f_vol[i] * cpro_rom[i] * ckp;
_st_exp[i][0] = cell_f_vol[i] * cpro_rom[i] * xmmt;
}
}

Example of a boussinesq momentum source term

Example to add Boussinesq source to the z component of $\vect{u}$:

Body

if (f == CS_F_(vel) && CS_F_(t) != NULL) { /* velocity and temperature */
/* expansion coefficient and reference density */
const cs_real_t beta = 1.;
/* get temperature */
const cs_real_t *cvar_temperature = CS_F_(t)->val;
cs_real_3_t *_st_exp = (cs_real_3_t *)st_exp;
for (cs_lnum_t i = 0; i < n_cells; i++) {
_st_exp[c_id] = cell_f_vol[c_id] * rh0 * beta * (cvar_temperature[i]-t0);
}
}
cs_mesh_t::n_cells
cs_lnum_t n_cells
Definition: cs_mesh.h:73
f_id
void const int * f_id
Definition: cs_gui.h:292
t0
void const cs_real_t const cs_real_t const cs_real_t * t0
Definition: cs_ctwr_air_props.h:128
cs_glob_mesh_quantities
cs_mesh_quantities_t * cs_glob_mesh_quantities
mesh::cell_f_vol
double precision, dimension(:), pointer cell_f_vol
Definition: mesh.f90:156
rho
Definition: cs_field_pointer.h:103
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:315
cstphy::ro0
real(c_double), pointer, save ro0
reference density.
Definition: cstphy.f90:146
cpincl::beta
double precision, dimension(ncharm), save beta
Definition: cpincl.f90:99
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_fluid_properties_t::t0
double t0
Definition: cs_physical_constants.h:78
cs_glob_fluid_properties
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.c:346
cs_glob_mesh
cs_mesh_t * cs_glob_mesh
CS_F_
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_field_by_id
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2307
cs_mesh_quantities_t::cell_vol
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:93
cs_real_33_t
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:321
cs_fluid_properties_t::ro0
double ro0
Definition: cs_physical_constants.h:72
vel
void const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_real_t *const const cs_real_t *const const cs_real_t const cs_real_t const cs_real_3_t vel[]
Definition: cs_divergence.h:64
t
Definition: cs_field_pointer.h:98
cs_field_t
Field descriptor.
Definition: cs_field.h:124