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-2021 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 
43 BEGIN_C_DECLS
44 
45 /*=============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53  /*! Particle statistics moment type */
54 
55 typedef enum {
56 
57   CS_LAGR_MOMENT_MEAN,
58   CS_LAGR_MOMENT_VARIANCE
59 
60 } cs_lagr_stat_moment_t;
61 
62  /*! Particle statistics moment data type */
63 
64 typedef enum {
65 
66   CS_LAGR_STAT_GROUP_PARTICLE,
67   CS_LAGR_STAT_GROUP_TRACKING_EVENT,
68 
69   CS_LAGR_STAT_GROUP_N_GROUPS
70 
71 } cs_lagr_stat_group_t;
72 
73 /*! Moment restart behavior */
74 
75 typedef enum {
76 
77   CS_LAGR_MOMENT_RESTART_RESET,
78   CS_LAGR_MOMENT_RESTART_AUTO,
79   CS_LAGR_MOMENT_RESTART_EXACT
80 
81 } cs_lagr_stat_restart_t;
82 
83 /*! Predefined particle and event statistics */
84 /* ----------------------------------------- */
85 
86 typedef enum {
87 
88   /* Volume statistics */
89 
90   CS_LAGR_STAT_CUMULATIVE_WEIGHT,        /*!< cumulative particle statistical
91                                            weight (active if any particle
92                                            attribute statistics are active,
93                                            may be activated separately) */
94   CS_LAGR_STAT_VOLUME_FRACTION,          /*!< particle volume fraction */
95 
96   /* Boundary statistics */
97 
98   /*! cumulative particle event  statistical weight */
99   CS_LAGR_STAT_E_CUMULATIVE_WEIGHT,
100 
101   /*! cumulative fouling event statistical weight */
102   CS_LAGR_STAT_RESUSPENSION_CUMULATIVE_WEIGHT,
103 
104   /*! cumulative fouling event statistical weight */
105   CS_LAGR_STAT_FOULING_CUMULATIVE_WEIGHT,
106 
107   CS_LAGR_STAT_MASS_FLUX,                /*!< particle mass flux */
108   CS_LAGR_STAT_RESUSPENSION_MASS_FLUX,   /*!< particle resuspension mass flux */
109   CS_LAGR_STAT_FOULING_MASS_FLUX,        /*!< particle fouling mass flux */
110 
111   CS_LAGR_STAT_IMPACT_ANGLE,             /*!< particle impact angle
112                                            (in radians) */
113   CS_LAGR_STAT_IMPACT_VELOCITY,          /*!< particle impact velocity */
114   CS_LAGR_STAT_FOULING_DIAMETER,         /*!< fouled particle diameter */
115   CS_LAGR_STAT_FOULING_COKE_FRACTION,    /*!< fouled particle coke fraction */
116 
117   /* Particle or event-based attributes */
118 
119   CS_LAGR_STAT_ATTR                      /*!< particle or event attribute; add
120                                            attribute id for given attribute */
121 
122 } cs_lagr_stat_type_t;
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
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 
160 typedef 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 
184 typedef 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 
191 /*! Structure defining Lagrangian statistics options */
192 
193 typedef struct {
194 
195   /*! during a Lagrangian calculation restart, indicates whether the particle
196     statistics (volume and boundary) and two-way coupling terms are to be read
197     from a restart file (=1) or reinitialized (=0).
198     Useful if \ref cs_lagr_time_scheme_t::isuila "isuila" = 1 */
199   int  isuist;
200 
201   /*! absolute time step number (including the restarts) after
202     which the calculation of the volume statistics is activated. */
203   int  idstnt;
204 
205   /*! absolute time step number (includings the restarts) after
206     which the volume statistics are cumulated over time (they are then said
207     to be steady).
208     if the absolute time step number is lower than \ref nstist,
209     or if the flow is unsteady (\ref cs_lagr_time_scheme_t::isttio "isttio"=0),
210     the statistics are reset to zero at every time step (the volume statistics
211     are then said to be non-steady).
212     Useful if \ref cs_lagr_time_scheme_t::isttio "isttio" = 1 */
213   int  nstist;
214 
215   /*! threshold for statistical meaning when used by other model
216     features (such as the Poisson correction) */
217   cs_real_t  threshold;
218 
219 } cs_lagr_stat_options_t;
220 
221 /*============================================================================
222  * Global variables
223  *============================================================================*/
224 
225 /* Pointer to global statistic options structure */
226 
227 extern cs_lagr_stat_options_t   *cs_glob_lagr_stat_options;
228 
229 /*============================================================================
230  * Public function prototypes
231  *============================================================================*/
232 
233 /*----------------------------------------------------------------------------*/
234 /*!
235  * \brief Define a particle-based statistic.
236  *
237  * If dimension > 1, the val array is interleaved
238  *
239  * \param[in]  name           statistics base name
240  * \param[in]  location_id    id of associated mesh location
241  * \param[in]  stat_type      predefined statistics type, or -1
242  * \param[in]  stat_group     statistics group (particle or event)
243  * \param[in]  m_type         moment type
244  * \param[in]  class_id       particle class id, or 0 for all
245  * \param[in]  dim            dimension associated with element data
246  * \param[in]  component_id   attribute component id, or < 0 for all
247  * \param[in]  data_func      pointer to function to compute statistics
248  *                            (if stat_type < 0)
249  * \param[in]  data_input     associated input
250  * \param[in]  w_data_func    pointer to function to compute weight
251  *                            (if NULL, statistic weight assumed)
252  * \param[in]  w_data_input   associated input for w_data_func
253  * \param[in]  nt_start       starting time step (or -1 to use t_start,
254  *                            0 to use idstnt)
255  * \param[in]  t_start        starting time
256  * \param[in]  restart_mode   behavior in case of restart (reset,
257  *                            automatic, or strict)
258  *
259  * \return id of new moment in case of success, -1 in case of error.
260  */
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 /*----------------------------------------------------------------------------*/
280 /*!
281  * \brief Define an event-based statistic.
282  *
283  * If dimension > 1, the val array is interleaved
284  *
285  * \param[in]  name           statistics base name
286  * \param[in]  location_id    id of associated mesh location
287  * \param[in]  stat_type      predefined statistics type, or -1
288  * \param[in]  stat_group     statistics group (event type)
289  * \param[in]  m_type         moment type
290  * \param[in]  class_id       particle class id, or 0 for all
291  * \param[in]  dim            dimension associated with element data
292  * \param[in]  component_id   attribute component id, or < 0 for all
293  * \param[in]  data_func      pointer to function to compute statistics
294  *                            (if stat_type < 0)
295  * \param[in]  data_input     associated input
296  * \param[in]  w_data_func    pointer to function to compute weight
297  *                            (if NULL, statistic weight assumed)
298  * \param[in]  w_data_input   associated input for w_data_func
299  * \param[in]  nt_start       starting time step (or -1 to use t_start,
300  *                            0 to use idstnt)
301  * \param[in]  t_start        starting time
302  * \param[in]  restart_mode   behavior in case of restart (reset,
303  *                            automatic, or strict)
304  *
305  * \return id of new moment in case of success, -1 in case of error.
306  */
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 /*----------------------------------------------------------------------------*/
327 /*!
328  * \brief Define a particle weight type statistic.
329  *
330  * Weights are automatically associated to general statitistics, but defining
331  * them explicitely allows activation of standard logging and postprocessing
332  * for those weights, as well as defining specific weights.
333  *
334  * \param[in]  name           statistics base name
335  * \param[in]  location_id    id of associated mesh location
336  * \param[in]  stat_group     statistics group (particle or event)
337  * \param[in]  class_id       particle class id, or 0 for all
338  * \param[in]  p_data_func    pointer to function to compute particle weight
339  *                            (if NULL, statistic weight assumed)
340  * \param[in]  e_data_func    pointer to function to compute event weight
341  *                            (if NULL, statistic weight assumed)
342  * \param[in]  data_input     associated input for data_func
343  * \param[in]  nt_start       starting time step (or -1 to use t_start,
344  *                            0 to use idstnt)
345  * \param[in]  t_start        starting time
346  * \param[in]  restart_mode   behavior in case of restart (reset,
347  *                            automatic, or strict)
348  *
349  * \return id of new moment in case of success, -1 in case of error.
350  */
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 /*----------------------------------------------------------------------------*/
366 /*!
367  * \brief Define mesh-based statistic based on particles or particle events.
368  *
369  * This type of statistic is reinitialized and evaluated during each time step,
370  * but may be computed incrementally when based on particle events, so the
371  * associated data function must uptate the statistics without reinitializing
372  * them at each call.
373  *
374  * As this type of statistic does not need to keep state between time steps,
375  * it is ignored by the lagragian statistics checkpoint/restart mechanism.
376  *
377  * If dimension > 1, the val array is interleaved
378  *
379  * \param[in]  name           statistics base name
380  * \param[in]  location_id    id of associated mesh location
381  * \param[in]  stat_group     statistics group (particle or event)
382  * \param[in]  class_id       particle class id, or 0 for all
383  * \param[in]  dim            dimension associated with element data
384  * \param[in]  data_func      pointer to function to compute statistics
385  * \param[in]  data_input     associated input
386  * \param[in]  nt_start       starting time step (or -1 to use t_start,
387  *                            0 to use idstnt)
388  * \param[in]  t_start        starting time
389  *
390  * \return id of new moment in case of success, -1 in case of error.
391  */
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 /*----------------------------------------------------------------------------*/
406 /*!
407  * \brief Define a time moment associated to particle statistics.
408  *
409  * This is similar to general time moments (see \ref cs_time_moment.c),
410  * with restart, logging, and unsteady reinitialization behavior
411  * aligned with other particle statistics.
412  *
413  * Time moments must be based on values available at the end of each
414  * time step, so they cannot be based directly on events (though they
415  * can be based on fields defined through \ref cs_lagr_stat_mesh_define,
416  * as the matching event-based fields will be updated first).
417  *
418  * If dimension > 1, the val array is interleaved
419  *
420  * \param[in]  name           statistics base name
421  * \param[in]  location_id    id of associated mesh location
422  * \param[in]  stat_type      predefined statistics type, or -1
423  * \param[in]  m_type         moment type
424  * \param[in]  class_id       particle class id, or 0 for all
425  * \param[in]  dim            dimension associated with element data
426  * \param[in]  component_id   attribute component id, or < 0 for all
427  * \param[in]  data_func      pointer to function to compute statistics
428  *                            (if stat_type < 0)
429  * \param[in]  data_input     associated input
430  * \param[in]  nt_start       starting time step (or -1 to use t_start,
431  *                            0 to use idstnt)
432  * \param[in]  t_start        starting time
433  * \param[in]  restart_mode   behavior in case of restart (reset,
434  *                            automatic, or strict)
435  *
436  * \return id of new moment in case of success, -1 in case of error.
437  */
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 /*----------------------------------------------------------------------------*/
455 /*!
456  * \brief Activate Lagrangian statistics for a given statistics type.
457  *
458  * This function is ignored if called after \ref cs_lagr_stat_initialize.
459  *
460  * \param[in]  stat_type   particle statistics type
461  */
462 /*----------------------------------------------------------------------------*/
463 
464 void
465 cs_lagr_stat_activate(int  stat_type);
466 
467 /*----------------------------------------------------------------------------*/
468 /*!
469  * \brief Activate time moment for some predefined Lagrangian statistics types.
470  *
471  * By default, statistics such as mass flows are based on a current time step,
472  * and time moments are not computed by default. This function allows forcing
473  * the associated moment level so that it is computed also.
474  *
475  * Note that requesting a higher order moment will automatically include lower
476  * order moments, so activating the variance also activates the mean.
477  *
478  * \param[in]  stat_type   particle statistics type
479  * \param[in]  moment      associated time moment level
480  */
481 /*----------------------------------------------------------------------------*/
482 
483 void
484 cs_lagr_stat_activate_time_moment(int                    stat_type,
485                                   cs_lagr_stat_moment_t  moment);
486 
487 /*----------------------------------------------------------------------------*/
488 /*!
489  * \brief Deactivate Lagrangian statistics for a given statistics type.
490  *
491  * This function is ignored if called after \ref cs_lagr_stat_initialize.
492  *
493  * \param[in]  stat_type   particle statistics type
494  */
495 /*----------------------------------------------------------------------------*/
496 
497 void
498 cs_lagr_stat_deactivate(int  stat_type);
499 
500 /*----------------------------------------------------------------------------*/
501 /*!
502  * \brief Activate Lagrangian statistics for a given particle attribute.
503  *
504  * This function is ignored if called after \ref cs_lagr_stat_initialize.
505  *
506  * \param[in]  attr_id   particle attribute id
507  */
508 /*----------------------------------------------------------------------------*/
509 
510 void
511 cs_lagr_stat_activate_attr(int  attr_id);
512 
513 /*----------------------------------------------------------------------------*/
514 /*!
515  * \brief Deactivate Lagrangian statistics for a given particle attribute.
516  *
517  * This function is ignored if called after \ref cs_lagr_stat_initialize.
518  *
519  * \param[in]  attr_id   particle attribute id
520  */
521 /*----------------------------------------------------------------------------*/
522 
523 void
524 cs_lagr_stat_deactivate_attr(int  attr_id);
525 
526 /*---------------------------------------------------------------------------*/
527 /*!
528  * \brief Return statistics type associated with a given particle
529  *        attribute id.
530  *
531  * \param[in]  attr_id  particle  attribute id
532  *
533  * \return  associated  particle statistics type id
534  */
535 /*---------------------------------------------------------------------------*/
536 
537 int
538 cs_lagr_stat_type_from_attr_id(int attr_id);
539 
540 /*---------------------------------------------------------------------------*/
541 /*!
542  * \brief Return attribute id associated with a given statistics type.
543  *
544  * \param[in]   stat_type     particle statistics type
545  *
546  * \return attribute id, or -1 if not applicable
547  */
548 /*---------------------------------------------------------------------------*/
549 
550 int
551 cs_lagr_stat_type_to_attr_id(int  stat_type);
552 
553 /*----------------------------------------------------------------------------*/
554 /*!
555  * \brief Determine a basic statistic type by its base name.
556  *
557  * \param[in]  name  particle statistics base name (without class id)
558  *
559  * \return  matching stat type id, or -1 if not found
560  */
561 /*----------------------------------------------------------------------------*/
562 
563 int
564 cs_lagr_stat_type_by_name(const char  *name);
565 
566 /*----------------------------------------------------------------------------*/
567 /*!
568  * \brief Map time step values array for Lagrangian statistics.
569  *
570  * If this function is not called, the field referenced by field pointer
571  * CS_F_(dt) will be used instead.
572  *
573  * \param[in]   dt   pointer to time step values array
574  */
575 /*----------------------------------------------------------------------------*/
576 
577 void
578 cs_lagr_stat_map_cell_dt(const cs_real_t  *dt);
579 
580 /*----------------------------------------------------------------------------*/
581 /*!
582  * \brief Lagrangian statistics initialization.
583  *
584  * Statistics activated or deactivated by previous calls to
585  * \ref cs_lagr_stat_activate, \ref cs_lagr_stat_deactivate,
586  * \ref cs_lagr_stat_activate_attr, and \ref cs_lagr_stat_deactivate_attr
587  * will be initialized here.
588  *
589  * Restart info will be used after to fill in the moments structure
590  */
591 /*----------------------------------------------------------------------------*/
592 
593 void
594 cs_lagr_stat_initialize(void);
595 
596 /*----------------------------------------------------------------------------*/
597 /*!
598  * \brief Indicate if a given statistics type has active statistics.
599  *
600  * \param[in]  group   event group to update
601  *
602  * \return true if statistics are active for the given group
603  */
604 /*----------------------------------------------------------------------------*/
605 
606 bool
607 cs_lagr_stat_is_active( cs_lagr_stat_group_t   group);
608 
609 /*----------------------------------------------------------------------------*/
610 /*!
611  * \brief Read particle statistics restart info if needed.
612  */
613 /*----------------------------------------------------------------------------*/
614 
615 void
616 cs_lagr_stat_restart_read(void);
617 
618 /*----------------------------------------------------------------------------*/
619 /*!
620  * \brief Prepare particle statistics for a given time step.
621  */
622 /*----------------------------------------------------------------------------*/
623 
624 void
625 cs_lagr_stat_prepare(void);
626 
627 /*----------------------------------------------------------------------------*/
628 /*!
629  * \brief Update particle statistics for a given time step.
630  */
631 /*----------------------------------------------------------------------------*/
632 
633 void
634 cs_lagr_stat_update(void);
635 
636 /*----------------------------------------------------------------------------*/
637 /*!
638  * \brief Update event-based moment accumulators.
639  *
640  * Partial updates are allowed, so as to balance memory cost for storing
641  * events and repetition of mesh-location-based weight updates.
642  *
643  * \param[in]  events  pointer to event set
644  * \param[in]  group   event group to update
645  */
646 /*----------------------------------------------------------------------------*/
647 
648 void
649 cs_lagr_stat_update_event(cs_lagr_event_set_t   *events,
650                           cs_lagr_stat_group_t   group);
651 
652 /*----------------------------------------------------------------------------*/
653 /*!
654  * \brief Destroy all moments management metadata.
655  */
656 /*----------------------------------------------------------------------------*/
657 
658 void
659 cs_lagr_stat_finalize(void);
660 
661 /*----------------------------------------------------------------------------*/
662 /*!
663  * \brief Log moment definition setup information
664  */
665 /*----------------------------------------------------------------------------*/
666 
667 void
668 cs_lagr_stat_log_setup(void);
669 
670 /*----------------------------------------------------------------------------*/
671 /*!
672  * \brief Log moment definition information for a given iteration.
673  */
674 /*----------------------------------------------------------------------------*/
675 
676 void
677 cs_lagr_stat_log_iteration(void);
678 
679 /*----------------------------------------------------------------------------*/
680 /*!
681  * \brief Checkpoint moment data
682  *
683  * \param[in]  restart  associated restart file pointer
684  */
685 /*----------------------------------------------------------------------------*/
686 
687 void
688 cs_lagr_stat_restart_write(cs_restart_t  *restart);
689 
690 /*----------------------------------------------------------------------------*/
691 /*!
692  * \brief Return field associated with a given Lagrangian statistic,
693  *        given a statistics type (i.e. variable), group (particles or event),
694  *        moment order, statistical class, and component id.
695  *
696  * \param[in]  stat_type     statistics type
697  * \param[in]  stat_group    statistics group (particle or event)
698  * \param[in]  m_type        moment type (mean or variance)
699  * \param[in]  class_id      particle statistical class
700  * \param[in]  component_id  component id, or -1 for all
701  *
702  * \returns pointer to the field associated to the corresponding moment
703  */
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 /*----------------------------------------------------------------------------*/
714 /*!
715  * \brief Return statistical weight
716  *
717  * \param[in]  class_id    particle statistical class
718  *
719  * \returns pointer to the field associated to the corresponding weight
720  */
721 /*----------------------------------------------------------------------------*/
722 
723 cs_field_t *
724 cs_lagr_stat_get_stat_weight(int  class_id);
725 
726 /*----------------------------------------------------------------------------*/
727 /*!
728  * \brief Return global volume statistics age
729  *
730  * \returns age of volume statistics, or -1 if statistics not active yet
731  */
732 /*----------------------------------------------------------------------------*/
733 
734 cs_real_t
735 cs_lagr_stat_get_age(void);
736 
737 /*----------------------------------------------------------------------------*/
738 /*!
739  * \brief Return statistics age for a given moment
740  *
741  * \param[in]  f  field associated with given statistic
742  *
743  * \returns age of given statistic, or -1 if not active yet
744  */
745 /*----------------------------------------------------------------------------*/
746 
747 cs_real_t
748 cs_lagr_stat_get_moment_age(cs_field_t  *f);
749 
750 /*----------------------------------------------------------------------------*/
751 
752 END_C_DECLS
753 
754 #endif /* __CS_LAGR_STAT_H__ */
755