8.3
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-2024 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 "cs_defs.h"
31
32#include "assert.h"
33#include "cs_base.h"
34#include "cs_field.h"
35#include "cs_restart.h"
36
37#include "cs_lagr.h"
38#include "cs_lagr_event.h"
39#include "cs_lagr_particle.h"
40
41/*----------------------------------------------------------------------------*/
42
44
45/*=============================================================================
46 * Macro definitions
47 *============================================================================*/
48
49/*============================================================================
50 * Type definitions
51 *============================================================================*/
52
55typedef enum {
56
59
61
64typedef enum {
65
68
70
72
75typedef enum {
76
80
82
84/* ----------------------------------------- */
85
86typedef enum {
87
88 /* Volume statistics */
89
96 /* Boundary statistics */
97
100
103
106
117 /* Particle or event-based attributes */
118
123
124/*----------------------------------------------------------------------------
125 * Function pointer for computation of particle data values for
126 * Lagrangian statistics.
127 *
128 * Note: if the input pointer is non-null, it must point to valid data
129 * when the selection function is called, so that value or structure should
130 * not be temporary (i.e. local);
131 *
132 * parameters:
133 * input <-- pointer to optional (untyped) value or structure.
134 * particle <-- pointer to particle data
135 * p_am <-- pointer to particle attribute map
136 * vals --> pointer to values
137 *----------------------------------------------------------------------------*/
138
139typedef void
140(cs_lagr_moment_p_data_t) (const void *input,
141 const void *particle,
142 const cs_lagr_attribute_map_t *p_am,
143 cs_real_t vals[]);
144
145/*----------------------------------------------------------------------------
146 * Function pointer for computation of event data values for
147 * Lagrangian statistics.
148 *
149 * Note: if the input pointer is non-null, it must point to valid data
150 * when the selection function is called, so that value or structure should
151 * not be temporary (i.e. local);
152 *
153 * parameters:
154 * input <-- pointer to optional (untyped) value or structure.
155 * events <-- pointer to events
156 * event_id <-- event id range (first to past-last)
157 * vals --> pointer to values
158 *----------------------------------------------------------------------------*/
159
160typedef void
161(cs_lagr_moment_e_data_t) (const void *input,
162 const cs_lagr_event_set_t *events,
163 cs_lnum_t id_range[2],
164 cs_real_t vals[]);
165
166/*----------------------------------------------------------------------------
167 * Function pointer for computation of data values for particle statistics
168 * based on mesh
169 *
170 * If the matching values are multidimensional, they must be interleaved.
171 *
172 * Note: if the input pointer is non-null, it must point to valid data
173 * when the selection function is called, so that value or structure should
174 * not be temporary (i.e. local);
175 *
176 * parameters:
177 * input <-- pointer to optional value or structure, or NULL
178 * events <-- pointer to optional events set, or NULL.
179 * location_id <-- associated mesh location id
180 * class_id <-- associated particle class id (0 for all)
181 * vals --> pointer to values (size: n_local elements*dimension)
182 *----------------------------------------------------------------------------*/
183
184typedef void
185(cs_lagr_moment_m_data_t) (const void *input,
186 const cs_lagr_event_set_t *events,
187 int location_id,
188 int class_id,
189 cs_real_t vals[]);
190
193typedef struct {
194
200
204
214
218
220
221/*============================================================================
222 * Global variables
223 *============================================================================*/
224
225/* Pointer to global statistic options structure */
226
228
229/*============================================================================
230 * Public function prototypes
231 *============================================================================*/
232
233/*----------------------------------------------------------------------------*/
261/*----------------------------------------------------------------------------*/
262
263int
264cs_lagr_stat_particle_define(const char *name,
265 int location_id,
266 int stat_type,
268 int class_id,
269 int dim,
270 int component_id,
271 cs_lagr_moment_p_data_t *data_func,
272 void *data_input,
273 cs_lagr_moment_p_data_t *w_data_func,
274 void *w_data_input,
275 int nt_start,
276 double t_start,
277 cs_lagr_stat_restart_t restart_mode);
278
279/*----------------------------------------------------------------------------*/
307/*----------------------------------------------------------------------------*/
308
309int
310cs_lagr_stat_event_define(const char *name,
311 int location_id,
312 int stat_type,
313 cs_lagr_stat_group_t stat_group,
315 int class_id,
316 int dim,
317 int component_id,
318 cs_lagr_moment_e_data_t *data_func,
319 void *data_input,
320 cs_lagr_moment_e_data_t *w_data_func,
321 void *w_data_input,
322 int nt_start,
323 double t_start,
324 cs_lagr_stat_restart_t restart_mode);
325
326/*----------------------------------------------------------------------------*/
351/*----------------------------------------------------------------------------*/
352
353int
354cs_lagr_stat_accumulator_define(const char *name,
355 int location_id,
356 cs_lagr_stat_group_t stat_group,
357 int class_id,
358 cs_lagr_moment_p_data_t *p_data_func,
359 cs_lagr_moment_e_data_t *e_data_func,
360 void *data_input,
361 int nt_start,
362 double t_start,
363 cs_lagr_stat_restart_t restart_mode);
364
365/*----------------------------------------------------------------------------*/
392/*----------------------------------------------------------------------------*/
393
394int
395cs_lagr_stat_mesh_define(const char *name,
396 int location_id,
397 cs_lagr_stat_group_t stat_group,
398 int class_id,
399 int dim,
400 cs_lagr_moment_m_data_t *data_func,
401 void *data_input,
402 int nt_start,
403 double t_start);
404
405/*----------------------------------------------------------------------------*/
438/*----------------------------------------------------------------------------*/
439
440int
441cs_lagr_stat_time_moment_define(const char *name,
442 int location_id,
443 int stat_type,
445 int class_id,
446 int dim,
447 int component_id,
448 cs_lagr_moment_m_data_t *data_func,
449 void *data_input,
450 int nt_start,
451 double t_start,
452 cs_lagr_stat_restart_t restart_mode);
453
454/*----------------------------------------------------------------------------*/
462/*----------------------------------------------------------------------------*/
463
464void
465cs_lagr_stat_activate(int stat_type);
466
467/*----------------------------------------------------------------------------*/
481/*----------------------------------------------------------------------------*/
482
483void
485 cs_lagr_stat_moment_t moment);
486
487/*----------------------------------------------------------------------------*/
495/*----------------------------------------------------------------------------*/
496
497void
498cs_lagr_stat_deactivate(int stat_type);
499
500/*----------------------------------------------------------------------------*/
508/*----------------------------------------------------------------------------*/
509
510void
511cs_lagr_stat_activate_attr(int attr_id);
512
513/*----------------------------------------------------------------------------*/
521/*----------------------------------------------------------------------------*/
522
523void
525
526/*---------------------------------------------------------------------------*/
535/*---------------------------------------------------------------------------*/
536
537int
539
540/*---------------------------------------------------------------------------*/
548/*---------------------------------------------------------------------------*/
549
550int
551cs_lagr_stat_type_to_attr_id(int stat_type);
552
553/*----------------------------------------------------------------------------*/
561/*----------------------------------------------------------------------------*/
562
563int
564cs_lagr_stat_type_by_name(const char *name);
565
566/*----------------------------------------------------------------------------*/
575/*----------------------------------------------------------------------------*/
576
577void
579
580/*----------------------------------------------------------------------------*/
591/*----------------------------------------------------------------------------*/
592
593void
595
596/*----------------------------------------------------------------------------*/
604/*----------------------------------------------------------------------------*/
605
606bool
608
609/*----------------------------------------------------------------------------*/
613/*----------------------------------------------------------------------------*/
614
615void
617
618/*----------------------------------------------------------------------------*/
622/*----------------------------------------------------------------------------*/
623
624void
626
627/*----------------------------------------------------------------------------*/
631/*----------------------------------------------------------------------------*/
632
633void
635
636/*----------------------------------------------------------------------------*/
646/*----------------------------------------------------------------------------*/
647
648void
651
652/*----------------------------------------------------------------------------*/
656/*----------------------------------------------------------------------------*/
657
658void
660
661/*----------------------------------------------------------------------------*/
665/*----------------------------------------------------------------------------*/
666
667void
669
670/*----------------------------------------------------------------------------*/
674/*----------------------------------------------------------------------------*/
675
676void
678
679/*----------------------------------------------------------------------------*/
685/*----------------------------------------------------------------------------*/
686
687void
689
690/*----------------------------------------------------------------------------*/
704/*----------------------------------------------------------------------------*/
705
707cs_lagr_stat_get_moment(int stat_type,
708 cs_lagr_stat_group_t stat_group,
710 int class_id,
711 int component_id);
712
713/*----------------------------------------------------------------------------*/
721/*----------------------------------------------------------------------------*/
722
724cs_lagr_stat_get_stat_weight(int class_id);
725
726/*----------------------------------------------------------------------------*/
732/*----------------------------------------------------------------------------*/
733
736
737/*----------------------------------------------------------------------------*/
745/*----------------------------------------------------------------------------*/
746
749
750/*----------------------------------------------------------------------------*/
751
753
754#endif /* __CS_LAGR_STAT_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
@ dt
Definition: cs_field_pointer.h:65
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:3965
void cs_lagr_stat_activate_attr(int attr_id)
Activate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.cpp:4247
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:3757
void cs_lagr_stat_deactivate_attr(int attr_id)
Deactivate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.cpp:4263
cs_lagr_stat_type_t
Definition: cs_lagr_stat.h:86
@ CS_LAGR_STAT_VOLUME_FRACTION
Definition: cs_lagr_stat.h:94
@ CS_LAGR_STAT_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:90
@ CS_LAGR_STAT_E_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:99
@ CS_LAGR_STAT_RESUSPENSION_MASS_FLUX
Definition: cs_lagr_stat.h:108
@ CS_LAGR_STAT_ATTR
Definition: cs_lagr_stat.h:119
@ CS_LAGR_STAT_FOULING_MASS_FLUX
Definition: cs_lagr_stat.h:109
@ CS_LAGR_STAT_RESUSPENSION_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:102
@ CS_LAGR_STAT_MASS_FLUX
Definition: cs_lagr_stat.h:107
@ CS_LAGR_STAT_FOULING_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:105
@ CS_LAGR_STAT_IMPACT_ANGLE
Definition: cs_lagr_stat.h:111
@ CS_LAGR_STAT_IMPACT_VELOCITY
Definition: cs_lagr_stat.h:113
@ CS_LAGR_STAT_FOULING_DIAMETER
Definition: cs_lagr_stat.h:114
@ CS_LAGR_STAT_FOULING_COKE_FRACTION
Definition: cs_lagr_stat.h:115
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:140
cs_lagr_stat_restart_t
Definition: cs_lagr_stat.h:75
@ CS_LAGR_MOMENT_RESTART_EXACT
Definition: cs_lagr_stat.h:79
@ CS_LAGR_MOMENT_RESTART_AUTO
Definition: cs_lagr_stat.h:78
@ CS_LAGR_MOMENT_RESTART_RESET
Definition: cs_lagr_stat.h:77
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:4379
void cs_lagr_stat_log_iteration(void)
Log moment definition information for a given iteration.
Definition: cs_lagr_stat.cpp:5219
cs_lagr_stat_moment_t
Definition: cs_lagr_stat.h:55
@ CS_LAGR_MOMENT_VARIANCE
Definition: cs_lagr_stat.h:58
@ CS_LAGR_MOMENT_MEAN
Definition: cs_lagr_stat.h:57
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:3824
cs_lagr_stat_group_t
Definition: cs_lagr_stat.h:64
@ CS_LAGR_STAT_GROUP_TRACKING_EVENT
Definition: cs_lagr_stat.h:67
@ CS_LAGR_STAT_GROUP_PARTICLE
Definition: cs_lagr_stat.h:66
@ CS_LAGR_STAT_GROUP_N_GROUPS
Definition: cs_lagr_stat.h:69
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:4734
void cs_lagr_stat_finalize(void)
Destroy all moments management metadata.
Definition: cs_lagr_stat.cpp:5081
void cs_lagr_stat_initialize(void)
Lagrangian statistics initialization.
Definition: cs_lagr_stat.cpp:4398
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:4088
void cs_lagr_stat_activate(int stat_type)
Activate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.cpp:4138
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:5820
void cs_lagr_stat_prepare(void)
Prepare particle statistics for a given time step.
Definition: cs_lagr_stat.cpp:4627
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:5727
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:4280
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:161
cs_field_t * cs_lagr_stat_get_stat_weight(int class_id)
Return statistical weight.
Definition: cs_lagr_stat.cpp:5769
void cs_lagr_stat_restart_write(cs_restart_t *restart)
Checkpoint moment data.
Definition: cs_lagr_stat.cpp:5364
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:4298
void cs_lagr_stat_log_setup(void)
Log moment definition setup information.
Definition: cs_lagr_stat.cpp:5100
int cs_lagr_stat_type_by_name(const char *name)
Determine a basic statistic type by its base name.
Definition: cs_lagr_stat.cpp:4319
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:4195
void cs_lagr_stat_restart_read(void)
Read particle statistics restart info if needed.
Definition: cs_lagr_stat.cpp:4610
void cs_lagr_stat_update(void)
Update particle statistics for a given time step.
Definition: cs_lagr_stat.cpp:4693
void cs_lagr_stat_deactivate(int stat_type)
Deactivate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.cpp:4223
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:4594
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:185
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:3891
cs_real_t cs_lagr_stat_get_age(void)
Return global volume statistics age.
Definition: cs_lagr_stat.cpp:5792
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:95
Field descriptor.
Definition: cs_field.h:131
Definition: cs_lagr_particle.h:189
Definition: cs_lagr_event.h:130
Definition: cs_lagr_stat.h:193
int idstnt
Definition: cs_lagr_stat.h:203
cs_real_t threshold
Definition: cs_lagr_stat.h:217
int nstist
Definition: cs_lagr_stat.h:213
int isuist
Definition: cs_lagr_stat.h:199