8.0
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 extern const cs_flag_t cs_flag_primal_vtx;
166 extern const cs_flag_t cs_flag_primal_edge;
167 extern const cs_flag_t cs_flag_primal_face;
168 extern const cs_flag_t cs_flag_primal_cell;
169 extern const cs_flag_t cs_flag_vertex; /* equal to cs_flag_primal_vtx */
170 extern const cs_flag_t cs_flag_cell; /* equal to cs_flag_primal_cell */
171 extern const cs_flag_t cs_flag_boundary_face;
172 
173 extern const cs_flag_t cs_flag_dual_vtx;
174 extern const cs_flag_t cs_flag_dual_face;
175 extern const cs_flag_t cs_flag_dual_cell;
176 extern const cs_flag_t cs_flag_dual_cell_byc;
177 extern const cs_flag_t cs_flag_dual_face_byc;
178 
179 /* Part of dual cell closure belonging to a boundary primal face */
180 
182 
183 /* According to the extended flag defined below one can identify which set of
184  * quantities or connectivities have to be built on-the-fly and stored in a
185  * local structure possibly owned by each thread and with a cellwise scope */
186 
187 typedef unsigned int cs_eflag_t;
188 
189 /* Store predefined flags */
190 
191 extern const cs_eflag_t cs_flag_need_v;
192 extern const cs_eflag_t cs_flag_need_e;
193 extern const cs_eflag_t cs_flag_need_f;
194 extern const cs_eflag_t cs_flag_need_fe;
195 extern const cs_eflag_t cs_flag_need_ef;
196 extern const cs_eflag_t cs_flag_need_peq;
197 extern const cs_eflag_t cs_flag_need_dfq;
198 extern const cs_eflag_t cs_flag_need_pfq;
199 extern const cs_eflag_t cs_flag_need_deq;
200 extern const cs_eflag_t cs_flag_need_pfc;
201 
202 typedef enum {
203 
204  /* Compute simple and cellwise information for vertices */
205 
206  CS_FLAG_COMP_PV = 1 << 0, /* = 1 */
207 
208  /* Compute cellwise quantities for vertices */
209 
210  CS_FLAG_COMP_PVQ = 1 << 1, /* = 2 */
211 
212  /* Compute simple and cellwise information for edges */
213 
214  CS_FLAG_COMP_PE = 1 << 2, /* = 4 */
215 
216  /* Compute cellwise quantities for edges */
217 
218  CS_FLAG_COMP_PEQ = 1 << 3, /* = 8 */
219 
220  /* Compute cellwise quantities for dual faces (associated to edges) */
221 
222  CS_FLAG_COMP_DFQ = 1 << 4, /* = 16 */
223 
224  /* Compute simple and cellwise information for faces */
225 
226  CS_FLAG_COMP_PF = 1 << 5, /* = 32 */
227 
228  /* Compute cellwise quantities for faces */
229 
230  CS_FLAG_COMP_PFQ = 1 << 6, /* = 64 */
231 
232  /* Compute cellwise quantities for dual edges (associated to faces) */
233 
234  CS_FLAG_COMP_DEQ = 1 << 7, /* = 128 */
235 
236  /* Compute the cellwise connectivity edge to vertices */
237 
238  CS_FLAG_COMP_EV = 1 << 8, /* = 256 */
239 
240  /* Compute cellwise connectivity face to edges */
241 
242  CS_FLAG_COMP_FE = 1 << 9, /* = 512 */
243 
244  /* Compute cellwise quantities associated to the couple (face, edge) */
245 
246  CS_FLAG_COMP_FEQ = 1 << 10, /* = 1024 */
247 
248  /* Compute cellwise connectivity face to vertices */
249 
250  CS_FLAG_COMP_FV = 1 << 11, /* = 2048 */
251 
252  /* Compute cellwise connectivity edge to faces */
253 
254  CS_FLAG_COMP_EF = 1 << 12, /* = 4096 */
255 
256  /* Compute elemental portion of dual faces associated to the couple
257  (edge, face) */
258 
259  CS_FLAG_COMP_SEF = 1 << 13, /* = 8192 */
260 
261  /* Compute cellwise quantities related to the height of the pyramid with
262  basis spanned by a face and with apex the cell center */
263 
264  CS_FLAG_COMP_HFQ = 1 << 14, /* = 16384 */
265 
266  /* Compute cellwise orientation of oriented edges belonging to a face */
267 
268  CS_FLAG_COMP_FES = 1 << 15, /* = 32768 */
269 
270  /* Compute cellwise quantities related to the volume of the pyramid with
271  basis spanned by a face and with apex the cell center */
272 
273  CS_FLAG_COMP_PFC = 1 << 16, /* = 65536 */
274 
275  /* Compute cellwise quantities related to the volume surrounding an edge */
276 
277  CS_FLAG_COMP_PEC = 1 << 17, /* = 131072 */
278 
279  /* Compute cellwise diameters */
280 
281  CS_FLAG_COMP_DIAM = 1 << 18, /* = 262144 */
282 
284 
285 typedef enum {
286 
295 
297 
299 
300 /*============================================================================
301  * Public function prototypes
302  *============================================================================*/
303 
304 /*----------------------------------------------------------------------------*/
315 /*----------------------------------------------------------------------------*/
316 
317 static inline bool
318 cs_flag_test(cs_flag_t flag_to_check,
319  cs_flag_t reference)
320 {
321  if ((flag_to_check & reference) == reference)
322  return true;
323  else
324  return false;
325 }
326 
327 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 static inline bool
342  int n_masks,
343  cs_flag_t masks[])
344 {
345  for (int i = 0; i < n_masks; i++)
346  if ((flag_to_check & masks[i]) == masks[i])
347  return true;
348  return false;
349 }
350 
351 /*----------------------------------------------------------------------------*/
363 /*----------------------------------------------------------------------------*/
364 
365 static inline bool
366 cs_eflag_test(cs_eflag_t flag_to_check,
367  cs_eflag_t reference)
368 {
369  if ((flag_to_check & reference) == reference)
370  return true;
371  else
372  return false;
373 }
374 
375 /*----------------------------------------------------------------------------*/
381 /*----------------------------------------------------------------------------*/
382 
383 const char *
385 
386 /*----------------------------------------------------------------------------*/
387 
389 
390 #endif /* __CS_FLAG_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:509
#define END_C_DECLS
Definition: cs_defs.h:510
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:105
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:75
const cs_eflag_t cs_flag_need_e
Definition: cs_flag.c:90
const cs_eflag_t cs_flag_need_v
Definition: cs_flag.c:88
const cs_flag_t cs_flag_dual_closure_byf
Definition: cs_flag.c:68
cs_flag_location_t
Definition: cs_flag.h:285
@ CS_FLAG_LOCATION_DUAL_EDGE
Definition: cs_flag.h:292
@ CS_FLAG_LOCATION_DUAL_FACE
Definition: cs_flag.h:293
@ CS_FLAG_LOCATION_PRIMAL_FACE
Definition: cs_flag.h:289
@ CS_FLAG_N_LOCATIONS
Definition: cs_flag.h:296
@ CS_FLAG_LOCATION_PRIMAL_CELL
Definition: cs_flag.h:290
@ CS_FLAG_LOCATION_DUAL_CELL
Definition: cs_flag.h:294
@ CS_FLAG_LOCATION_PRIMAL_VTX
Definition: cs_flag.h:287
@ CS_FLAG_LOCATION_PRIMAL_EDGE
Definition: cs_flag.h:288
@ CS_FLAG_LOCATION_DUAL_VTX
Definition: cs_flag.h:291
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:318
const cs_flag_t cs_flag_dual_cell_byc
Definition: cs_flag.c:64
const cs_flag_t cs_flag_vertex
Definition: cs_flag.c:74
const cs_flag_t cs_flag_boundary_face
Definition: cs_flag.c:77
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:108
const char * cs_flag_str_location(cs_flag_t loc)
Retrieve the label associated to a location flag.
Definition: cs_flag.c:130
const cs_eflag_t cs_flag_need_peq
Definition: cs_flag.c:101
const cs_eflag_t cs_flag_need_dfq
Definition: cs_flag.c:103
const cs_eflag_t cs_flag_need_pfc
Definition: cs_flag.c:110
const cs_eflag_t cs_flag_need_ef
Definition: cs_flag.c:99
#define CS_FLAG_FACE
Definition: cs_flag.h:125
const cs_eflag_t cs_flag_need_f
Definition: cs_flag.c:93
#define CS_FLAG_PRIMAL
Definition: cs_flag.h:127
const cs_eflag_t cs_flag_need_fe
Definition: cs_flag.c:97
const cs_flag_t cs_flag_dual_cell
Definition: cs_flag.c:63
unsigned int cs_eflag_t
Definition: cs_flag.h:187
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:341
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:366
const cs_flag_t cs_flag_dual_vtx
Definition: cs_flag.c:60
cs_flag_comp_bits_t
Definition: cs_flag.h:202
@ CS_FLAG_COMP_DFQ
Definition: cs_flag.h:222
@ CS_FLAG_COMP_FV
Definition: cs_flag.h:250
@ CS_FLAG_COMP_PVQ
Definition: cs_flag.h:210
@ CS_FLAG_COMP_PE
Definition: cs_flag.h:214
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:246
@ CS_FLAG_COMP_HFQ
Definition: cs_flag.h:264
@ CS_FLAG_COMP_PEC
Definition: cs_flag.h:277
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:230
@ CS_FLAG_COMP_EF
Definition: cs_flag.h:254
@ CS_FLAG_COMP_PF
Definition: cs_flag.h:226
@ CS_FLAG_COMP_FES
Definition: cs_flag.h:268
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:238
@ CS_FLAG_COMP_FE
Definition: cs_flag.h:242
@ CS_FLAG_COMP_PEQ
Definition: cs_flag.h:218
@ CS_FLAG_COMP_PV
Definition: cs_flag.h:206
@ CS_FLAG_COMP_PFC
Definition: cs_flag.h:273
@ CS_FLAG_COMP_DIAM
Definition: cs_flag.h:281
@ CS_FLAG_COMP_DEQ
Definition: cs_flag.h:234
@ CS_FLAG_COMP_SEF
Definition: cs_flag.h:259
const cs_flag_t cs_flag_dual_face_byc
Definition: cs_flag.c:66
const cs_flag_t cs_flag_primal_vtx
Definition: cs_flag.c:55