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-2016 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 either:
94  * - that value or structure should not be temporary (i.e. local);
95  * - post-processing output must be ensured using cs_post_write_meshes()
96  * with a fixed-mesh writer before the data pointed to goes out of scope;
97  *
98  * parameters:
99  * input <-- pointer to optional (untyped) value or structure.
100  * particle <-- pointer to particle data
101  * p_am <-- pointer to particle attribute map
102  * vals --> pointer to values
103  *----------------------------------------------------------------------------*/
104 
105 typedef void
107  const void *particle,
108  const cs_lagr_attribute_map_t *p_am,
109  cs_real_t vals[]);
110 
111 /*----------------------------------------------------------------------------
112  * Function pointer for computation of data values for particle statistics
113  * based on mesh
114  *
115  * If the matching values are multidimensional, they must be interleaved.
116  *
117  * Note: if the input pointer is non-NULL, it must point to valid data
118  * when the selection function is called, so either:
119  * - that value or structure should not be temporary (i.e. local);
120  * - post-processing output must be ensured using cs_post_write_meshes()
121  * with a fixed-mesh writer before the data pointed to goes out of scope;
122  *
123  * parameters:
124  * input <-- pointer to optional (untyped) value or structure.
125  * location_id <-- associated mesh location id
126  * class_id <-- associated particle class id (0 for all)
127  * vals --> pointer to values (size: n_local elements*dimension)
128  *----------------------------------------------------------------------------*/
129 
130 typedef void
132  int location_id,
133  int class_id,
134  cs_real_t vals[]);
135 
138 typedef struct {
139 
144  int isuist;
145 
148  int idstnt;
149 
158  int nstist;
159 
163 
165 
166 /*============================================================================
167  * Global variables
168  *============================================================================*/
169 
170 /* Pointer to global statistic options structure */
171 
173 
174 /*============================================================================
175  * Public function prototypes
176  *============================================================================*/
177 
178 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
207 int
208 cs_lagr_stat_define(const char *name,
209  int location_id,
210  int stat_type,
211  cs_lagr_stat_moment_t m_type,
212  int class_id,
213  int dim,
214  int component_id,
215  cs_lagr_moment_p_data_t *data_func,
216  void *data_input,
217  cs_lagr_moment_p_data_t *w_data_func,
218  void *w_data_input,
219  int nt_start,
220  double t_start,
221  cs_lagr_stat_restart_t restart_mode);
222 
223 /*----------------------------------------------------------------------------*/
245 /*----------------------------------------------------------------------------*/
246 
247 int
248 cs_lagr_stat_accumulator_define(const char *name,
249  int location_id,
250  int class_id,
251  cs_lagr_moment_p_data_t *w_data_func,
252  void *w_data_input,
253  int nt_start,
254  double t_start,
255  cs_lagr_stat_restart_t restart_mode);
256 
257 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 int
291 cs_lagr_stat_time_moment_define(const char *name,
292  int location_id,
293  int stat_type,
294  cs_lagr_stat_moment_t m_type,
295  int class_id,
296  int dim,
297  int component_id,
298  cs_lagr_moment_m_data_t *data_func,
299  void *data_input,
300  cs_lagr_moment_m_data_t *w_data_func,
301  void *w_data_input,
302  int nt_start,
303  double t_start,
304  cs_lagr_stat_restart_t restart_mode);
305 
306 /*----------------------------------------------------------------------------*/
314 /*----------------------------------------------------------------------------*/
315 
316 void
317 cs_lagr_stat_activate(int stat_type);
318 
319 /*----------------------------------------------------------------------------*/
327 /*----------------------------------------------------------------------------*/
328 
329 void
330 cs_lagr_stat_deactivate(int stat_type);
331 
332 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 void
343 cs_lagr_stat_activate_attr(int attr_id);
344 
345 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 void
356 cs_lagr_stat_deactivate_attr(int attr_id);
357 
358 /*---------------------------------------------------------------------------*/
367 /*---------------------------------------------------------------------------*/
368 
369 int
370 cs_lagr_stat_type_from_attr_id(int attr_id);
371 
372 /*---------------------------------------------------------------------------*/
380 /*---------------------------------------------------------------------------*/
381 
382 int
383 cs_lagr_stat_type_to_attr_id(int stat_type);
384 
385 /*----------------------------------------------------------------------------*/
394 /*----------------------------------------------------------------------------*/
395 
396 void
398 
399 /*----------------------------------------------------------------------------*/
410 /*----------------------------------------------------------------------------*/
411 
412 void
414 
415 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
421 void
422 cs_lagr_stat_update(void);
423 
424 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
432 
433 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
439 void
441 
442 /*----------------------------------------------------------------------------*/
448 /*----------------------------------------------------------------------------*/
449 
450 void
452 
453 /*----------------------------------------------------------------------------*/
466 /*----------------------------------------------------------------------------*/
467 
468 cs_field_t *
469 cs_lagr_stat_get_moment(int stat_type,
470  cs_lagr_stat_moment_t m_type,
471  int class_id,
472  int component_id);
473 
474 /*----------------------------------------------------------------------------*/
482 /*----------------------------------------------------------------------------*/
483 
484 cs_field_t *
485 cs_lagr_stat_get_stat_weight(int class_id);
486 
487 /*----------------------------------------------------------------------------*/
493 /*----------------------------------------------------------------------------*/
494 
495 cs_real_t
497 
498 /*----------------------------------------------------------------------------*/
506 /*----------------------------------------------------------------------------*/
507 
508 cs_real_t
510 
511 /*----------------------------------------------------------------------------*/
512 
514 
515 #endif /* __CS_LAGR_STAT_H__ */
Field descriptor.
Definition: cs_field.h:121
Definition: cs_lagr_stat.h:56
Definition: cs_lagr_stat.h:57
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
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:138
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:296
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:64
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:106
int nstist
Definition: cs_lagr_stat.h:158
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
static int input(void)
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:162
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:148
cs_lagr_stat_restart_t
Definition: cs_lagr_stat.h:63
#define END_C_DECLS
Definition: cs_defs.h:449
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:144
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:138
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:131
Definition: cs_lagr_stat.h:67
cs_lagr_stat_type_t
Definition: cs_lagr_stat.h:74