My Project
programmer's 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-2019 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 
55 typedef enum {
56 
59 
61 
64 typedef enum {
65 
68 
70 
72 
75 typedef enum {
76 
80 
82 
84 /* ----------------------------------------- */
85 
86 typedef 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 
139 typedef void
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 
160 typedef void
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 
184 typedef void
186  const cs_lagr_event_set_t *events,
187  int location_id,
188  int class_id,
189  cs_real_t vals[]);
190 
193 typedef struct {
194 
199  int isuist;
200 
203  int idstnt;
204 
213  int nstist;
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 
263 int
264 cs_lagr_stat_particle_define(const char *name,
265  int location_id,
266  int stat_type,
267  cs_lagr_stat_moment_t m_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 
309 int
310 cs_lagr_stat_event_define(const char *name,
311  int location_id,
312  int stat_type,
313  cs_lagr_stat_group_t stat_group,
314  cs_lagr_stat_moment_t m_type,
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 
353 int
354 cs_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 
394 int
395 cs_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 
440 int
441 cs_lagr_stat_time_moment_define(const char *name,
442  int location_id,
443  int stat_type,
444  cs_lagr_stat_moment_t m_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 
464 void
465 cs_lagr_stat_activate(int stat_type);
466 
467 /*----------------------------------------------------------------------------*/
481 /*----------------------------------------------------------------------------*/
482 
483 void
485  cs_lagr_stat_moment_t moment);
486 
487 /*----------------------------------------------------------------------------*/
495 /*----------------------------------------------------------------------------*/
496 
497 void
498 cs_lagr_stat_deactivate(int stat_type);
499 
500 /*----------------------------------------------------------------------------*/
508 /*----------------------------------------------------------------------------*/
509 
510 void
511 cs_lagr_stat_activate_attr(int attr_id);
512 
513 /*----------------------------------------------------------------------------*/
521 /*----------------------------------------------------------------------------*/
522 
523 void
524 cs_lagr_stat_deactivate_attr(int attr_id);
525 
526 /*---------------------------------------------------------------------------*/
535 /*---------------------------------------------------------------------------*/
536 
537 int
538 cs_lagr_stat_type_from_attr_id(int attr_id);
539 
540 /*---------------------------------------------------------------------------*/
548 /*---------------------------------------------------------------------------*/
549 
550 int
551 cs_lagr_stat_type_to_attr_id(int stat_type);
552 
553 /*----------------------------------------------------------------------------*/
561 /*----------------------------------------------------------------------------*/
562 
563 int
564 cs_lagr_stat_type_by_name(const char *name);
565 
566 /*----------------------------------------------------------------------------*/
575 /*----------------------------------------------------------------------------*/
576 
577 void
579 
580 /*----------------------------------------------------------------------------*/
591 /*----------------------------------------------------------------------------*/
592 
593 void
595 
596 /*----------------------------------------------------------------------------*/
604 /*----------------------------------------------------------------------------*/
605 
606 bool
608 
609 /*----------------------------------------------------------------------------*/
613 /*----------------------------------------------------------------------------*/
614 
615 void
617 
618 /*----------------------------------------------------------------------------*/
622 /*----------------------------------------------------------------------------*/
623 
624 void
626 
627 /*----------------------------------------------------------------------------*/
631 /*----------------------------------------------------------------------------*/
632 
633 void
634 cs_lagr_stat_update(void);
635 
636 /*----------------------------------------------------------------------------*/
646 /*----------------------------------------------------------------------------*/
647 
648 void
650  cs_lagr_stat_group_t group);
651 
652 /*----------------------------------------------------------------------------*/
656 /*----------------------------------------------------------------------------*/
657 
658 void
660 
661 /*----------------------------------------------------------------------------*/
665 /*----------------------------------------------------------------------------*/
666 
667 void
669 
670 /*----------------------------------------------------------------------------*/
674 /*----------------------------------------------------------------------------*/
675 
676 void
678 
679 /*----------------------------------------------------------------------------*/
685 /*----------------------------------------------------------------------------*/
686 
687 void
689 
690 /*----------------------------------------------------------------------------*/
704 /*----------------------------------------------------------------------------*/
705 
706 cs_field_t *
707 cs_lagr_stat_get_moment(int stat_type,
708  cs_lagr_stat_group_t stat_group,
709  cs_lagr_stat_moment_t m_type,
710  int class_id,
711  int component_id);
712 
713 /*----------------------------------------------------------------------------*/
721 /*----------------------------------------------------------------------------*/
722 
723 cs_field_t *
724 cs_lagr_stat_get_stat_weight(int class_id);
725 
726 /*----------------------------------------------------------------------------*/
732 /*----------------------------------------------------------------------------*/
733 
734 cs_real_t
736 
737 /*----------------------------------------------------------------------------*/
745 /*----------------------------------------------------------------------------*/
746 
747 cs_real_t
749 
750 /*----------------------------------------------------------------------------*/
751 
753 
754 #endif /* __CS_LAGR_STAT_H__ */
cs_lagr_attribute_map_t
Definition: cs_lagr_particle.h:176
cs_lagr_stat_get_stat_weight
cs_field_t * cs_lagr_stat_get_stat_weight(int class_id)
Return statistical weight.
Definition: cs_lagr_stat.c:5742
input
static int input(void)
CS_LAGR_MOMENT_MEAN
Definition: cs_lagr_stat.h:57
cs_lagr_event.h
cs_defs.h
cs_lagr_stat_accumulator_define
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.c:3956
CS_LAGR_STAT_GROUP_TRACKING_EVENT
Definition: cs_lagr_stat.h:67
cs_lagr_stat_event_define
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.c:3815
CS_LAGR_STAT_ATTR
Definition: cs_lagr_stat.h:119
CS_LAGR_STAT_FOULING_DIAMETER
Definition: cs_lagr_stat.h:114
CS_LAGR_STAT_FOULING_MASS_FLUX
Definition: cs_lagr_stat.h:109
cs_lagr_stat_options_t
Definition: cs_lagr_stat.h:193
cs_glob_lagr_stat_options
cs_lagr_stat_options_t * cs_glob_lagr_stat_options
Definition: cs_lagr_stat.c:311
cs_lagr_stat_options_t::threshold
cs_real_t threshold
Definition: cs_lagr_stat.h:217
cs_lagr_stat_moment_t
cs_lagr_stat_moment_t
Definition: cs_lagr_stat.h:55
CS_LAGR_STAT_VOLUME_FRACTION
Definition: cs_lagr_stat.h:94
CS_LAGR_MOMENT_RESTART_AUTO
Definition: cs_lagr_stat.h:78
CS_LAGR_STAT_IMPACT_ANGLE
Definition: cs_lagr_stat.h:111
cs_lagr_stat_deactivate_attr
void cs_lagr_stat_deactivate_attr(int attr_id)
Deactivate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.c:4254
cs_lagr_stat_options_t::idstnt
int idstnt
Definition: cs_lagr_stat.h:203
cs_lagr_stat_particle_define
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.c:3748
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_lagr_stat_type_to_attr_id
int cs_lagr_stat_type_to_attr_id(int stat_type)
Return attribute id associated with a given statistics type.
Definition: cs_lagr_stat.c:4289
CS_LAGR_MOMENT_RESTART_EXACT
Definition: cs_lagr_stat.h:79
cs_lagr_stat_deactivate
void cs_lagr_stat_deactivate(int stat_type)
Deactivate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.c:4214
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
CS_LAGR_STAT_GROUP_PARTICLE
Definition: cs_lagr_stat.h:66
CS_LAGR_STAT_E_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:99
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_lagr_stat_options_t::nstist
int nstist
Definition: cs_lagr_stat.h:213
cs_lagr_moment_p_data_t
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_mesh_define
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.c:3882
CS_LAGR_STAT_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:90
cs_lagr_stat_update
void cs_lagr_stat_update(void)
Update particle statistics for a given time step.
Definition: cs_lagr_stat.c:4674
CS_LAGR_STAT_RESUSPENSION_MASS_FLUX
Definition: cs_lagr_stat.h:108
cs_lagr_stat_restart_write
void cs_lagr_stat_restart_write(cs_restart_t *restart)
Checkpoint moment data.
Definition: cs_lagr_stat.c:5342
cs_lagr_stat_activate_attr
void cs_lagr_stat_activate_attr(int attr_id)
Activate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.c:4238
cs_lagr_stat_map_cell_dt
void cs_lagr_stat_map_cell_dt(const cs_real_t *dt)
Map time step values array for Lagrangian statistics.
Definition: cs_lagr_stat.c:4370
cs_lagr_stat_activate_time_moment
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.c:4186
cs_lagr_stat_log_iteration
void cs_lagr_stat_log_iteration(void)
Log moment definition information for a given iteration.
Definition: cs_lagr_stat.c:5197
cs_lagr_particle.h
CS_LAGR_STAT_GROUP_N_GROUPS
Definition: cs_lagr_stat.h:69
CS_LAGR_MOMENT_VARIANCE
Definition: cs_lagr_stat.h:58
cs_lagr_stat_restart_read
void cs_lagr_stat_restart_read(void)
Read particle statistics restart info if needed.
Definition: cs_lagr_stat.c:4591
cs_lagr_stat_options_t::isuist
int isuist
Definition: cs_lagr_stat.h:199
CS_LAGR_STAT_FOULING_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:105
cs_lagr_stat_type_by_name
int cs_lagr_stat_type_by_name(const char *name)
Determine a basic statistic type by its base name.
Definition: cs_lagr_stat.c:4310
cs_lagr_stat_restart_t
cs_lagr_stat_restart_t
Definition: cs_lagr_stat.h:75
CS_LAGR_STAT_RESUSPENSION_CUMULATIVE_WEIGHT
Definition: cs_lagr_stat.h:102
cs_lagr_moment_m_data_t
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
cs_lagr_stat_group_t
cs_lagr_stat_group_t
Definition: cs_lagr_stat.h:64
cs_field.h
cs_lagr_stat_activate
void cs_lagr_stat_activate(int stat_type)
Activate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.c:4129
CS_LAGR_STAT_FOULING_COKE_FRACTION
Definition: cs_lagr_stat.h:115
cs_lagr.h
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_restart_t
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:87
CS_LAGR_STAT_MASS_FLUX
Definition: cs_lagr_stat.h:107
cs_lagr_moment_e_data_t
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_lagr_stat_time_moment_define
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.c:4079
cs_lagr_stat_type_from_attr_id
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.c:4271
CS_LAGR_MOMENT_RESTART_RESET
Definition: cs_lagr_stat.h:77
cs_lagr_stat_is_active
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.c:4575
cs_lagr_stat_type_t
cs_lagr_stat_type_t
Definition: cs_lagr_stat.h:86
cs_lagr_event_set_t
Definition: cs_lagr_event.h:130
dt
Definition: cs_field_pointer.h:65
cs_lagr_stat_update_event
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.c:4715
cs_lagr_stat_get_moment_age
cs_real_t cs_lagr_stat_get_moment_age(cs_field_t *f)
Return statistics age for a given moment.
Definition: cs_lagr_stat.c:5793
cs_lagr_stat_prepare
void cs_lagr_stat_prepare(void)
Prepare particle statistics for a given time step.
Definition: cs_lagr_stat.c:4608
cs_lagr_stat_initialize
void cs_lagr_stat_initialize(void)
Lagrangian statistics initialization.
Definition: cs_lagr_stat.c:4389
cs_lagr_stat_log_setup
void cs_lagr_stat_log_setup(void)
Log moment definition setup information.
Definition: cs_lagr_stat.c:5078
cs_lagr_stat_get_moment
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.c:5705
cs_restart.h
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_lagr_stat_finalize
void cs_lagr_stat_finalize(void)
Destroy all moments management metadata.
Definition: cs_lagr_stat.c:5059
cs_base.h
CS_LAGR_STAT_IMPACT_VELOCITY
Definition: cs_lagr_stat.h:113
cs_lagr_stat_get_age
cs_real_t cs_lagr_stat_get_age(void)
Return global volume statistics age.
Definition: cs_lagr_stat.c:5765