7.2
general documentation
Interpolation

Probe set interpolation

By default, probes and profile values are "P0" interpolated, that is their value is that of the containing cell or face, or closest vertex.

For cell-based values, a "P1" piecewise linear interpolation may be used.

The P1 interpolation is based on a local least-squares gradient, so ghost cell values must be synchronized (this is automatically the case for fields, but must be handled by the user in case of auxiliary arrays).

If a field's boundary values (i.e. associated field) are known, they are used in the interpolation. Otherwise, if boundary conditions are defined, they are used. When neither boundary values nor boundary conditions are known (i.e. for a non-solved variable field or values not defined as a field), homogeneous Neumann boundary conditions are assumed. Improved gradient interpolation for stratification and "jumps" is also ignored here, so this may lead to excessively smooth output in areas where this should occur.

Interpolation may be activated in a global manner for all outputs using a given probe set as by setting the set's "interpolate", option to 1, as shown on the following example. The "probes" set configured here is the default probe set defined using the GUI:

{
cs_probe_set_t *pset = cs_probe_set_get("probes");
cs_probe_set_option(pset, "interpolation", "1");
}

If a finer control is needed, such as applying a different interpolation option to selected fields, or providing a more precice (but usually more costly interpolation, interpolation may also be defined on a case per case basis using the cs_user_postprocess_values function.

The following example shows how this may be done, using the built-in cs_interpolate_from_location_p1 function (which is based on the "P1" interpolation described above) by passing its pointer to the to cs_post_write_probe_values outout function.

int n_p_fields = 2;
const char *p_field_names[] = {"velocity", "temperature"};
for (int i = 0; i < n_p_fields; i++) {
cs_field_t *f = cs_field_by_name_try(p_field_names[i]);
if (f != NULL) {
/* use different name to avoid conflict with field name in case already
present in probe set through default output */
char f_name[128], p_name[128];
snprintf(f_name, 63, "%s", f->name); f_name[127] = '\0';
snprintf(p_name, 63, "%s_p", f->name); p_name[63] = '\0';
(mesh_id,
CS_POST_WRITER_ALL_ASSOCIATED, /* writer id filter */
p_name, /* var_name */
f->dim, /* var_dim */
1, /* parent location id */
cs_interpolate_from_location_p1, /* P1 interpolation */
f_name, /* interpolation input */
f->val,
ts);
}
}
}

In this case, selected outputs are named by appending "_p" to the field name to allow combining default probe outputs with interpolated outputs of specific fields.

For simplicity here, values are output to the main probe set and writer, which is assumed to be defined using the GUI in this example.

Note also that interpolation could be also used in some cs_user_extra_operations cases.

If needed, users may also define their own interpolation functions, whose arguments should match cs_interpolate_from_location_t and pass the appropriate pointer to cs_post_write_probe_values.