8.3
general documentation
cs_flag.h
Go to the documentation of this file.
1#ifndef __CS_FLAG_H__
2#define __CS_FLAG_H__
3
4/*============================================================================
5 * Manage the definition/setting of a computation
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2024 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/*----------------------------------------------------------------------------*/
37
39
40/*============================================================================
41 * Macro definitions
42 *============================================================================*/
43
62#define CS_FLAG_BOUNDARY_CELL_BY_FACE (1 << 0)
63#define CS_FLAG_BOUNDARY_CELL_BY_VERTEX (1 << 1)
64#define CS_FLAG_BOUNDARY_CELL_BY_EDGE (1 << 2)
65#define CS_FLAG_SOLID_CELL (1 << 3)
66
80#define CS_FLAG_CURRENT_TO_PREVIOUS (1 << 0)
81#define CS_FLAG_INITIALIZATION (1 << 1)
82
89#define CS_FLAG_SYS_MASS_MATRIX (1 << 0)
90#define CS_FLAG_SYS_SYM (1 << 1)
91#define CS_FLAG_SYS_TIME_DIAG (1 << 2)
92#define CS_FLAG_SYS_REAC_DIAG (1 << 3)
93#define CS_FLAG_SYS_SOURCES_HLOC (1 << 4)
94#define CS_FLAG_SYS_VECTOR (1 << 5)
103#define CS_FLAG_STATE_UNIFORM (1 << 0)
104#define CS_FLAG_STATE_CELLWISE (1 << 1)
105#define CS_FLAG_STATE_FACEWISE (1 << 2)
106#define CS_FLAG_STATE_STEADY (1 << 3)
107#define CS_FLAG_STATE_POTENTIAL (1 << 4)
108#define CS_FLAG_STATE_CIRCULATION (1 << 5)
109#define CS_FLAG_STATE_FLUX (1 << 6)
110#define CS_FLAG_STATE_DENSITY (1 << 7)
119#define CS_FLAG_FULL_LOC (1 << 0)
120#define CS_FLAG_SCALAR (1 << 1)
121#define CS_FLAG_VECTOR (1 << 2)
122#define CS_FLAG_TENSOR (1 << 3)
123#define CS_FLAG_VERTEX (1 << 4)
124#define CS_FLAG_EDGE (1 << 5)
125#define CS_FLAG_FACE (1 << 6)
126#define CS_FLAG_CELL (1 << 7)
127#define CS_FLAG_PRIMAL (1 << 8)
128#define CS_FLAG_DUAL (1 << 9)
129#define CS_FLAG_BORDER (1 << 10)
130#define CS_FLAG_BY_CELL (1 << 11)
131#define CS_FLAG_BY_FACE (1 << 12)
132#define CS_FLAG_MAC_LOC (1 << 13)
144#define CS_FLAG_SCHEME_SCALAR (1 << 0)
145#define CS_FLAG_SCHEME_VECTOR (1 << 1)
146#define CS_FLAG_SCHEME_NAVSTO (1 << 2)
147#define CS_FLAG_SCHEME_POLY0 (1 << 3)
148#define CS_FLAG_SCHEME_POLY1 (1 << 4)
149#define CS_FLAG_SCHEME_POLY2 (1 << 5)
155/*============================================================================
156 * Type definitions
157 *============================================================================*/
158
159typedef unsigned char cs_mask_t; /* Elementary flag */
160
161/*============================================================================
162 * Global variables
163 *============================================================================*/
164
165/* Default locations */
166
167extern const cs_flag_t cs_flag_primal_vtx;
168extern const cs_flag_t cs_flag_primal_edge;
169extern const cs_flag_t cs_flag_primal_face;
170extern const cs_flag_t cs_flag_primal_cell;
171extern const cs_flag_t cs_flag_vertex; /* equal to cs_flag_primal_vtx */
172extern const cs_flag_t cs_flag_cell; /* equal to cs_flag_primal_cell */
175
176extern const cs_flag_t cs_flag_dual_vtx;
177extern const cs_flag_t cs_flag_dual_face;
178extern const cs_flag_t cs_flag_dual_cell;
179
183
184/* Part of dual cell closure belonging to a boundary primal face */
185
187
188/* According to the extended flag defined below one can identify which set of
189 * quantities or connectivities have to be built on-the-fly and stored in a
190 * local structure possibly owned by each thread and with a cellwise scope */
191
192typedef unsigned int cs_eflag_t;
193
194/* Store predefined flags */
195
196extern const cs_eflag_t cs_flag_need_v;
197extern const cs_eflag_t cs_flag_need_e;
198extern const cs_eflag_t cs_flag_need_f;
199extern const cs_eflag_t cs_flag_need_fe;
200extern const cs_eflag_t cs_flag_need_ef;
201extern const cs_eflag_t cs_flag_need_peq;
202extern const cs_eflag_t cs_flag_need_dfq;
203extern const cs_eflag_t cs_flag_need_pfq;
204extern const cs_eflag_t cs_flag_need_deq;
205extern const cs_eflag_t cs_flag_need_pfc;
206
207typedef enum {
208
209 /* Compute simple and cellwise information for vertices */
210
211 CS_FLAG_COMP_PV = 1 << 0, /* = 1 */
212
213 /* Compute cellwise quantities for vertices */
214
215 CS_FLAG_COMP_PVQ = 1 << 1, /* = 2 */
216
217 /* Compute simple and cellwise information for edges */
218
219 CS_FLAG_COMP_PE = 1 << 2, /* = 4 */
220
221 /* Compute cellwise quantities for edges */
222
223 CS_FLAG_COMP_PEQ = 1 << 3, /* = 8 */
224
225 /* Compute cellwise quantities for dual faces (associated to edges) */
226
227 CS_FLAG_COMP_DFQ = 1 << 4, /* = 16 */
228
229 /* Compute simple and cellwise information for faces */
230
231 CS_FLAG_COMP_PF = 1 << 5, /* = 32 */
232
233 /* Compute cellwise quantities for faces */
234
235 CS_FLAG_COMP_PFQ = 1 << 6, /* = 64 */
236
237 /* Compute cellwise quantities for dual edges (associated to faces) */
238
239 CS_FLAG_COMP_DEQ = 1 << 7, /* = 128 */
240
241 /* Compute the cellwise connectivity edge to vertices */
242
243 CS_FLAG_COMP_EV = 1 << 8, /* = 256 */
244
245 /* Compute cellwise connectivity face to edges */
246
247 CS_FLAG_COMP_FE = 1 << 9, /* = 512 */
248
249 /* Compute cellwise quantities associated to the couple (face, edge) */
250
251 CS_FLAG_COMP_FEQ = 1 << 10, /* = 1024 */
252
253 /* Compute cellwise connectivity face to vertices */
254
255 CS_FLAG_COMP_FV = 1 << 11, /* = 2048 */
256
257 /* Compute cellwise connectivity edge to faces */
258
259 CS_FLAG_COMP_EF = 1 << 12, /* = 4096 */
260
261 /* Compute elemental portion of dual faces associated to the couple
262 (edge, face) */
263
264 CS_FLAG_COMP_SEF = 1 << 13, /* = 8192 */
265
266 /* Compute cellwise quantities related to the height of the pyramid with
267 basis spanned by a face and with apex the cell center */
268
269 CS_FLAG_COMP_HFQ = 1 << 14, /* = 16384 */
270
271 /* Compute cellwise orientation of oriented edges belonging to a face */
272
273 CS_FLAG_COMP_FES = 1 << 15, /* = 32768 */
274
275 /* Compute cellwise quantities related to the volume of the pyramid with
276 basis spanned by a face and with apex the cell center */
277
278 CS_FLAG_COMP_PFC = 1 << 16, /* = 65536 */
279
280 /* Compute cellwise quantities related to the volume surrounding an edge */
281
282 CS_FLAG_COMP_PEC = 1 << 17, /* = 131072 */
283
284 /* Compute cellwise diameters */
285
286 CS_FLAG_COMP_DIAM = 1 << 18, /* = 262144 */
287
289
290typedef enum {
291
302
304
306
307typedef enum {
308
312
313 CS_FLAG_N_AXIS /* undefined Cartesian axis */
314
316
317/*============================================================================
318 * Public function prototypes
319 *============================================================================*/
320
321/*----------------------------------------------------------------------------*/
332/*----------------------------------------------------------------------------*/
333
334static inline bool
336 cs_flag_t reference)
337{
338 if ((flag_to_check & reference) == reference)
339 return true;
340 else
341 return false;
342}
343
344/*----------------------------------------------------------------------------*/
355/*----------------------------------------------------------------------------*/
356
357static inline bool
359 int n_masks,
360 cs_flag_t masks[])
361{
362 for (int i = 0; i < n_masks; i++)
363 if ((flag_to_check & masks[i]) == masks[i])
364 return true;
365 return false;
366}
367
368/*----------------------------------------------------------------------------*/
380/*----------------------------------------------------------------------------*/
381
382static inline bool
384 cs_eflag_t reference)
385{
386 if ((flag_to_check & reference) == reference)
387 return true;
388 else
389 return false;
390}
391
392/*----------------------------------------------------------------------------*/
398/*----------------------------------------------------------------------------*/
399
400const char *
402
403/*----------------------------------------------------------------------------*/
404
406
407#endif /* __CS_FLAG_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
#define END_C_DECLS
Definition: cs_defs.h:543
unsigned short int cs_flag_t
Definition: cs_defs.h:344
const cs_flag_t cs_flag_primal_cell
Definition: cs_flag.cpp:58
#define CS_FLAG_CELL
Definition: cs_flag.h:126
#define CS_FLAG_VERTEX
Definition: cs_flag.h:123
const cs_eflag_t cs_flag_need_pfq
Definition: cs_flag.cpp:110
const cs_flag_t cs_flag_dual_face
Definition: cs_flag.cpp:64
#define CS_FLAG_EDGE
Definition: cs_flag.h:124
const cs_flag_t cs_flag_cell
Definition: cs_flag.cpp:80
const cs_eflag_t cs_flag_need_e
Definition: cs_flag.cpp:95
const cs_eflag_t cs_flag_need_v
Definition: cs_flag.cpp:93
const cs_flag_t cs_flag_dual_closure_byf
Definition: cs_flag.cpp:73
cs_flag_location_t
Definition: cs_flag.h:290
@ CS_FLAG_LOCATION_DUAL_EDGE
Definition: cs_flag.h:297
@ CS_FLAG_LOCATION_MAC_PRIMAL_FACE
Definition: cs_flag.h:300
@ CS_FLAG_LOCATION_DUAL_FACE
Definition: cs_flag.h:298
@ CS_FLAG_LOCATION_PRIMAL_FACE
Definition: cs_flag.h:294
@ CS_FLAG_N_LOCATIONS
Definition: cs_flag.h:303
@ CS_FLAG_LOCATION_PRIMAL_CELL
Definition: cs_flag.h:295
@ CS_FLAG_LOCATION_DUAL_CELL
Definition: cs_flag.h:299
@ CS_FLAG_LOCATION_PRIMAL_VTX
Definition: cs_flag.h:292
@ CS_FLAG_LOCATION_PRIMAL_EDGE
Definition: cs_flag.h:293
@ CS_FLAG_LOCATION_DUAL_VTX
Definition: cs_flag.h:296
static bool cs_flag_test(cs_flag_t flag_to_check, cs_flag_t reference)
Check if two flags share the same pattern Return true if the flag to check has at least the pattern o...
Definition: cs_flag.h:335
const cs_flag_t cs_flag_dual_cell_byc
Definition: cs_flag.cpp:69
const cs_flag_t cs_flag_vertex
Definition: cs_flag.cpp:79
const cs_flag_t cs_flag_boundary_face
Definition: cs_flag.cpp:82
const cs_flag_t cs_flag_primal_edge
Definition: cs_flag.cpp:56
unsigned char cs_mask_t
Definition: cs_flag.h:159
cs_flag_cartesian_axis_t
Definition: cs_flag.h:307
@ CS_FLAG_X_AXIS
Definition: cs_flag.h:309
@ CS_FLAG_N_AXIS
Definition: cs_flag.h:313
@ CS_FLAG_Y_AXIS
Definition: cs_flag.h:310
@ CS_FLAG_Z_AXIS
Definition: cs_flag.h:311
#define CS_FLAG_DUAL
Definition: cs_flag.h:128
const cs_eflag_t cs_flag_need_deq
Definition: cs_flag.cpp:113
const cs_eflag_t cs_flag_need_peq
Definition: cs_flag.cpp:106
const cs_eflag_t cs_flag_need_dfq
Definition: cs_flag.cpp:108
const cs_eflag_t cs_flag_need_pfc
Definition: cs_flag.cpp:115
const cs_eflag_t cs_flag_need_ef
Definition: cs_flag.cpp:104
#define CS_FLAG_MAC_LOC
Definition: cs_flag.h:132
#define CS_FLAG_FACE
Definition: cs_flag.h:125
const cs_eflag_t cs_flag_need_f
Definition: cs_flag.cpp:98
#define CS_FLAG_PRIMAL
Definition: cs_flag.h:127
const cs_eflag_t cs_flag_need_fe
Definition: cs_flag.cpp:102
const cs_flag_t cs_flag_primal_edge_byc
Definition: cs_flag.cpp:67
const cs_flag_t cs_flag_mac_primal_face
Definition: cs_flag.cpp:60
const cs_flag_t cs_flag_dual_cell
Definition: cs_flag.cpp:65
unsigned int cs_eflag_t
Definition: cs_flag.h:192
const cs_flag_t cs_flag_primal_face
Definition: cs_flag.cpp:57
static bool cs_flag_at_least(cs_flag_t flag_to_check, int n_masks, cs_flag_t masks[])
Check if a flag has in common at least one of the given masks Return true if the test is satisfied.
Definition: cs_flag.h:358
static bool cs_eflag_test(cs_eflag_t flag_to_check, cs_eflag_t reference)
Check if a two compute flag share the same pattern Return true if the computed flag to check has at l...
Definition: cs_flag.h:383
const cs_flag_t cs_flag_dual_vtx
Definition: cs_flag.cpp:62
cs_flag_comp_bits_t
Definition: cs_flag.h:207
@ CS_FLAG_COMP_DFQ
Definition: cs_flag.h:227
@ CS_FLAG_COMP_FV
Definition: cs_flag.h:255
@ CS_FLAG_COMP_PVQ
Definition: cs_flag.h:215
@ CS_FLAG_COMP_PE
Definition: cs_flag.h:219
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:251
@ CS_FLAG_COMP_HFQ
Definition: cs_flag.h:269
@ CS_FLAG_COMP_PEC
Definition: cs_flag.h:282
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:235
@ CS_FLAG_COMP_EF
Definition: cs_flag.h:259
@ CS_FLAG_COMP_PF
Definition: cs_flag.h:231
@ CS_FLAG_COMP_FES
Definition: cs_flag.h:273
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:243
@ CS_FLAG_COMP_FE
Definition: cs_flag.h:247
@ CS_FLAG_COMP_PEQ
Definition: cs_flag.h:223
@ CS_FLAG_COMP_PV
Definition: cs_flag.h:211
@ CS_FLAG_COMP_PFC
Definition: cs_flag.h:278
@ CS_FLAG_COMP_DIAM
Definition: cs_flag.h:286
@ CS_FLAG_COMP_DEQ
Definition: cs_flag.h:239
@ CS_FLAG_COMP_SEF
Definition: cs_flag.h:264
const cs_flag_t cs_flag_dual_face_byc
Definition: cs_flag.cpp:71
const cs_flag_t cs_flag_primal_vtx
Definition: cs_flag.cpp:55
const char * cs_flag_str_location(cs_flag_t loc)
Retrieve the label associated to a location flag.
Definition: cs_flag.cpp:135