7.1
general 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");
}

The same set could also be defined using predifined arrays:

{
const cs_real_t coords[][3] = {{0.25, 0.025, 0.025},
{0.50, 0.025, 0.025},
{0.75, 0.025, 0.025}};
const char *labels[] = {"M1", "M2", "M3"};
3,
coords,
labels);
}

In both cases, labels are optional (NULL may be used instead).

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.

Profiles are special probe sets, for which a curvilinear coordinate is usually provided (or deduced, when cs_probe_set_create_from_segment or cs_probe_set_create_from_local construction function is used). Curvilinear coordinates may also be assigned to probe sets generated using cs_probe_set_create or cs_probe_set_create_from_array by using the cs_probe_set_assign_curvilinear_abscissa function.

Instead of being assigned by default to a time plot, profiles are generally used with writers using the "plot" format (with a "dat" or "csv" sub-option). Instead of using one file per variable with one column per point and one line per output time, this produces one file pour output time, with une column per variable and one line per point. But they may also be used with time plots (as a regular probe set), or as with any post-processing output mesh, with 3D formats such as EnSight or MED.

The following example shows how to simply define a profile on a given segment, and associate it to writer 2:

{
cs_coord_3_t start = {0., 0.025, 0.025};
cs_coord_3_t end = {1., 0.025, 0.025};
int writer_ids[] = {2};
11, // n_probes
start, // start coordinates
end); // end coordinates
cs_probe_set_associate_writers(pset, 1, writer_ids);
}

Probe sets (including profiles) may also be located along the domain boundary, if this is specified. In the following example, we set the "boundary" option to "true" to specify that the probes should be located on the boundary instead of the default volume mesh. We could also set a "criteria" option to define a selection filter for the portion of the mesh in which probes should be located (by default, the whole mesh).

Here We also choose to "snap" the points to the nearest vertices. Snapping probes to cell centers or vertices is useful mainly when the values to plot are located on those points.

{
cs_coord_3_t start = {0., 0., 0.};
cs_coord_3_t end = {1., 0., 0.};
11, // n_probes
start, // start coordinates
end); // end coordinates
int writer_ids[] = {2};
cs_probe_set_associate_writers(pset, 1, writer_ids);
cs_probe_set_option(pset, "boundary", "true");
}

Defining output on a probe set

To select a specific set of fields to output with a given probe set or profile, the cs_probe_set_associate_field function may be used. It allows specifying whether the output relates to all associated writers or specific ones, and for multidimensional fields, allows selecting specific components (comp_id = -1 for all components, or the (0 to n-1)-th component if filtering is desired.

This is used in general for probe sets whose "automatic" variables output is turned off (using cs_probe_set_auto_var), though it can be used to extend that glob setting.

Finally, the user may choose to output the curvilinear coordinates associated with a profile and/or the point coordinates, using the cs_probe_set_auto_curvilinear_coords and cs_probe_set_auto_cartesian_coords respectively, since these are not output by default.

This last example illustrates a combination of those possibilities:

{
cs_coord_3_t start = {0., 0., 0.};
cs_coord_3_t end = {1., 0., 0.};
11, // n_probes
start, // start coordinates
end); // end coordinates
int writer_ids[] = {2};
cs_probe_set_associate_writers(pset, 1, writer_ids);
cs_probe_set_option(pset, "boundary", "true");
}

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:

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 */
const cs_real_t x = atof(line_defs[i*2]);
const cs_real_t start_coords[3] = {x, 0.1, 0.05};
const cs_real_t end_coords[3] = {x, -5, 0.05};
-1, /* Automatic sampling */
start_coords,
end_coords);
/* Associate writers */
const int writer_ids[] = {CS_POST_WRITER_PROFILES};
cs_probe_set_associate_writers(pset, 1, writer_ids);
}

Boundary profiles

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

In the following example, a profile is 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):

= cs_probe_set_create_from_local("foil_profile", /* probes set name */
/* probe def. function */
(void *)"FOIL_WALL"); /* input */
/* Indicate that the probes are located on the boundary */
cs_probe_set_option(pset, "boundary", "true");
/* Associate profile writer to this probes set */
const int writer_ids[] = {CS_POST_WRITER_PROFILES};
cs_probe_set_associate_writers(pset, 1, writer_ids);

and in the below example using an array of 2 selection criteria:

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],
_b_face_criterion_probes_define,
(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);
}

In this example, we provide a local selection function (which may be defined in the private function definitions section near the beginning of the file) and whose code is shown below:

static void
_b_face_criterion_probes_define(void *input,
cs_lnum_t *n_elts,
cs_real_3_t **coords,
cs_real_t **s)
{
const char *criterion = (const char *)input;
const cs_mesh_t *m = cs_glob_mesh;
cs_lnum_t n_faces;
cs_lnum_t *face_ids;
BFT_MALLOC(face_ids, m->n_b_faces, cs_lnum_t);
cs_selector_get_b_face_list(criterion, &n_faces, face_ids);
cs_real_3_t *_coords;
cs_real_t *_s;
BFT_MALLOC(_coords, n_faces, cs_real_3_t);
BFT_MALLOC(_s, n_faces, cs_real_t);
for (cs_lnum_t i = 0; i < n_faces; i++) {
for (cs_lnum_t j = 0; j < 3; j++)
_coords[i][j] = mq->b_face_cog[face_ids[i]*3 + j];
_s[i] = _coords[i][0];
}
BFT_FREE(face_ids);
/* Set return values */
*n_elts = n_faces;
*coords = _coords;
*s = _s;
}