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 /*----------------------------------------------------------------------------*/
562 /*----------------------------------------------------------------------------*/
563 
564 void
566 
567 /*----------------------------------------------------------------------------*/
578 /*----------------------------------------------------------------------------*/
579 
580 void
582 
583 /*----------------------------------------------------------------------------*/
591 /*----------------------------------------------------------------------------*/
592 
593 bool
595 
596 /*----------------------------------------------------------------------------*/
600 /*----------------------------------------------------------------------------*/
601 
602 void
604 
605 /*----------------------------------------------------------------------------*/
609 /*----------------------------------------------------------------------------*/
610 
611 void
613 
614 /*----------------------------------------------------------------------------*/
618 /*----------------------------------------------------------------------------*/
619 
620 void
621 cs_lagr_stat_update(void);
622 
623 /*----------------------------------------------------------------------------*/
633 /*----------------------------------------------------------------------------*/
634 
635 void
637  cs_lagr_stat_group_t group);
638 
639 /*----------------------------------------------------------------------------*/
643 /*----------------------------------------------------------------------------*/
644 
645 void
647 
648 /*----------------------------------------------------------------------------*/
652 /*----------------------------------------------------------------------------*/
653 
654 void
656 
657 /*----------------------------------------------------------------------------*/
661 /*----------------------------------------------------------------------------*/
662 
663 void
665 
666 /*----------------------------------------------------------------------------*/
672 /*----------------------------------------------------------------------------*/
673 
674 void
676 
677 /*----------------------------------------------------------------------------*/
691 /*----------------------------------------------------------------------------*/
692 
693 cs_field_t *
694 cs_lagr_stat_get_moment(int stat_type,
695  cs_lagr_stat_group_t stat_group,
696  cs_lagr_stat_moment_t m_type,
697  int class_id,
698  int component_id);
699 
700 /*----------------------------------------------------------------------------*/
708 /*----------------------------------------------------------------------------*/
709 
710 cs_field_t *
711 cs_lagr_stat_get_stat_weight(int class_id);
712 
713 /*----------------------------------------------------------------------------*/
719 /*----------------------------------------------------------------------------*/
720 
721 cs_real_t
723 
724 /*----------------------------------------------------------------------------*/
732 /*----------------------------------------------------------------------------*/
733 
734 cs_real_t
736 
737 /*----------------------------------------------------------------------------*/
738 
740 
741 #endif /* __CS_LAGR_STAT_H__ */
Definition: cs_lagr_event.h:130
void cs_lagr_stat_prepare(void)
Prepare particle statistics for a given time step.
Definition: cs_lagr_stat.c:4531
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:4498
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:3730
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:5628
Field descriptor.
Definition: cs_field.h:124
Definition: cs_lagr_stat.h:57
Definition: cs_lagr_stat.h:69
Definition: cs_lagr_stat.h:58
Definition: cs_lagr_stat.h:67
Definition: cs_lagr_stat.h:99
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
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:3938
void cs_lagr_stat_activate_attr(int attr_id)
Activate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.c:4220
Definition: cs_lagr_stat.h:90
Definition: cs_lagr_stat.h:193
void cs_lagr_stat_restart_read(void)
Read particle statistics restart info if needed.
Definition: cs_lagr_stat.c:4514
void cs_lagr_stat_restart_write(cs_restart_t *restart)
Checkpoint moment data.
Definition: cs_lagr_stat.c:5265
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:4293
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:3797
cs_lagr_stat_options_t * cs_glob_lagr_stat_options
Definition: cs_lagr_stat.c:298
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:4168
Definition: cs_lagr_stat.h:94
Definition: cs_lagr_stat.h:108
cs_lagr_stat_group_t
Definition: cs_lagr_stat.h:64
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_lagr_stat_moment_t
Definition: cs_lagr_stat.h:55
Definition: cs_lagr_stat.h:119
void cs_lagr_stat_deactivate_attr(int attr_id)
Deactivate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.c:4236
Definition: cs_lagr_stat.h:66
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:4271
Definition: cs_lagr_stat.h:77
void cs_lagr_stat_deactivate(int stat_type)
Deactivate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.c:4196
Definition: cs_lagr_stat.h:78
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:3864
Definition: cs_field_pointer.h:65
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:4061
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
int nstist
Definition: cs_lagr_stat.h:213
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:4253
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:87
static int input(void)
void cs_lagr_stat_log_iteration(void)
Log moment definition information for a given iteration.
Definition: cs_lagr_stat.c:5120
void cs_lagr_stat_update(void)
Update particle statistics for a given time step.
Definition: cs_lagr_stat.c:4597
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:4638
Definition: cs_lagr_stat.h:105
cs_real_t threshold
Definition: cs_lagr_stat.h:217
Definition: cs_lagr_stat.h:102
void cs_lagr_stat_log_setup(void)
Log moment definition setup information.
Definition: cs_lagr_stat.c:5001
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:5716
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
void cs_lagr_stat_initialize(void)
Lagrangian statistics initialization.
Definition: cs_lagr_stat.c:4312
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 idstnt
Definition: cs_lagr_stat.h:203
Definition: cs_lagr_stat.h:115
cs_lagr_stat_restart_t
Definition: cs_lagr_stat.h:75
#define END_C_DECLS
Definition: cs_defs.h:468
void cs_lagr_stat_finalize(void)
Destroy all moments management metadata.
Definition: cs_lagr_stat.c:4982
Definition: cs_lagr_stat.h:109
cs_field_t * cs_lagr_stat_get_stat_weight(int class_id)
Return statistical weight.
Definition: cs_lagr_stat.c:5665
void cs_lagr_stat_activate(int stat_type)
Activate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.c:4111
cs_real_t cs_lagr_stat_get_age(void)
Return global volume statistics age.
Definition: cs_lagr_stat.c:5688
Definition: cs_lagr_stat.h:113
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
int isuist
Definition: cs_lagr_stat.h:199
Definition: cs_lagr_stat.h:111
Definition: cs_lagr_particle.h:176
Definition: cs_lagr_stat.h:79
Definition: cs_lagr_stat.h:107
cs_lagr_stat_type_t
Definition: cs_lagr_stat.h:86
Definition: cs_lagr_stat.h:114