9.2
general documentation
cs_lagr_stat.h
Go to the documentation of this file.
1#ifndef CS_LAGR_STAT_H
2#define CS_LAGR_STAT_H
3
4/*============================================================================
5 * Functions and types for the Lagrangian module
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30#include "base/cs_defs.h"
31
32#include "assert.h"
33#include "base/cs_base.h"
34#include "base/cs_field.h"
35#include "base/cs_restart.h"
36
37#include "lagr/cs_lagr.h"
38#include "lagr/cs_lagr_event.h"
40
41/*----------------------------------------------------------------------------*/
42
43/*=============================================================================
44 * Macro definitions
45 *============================================================================*/
46
47/*============================================================================
48 * Type definitions
49 *============================================================================*/
50
53typedef enum {
54
57
59
62typedef enum {
63
66
68
70
73typedef enum {
74
78
80
82/* ----------------------------------------- */
83
84typedef enum {
85
86 /* Volume statistics */
87
94 /* Boundary statistics */
95
98
101
104
115 /* Particle or event-based attributes */
116
121
122/*----------------------------------------------------------------------------
123 * Function pointer for computation of particle data values for
124 * Lagrangian statistics.
125 *
126 * Note: if the input pointer is non-null, it must point to valid data
127 * when the selection function is called, so that value or structure should
128 * not be temporary (i.e. local);
129 *
130 * parameters:
131 * input <-- pointer to optional (untyped) value or structure.
132 * particle <-- pointer to particle data
133 * p_am <-- pointer to particle attribute map
134 * vals --> pointer to values
135 *----------------------------------------------------------------------------*/
136
137typedef void
138(cs_lagr_moment_p_data_t) (const void *input,
139 const void *particle,
140 const cs_lagr_attribute_map_t *p_am,
141 cs_real_t vals[]);
142
143/*----------------------------------------------------------------------------
144 * Function pointer for computation of event data values for
145 * Lagrangian statistics.
146 *
147 * Note: if the input pointer is non-null, it must point to valid data
148 * when the selection function is called, so that value or structure should
149 * not be temporary (i.e. local);
150 *
151 * parameters:
152 * input <-- pointer to optional (untyped) value or structure.
153 * events <-- pointer to events
154 * event_id <-- event id range (first to past-last)
155 * vals --> pointer to values
156 *----------------------------------------------------------------------------*/
157
158typedef void
159(cs_lagr_moment_e_data_t) (const void *input,
160 const cs_lagr_event_set_t *events,
161 cs_lnum_t id_range[2],
162 cs_real_t vals[]);
163
164/*----------------------------------------------------------------------------
165 * Function pointer for computation of data values for particle statistics
166 * based on mesh
167 *
168 * If the matching values are multidimensional, they must be interleaved.
169 *
170 * Note: if the input pointer is non-null, it must point to valid data
171 * when the selection function is called, so that value or structure should
172 * not be temporary (i.e. local);
173 *
174 * parameters:
175 * input <-- pointer to optional value or structure, or NULL
176 * events <-- pointer to optional events set, or NULL.
177 * location_id <-- associated mesh location id
178 * class_id <-- associated particle class id (0 for all)
179 * vals --> pointer to values (size: n_local elements*dimension)
180 *----------------------------------------------------------------------------*/
181
182typedef void
183(cs_lagr_moment_m_data_t) (const void *input,
184 const cs_lagr_event_set_t *events,
185 int location_id,
186 int class_id,
187 cs_real_t vals[]);
188
191typedef struct {
192
198
202
212
216
218
219/*============================================================================
220 * Global variables
221 *============================================================================*/
222
223/* Pointer to global statistic options structure */
224
226
227/*============================================================================
228 * Public function prototypes
229 *============================================================================*/
230
231/*----------------------------------------------------------------------------*/
259/*----------------------------------------------------------------------------*/
260
261int
262cs_lagr_stat_particle_define(const char *name,
263 int location_id,
264 int stat_type,
266 int class_id,
267 int dim,
268 int component_id,
269 cs_lagr_moment_p_data_t *data_func,
270 void *data_input,
271 cs_lagr_moment_p_data_t *w_data_func,
272 void *w_data_input,
273 int nt_start,
274 double t_start,
275 cs_lagr_stat_restart_t restart_mode);
276
277/*----------------------------------------------------------------------------*/
305/*----------------------------------------------------------------------------*/
306
307int
308cs_lagr_stat_event_define(const char *name,
309 int location_id,
310 int stat_type,
311 cs_lagr_stat_group_t stat_group,
313 int class_id,
314 int dim,
315 int component_id,
316 cs_lagr_moment_e_data_t *data_func,
317 void *data_input,
318 cs_lagr_moment_e_data_t *w_data_func,
319 void *w_data_input,
320 int nt_start,
321 double t_start,
322 cs_lagr_stat_restart_t restart_mode);
323
324/*----------------------------------------------------------------------------*/
349/*----------------------------------------------------------------------------*/
350
351int
352cs_lagr_stat_accumulator_define(const char *name,
353 int location_id,
354 cs_lagr_stat_group_t stat_group,
355 int class_id,
356 cs_lagr_moment_p_data_t *p_data_func,
357 cs_lagr_moment_e_data_t *e_data_func,
358 void *data_input,
359 int nt_start,
360 double t_start,
361 cs_lagr_stat_restart_t restart_mode);
362
363/*----------------------------------------------------------------------------*/
390/*----------------------------------------------------------------------------*/
391
392int
393cs_lagr_stat_mesh_define(const char *name,
394 int location_id,
395 cs_lagr_stat_group_t stat_group,
396 int class_id,
397 int dim,
398 cs_lagr_moment_m_data_t *data_func,
399 void *data_input,
400 int nt_start,
401 double t_start);
402
403/*----------------------------------------------------------------------------*/
436/*----------------------------------------------------------------------------*/
437
438int
439cs_lagr_stat_time_moment_define(const char *name,
440 int location_id,
441 int stat_type,
443 int class_id,
444 int dim,
445 int component_id,
446 cs_lagr_moment_m_data_t *data_func,
447 void *data_input,
448 int nt_start,
449 double t_start,
450 cs_lagr_stat_restart_t restart_mode);
451
452/*----------------------------------------------------------------------------*/
460/*----------------------------------------------------------------------------*/
461
462void
463cs_lagr_stat_activate(int stat_type);
464
465/*----------------------------------------------------------------------------*/
479/*----------------------------------------------------------------------------*/
480
481void
483 cs_lagr_stat_moment_t moment);
484
485/*----------------------------------------------------------------------------*/
493/*----------------------------------------------------------------------------*/
494
495void
496cs_lagr_stat_deactivate(int stat_type);
497
498/*----------------------------------------------------------------------------*/
506/*----------------------------------------------------------------------------*/
507
508void
509cs_lagr_stat_activate_attr(int attr_id);
510
511/*----------------------------------------------------------------------------*/
519/*----------------------------------------------------------------------------*/
520
521void
523
524/*---------------------------------------------------------------------------*/
533/*---------------------------------------------------------------------------*/
534
535int
537
538/*---------------------------------------------------------------------------*/
546/*---------------------------------------------------------------------------*/
547
548int
549cs_lagr_stat_type_to_attr_id(int stat_type);
550
551/*----------------------------------------------------------------------------*/
559/*----------------------------------------------------------------------------*/
560
561int
562cs_lagr_stat_type_by_name(const char *name);
563
564/*----------------------------------------------------------------------------*/
573/*----------------------------------------------------------------------------*/
574
575void
577
578/*----------------------------------------------------------------------------*/
589/*----------------------------------------------------------------------------*/
590
591void
593
594/*----------------------------------------------------------------------------*/
602/*----------------------------------------------------------------------------*/
603
604bool
606
607/*----------------------------------------------------------------------------*/
611/*----------------------------------------------------------------------------*/
612
613void
615
616/*----------------------------------------------------------------------------*/
620/*----------------------------------------------------------------------------*/
621
622void
624
625/*----------------------------------------------------------------------------*/
634/*----------------------------------------------------------------------------*/
635
636#if defined(__cplusplus)
637void
639 const cs_lnum_t p_id,
640 const cs_real_t rel_time);
641#endif /* __cplusplus */
642
643/*----------------------------------------------------------------------------*/
647/*----------------------------------------------------------------------------*/
648
649void
651
652/*----------------------------------------------------------------------------*/
662/*----------------------------------------------------------------------------*/
663
664void
667
668/*----------------------------------------------------------------------------*/
672/*----------------------------------------------------------------------------*/
673
674void
676
677/*----------------------------------------------------------------------------*/
681/*----------------------------------------------------------------------------*/
682
683void
685
686/*----------------------------------------------------------------------------*/
690/*----------------------------------------------------------------------------*/
691
692void
694
695/*----------------------------------------------------------------------------*/
701/*----------------------------------------------------------------------------*/
702
703void
705
706/*----------------------------------------------------------------------------*/
720/*----------------------------------------------------------------------------*/
721
723cs_lagr_stat_get_moment(int stat_type,
724 cs_lagr_stat_group_t stat_group,
726 int class_id,
727 int component_id);
728
729/*----------------------------------------------------------------------------*/
737/*----------------------------------------------------------------------------*/
738
740cs_lagr_stat_get_stat_weight(int class_id);
741
742/*----------------------------------------------------------------------------*/
748/*----------------------------------------------------------------------------*/
749
752
753/*----------------------------------------------------------------------------*/
761/*----------------------------------------------------------------------------*/
762
765
766/*----------------------------------------------------------------------------*/
767
768#endif /* CS_LAGR_STAT_H */
Field descriptor.
Definition: cs_field.h:275
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ dt
Definition: cs_field_pointer.h:61
int cs_lagr_stat_accumulator_define(const char *name, int location_id, cs_lagr_stat_group_t stat_group, int class_id, cs_lagr_moment_p_data_t *p_data_func, cs_lagr_moment_e_data_t *e_data_func, void *data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
Define a particle weight type statistic.
Definition: cs_lagr_stat.cpp:4024
void cs_lagr_stat_activate_attr(int attr_id)
Activate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.cpp:4306
int cs_lagr_stat_particle_define(const char *name, int location_id, int stat_type, cs_lagr_stat_moment_t m_type, int class_id, int dim, int component_id, cs_lagr_moment_p_data_t *data_func, void *data_input, cs_lagr_moment_p_data_t *w_data_func, void *w_data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
Define a particle-based statistic.
Definition: cs_lagr_stat.cpp:3816
void cs_lagr_stat_deactivate_attr(int attr_id)
Deactivate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.cpp:4322
cs_lagr_stat_type_t
Definition: cs_lagr_stat.h:84
@ CS_LAGR_STAT_VOLUME_FRACTION
Definition: cs_lagr_stat.h:92
@ CS_LAGR_STAT_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:88
@ CS_LAGR_STAT_E_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:97
@ CS_LAGR_STAT_RESUSPENSION_MASS_FLUX
Definition: cs_lagr_stat.h:106
@ CS_LAGR_STAT_ATTR
Definition: cs_lagr_stat.h:117
@ CS_LAGR_STAT_FOULING_MASS_FLUX
Definition: cs_lagr_stat.h:107
@ CS_LAGR_STAT_RESUSPENSION_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:100
@ CS_LAGR_STAT_MASS_FLUX
Definition: cs_lagr_stat.h:105
@ CS_LAGR_STAT_FOULING_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:103
@ CS_LAGR_STAT_IMPACT_ANGLE
Definition: cs_lagr_stat.h:109
@ CS_LAGR_STAT_IMPACT_VELOCITY
Definition: cs_lagr_stat.h:111
@ CS_LAGR_STAT_FOULING_DIAMETER
Definition: cs_lagr_stat.h:112
@ CS_LAGR_STAT_FOULING_COKE_FRACTION
Definition: cs_lagr_stat.h:113
void() cs_lagr_moment_p_data_t(const void *input, const void *particle, const cs_lagr_attribute_map_t *p_am, cs_real_t vals[])
Definition: cs_lagr_stat.h:138
cs_lagr_stat_restart_t
Definition: cs_lagr_stat.h:73
@ CS_LAGR_MOMENT_RESTART_EXACT
Definition: cs_lagr_stat.h:77
@ CS_LAGR_MOMENT_RESTART_AUTO
Definition: cs_lagr_stat.h:76
@ CS_LAGR_MOMENT_RESTART_RESET
Definition: cs_lagr_stat.h:75
void cs_lagr_stat_map_cell_dt(const cs_real_t *dt)
Map time step values array for Lagrangian statistics.
Definition: cs_lagr_stat.cpp:4438
void cs_lagr_stat_log_iteration(void)
Log moment definition information for a given iteration.
Definition: cs_lagr_stat.cpp:5381
cs_lagr_stat_moment_t
Definition: cs_lagr_stat.h:53
@ CS_LAGR_MOMENT_VARIANCE
Definition: cs_lagr_stat.h:56
@ CS_LAGR_MOMENT_MEAN
Definition: cs_lagr_stat.h:55
int cs_lagr_stat_event_define(const char *name, int location_id, int stat_type, cs_lagr_stat_group_t stat_group, cs_lagr_stat_moment_t m_type, int class_id, int dim, int component_id, cs_lagr_moment_e_data_t *data_func, void *data_input, cs_lagr_moment_e_data_t *w_data_func, void *w_data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
Define an event-based statistic.
Definition: cs_lagr_stat.cpp:3883
cs_lagr_stat_group_t
Definition: cs_lagr_stat.h:62
@ CS_LAGR_STAT_GROUP_TRACKING_EVENT
Definition: cs_lagr_stat.h:65
@ CS_LAGR_STAT_GROUP_PARTICLE
Definition: cs_lagr_stat.h:64
@ CS_LAGR_STAT_GROUP_N_GROUPS
Definition: cs_lagr_stat.h:67
void cs_lagr_stat_update_event(cs_lagr_event_set_t *events, cs_lagr_stat_group_t group)
Update event-based moment accumulators.
Definition: cs_lagr_stat.cpp:4896
void cs_lagr_stat_update_all_incr(cs_lagr_particle_set_t &p_set, const cs_lnum_t p_id, const cs_real_t rel_time)
Increment particle contibution on moment and time moment accumulators.
void cs_lagr_stat_finalize(void)
Destroy all moments management metadata.
Definition: cs_lagr_stat.cpp:5243
void cs_lagr_stat_initialize(void)
Lagrangian statistics initialization.
Definition: cs_lagr_stat.cpp:4457
int cs_lagr_stat_time_moment_define(const char *name, int location_id, int stat_type, cs_lagr_stat_moment_t m_type, int class_id, int dim, int component_id, cs_lagr_moment_m_data_t *data_func, void *data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
Define a time moment associated to particle statistics.
Definition: cs_lagr_stat.cpp:4147
void cs_lagr_stat_activate(int stat_type)
Activate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.cpp:4197
cs_real_t cs_lagr_stat_get_moment_age(cs_field_t *f)
Return statistics age for a given moment.
Definition: cs_lagr_stat.cpp:5985
void cs_lagr_stat_prepare(void)
Prepare particle statistics for a given time step.
Definition: cs_lagr_stat.cpp:4718
cs_field_t * cs_lagr_stat_get_moment(int stat_type, cs_lagr_stat_group_t stat_group, cs_lagr_stat_moment_t m_type, int class_id, int component_id)
Return field associated with a given Lagrangian statistic, given a statistics type (i....
Definition: cs_lagr_stat.cpp:5892
int cs_lagr_stat_type_from_attr_id(int attr_id)
Return statistics type associated with a given particle attribute id.
Definition: cs_lagr_stat.cpp:4339
void() cs_lagr_moment_e_data_t(const void *input, const cs_lagr_event_set_t *events, cs_lnum_t id_range[2], cs_real_t vals[])
Definition: cs_lagr_stat.h:159
cs_field_t * cs_lagr_stat_get_stat_weight(int class_id)
Return statistical weight.
Definition: cs_lagr_stat.cpp:5934
void cs_lagr_stat_restart_write(cs_restart_t *restart)
Checkpoint moment data.
Definition: cs_lagr_stat.cpp:5529
int cs_lagr_stat_type_to_attr_id(int stat_type)
Return attribute id associated with a given statistics type.
Definition: cs_lagr_stat.cpp:4357
void cs_lagr_stat_log_setup(void)
Log moment definition setup information.
Definition: cs_lagr_stat.cpp:5262
int cs_lagr_stat_type_by_name(const char *name)
Determine a basic statistic type by its base name.
Definition: cs_lagr_stat.cpp:4378
cs_lagr_stat_options_t * cs_glob_lagr_stat_options
void cs_lagr_stat_activate_time_moment(int stat_type, cs_lagr_stat_moment_t moment)
Activate time moment for some predefined Lagrangian statistics types.
Definition: cs_lagr_stat.cpp:4254
void cs_lagr_stat_restart_read(void)
Read particle statistics restart info if needed.
Definition: cs_lagr_stat.cpp:4701
void cs_lagr_stat_update(void)
Update particle statistics for a given time step.
Definition: cs_lagr_stat.cpp:4809
void cs_lagr_stat_deactivate(int stat_type)
Deactivate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.cpp:4282
bool cs_lagr_stat_is_active(cs_lagr_stat_group_t group)
Indicate if a given statistics type has active statistics.
Definition: cs_lagr_stat.cpp:4685
void() cs_lagr_moment_m_data_t(const void *input, const cs_lagr_event_set_t *events, int location_id, int class_id, cs_real_t vals[])
Definition: cs_lagr_stat.h:183
int cs_lagr_stat_mesh_define(const char *name, int location_id, cs_lagr_stat_group_t stat_group, int class_id, int dim, cs_lagr_moment_m_data_t *data_func, void *data_input, int nt_start, double t_start)
Define mesh-based statistic based on particles or particle events.
Definition: cs_lagr_stat.cpp:3950
cs_real_t cs_lagr_stat_get_age(void)
Return global volume statistics age.
Definition: cs_lagr_stat.cpp:5957
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:91
Definition: cs_lagr_particle.h:188
Definition: cs_lagr_event.h:130
Definition: cs_lagr_particle.h:324
Definition: cs_lagr_stat.h:191
int idstnt
Definition: cs_lagr_stat.h:201
cs_real_t threshold
Definition: cs_lagr_stat.h:215
int nstist
Definition: cs_lagr_stat.h:211
int isuist
Definition: cs_lagr_stat.h:197