8.3
general documentation
User extra operations for the Lagrangian module

Introduction

This page provides an example that may be used or adapted to perform extra or advanced extra-operations within the Lagrangian module.

Example

First we initialize some variables:

cs_lagr_particle_set_t * cs_lagr_get_particle_set(void)
Return pointer to the main cs_lagr_particle_set_t structure.
Definition: cs_lagr_particle.cpp:1194
Definition: cs_lagr_particle.h:223

In the next example we compute the particle mass flow rate on 4 planes

{
cs_real_t zz[4] = {0.1e0, 0.15e0, 0.20e0, 0.25e0};
/* If we are in an unsteady case, or if the beginning of the steady stats
* is not reached yet, all statistics are reset to zero at each time
step before entering this function.*/
for (cs_lnum_t iplan = 0; iplan < 4; iplan++)
_m_flow[iplan] = 0.0;
}
for (cs_lnum_t iplan = 0; iplan < 4; iplan++) {
for (cs_lnum_t p_id = 0; p_set->n_particles; p_id++) {
const cs_real_t *part_coords
= (const cs_real_t *)cs_lagr_particles_attr_const(p_set, p_id,
const cs_real_t *prev_part_coords
= (const cs_real_t *)cs_lagr_particles_attr_n_const(p_set, p_id, 1,
if ( part_coords[0] > zz[iplan]
&& prev_part_coords[0] <= zz[iplan])
_m_flow[iplan] += cs_lagr_particles_get_real(p_set, p_id,
}
}
for (int iplan = 0; iplan < 4; iplan++)
bft_printf(" Particle mass flow at Z(%d): %e14.5)",
iplan,
_m_flow[iplan]/stat_age);
}
int bft_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: bft_printf.cpp:140
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
cs_lagr_time_scheme_t * cs_glob_lagr_time_scheme
@ CS_LAGR_MASS
Definition: cs_lagr_particle.h:93
@ CS_LAGR_STAT_WEIGHT
Definition: cs_lagr_particle.h:91
@ CS_LAGR_COORDS
Definition: cs_lagr_particle.h:96
static const void * cs_lagr_particles_attr_const(const cs_lagr_particle_set_t *particle_set, cs_lnum_t particle_id, cs_lagr_attribute_t attr)
Get const pointer to current attribute data of a given particle in a set.
Definition: cs_lagr_particle.h:438
static const void * cs_lagr_particles_attr_n_const(const cs_lagr_particle_set_t *particle_set, cs_lnum_t particle_id, int time_id, cs_lagr_attribute_t attr)
Get const pointer to attribute data of a given particle in a set at a given time.
Definition: cs_lagr_particle.h:491
static cs_real_t cs_lagr_particles_get_real(const cs_lagr_particle_set_t *particle_set, cs_lnum_t particle_id, cs_lagr_attribute_t attr)
Get attribute value of type cs_real_t of a given particle in a set.
Definition: cs_lagr_particle.h:799
cs_real_t cs_lagr_stat_get_age(void)
Return global volume statistics age.
Definition: cs_lagr_stat.cpp:5792
cs_lagr_stat_options_t * cs_glob_lagr_stat_options
const cs_time_step_t * cs_glob_time_step
cs_lnum_t n_particles
Definition: cs_lagr_particle.h:225
int nstist
Definition: cs_lagr_stat.h:213
int isttio
Definition: cs_lagr.h:210
int nt_cur
Definition: cs_time_step.h:74