9.2
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-2026 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 "base/cs_defs.h"
35
36/*============================================================================
37 * Macro definitions
38 *============================================================================*/
39
59#define CS_FLAG_BOUNDARY_CELL_BY_FACE (1 << 0)
60#define CS_FLAG_BOUNDARY_CELL_BY_VERTEX (1 << 1)
61#define CS_FLAG_BOUNDARY_CELL_BY_EDGE (1 << 2)
62#define CS_FLAG_SOLID_CELL (1 << 3)
63
79#define CS_FLAG_CURRENT_TO_PREVIOUS (1 << 0)
80#define CS_FLAG_INITIALIZATION (1 << 1)
81
87#define CS_FLAG_SYS_MASS_MATRIX (1 << 0)
88#define CS_FLAG_SYS_SYM (1 << 1)
89#define CS_FLAG_SYS_TIME_DIAG (1 << 2)
90#define CS_FLAG_SYS_REAC_DIAG (1 << 3)
91#define CS_FLAG_SYS_SOURCES_HLOC (1 << 4)
92#define CS_FLAG_SYS_VECTOR (1 << 5)
101#define CS_FLAG_STATE_UNIFORM (1 << 0)
102#define CS_FLAG_STATE_CELLWISE (1 << 1)
103#define CS_FLAG_STATE_FACEWISE (1 << 2)
104#define CS_FLAG_STATE_STEADY (1 << 3)
105#define CS_FLAG_STATE_POTENTIAL (1 << 4)
106#define CS_FLAG_STATE_CIRCULATION (1 << 5)
107#define CS_FLAG_STATE_FLUX (1 << 6)
108#define CS_FLAG_STATE_DENSITY (1 << 7)
117#define CS_FLAG_FULL_LOC (1 << 0)
118#define CS_FLAG_SCALAR (1 << 1)
119#define CS_FLAG_VECTOR (1 << 2)
120#define CS_FLAG_TENSOR (1 << 3)
121#define CS_FLAG_VERTEX (1 << 4)
122#define CS_FLAG_EDGE (1 << 5)
123#define CS_FLAG_FACE (1 << 6)
124#define CS_FLAG_CELL (1 << 7)
125#define CS_FLAG_PRIMAL (1 << 8)
126#define CS_FLAG_DUAL (1 << 9)
127#define CS_FLAG_BORDER (1 << 10)
128#define CS_FLAG_BY_CELL (1 << 11)
129#define CS_FLAG_BY_FACE (1 << 12)
130#define CS_FLAG_MAC_LOC (1 << 13)
142#define CS_FLAG_SCHEME_SCALAR (1 << 0)
143#define CS_FLAG_SCHEME_VECTOR (1 << 1)
144#define CS_FLAG_SCHEME_NAVSTO (1 << 2)
145#define CS_FLAG_SCHEME_POLY0 (1 << 3)
146#define CS_FLAG_SCHEME_POLY1 (1 << 4)
147#define CS_FLAG_SCHEME_POLY2 (1 << 5)
153/*============================================================================
154 * Type definitions
155 *============================================================================*/
156
157typedef unsigned char cs_mask_t; /* Elementary flag */
158
159/*============================================================================
160 * Global variables
161 *============================================================================*/
162
163/* Default locations */
164
165extern const cs_flag_t cs_flag_primal_vtx;
166extern const cs_flag_t cs_flag_primal_edge;
167extern const cs_flag_t cs_flag_primal_face;
168extern const cs_flag_t cs_flag_primal_cell;
169extern const cs_flag_t cs_flag_vertex; /* equal to cs_flag_primal_vtx */
170extern const cs_flag_t cs_flag_cell; /* equal to cs_flag_primal_cell */
173
174extern const cs_flag_t cs_flag_dual_vtx;
175extern const cs_flag_t cs_flag_dual_face;
176extern const cs_flag_t cs_flag_dual_cell;
177
181
182/* Part of dual cell closure belonging to a boundary primal face */
183
185
186/* According to the extended flag defined below one can identify which set of
187 * quantities or connectivities have to be built on-the-fly and stored in a
188 * local structure possibly owned by each thread and with a cellwise scope */
189
190typedef unsigned int cs_eflag_t;
191
192/* Store predefined flags */
193
194extern const cs_eflag_t cs_flag_need_v;
195extern const cs_eflag_t cs_flag_need_e;
196extern const cs_eflag_t cs_flag_need_f;
197extern const cs_eflag_t cs_flag_need_fe;
198extern const cs_eflag_t cs_flag_need_ef;
199extern const cs_eflag_t cs_flag_need_peq;
200extern const cs_eflag_t cs_flag_need_dfq;
201extern const cs_eflag_t cs_flag_need_pfq;
202extern const cs_eflag_t cs_flag_need_deq;
203extern const cs_eflag_t cs_flag_need_pfc;
204
205typedef enum {
206
207 /* Compute simple and cellwise information for vertices */
208
209 CS_FLAG_COMP_PV = 1 << 0, /* = 1 */
210
211 /* Compute cellwise quantities for vertices */
212
213 CS_FLAG_COMP_PVQ = 1 << 1, /* = 2 */
214
215 /* Compute simple and cellwise information for edges */
216
217 CS_FLAG_COMP_PE = 1 << 2, /* = 4 */
218
219 /* Compute cellwise quantities for edges */
220
221 CS_FLAG_COMP_PEQ = 1 << 3, /* = 8 */
222
223 /* Compute cellwise quantities for dual faces (associated to edges) */
224
225 CS_FLAG_COMP_DFQ = 1 << 4, /* = 16 */
226
227 /* Compute simple and cellwise information for faces */
228
229 CS_FLAG_COMP_PF = 1 << 5, /* = 32 */
230
231 /* Compute cellwise quantities for faces */
232
233 CS_FLAG_COMP_PFQ = 1 << 6, /* = 64 */
234
235 /* Compute cellwise quantities for dual edges (associated to faces) */
236
237 CS_FLAG_COMP_DEQ = 1 << 7, /* = 128 */
238
239 /* Compute the cellwise connectivity edge to vertices */
240
241 CS_FLAG_COMP_EV = 1 << 8, /* = 256 */
242
243 /* Compute cellwise connectivity face to edges */
244
245 CS_FLAG_COMP_FE = 1 << 9, /* = 512 */
246
247 /* Compute cellwise quantities associated to the couple (face, edge) */
248
249 CS_FLAG_COMP_FEQ = 1 << 10, /* = 1024 */
250
251 /* Compute cellwise connectivity face to vertices */
252
253 CS_FLAG_COMP_FV = 1 << 11, /* = 2048 */
254
255 /* Compute cellwise connectivity edge to faces */
256
257 CS_FLAG_COMP_EF = 1 << 12, /* = 4096 */
258
259 /* Compute elemental portion of dual faces associated to the couple
260 (edge, face) */
261
262 CS_FLAG_COMP_SEF = 1 << 13, /* = 8192 */
263
264 /* Compute cellwise quantities related to the height of the pyramid with
265 basis spanned by a face and with apex the cell center */
266
267 CS_FLAG_COMP_HFQ = 1 << 14, /* = 16384 */
268
269 /* Compute cellwise orientation of oriented edges belonging to a face */
270
271 CS_FLAG_COMP_FES = 1 << 15, /* = 32768 */
272
273 /* Compute cellwise quantities related to the volume of the pyramid with
274 basis spanned by a face and with apex the cell center */
275
276 CS_FLAG_COMP_PFC = 1 << 16, /* = 65536 */
277
278 /* Compute cellwise quantities related to the volume surrounding an edge */
279
280 CS_FLAG_COMP_PEC = 1 << 17, /* = 131072 */
281
282 /* Compute cellwise diameters */
283
284 CS_FLAG_COMP_DIAM = 1 << 18, /* = 262144 */
285
287
288typedef enum {
289
300
302
304
305typedef enum {
306
310
311 CS_FLAG_N_AXIS /* undefined Cartesian axis */
312
314
315/*============================================================================
316 * Public function prototypes
317 *============================================================================*/
318
319/*----------------------------------------------------------------------------*/
330/*----------------------------------------------------------------------------*/
331
332static inline bool
334 cs_flag_t reference)
335{
336 if ((flag_to_check & reference) == reference)
337 return true;
338 else
339 return false;
340}
341
342/*----------------------------------------------------------------------------*/
353/*----------------------------------------------------------------------------*/
354
355static inline bool
357 int n_masks,
358 cs_flag_t masks[])
359{
360 for (int i = 0; i < n_masks; i++)
361 if ((flag_to_check & masks[i]) == masks[i])
362 return true;
363 return false;
364}
365
366/*----------------------------------------------------------------------------*/
378/*----------------------------------------------------------------------------*/
379
380static inline bool
382 cs_eflag_t reference)
383{
384 if ((flag_to_check & reference) == reference)
385 return true;
386 else
387 return false;
388}
389
390/*----------------------------------------------------------------------------*/
398/*----------------------------------------------------------------------------*/
399
400const char *
402
403#endif /* CS_FLAG_H */
unsigned short int cs_flag_t
Definition: cs_defs.h:334
const cs_flag_t cs_flag_primal_cell
Definition: cs_flag.cpp:54
#define CS_FLAG_CELL
Definition: cs_flag.h:124
#define CS_FLAG_VERTEX
Definition: cs_flag.h:121
const cs_eflag_t cs_flag_need_pfq
Definition: cs_flag.cpp:106
const cs_flag_t cs_flag_dual_face
Definition: cs_flag.cpp:60
#define CS_FLAG_EDGE
Definition: cs_flag.h:122
const cs_flag_t cs_flag_cell
Definition: cs_flag.cpp:76
const cs_eflag_t cs_flag_need_e
Definition: cs_flag.cpp:91
const cs_eflag_t cs_flag_need_v
Definition: cs_flag.cpp:89
const cs_flag_t cs_flag_dual_closure_byf
Definition: cs_flag.cpp:69
cs_flag_location_t
Definition: cs_flag.h:288
@ CS_FLAG_LOCATION_DUAL_EDGE
Definition: cs_flag.h:295
@ CS_FLAG_LOCATION_MAC_PRIMAL_FACE
Definition: cs_flag.h:298
@ CS_FLAG_LOCATION_DUAL_FACE
Definition: cs_flag.h:296
@ CS_FLAG_LOCATION_PRIMAL_FACE
Definition: cs_flag.h:292
@ CS_FLAG_N_LOCATIONS
Definition: cs_flag.h:301
@ CS_FLAG_LOCATION_PRIMAL_CELL
Definition: cs_flag.h:293
@ CS_FLAG_LOCATION_DUAL_CELL
Definition: cs_flag.h:297
@ CS_FLAG_LOCATION_PRIMAL_VTX
Definition: cs_flag.h:290
@ CS_FLAG_LOCATION_PRIMAL_EDGE
Definition: cs_flag.h:291
@ CS_FLAG_LOCATION_DUAL_VTX
Definition: cs_flag.h:294
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:333
const cs_flag_t cs_flag_dual_cell_byc
Definition: cs_flag.cpp:65
const cs_flag_t cs_flag_vertex
Definition: cs_flag.cpp:75
const cs_flag_t cs_flag_boundary_face
Definition: cs_flag.cpp:78
const cs_flag_t cs_flag_primal_edge
Definition: cs_flag.cpp:52
unsigned char cs_mask_t
Definition: cs_flag.h:157
cs_flag_cartesian_axis_t
Definition: cs_flag.h:305
@ CS_FLAG_X_AXIS
Definition: cs_flag.h:307
@ CS_FLAG_N_AXIS
Definition: cs_flag.h:311
@ CS_FLAG_Y_AXIS
Definition: cs_flag.h:308
@ CS_FLAG_Z_AXIS
Definition: cs_flag.h:309
#define CS_FLAG_DUAL
Definition: cs_flag.h:126
const cs_eflag_t cs_flag_need_deq
Definition: cs_flag.cpp:109
const cs_eflag_t cs_flag_need_peq
Definition: cs_flag.cpp:102
const cs_eflag_t cs_flag_need_dfq
Definition: cs_flag.cpp:104
const cs_eflag_t cs_flag_need_pfc
Definition: cs_flag.cpp:111
const cs_eflag_t cs_flag_need_ef
Definition: cs_flag.cpp:100
#define CS_FLAG_MAC_LOC
Definition: cs_flag.h:130
#define CS_FLAG_FACE
Definition: cs_flag.h:123
const cs_eflag_t cs_flag_need_f
Definition: cs_flag.cpp:94
#define CS_FLAG_PRIMAL
Definition: cs_flag.h:125
const cs_eflag_t cs_flag_need_fe
Definition: cs_flag.cpp:98
const cs_flag_t cs_flag_primal_edge_byc
Definition: cs_flag.cpp:63
const cs_flag_t cs_flag_mac_primal_face
Definition: cs_flag.cpp:56
const cs_flag_t cs_flag_dual_cell
Definition: cs_flag.cpp:61
unsigned int cs_eflag_t
Definition: cs_flag.h:190
const cs_flag_t cs_flag_primal_face
Definition: cs_flag.cpp:53
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:356
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:381
const cs_flag_t cs_flag_dual_vtx
Definition: cs_flag.cpp:58
cs_flag_comp_bits_t
Definition: cs_flag.h:205
@ CS_FLAG_COMP_DFQ
Definition: cs_flag.h:225
@ CS_FLAG_COMP_FV
Definition: cs_flag.h:253
@ CS_FLAG_COMP_PVQ
Definition: cs_flag.h:213
@ CS_FLAG_COMP_PE
Definition: cs_flag.h:217
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:249
@ CS_FLAG_COMP_HFQ
Definition: cs_flag.h:267
@ CS_FLAG_COMP_PEC
Definition: cs_flag.h:280
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:233
@ CS_FLAG_COMP_EF
Definition: cs_flag.h:257
@ CS_FLAG_COMP_PF
Definition: cs_flag.h:229
@ CS_FLAG_COMP_FES
Definition: cs_flag.h:271
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:241
@ CS_FLAG_COMP_FE
Definition: cs_flag.h:245
@ CS_FLAG_COMP_PEQ
Definition: cs_flag.h:221
@ CS_FLAG_COMP_PV
Definition: cs_flag.h:209
@ CS_FLAG_COMP_PFC
Definition: cs_flag.h:276
@ CS_FLAG_COMP_DIAM
Definition: cs_flag.h:284
@ CS_FLAG_COMP_DEQ
Definition: cs_flag.h:237
@ CS_FLAG_COMP_SEF
Definition: cs_flag.h:262
const cs_flag_t cs_flag_dual_face_byc
Definition: cs_flag.cpp:67
const cs_flag_t cs_flag_primal_vtx
Definition: cs_flag.cpp:51
const char * cs_flag_str_location(cs_flag_t loc)
Retrieve the label associated to a location flag.
Definition: cs_flag.cpp:133