8.1
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-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 /*----------------------------------------------------------------------------*/
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)
143 #define CS_FLAG_SCHEME_SCALAR (1 << 0)
144 #define CS_FLAG_SCHEME_VECTOR (1 << 1)
145 #define CS_FLAG_SCHEME_NAVSTO (1 << 2)
146 #define CS_FLAG_SCHEME_POLY0 (1 << 3)
147 #define CS_FLAG_SCHEME_POLY1 (1 << 4)
148 #define CS_FLAG_SCHEME_POLY2 (1 << 5)
154 /*============================================================================
155  * Type definitions
156  *============================================================================*/
157 
158 typedef unsigned char cs_mask_t; /* Elementary flag */
159 
160 /*============================================================================
161  * Global variables
162  *============================================================================*/
163 
164 /* Default locations */
165 
166 extern const cs_flag_t cs_flag_primal_vtx;
167 extern const cs_flag_t cs_flag_primal_edge;
168 extern const cs_flag_t cs_flag_primal_face;
169 extern const cs_flag_t cs_flag_primal_cell;
170 extern const cs_flag_t cs_flag_vertex; /* equal to cs_flag_primal_vtx */
171 extern const cs_flag_t cs_flag_cell; /* equal to cs_flag_primal_cell */
172 extern const cs_flag_t cs_flag_boundary_face;
173 
174 extern const cs_flag_t cs_flag_dual_vtx;
175 extern const cs_flag_t cs_flag_dual_face;
176 extern const cs_flag_t cs_flag_dual_cell;
177 
179 extern const cs_flag_t cs_flag_dual_cell_byc;
180 extern const cs_flag_t cs_flag_dual_face_byc;
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 
190 typedef unsigned int cs_eflag_t;
191 
192 /* Store predefined flags */
193 
194 extern const cs_eflag_t cs_flag_need_v;
195 extern const cs_eflag_t cs_flag_need_e;
196 extern const cs_eflag_t cs_flag_need_f;
197 extern const cs_eflag_t cs_flag_need_fe;
198 extern const cs_eflag_t cs_flag_need_ef;
199 extern const cs_eflag_t cs_flag_need_peq;
200 extern const cs_eflag_t cs_flag_need_dfq;
201 extern const cs_eflag_t cs_flag_need_pfq;
202 extern const cs_eflag_t cs_flag_need_deq;
203 extern const cs_eflag_t cs_flag_need_pfc;
204 
205 typedef 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 
288 typedef enum {
289 
298 
300 
302 
303 /*============================================================================
304  * Public function prototypes
305  *============================================================================*/
306 
307 /*----------------------------------------------------------------------------*/
318 /*----------------------------------------------------------------------------*/
319 
320 static inline bool
321 cs_flag_test(cs_flag_t flag_to_check,
322  cs_flag_t reference)
323 {
324  if ((flag_to_check & reference) == reference)
325  return true;
326  else
327  return false;
328 }
329 
330 /*----------------------------------------------------------------------------*/
341 /*----------------------------------------------------------------------------*/
342 
343 static inline bool
345  int n_masks,
346  cs_flag_t masks[])
347 {
348  for (int i = 0; i < n_masks; i++)
349  if ((flag_to_check & masks[i]) == masks[i])
350  return true;
351  return false;
352 }
353 
354 /*----------------------------------------------------------------------------*/
366 /*----------------------------------------------------------------------------*/
367 
368 static inline bool
369 cs_eflag_test(cs_eflag_t flag_to_check,
370  cs_eflag_t reference)
371 {
372  if ((flag_to_check & reference) == reference)
373  return true;
374  else
375  return false;
376 }
377 
378 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 
386 const char *
388 
389 /*----------------------------------------------------------------------------*/
390 
392 
393 #endif /* __CS_FLAG_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
#define END_C_DECLS
Definition: cs_defs.h:515
unsigned short int cs_flag_t
Definition: cs_defs.h:321
const cs_flag_t cs_flag_primal_cell
Definition: cs_flag.c: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.c:108
const cs_flag_t cs_flag_dual_face
Definition: cs_flag.c:62
#define CS_FLAG_EDGE
Definition: cs_flag.h:124
const cs_flag_t cs_flag_cell
Definition: cs_flag.c:78
const cs_eflag_t cs_flag_need_e
Definition: cs_flag.c:93
const cs_eflag_t cs_flag_need_v
Definition: cs_flag.c:91
const cs_flag_t cs_flag_dual_closure_byf
Definition: cs_flag.c:71
cs_flag_location_t
Definition: cs_flag.h:288
@ CS_FLAG_LOCATION_DUAL_EDGE
Definition: cs_flag.h:295
@ 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:299
@ 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 a two flag share the same pattern Return true if the flag to check has at least the pattern ...
Definition: cs_flag.h:321
const cs_flag_t cs_flag_dual_cell_byc
Definition: cs_flag.c:67
const cs_flag_t cs_flag_vertex
Definition: cs_flag.c:77
const cs_flag_t cs_flag_boundary_face
Definition: cs_flag.c:80
const cs_flag_t cs_flag_primal_edge
Definition: cs_flag.c:56
unsigned char cs_mask_t
Definition: cs_flag.h:158
#define CS_FLAG_DUAL
Definition: cs_flag.h:128
const cs_eflag_t cs_flag_need_deq
Definition: cs_flag.c:111
const char * cs_flag_str_location(cs_flag_t loc)
Retrieve the label associated to a location flag.
Definition: cs_flag.c:133
const cs_eflag_t cs_flag_need_peq
Definition: cs_flag.c:104
const cs_eflag_t cs_flag_need_dfq
Definition: cs_flag.c:106
const cs_eflag_t cs_flag_need_pfc
Definition: cs_flag.c:113
const cs_eflag_t cs_flag_need_ef
Definition: cs_flag.c:102
#define CS_FLAG_FACE
Definition: cs_flag.h:125
const cs_eflag_t cs_flag_need_f
Definition: cs_flag.c:96
#define CS_FLAG_PRIMAL
Definition: cs_flag.h:127
const cs_eflag_t cs_flag_need_fe
Definition: cs_flag.c:100
const cs_flag_t cs_flag_primal_edge_byc
Definition: cs_flag.c:65
const cs_flag_t cs_flag_dual_cell
Definition: cs_flag.c:63
unsigned int cs_eflag_t
Definition: cs_flag.h:190
const cs_flag_t cs_flag_primal_face
Definition: cs_flag.c: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:344
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:369
const cs_flag_t cs_flag_dual_vtx
Definition: cs_flag.c:60
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.c:69
const cs_flag_t cs_flag_primal_vtx
Definition: cs_flag.c:55