9.0
general documentation
Loading...
Searching...
No Matches
Boundary conditions using time table

Compute a time dependent parameter value from a time table defined by the user.

To access a time table defined variable when defining boundary conditions, a callback function of the type of type cs_dof_func_t can be defined, such as the following (for a time table named "inlet_temperature"):

static void
_time_table_t_inlet(cs_lnum_t n_elts,
const cs_lnum_t *elt_ids,
bool dense_output,
void *input,
cs_real_t *retval)
{
/* Get current time */
const cs_real_t time = cs_glob_time_step->t_cur;
/* Compute inlet temperature from time table "inlet_temperature" */
cs_real_t inlet_temp =
cs_time_table_compute_time_value("inlet_temperature",
time,
1, /* 2nd column */
false); /* Don't overwrite last position */
/* Apply values at selected locations */
for (cs_lnum_t i = 0; i < n_elts; i++) {
const cs_lnum_t face_id = (elt_ids == nullptr) ? i : elt_ids[i];
const cs_lnum_t j = dense_output ? i : face_id;
retval[j] = inlet_temp;
}
}

Note that accessing the time table value in the function above is done through the call to cs_time_table_compute_time_value.

The callback function can then be assigned to the zone named "inlet" for variable "scalar1" in the usual way (in cs_user_boundary_conditions_setup):

"inlet", // zone name
cs_flag_boundary_face, // location flag
_time_table_t_inlet, // callback function
nullptr); // input structure