9.2
general documentation
Examples to use slice postprocessing functions based on medcoupling

Examples for the definition of a new slices

/* Add a slice plane intersecting the origin (0,0,0) with a normal
* along the Z axis (0,0,1), and length of 1m along both axis.
*
* If code_saturne is compiled without MEDCoupling, this call will
* raise an error during runtime.
*/
cs_real_t o[3] = {0.};
cs_real_t n[3] = {0., 0., 1.};
cs_medcoupling_postprocess_add_plane_slice("slice_OZ", /* Name of the slice */
"all[]", /* Selection criteria for cells to intersect */
o, /* Slice origin point */
n, /* Slice normal vector */
1., /* Plane length along first axis */
1.); /* Plane length along second axis */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
void cs_medcoupling_postprocess_add_plane_slice(const char *name, const char *selection_criteria, const cs_real_t origin[], const cs_real_t normal[], const cs_real_t length1, const cs_real_t length2)
Add a slice based on a plane.
Definition: cs_medcoupling_postprocess.cxx:640
/* Add a disc slice intersecting the origin (0,0,0) with a normal
* along the Z axis (0,0,1), and a radius of 0.5m.
*
* If code_saturne is compiled without MEDCoupling, this call will
* raise an error during runtime.
*/
cs_real_t o[3] = {0.};
cs_real_t n[3] = {0., 0., 1.};
cs_medcoupling_postprocess_add_disc_slice("disc1", /* Name of the slice */
"all[]", /* Selection criteria for cells to intersect */
o, /* Slice origin point */
n, /* Slice normal vector */
0.5, /* Disc radius */
-1); /* Number of sectors. if < 0 default value of 36 is used. */
void cs_medcoupling_postprocess_add_disc_slice(const char *name, const char *selection_criteria, const cs_real_t origin[], const cs_real_t normal[], const cs_real_t radius, const int n_sectors)
Add a slice based on a disc.
Definition: cs_medcoupling_postprocess.cxx:689
/* Add a slice plane intersecting the origin (0,0,0) with a normal
* along the Z axis (0,0,1), and length of 1m along both axis.
*
* If code_saturne is compiled without MEDCoupling, this call will
* raise an error during runtime.
*/
cs_real_t o[3] = {0.};
cs_real_t n[3] = {0., 0., 1.};
cs_medcoupling_postprocess_add_annulus_slice("annulus_slice", /* Name of the slice */
"all[]", /* Selection criteria for cells to intersect */
o, /* Slice origin point */
n, /* Slice normal vector */
0.2, /* Inner radius (hole) */
0.5, /* Outer radius */
72); /* Number of sectors. if < 0 default value of 36 is used */
void cs_medcoupling_postprocess_add_annulus_slice(const char *name, const char *selection_criteria, const cs_real_t origin[], const cs_real_t normal[], const cs_real_t radius1, const cs_real_t radius2, const int n_sectors)
Add a slice based on an annulus.
Definition: cs_medcoupling_postprocess.cxx:732

Compute the integral of a scalar

/* Compute an integral of a given scalar over the slice "annulus_slice" */
cs_real_t *cpro_scal = cs_field("my_scalar")->val;
[[maybe_unused]] cs_real_t int_val
= cs_medcoupling_slice_scalar_integral("annulus_slice", /* Name of the slice */
cpro_scal); /* Pointer to scalar values */
cs_real_t * val
Definition: cs_field.h:298
cs_field_t * cs_field(int id)
Return a pointer to a field based on its id. This function requires that a field of the given id is d...
Definition: cs_field.cpp:4295
cs_real_t cs_medcoupling_slice_scalar_integral(const char *name, const cs_real_t *scalar)
Compute integral of a scalar over a slice.
Definition: cs_medcoupling_postprocess.cxx:873

Compute the mean value of a scalar

/* Compute mean of a scalar over the slice "slice_OZ" */
cs_real_t *cpro_scal = cs_field("my_scalar")->val;
[[maybe_unused]] cs_real_t mean_val
= cs_medcoupling_slice_scalar_mean("slice_OZ", cpro_scal);
cs_real_t cs_medcoupling_slice_scalar_mean(const char *name, const cs_real_t *scalar)
Compute mean value of a scalar over a slice.
Definition: cs_medcoupling_postprocess.cxx:906

Example for the computation Tbulk over a given slice

/* Compute t_bulk of a disc slice.
* t_bulk = Int(T * cp * rho * <u|n>) / Int(cp * rho * <u|n>)
*/
const cs_lnum_t n_cells = domain->mesh->n_cells;
cs_array<cs_real_t> rho_cp(n_cells);
for (cs_lnum_t c_id = 0; c_id < n_cells; c_id++)
rho_cp[c_id] = CS_F_(cp)->val[c_id] * CS_F_(rho)->val[c_id];
cs_real_3_t *cvar_vel = (cs_real_3_t *)CS_F_(vel)->val;
CS_F_(t)->val,
rho_cp,
cvar_vel);
Define a templated array class (owner of data)
Definition: cs_array.h:1118
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ t
Definition: cs_field_pointer.h:91
@ vel
Definition: cs_field_pointer.h:66
@ cp
Definition: cs_field_pointer.h:99
@ rho
Definition: cs_field_pointer.h:96
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:47
cs_real_t cs_medcoupling_slice_scalar_mean_weighted(const char *name, const cs_real_t *scalar, const cs_real_t *weight_s, const cs_real_3_t *weight_v)
Compute mean of a scalar over a slice using a scalar and/or vectorial weights. If nullptr is provided...
Definition: cs_medcoupling_postprocess.cxx:993