8.1
general documentation
Compressible example

A complete initialization routine with the compresssible module is provided below. When adapting it, it is recommended to remove all parts not needed or than may be handled through the GUI.

/* If this is restarted computation, do not reinitialize values */
if (domain->time_step->nt_prev > 0)
return;
const cs_lnum_t n_cells = domain->mesh->n_cells;
cs_real_t *cvar_pr = CS_F_(p)->val;
cs_real_t *cpro_rho = CS_F_(rho)->val;
cs_real_t *cvar_energ = CS_F_(e_tot)->val;
cs_real_t *cvar_tempk = CS_F_(t_kelvin)->val;
cs_real_3_t *cvar_vel = (cs_real_3_t *)CS_F_(vel)->val;
/* Velocity all components */
cs_array_real_fill_zero(3*n_cells, (cs_real_t*)cvar_vel);
/* User defined scalars */
cs_real_t * cvar_scal = cs_field_by_name("user_name")->val;
/* Initialize each cell value */
cs_array_real_fill_zero(n_cells, cvar_scal);
/* Pressure, Density, Temperature, Total Energy
* Only 2 out of these 4 variables are independent: one may choose to
* initialize any pair of variables picked out of these 4, except
* (Temperature-Energy). The remaining 2 variables will be deduced
* automatically.
* Initialize 2 and only 2 variables
* To do so, set iutile=1 for each of the 2 selected variables
* and iutile=0 for each of the 2 others
* In the example provided below, Pressure and Temperature are
* initialized.
* ithvar indicates which variables have been set:
* it is completed automatically for each variable and
* it must not be modified. */
const int ithvar = cf_model->ithvar;
/* 1. Pressure (Pa) */
if (true) {
cf_model->ithvar = 2*ithvar;
cs_array_real_set_scalar(n_cells, p0, cvar_pr);
}
/* 2. Density (kg.m-3) */
if (false) {
cf_model->ithvar = 3*ithvar;
cs_array_real_set_scalar(n_cells, ro0, cpro_rho);
}
/* 3. Temperature (K -- Warning: Kelvin) */
if (true) {
cf_model->ithvar = 5*ithvar;
cs_array_real_set_scalar(n_cells, t0, cvar_tempk);
}
/* 4. Total Energy (J/kg) */
if (false) {
cf_model->ithvar = 7*ithvar;
cs_array_real_set_scalar(n_cells, cv0*t0, cvar_energ);
}
void cs_array_real_fill_zero(cs_lnum_t size, cs_real_t a[])
Assign zero to all elements of an array.
Definition: cs_array.c:879
void cs_array_real_set_scalar(cs_lnum_t n_elts, cs_real_t ref_val, cs_real_t a[restrict])
Assign a constant scalar value to an array.
Definition: cs_array.c:581
cs_cf_model_t * cs_get_glob_cf_model(void)
Provide access to compressible model global structure cs_glob_cf_model.
Definition: cs_cf_model.c:189
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:334
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.c:2344
@ p
Definition: cs_field_pointer.h:67
@ t_kelvin
Definition: cs_field_pointer.h:115
@ vel
Definition: cs_field_pointer.h:68
@ e_tot
Definition: cs_field_pointer.h:94
@ rho
Definition: cs_field_pointer.h:97
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.c:424
integer(c_int), pointer, save ithvar
thermodynamic variables indicator for initialization mapping cs_cf_model_t::ithvar
Definition: cfpoin.f90:44
int ithvar
Definition: cs_cf_model.h:53
real(c_double), pointer, save p0
reference pressure for the total pressure.
Definition: cstphy.f90:170
real(c_double), pointer, save t0
reference temperature.
Definition: cstphy.f90:217
real(c_double), pointer, save cv0
Reference isochoric specific heat.
Definition: cstphy.f90:241
real(c_double), pointer, save ro0
reference density.
Definition: cstphy.f90:153
Compressible model general options descriptor.
Definition: cs_cf_model.h:49
cs_real_t * val
Definition: cs_field.h:152
double ro0
Definition: cs_physical_constants.h:72
double cv0
Definition: cs_physical_constants.h:82
double t0
Definition: cs_physical_constants.h:80
double p0
Definition: cs_physical_constants.h:76