8.0
general documentation
Loading...
Searching...
No Matches
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-2023 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
51
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
101
103/* ------------------------------------- */
104
105typedef 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 */
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
130typedef struct {
131
132 cs_lnum_t n_events; /* number of events */
134
136 unsigned char *e_buffer;
137
139
140/*=============================================================================
141 * Global variables
142 *============================================================================*/
143
144/*============================================================================
145 * Public function prototypes
146 *============================================================================*/
147
148/*----------------------------------------------------------------------------*/
156/*----------------------------------------------------------------------------*/
157
158void
160
161/*----------------------------------------------------------------------------*/
165/*----------------------------------------------------------------------------*/
166
167void
169
170/*----------------------------------------------------------------------------*/
176/*----------------------------------------------------------------------------*/
177
180
181/*----------------------------------------------------------------------------*/
187/*----------------------------------------------------------------------------*/
188
189const char *
191
192/*----------------------------------------------------------------------------*/
198/*----------------------------------------------------------------------------*/
199
202
203/*----------------------------------------------------------------------------*/
209/*----------------------------------------------------------------------------*/
210
211void
213
214/*----------------------------------------------------------------------------*/
232/*----------------------------------------------------------------------------*/
233
234void
237 size_t *extents,
238 size_t *size,
239 ptrdiff_t *displ,
240 cs_datatype_t *datatype,
241 int *count);
242
243/*----------------------------------------------------------------------------*/
251/*----------------------------------------------------------------------------*/
252
253void
255
256/*----------------------------------------------------------------------------*/
266/*----------------------------------------------------------------------------*/
267
268inline static void *
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
293inline static const void *
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
317inline static cs_lnum_t
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
340inline static void
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
365inline static cs_real_t
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
388inline static void
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
408void
410 cs_lnum_t min_size);
411
412/*----------------------------------------------------------------------------*/
418/*----------------------------------------------------------------------------*/
419
420void
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
432void
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__ */
cs_datatype_t
Definition cs_defs.h:272
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
void cs_lagr_event_finalize(void)
Destroy event set map if it exists.
Definition cs_lagr_event.c:517
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_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
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
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
void cs_lagr_event_set_resize(cs_lagr_event_set_t *event_set, cs_lnum_t min_size)
Definition cs_lagr_event.c:679
static const void * cs_lagr_events_attr_const(const cs_lagr_event_set_t *event_set, cs_lnum_t event_id, cs_lagr_event_attribute_t attr)
Get const pointer to current attribute data of a given event in a set.
Definition cs_lagr_event.h:294
cs_lagr_event_attribute_t
Definition cs_lagr_event.h:87
@ CS_LAGR_N_E_ATTRIBUTES
Definition cs_lagr_event.h:98
@ CS_LAGR_E_FACE_ID
Definition cs_lagr_event.h:91
@ CS_LAGR_E_FLAG
Definition cs_lagr_event.h:89
@ CS_LAGR_E_CELL_ID
Definition cs_lagr_event.h:90
@ CS_LAGR_E_VELOCITY
Definition cs_lagr_event.h:94
static cs_real_t cs_lagr_events_get_real(const cs_lagr_event_set_t *event_set, cs_lnum_t event_id, cs_lagr_event_attribute_t attr)
Get attribute value of type cs_real_t of a given event in a set.
Definition cs_lagr_event.h:366
cs_lagr_event_set_t * cs_lagr_event_set_boundary_interaction(void)
Definition cs_lagr_event.c:780
static void cs_lagr_events_set_lnum(cs_lagr_event_set_t *event_set, cs_lnum_t event_id, cs_lagr_event_attribute_t attr, cs_lnum_t value)
Set attribute value of type cs_lnum_t of a given event in a set.
Definition cs_lagr_event.h:341
static void * cs_lagr_events_attr(cs_lagr_event_set_t *event_set, cs_lnum_t event_id, cs_lagr_event_attribute_t attr)
Get pointer to a current attribute of a given event in a set.
Definition cs_lagr_event.h:269
static cs_lnum_t cs_lagr_events_get_lnum(const cs_lagr_event_set_t *event_set, cs_lnum_t event_id, cs_lagr_event_attribute_t attr)
Get attribute value of type cs_lnum_t of a given event in a set.
Definition cs_lagr_event.h:318
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
static void cs_lagr_events_set_real(cs_lagr_event_set_t *event_set, cs_lnum_t event_id, cs_lagr_event_attribute_t attr, cs_real_t value)
Set attribute value of type cs_real_t of a given event in a set.
Definition cs_lagr_event.h:389
void cs_lagr_event_initialize(void)
Define event map based on defined options.
Definition cs_lagr_event.c:394
void cs_lagr_event_set_destroy(cs_lagr_event_set_t **events)
Definition cs_lagr_event.c:600
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
@ CS_LAGR_N_ATTRIBUTES
Definition cs_lagr_particle.h:181
Definition cs_lagr_event.h:105
cs_datatype_t datatype[CS_LAGR_N_E_ATTRIBUTES]
Definition cs_lagr_event.h:117
ptrdiff_t displ[CS_LAGR_N_E_ATTRIBUTES]
Definition cs_lagr_event.h:121
size_t lb
Definition cs_lagr_event.h:109
int count[CS_LAGR_N_E_ATTRIBUTES]
Definition cs_lagr_event.h:119
size_t size[CS_LAGR_N_E_ATTRIBUTES]
Definition cs_lagr_event.h:113
size_t extents
Definition cs_lagr_event.h:107
Definition cs_lagr_event.h:130
cs_lnum_t n_events_max
Definition cs_lagr_event.h:133
const cs_lagr_event_attribute_map_t * e_am
Definition cs_lagr_event.h:135
unsigned char * e_buffer
Definition cs_lagr_event.h:136
cs_lnum_t n_events
Definition cs_lagr_event.h:132
Definition cs_lagr_particle.h:222