My Project
programmer's 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;
/* Initialiase "scalar1" field to 25 only if it exists and if
* there is not restart computation */
if (f != NULL) {
for (cs_lnum_t cell_id = 0; cell_id < m->n_cells; cell_id++)
f->val[cell_id] = 25.;
}
}
cs_mesh_t::n_cells
cs_lnum_t n_cells
Definition: cs_mesh.h:73
cs_restart_present
int cs_restart_present(void)
Check if we have a restart directory.
Definition: cs_restart.c:1912
cs_field_by_name_try
cs_field_t * cs_field_by_name_try(const char *name)
Return a pointer to a field based on its name if present.
Definition: cs_field.c:2357
cs_field_t::val
cs_real_t * val
Definition: cs_field.h:145
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_mesh_t
Definition: cs_mesh.h:63