7.1
general documentation
cs_lagr_event.h
Go to the documentation of this file.
1 #ifndef __CS_LAGR_EVENT_H__
2 #define __CS_LAGR_EVENT_H__
3 
4 /*============================================================================
5  * Lagrangian particle event model
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 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 
36 #include "cs_lagr_particle.h"
37 
38 #include "assert.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*=============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
53 #define CS_EVENT_INFLOW (1 << 0)
54 
56 #define CS_EVENT_OUTFLOW (1 << 1)
57 
59 #define CS_EVENT_REBOUND (1 << 2)
60 
62 #define CS_EVENT_DEPOSITION (1 << 3)
63 
65 #define CS_EVENT_RESUSPENSION (1 << 4)
66 
68 #define CS_EVENT_ROLL_OFF (1 << 5)
69 
71 #define CS_EVENT_ROLL_ON (1 << 6)
72 
74 #define CS_EVENT_FOULING (1 << 7)
75 
76 /*============================================================================
77  * Type definitions
78  *============================================================================*/
79 
81 /* ----------------------------- */
82 
83 /* Numbering of predefined attributes starts after particle attributes,
84  so that particle attribute can be added to mapped variables traced
85  a particle events */
86 
87 typedef enum {
88 
96  /* End of event attributes */
97 
99 
101 
103 /* ------------------------------------- */
104 
105 typedef struct {
106 
107  size_t extents; /* size (in bytes) of event
108  structure */
109  size_t lb; /* size (in bytes) of lower
110  bounds of event data
111  (work area before) */
112 
113  size_t size[CS_LAGR_N_E_ATTRIBUTES]; /* size (in bytes) of
114  attributes in event
115  structure for a given
116  time value */
117  cs_datatype_t datatype[CS_LAGR_N_E_ATTRIBUTES]; /* datatype of associated
118  attributes */
119  int count[CS_LAGR_N_E_ATTRIBUTES]; /* number of values for each
120  attribute */
121  ptrdiff_t displ[CS_LAGR_N_E_ATTRIBUTES]; /* displacement (in bytes)
122  of attributes in event
123  data */
124 
126 
127 /* Event set */
128 /* ------------ */
129 
130 typedef struct {
131 
132  cs_lnum_t n_events; /* number of events */
134 
136  unsigned char *e_buffer;
139 
140 /*=============================================================================
141  * Global variables
142  *============================================================================*/
143 
144 /*============================================================================
145  * Public function prototypes
146  *============================================================================*/
147 
148 /*----------------------------------------------------------------------------*/
156 /*----------------------------------------------------------------------------*/
157 
158 void
160 
161 /*----------------------------------------------------------------------------*/
165 /*----------------------------------------------------------------------------*/
166 
167 void
169 
170 /*----------------------------------------------------------------------------*/
176 /*----------------------------------------------------------------------------*/
177 
180 
181 /*----------------------------------------------------------------------------*/
187 /*----------------------------------------------------------------------------*/
188 
189 const char *
191 
192 /*----------------------------------------------------------------------------*/
198 /*----------------------------------------------------------------------------*/
199 
202 
203 /*----------------------------------------------------------------------------*/
209 /*----------------------------------------------------------------------------*/
210 
211 void
213 
214 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 void
237  size_t *extents,
238  size_t *size,
239  ptrdiff_t *displ,
240  cs_datatype_t *datatype,
241  int *count);
242 
243 /*----------------------------------------------------------------------------*/
251 /*----------------------------------------------------------------------------*/
252 
253 void
255 
256 /*----------------------------------------------------------------------------*/
266 /*----------------------------------------------------------------------------*/
267 
268 inline static void *
269 cs_lagr_events_attr(cs_lagr_event_set_t *event_set,
270  cs_lnum_t event_id,
272 {
273  assert(event_set->e_am->count[attr] > 0);
274 
275  return (unsigned char *)event_set->e_buffer
276  + event_set->e_am->extents*event_id
277  + event_set->e_am->displ[attr];
278 }
279 
280 /*----------------------------------------------------------------------------*/
291 /*----------------------------------------------------------------------------*/
292 
293 inline static const void *
294 cs_lagr_events_attr_const(const cs_lagr_event_set_t *event_set,
295  cs_lnum_t event_id,
297 {
298  assert(event_set->e_am->count[attr] > 0);
299 
300  return event_set->e_buffer
301  + event_set->e_am->extents*event_id
302  + event_set->e_am->displ[attr];
303 }
304 
305 /*----------------------------------------------------------------------------*/
315 /*----------------------------------------------------------------------------*/
316 
317 inline static cs_lnum_t
318 cs_lagr_events_get_lnum(const cs_lagr_event_set_t *event_set,
319  cs_lnum_t event_id,
321 {
322  assert(event_set->e_am->count[attr] > 0);
323 
324  return *((const cs_lnum_t *)( event_set->e_buffer
325  + event_set->e_am->extents*event_id
326  + event_set->e_am->displ[attr]));
327 }
328 
329 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 inline static void
341 cs_lagr_events_set_lnum(cs_lagr_event_set_t *event_set,
342  cs_lnum_t event_id,
344  cs_lnum_t value)
345 {
346  assert(event_set->e_am->count[attr] > 0);
347 
348  *((cs_lnum_t *)( event_set->e_buffer
349  + event_set->e_am->extents*event_id
350  + event_set->e_am->displ[attr])) = value;
351 }
352 
353 /*----------------------------------------------------------------------------*/
363 /*----------------------------------------------------------------------------*/
364 
365 inline static cs_real_t
366 cs_lagr_events_get_real(const cs_lagr_event_set_t *event_set,
367  cs_lnum_t event_id,
369 {
370  assert(event_set->e_am->count[attr] > 0);
371 
372  return *((const cs_real_t *)( event_set->e_buffer
373  + event_set->e_am->extents*event_id
374  + event_set->e_am->displ[attr]));
375 }
376 
377 /*----------------------------------------------------------------------------*/
386 /*----------------------------------------------------------------------------*/
387 
388 inline static void
389 cs_lagr_events_set_real(cs_lagr_event_set_t *event_set,
390  cs_lnum_t event_id,
392  cs_real_t value)
393 {
394  assert(event_set->e_am->count[attr] > 0);
395 
396  *((cs_real_t *)( event_set->e_buffer
397  + event_set->e_am->extents*event_id
398  + event_set->e_am->displ[attr])) = value;
399 }
400 
401 /*----------------------------------------------------------------------------
402  * Resize event set buffers if needed.
403  *
404  * \param[in, out] event_set pointer to event set
405  * \param[in] mini mum required
406  *----------------------------------------------------------------------------*/
407 
408 void
410  cs_lnum_t min_size);
411 
412 /*----------------------------------------------------------------------------*/
418 /*----------------------------------------------------------------------------*/
419 
420 void
422 
423 /*----------------------------------------------------------------------------
424  * Resize event set buffers if needed.
425  *
426  * \param[in, out] events pointer to event set
427  * \param[in, out] particles pointer to particle set
428  * \param[in] event_id event id
429  * \param[in] particle_id particle id
430  *----------------------------------------------------------------------------*/
431 
432 void
434  cs_lagr_particle_set_t *particles,
435  cs_lnum_t event_id,
436  cs_lnum_t particle_id);
437 
438 /*----------------------------------------------------------------------------*/
449 /*----------------------------------------------------------------------------*/
450 
453 
454 /*----------------------------------------------------------------------------*/
455 
457 
458 #endif /* __CS_LAGR_EVENT_H__ */
Definition: cs_lagr_event.h:130
const char * cs_lagr_event_get_attr_name(cs_lagr_event_attribute_t attr)
Return name associated with a given attribute.
Definition: cs_lagr_event.c:553
cs_datatype_t
Definition: cs_defs.h:275
void cs_lagr_event_initialize(void)
Define event map based on defined options.
Definition: cs_lagr_event.c:394
size_t extents
Definition: cs_lagr_event.h:107
cs_lagr_event_attribute_t
Definition: cs_lagr_event.h:87
void cs_lagr_event_set_resize(cs_lagr_event_set_t *event_set, cs_lnum_t min_size)
Definition: cs_lagr_event.c:679
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
Definition: cs_lagr_particle.h:222
void cs_lagr_event_get_attr_info(const cs_lagr_event_set_t *events, cs_lagr_event_attribute_t attr, size_t *extents, size_t *size, ptrdiff_t *displ, cs_datatype_t *datatype, int *count)
Get data extents for a given event attribute.
Definition: cs_lagr_event.c:632
int count[CS_LAGR_N_E_ATTRIBUTES]
Definition: cs_lagr_event.h:119
void cs_lagr_event_init_from_particle(cs_lagr_event_set_t *events, cs_lagr_particle_set_t *particles, cs_lnum_t event_id, cs_lnum_t particle_id)
Definition: cs_lagr_event.c:732
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
void cs_lagr_event_set_destroy(cs_lagr_event_set_t **events)
Definition: cs_lagr_event.c:600
Definition: cs_lagr_event.h:98
Definition: cs_lagr_event.h:89
Definition: cs_lagr_event.h:91
unsigned char * e_buffer
Definition: cs_lagr_event.h:136
cs_lnum_t n_events_max
Definition: cs_lagr_event.h:133
cs_lnum_t n_events
Definition: cs_lagr_event.h:132
const cs_lagr_event_attribute_map_t * cs_lagr_event_get_attr_map(void)
Return const pointer to the main event attribute map structure.
Definition: cs_lagr_event.c:538
const cs_lagr_event_attribute_map_t * e_am
Definition: cs_lagr_event.h:135
Definition: cs_lagr_event.h:94
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
#define END_C_DECLS
Definition: cs_defs.h:511
void cs_lagr_event_set_dump(const cs_lagr_event_set_t *events)
Dump a cs_lagr_event_set_t structure.
Definition: cs_lagr_event.c:703
void cs_lagr_event_finalize(void)
Destroy event set map if it exists.
Definition: cs_lagr_event.c:517
Definition: cs_lagr_event.h:105
ptrdiff_t displ[CS_LAGR_N_E_ATTRIBUTES]
Definition: cs_lagr_event.h:121
size_t lb
Definition: cs_lagr_event.h:109
cs_lagr_event_set_t * cs_lagr_event_set_boundary_interaction(void)
Definition: cs_lagr_event.c:780
Definition: cs_lagr_event.h:90
void cs_lagr_event_attr_in_range(int attr)
Check if an event attribute is in a valid range.
Definition: cs_lagr_event.c:663
cs_lagr_event_set_t * cs_lagr_event_set_create(void)
Definition: cs_lagr_event.c:579
Definition: cs_lagr_particle.h:181