9.0
general documentation
Loading...
Searching...
No Matches
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 */
/* 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. */
/* 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 */
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 */
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);
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
;
CS_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_real_t
Tbulk =
cs_medcoupling_slice_scalar_mean_weighted
(
"disc1"
,
CS_F_
(
t
)->val,
rho_cp,
cvar_vel);
CS_FREE
(rho_cp);
Generated on
for code_saturne by
1.14.0