8.3
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:342
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:642
/* 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:691
/* 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:734

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_by_name("my_scalar")->val;
cs_real_t int_val =
cs_medcoupling_slice_scalar_integral("annulus_slice", /* Name of the slice */
cpro_scal); /* Pointer to scalar values */
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.cpp:2489
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:875
cs_real_t * val
Definition: cs_field.h:152

Compute the mean value of a scalar

/* Compute mean of a scalar over the slice "slice_OZ" */
cs_real_t *cpro_scal = cs_field_by_name("my_scalar")->val;
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:908

Example for the computation Tbulk over a given slice

/* Compute Tbulk of a disc slice.
* Tbulk = Int(T * cp * rho * <u|n>) / Int(cp * rho * <u|n>)
*/
const cs_lnum_t n_cells = domain->mesh->n_cells;
cs_real_t *rho_cp = nullptr;
BFT_MALLOC(rho_cp, n_cells, cs_real_t);
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);
BFT_FREE(rho_cp);
#define BFT_FREE(_ptr)
Definition: bft_mem.h:90
#define BFT_MALLOC(_ptr, _ni, _type)
Definition: bft_mem.h:58
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:359
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
@ t
Definition: cs_field_pointer.h:94
@ vel
Definition: cs_field_pointer.h:70
@ cp
Definition: cs_field_pointer.h:102
@ rho
Definition: cs_field_pointer.h:99
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
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:995