programmer's documentation
Probes and profiles

About Probes and profiles

Sets of probes may also be defined through the cs_user_postprocess_probes function, to allow for extraction and output of values at specific mesh locations, often with a higher time frequency than for volume or surface meshes.

Probe sets, and profiles (which can be viewed as a series of probes lying on a user-defined curve) are handled as a point mesh, which can be associated with plot and time_plot 2D-plot writers, as well as any of the general (3D-output) writer types (the priviledged writer types being plot for a profile, and time_plot for other probes).

Probe sets may be defined using the cs_probe_set_create_from_array function. In some cases, it might be useful to define those in multiple stages, using first cs_probe_set_create then a series of calls to cs_probe_set_add_probe.

The following example shows how probes may be added using that function.

{
cs_probe_set_t *pset = cs_probe_set_create("Monitoring");
cs_probe_set_add_probe(pset, 0.25, 0.025, 0.025, "M1");
cs_probe_set_add_probe(pset, 0.50, 0.025, 0.025, "M2");
cs_probe_set_add_probe(pset, 0.75, 0.025, 0.025, "M3");
}

Probe set creation functions return a pointer to a cs_probe_set_t structure which can be used to specify additional options using the cs_probe_set_option function.

A writer (id = CS_POST_WRITER_PROBES) using the format "time_plot" is associated by default to a set of monitoring probes. This is not the case for profiles.

Advanced profile definitions

As with regular meshes, profiles may be defined using user functions.

Definition of a series of profiles

In this example, we define a series of profiles. To avoid redundant code, an array defining both the name of each profile and the matching x coordinate (as a text string) is defined. The code then loops along these array values to define the series:

static const char *line_defs[]
= {"-5.87", "buicesat-6",
"2.59", "buicesat03",
"5.98", "buicesat06",
"12.75", "buicesat13",
"13.56", "buicesat14",
"16.14", "buicesat16",
"16.93", "buicesat17",
"19.53", "buicesat19",
"20.32", "buicesat20",
"22.91", "buicesat23",
"23.71", "buicesat24",
"26.3", "buicesat26",
"27.09", "buicesat27",
"29.69", "buicesat29",
"30.48", "buicesat30",
"33.07", "buicesat33",
"33.87", "buicesat34",
"39.85", "buicesat40",
"46.62", "buicesat47",
"53.39", "buicesat53",
"60.17", "buicesat60",
"66.94", "buicesat67",
"73.71", "buicesat74"};
for (int i = 0; i < 23; i++) {
/* Define profiles */
= cs_probe_set_create_from_local(line_defs[i*2+1],
_cell_x_profile_probes_define,
(void *)line_defs[i*2]); /* input */
/* Associate writers */
const int writer_ids[] = {CS_POST_WRITER_PROFILES};
cs_probe_set_associate_writers(pset, 1, writer_ids);
}

As we observe here, the cs_probe_set_create_from_local requires a process-local definition, calling a user-defined function. This requires that the line_defs array be defined as static, so as to be available when this function is called. For this example, the function is defined as follows (before the calling function, preferably in the file's local function definitions section).

static void
_cell_x_profile_probes_define(void *input,
cs_lnum_t *n_elts,
cs_real_3_t **coords,
cs_real_t **s)
{
/* Determine x value from input string, to define
associated segment (with fixed y and z values) */
const char *x_str = (const char *)input;
cs_real_t x = atof(x_str);
cs_real_t seg[6] = {x, 0.1, -0.05, x, -5, -0.05};
/* Call general cell selection function with adapted input */
cs_cell_segment_intersect_probes_define(seg, n_elts, coords, s);
}

Boundary profiles

Probes and profiles may also be associated to the mesh boundary.

In the following example, two profiles are defined based on a mesh boundary selection criterion, using the predefined cs_b_face_criterion_probes_define (which assumes curvilinear coordinates based on the "x" direction):

static const char *wall_defs[]
= {"UP", "buicstr",
"DOWN", "buicinc"};
for (int i = 0; i < 2; i++) {
= cs_probe_set_create_from_local(wall_defs[i*2+1],
(void *)wall_defs[i*2]); /* input */
cs_probe_set_option(pset, "boundary", "true");
/* Associate writers */
const int writer_ids[] = {CS_POST_WRITER_PROFILES};
cs_probe_set_associate_writers(pset, 1, writer_ids);
}