programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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-2017 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_particle.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*=============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
54 typedef enum {
55 
58 
60 
63 typedef enum {
64 
68 
70 
72 /* ----------------------------------------------------------------- */
73 
74 typedef enum {
75 
87 
88 /*----------------------------------------------------------------------------
89  * Function pointer for computation of particle data values for
90  * Lagrangian statistics.
91  *
92  * Note: if the input pointer is non-NULL, it must point to valid data
93  * when the selection function is called, so that value or structure should
94  * not be temporary (i.e. local);
95  *
96  * parameters:
97  * input <-- pointer to optional (untyped) value or structure.
98  * particle <-- pointer to particle data
99  * p_am <-- pointer to particle attribute map
100  * vals --> pointer to values
101  *----------------------------------------------------------------------------*/
102 
103 typedef void
104 (cs_lagr_moment_p_data_t) (const void *input,
105  const void *particle,
106  const cs_lagr_attribute_map_t *p_am,
107  cs_real_t vals[]);
108 
109 /*----------------------------------------------------------------------------
110  * Function pointer for computation of data values for particle statistics
111  * based on mesh
112  *
113  * If the matching values are multidimensional, they must be interleaved.
114  *
115  * Note: if the input pointer is non-NULL, it must point to valid data
116  * when the selection function is called, so that value or structure should
117  * not be temporary (i.e. local);
118  *
119  * parameters:
120  * input <-- pointer to optional (untyped) value or structure.
121  * location_id <-- associated mesh location id
122  * class_id <-- associated particle class id (0 for all)
123  * vals --> pointer to values (size: n_local elements*dimension)
124  *----------------------------------------------------------------------------*/
125 
126 typedef void
127 (cs_lagr_moment_m_data_t) (const void *input,
128  int location_id,
129  int class_id,
130  cs_real_t vals[]);
131 
134 typedef struct {
135 
140  int isuist;
141 
144  int idstnt;
145 
154  int nstist;
155 
159 
161 
162 /*============================================================================
163  * Global variables
164  *============================================================================*/
165 
166 /* Pointer to global statistic options structure */
167 
169 
170 /*============================================================================
171  * Public function prototypes
172  *============================================================================*/
173 
174 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 int
204 cs_lagr_stat_define(const char *name,
205  int location_id,
206  int stat_type,
207  cs_lagr_stat_moment_t m_type,
208  int class_id,
209  int dim,
210  int component_id,
211  cs_lagr_moment_p_data_t *data_func,
212  void *data_input,
213  cs_lagr_moment_p_data_t *w_data_func,
214  void *w_data_input,
215  int nt_start,
216  double t_start,
217  cs_lagr_stat_restart_t restart_mode);
218 
219 /*----------------------------------------------------------------------------*/
241 /*----------------------------------------------------------------------------*/
242 
243 int
244 cs_lagr_stat_accumulator_define(const char *name,
245  int location_id,
246  int class_id,
247  cs_lagr_moment_p_data_t *w_data_func,
248  void *w_data_input,
249  int nt_start,
250  double t_start,
251  cs_lagr_stat_restart_t restart_mode);
252 
253 /*----------------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------------*/
285 
286 int
287 cs_lagr_stat_time_moment_define(const char *name,
288  int location_id,
289  int stat_type,
290  cs_lagr_stat_moment_t m_type,
291  int class_id,
292  int dim,
293  int component_id,
294  cs_lagr_moment_m_data_t *data_func,
295  void *data_input,
296  cs_lagr_moment_m_data_t *w_data_func,
297  void *w_data_input,
298  int nt_start,
299  double t_start,
300  cs_lagr_stat_restart_t restart_mode);
301 
302 /*----------------------------------------------------------------------------*/
310 /*----------------------------------------------------------------------------*/
311 
312 void
313 cs_lagr_stat_activate(int stat_type);
314 
315 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 void
326 cs_lagr_stat_deactivate(int stat_type);
327 
328 /*----------------------------------------------------------------------------*/
336 /*----------------------------------------------------------------------------*/
337 
338 void
339 cs_lagr_stat_activate_attr(int attr_id);
340 
341 /*----------------------------------------------------------------------------*/
349 /*----------------------------------------------------------------------------*/
350 
351 void
352 cs_lagr_stat_deactivate_attr(int attr_id);
353 
354 /*---------------------------------------------------------------------------*/
363 /*---------------------------------------------------------------------------*/
364 
365 int
366 cs_lagr_stat_type_from_attr_id(int attr_id);
367 
368 /*---------------------------------------------------------------------------*/
376 /*---------------------------------------------------------------------------*/
377 
378 int
379 cs_lagr_stat_type_to_attr_id(int stat_type);
380 
381 /*----------------------------------------------------------------------------*/
390 /*----------------------------------------------------------------------------*/
391 
392 void
394 
395 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 void
410 
411 /*----------------------------------------------------------------------------*/
415 /*----------------------------------------------------------------------------*/
416 
417 void
418 cs_lagr_stat_update(void);
419 
420 /*----------------------------------------------------------------------------*/
424 /*----------------------------------------------------------------------------*/
425 
426 void
428 
429 /*----------------------------------------------------------------------------*/
433 /*----------------------------------------------------------------------------*/
434 
435 void
437 
438 /*----------------------------------------------------------------------------*/
444 /*----------------------------------------------------------------------------*/
445 
446 void
448 
449 /*----------------------------------------------------------------------------*/
462 /*----------------------------------------------------------------------------*/
463 
464 cs_field_t *
465 cs_lagr_stat_get_moment(int stat_type,
466  cs_lagr_stat_moment_t m_type,
467  int class_id,
468  int component_id);
469 
470 /*----------------------------------------------------------------------------*/
478 /*----------------------------------------------------------------------------*/
479 
480 cs_field_t *
481 cs_lagr_stat_get_stat_weight(int class_id);
482 
483 /*----------------------------------------------------------------------------*/
489 /*----------------------------------------------------------------------------*/
490 
491 cs_real_t
493 
494 /*----------------------------------------------------------------------------*/
502 /*----------------------------------------------------------------------------*/
503 
504 cs_real_t
506 
507 /*----------------------------------------------------------------------------*/
508 
510 
511 #endif /* __CS_LAGR_STAT_H__ */
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:104
Field descriptor.
Definition: cs_field.h:124
Definition: cs_lagr_stat.h:56
void( cs_lagr_moment_m_data_t)(const void *input, int location_id, int class_id, cs_real_t vals[])
Definition: cs_lagr_stat.h:127
Definition: cs_lagr_stat.h:57
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
void cs_lagr_stat_activate_attr(int attr_id)
Activate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.c:2659
Definition: cs_lagr_stat.h:76
Definition: cs_lagr_stat.h:134
void cs_lagr_stat_restart_write(cs_restart_t *restart)
Checkpoint moment data.
Definition: cs_lagr_stat.c:3070
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:2732
cs_lagr_stat_options_t * cs_glob_lagr_stat_options
Definition: cs_lagr_stat.c:243
Definition: cs_lagr_stat.h:81
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
cs_lagr_stat_moment_t
Definition: cs_lagr_stat.h:54
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, cs_lagr_moment_m_data_t *w_data_func, void *w_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:2558
void cs_lagr_stat_deactivate_attr(int attr_id)
Deactivate Lagrangian statistics for a given particle attribute.
Definition: cs_lagr_stat.c:2675
int cs_lagr_stat_accumulator_define(const char *name, int location_id, int class_id, 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 weight type statistic.
Definition: cs_lagr_stat.c:2454
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:2710
Definition: cs_lagr_stat.h:65
void cs_lagr_stat_deactivate(int stat_type)
Deactivate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.c:2635
Definition: cs_lagr_stat.h:66
Definition: cs_field_pointer.h:65
int nstist
Definition: cs_lagr_stat.h:154
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:2692
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:86
void cs_lagr_stat_log_iteration(void)
Log moment definition information for a given iteration.
Definition: cs_lagr_stat.c:2928
void cs_lagr_stat_update(void)
Update particle statistics for a given time step.
Definition: cs_lagr_stat.c:2886
cs_real_t threshold
Definition: cs_lagr_stat.h:158
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:3444
cs_field_t * cs_lagr_stat_get_moment(int stat_type, 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:3359
Definition: cs_lagr_stat.h:83
void cs_lagr_stat_initialize(void)
Lagrangian statistics initialization.
Definition: cs_lagr_stat.c:2751
int idstnt
Definition: cs_lagr_stat.h:144
cs_lagr_stat_restart_t
Definition: cs_lagr_stat.h:63
#define END_C_DECLS
Definition: cs_defs.h:454
void cs_lagr_stat_finalize(void)
Destroy all moments management metadata.
Definition: cs_lagr_stat.c:2913
cs_field_t * cs_lagr_stat_get_stat_weight(int class_id)
Return statistical weight.
Definition: cs_lagr_stat.c:3393
void cs_lagr_stat_activate(int stat_type)
Activate Lagrangian statistics for a given statistics type.
Definition: cs_lagr_stat.c:2602
cs_real_t cs_lagr_stat_get_age(void)
Return global volume statistics age.
Definition: cs_lagr_stat.c:3416
int isuist
Definition: cs_lagr_stat.h:140
int cs_lagr_stat_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 statistic.
Definition: cs_lagr_stat.c:2396
Definition: cs_lagr_particle.h:145
Definition: cs_lagr_stat.h:67
cs_lagr_stat_type_t
Definition: cs_lagr_stat.h:74