7.2
general documentation
Basic example

Basic example

Local variables to be added

Initialization

One can get any field using cs_field_by_name function (use cs_field_by_name_try if one is not sure the field exists). "scalar1" is the name related to the first user-defined scalar variable. f->val[cell_id] is the value of this variable in cell number cell_id.

ONLY done if there is no restart computation.

const cs_mesh_t *m = domain->mesh;
/* If this is restarted computation, do not reinitialize values */
if (domain->time_step->nt_prev > 0)
return;
/* Initialize "scalar1" field to 25 only if it exists */
if (f != NULL) {
for (cs_lnum_t cell_id = 0; cell_id < m->n_cells; cell_id++)
f->val[cell_id] = 25.;
}