7.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-2021 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 
73 #define CS_FLAG_SYS_MASS_MATRIX (1 << 0)
74 #define CS_FLAG_SYS_SYM (1 << 1)
75 #define CS_FLAG_SYS_TIME_DIAG (1 << 2)
76 #define CS_FLAG_SYS_REAC_DIAG (1 << 3)
77 #define CS_FLAG_SYS_SOURCES_HLOC (1 << 4)
78 #define CS_FLAG_SYS_VECTOR (1 << 5)
87 #define CS_FLAG_STATE_UNIFORM (1 << 0)
88 #define CS_FLAG_STATE_CELLWISE (1 << 1)
89 #define CS_FLAG_STATE_FACEWISE (1 << 2)
90 #define CS_FLAG_STATE_STEADY (1 << 3)
91 #define CS_FLAG_STATE_POTENTIAL (1 << 4)
92 #define CS_FLAG_STATE_CIRCULATION (1 << 5)
93 #define CS_FLAG_STATE_FLUX (1 << 6)
94 #define CS_FLAG_STATE_DENSITY (1 << 7)
95 #define CS_FLAG_STATE_OWNER (1 << 8)
104 #define CS_FLAG_FULL_LOC (1 << 0)
105 #define CS_FLAG_SCALAR (1 << 1)
106 #define CS_FLAG_VECTOR (1 << 2)
107 #define CS_FLAG_TENSOR (1 << 3)
108 #define CS_FLAG_VERTEX (1 << 4)
109 #define CS_FLAG_EDGE (1 << 5)
110 #define CS_FLAG_FACE (1 << 6)
111 #define CS_FLAG_CELL (1 << 7)
112 #define CS_FLAG_PRIMAL (1 << 8)
113 #define CS_FLAG_DUAL (1 << 9)
114 #define CS_FLAG_BORDER (1 << 10)
115 #define CS_FLAG_BY_CELL (1 << 11)
116 #define CS_FLAG_BY_FACE (1 << 12)
128 #define CS_FLAG_SCHEME_SCALAR (1 << 0)
129 #define CS_FLAG_SCHEME_VECTOR (1 << 1)
130 #define CS_FLAG_SCHEME_NAVSTO (1 << 2)
131 #define CS_FLAG_SCHEME_POLY0 (1 << 3)
132 #define CS_FLAG_SCHEME_POLY1 (1 << 4)
133 #define CS_FLAG_SCHEME_POLY2 (1 << 5)
139 /*============================================================================
140  * Type definitions
141  *============================================================================*/
142 
143 typedef unsigned char cs_mask_t; /* Elementary flag */
144 
145 /*============================================================================
146  * Global variables
147  *============================================================================*/
148 
149 /* Default locations */
150 extern const cs_flag_t cs_flag_primal_vtx;
151 extern const cs_flag_t cs_flag_primal_edge;
152 extern const cs_flag_t cs_flag_primal_face;
153 extern const cs_flag_t cs_flag_primal_cell;
154 extern const cs_flag_t cs_flag_vertex; /* equal to cs_flag_primal_vtx */
155 extern const cs_flag_t cs_flag_cell; /* equal to cs_flag_primal_cell */
156 extern const cs_flag_t cs_flag_boundary_face;
157 
158 extern const cs_flag_t cs_flag_dual_vtx;
159 extern const cs_flag_t cs_flag_dual_face;
160 extern const cs_flag_t cs_flag_dual_cell;
161 extern const cs_flag_t cs_flag_dual_face_byc;
162 
163 /* Part of dual cell closure belonging to a boundary primal face */
165 
166 /* According to the extended flag defined below one can identify which set of
167  * quantities or connectivities have to be built on-the-fly and stored in a
168  * local structure possibly owned by each thread and with a cellwise scope */
169 
170 typedef unsigned int cs_eflag_t;
171 
172 /* Store predefined flags */
173 extern const cs_eflag_t cs_flag_need_v;
174 extern const cs_eflag_t cs_flag_need_e;
175 extern const cs_eflag_t cs_flag_need_f;
176 extern const cs_eflag_t cs_flag_need_fe;
177 extern const cs_eflag_t cs_flag_need_ef;
178 extern const cs_eflag_t cs_flag_need_peq;
179 extern const cs_eflag_t cs_flag_need_dfq;
180 extern const cs_eflag_t cs_flag_need_pfq;
181 extern const cs_eflag_t cs_flag_need_deq;
182 extern const cs_eflag_t cs_flag_need_pfc;
183 
184 typedef enum {
185 
186  /* Compute simple and cellwise information for vertices */
187  CS_FLAG_COMP_PV = 1 << 0, /* = 1 */
188 
189  /* Compute cellwise quantities for vertices */
190  CS_FLAG_COMP_PVQ = 1 << 1, /* = 2 */
191 
192  /* Compute simple and cellwise information for edges */
193  CS_FLAG_COMP_PE = 1 << 2, /* = 4 */
194 
195  /* Compute cellwise quantities for edges */
196  CS_FLAG_COMP_PEQ = 1 << 3, /* = 8 */
197 
198  /* Compute cellwise quantities for dual faces (associated to edges) */
199  CS_FLAG_COMP_DFQ = 1 << 4, /* = 16 */
200 
201  /* Compute simple and cellwise information for faces */
202  CS_FLAG_COMP_PF = 1 << 5, /* = 32 */
203 
204  /* Compute cellwise quantities for faces */
205  CS_FLAG_COMP_PFQ = 1 << 6, /* = 64 */
206 
207  /* Compute cellwise quantities for dual edges (associated to faces) */
208  CS_FLAG_COMP_DEQ = 1 << 7, /* = 128 */
209 
210  /* Compute the cellwise connectivity edge to vertices */
211  CS_FLAG_COMP_EV = 1 << 8, /* = 256 */
212 
213  /* Compute cellwise connectivity face to edges */
214  CS_FLAG_COMP_FE = 1 << 9, /* = 512 */
215 
216  /* Compute cellwise quantities associated to the couple (face, edge) */
217  CS_FLAG_COMP_FEQ = 1 << 10, /* = 1024 */
218 
219  /* Compute cellwise connectivity face to vertices */
220  CS_FLAG_COMP_FV = 1 << 11, /* = 2048 */
221 
222  /* Compute cellwise connectivity edge to faces */
223  CS_FLAG_COMP_EF = 1 << 12, /* = 4096 */
224 
225  /* Compute elemental portion of dual faces associated to the couple
226  (edge, face) */
227  CS_FLAG_COMP_SEF = 1 << 13, /* = 8192 */
228 
229  /* Compute cellwise quantities related to the height of the pyramid with
230  basis spanned by a face and with apex the cell center */
231  CS_FLAG_COMP_HFQ = 1 << 14, /* = 16384 */
232 
233  /* Compute cellwise orientation of oriented edges belonging to a face */
234  CS_FLAG_COMP_FES = 1 << 15, /* = 32768 */
235 
236  /* Compute cellwise quantities related to the volume of the pyramid with
237  basis spanned by a face and with apex the cell center */
238  CS_FLAG_COMP_PFC = 1 << 16, /* = 65536 */
239 
240  /* Compute cellwise quantities related to the volume surrounding an edge */
241  CS_FLAG_COMP_PEC = 1 << 17, /* = 131072 */
242 
243  /* Compute cellwise diameters */
244  CS_FLAG_COMP_DIAM = 1 << 18, /* = 262144 */
245 
247 
248 /*============================================================================
249  * Public function prototypes
250  *============================================================================*/
251 
252 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
265 static inline bool
266 cs_flag_test(cs_flag_t flag_to_check,
267  cs_flag_t reference)
268 {
269  if ((flag_to_check & reference) == reference)
270  return true;
271  else
272  return false;
273 }
274 
275 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 static inline bool
289 cs_flag_at_least(cs_flag_t flag_to_check,
290  int n_masks,
291  cs_flag_t masks[])
292 {
293  for (int i = 0; i < n_masks; i++)
294  if ((flag_to_check & masks[i]) == masks[i])
295  return true;
296  return false;
297 }
298 
299 /*----------------------------------------------------------------------------*/
311 /*----------------------------------------------------------------------------*/
312 
313 static inline bool
314 cs_eflag_test(cs_eflag_t flag_to_check,
315  cs_eflag_t reference)
316 {
317  if ((flag_to_check & reference) == reference)
318  return true;
319  else
320  return false;
321 }
322 
323 /*----------------------------------------------------------------------------*/
329 /*----------------------------------------------------------------------------*/
330 
331 const char *
333 
334 /*----------------------------------------------------------------------------*/
335 
337 
338 #endif /* __CS_FLAG_H__ */
Definition: cs_flag.h:227
Definition: cs_flag.h:205
Definition: cs_flag.h:220
unsigned char cs_mask_t
Definition: cs_flag.h:143
const char * cs_flag_str_location(cs_flag_t loc)
Retrieve the label associated to a location flag.
Definition: cs_flag.c:124
const cs_flag_t cs_flag_boundary_face
Definition: cs_flag.c:72
Definition: cs_flag.h:202
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
const cs_flag_t cs_flag_dual_cell
Definition: cs_flag.c:61
Definition: cs_flag.h:241
const cs_flag_t cs_flag_primal_cell
Definition: cs_flag.c:56
Definition: cs_flag.h:238
Definition: cs_flag.h:211
Definition: cs_flag.h:193
const cs_eflag_t cs_flag_need_e
Definition: cs_flag.c:84
const cs_eflag_t cs_flag_need_pfq
Definition: cs_flag.c:99
Definition: cs_flag.h:223
const cs_flag_t cs_flag_dual_face_byc
Definition: cs_flag.c:62
const cs_eflag_t cs_flag_need_deq
Definition: cs_flag.c:102
Definition: cs_flag.h:196
const cs_flag_t cs_flag_dual_face
Definition: cs_flag.c:60
const cs_eflag_t cs_flag_need_pfc
Definition: cs_flag.c:104
const cs_flag_t cs_flag_primal_face
Definition: cs_flag.c:55
Definition: cs_flag.h:231
Definition: cs_flag.h:208
const cs_flag_t cs_flag_dual_closure_byf
Definition: cs_flag.c:64
const cs_flag_t cs_flag_primal_vtx
Definition: cs_flag.c:53
const cs_eflag_t cs_flag_need_peq
Definition: cs_flag.c:95
Definition: cs_flag.h:214
const cs_eflag_t cs_flag_need_f
Definition: cs_flag.c:87
const cs_flag_t cs_flag_primal_edge
Definition: cs_flag.c:54
#define END_C_DECLS
Definition: cs_defs.h:511
unsigned short int cs_flag_t
Definition: cs_defs.h:324
Definition: cs_flag.h:244
Definition: cs_flag.h:234
unsigned int cs_eflag_t
Definition: cs_flag.h:170
const cs_eflag_t cs_flag_need_fe
Definition: cs_flag.c:91
cs_flag_comp_bits_t
Definition: cs_flag.h:184
const cs_flag_t cs_flag_vertex
Definition: cs_flag.c:69
const cs_eflag_t cs_flag_need_ef
Definition: cs_flag.c:93
Definition: cs_flag.h:187
Definition: cs_flag.h:190
const cs_eflag_t cs_flag_need_v
Definition: cs_flag.c:82
const cs_flag_t cs_flag_cell
Definition: cs_flag.c:70
Definition: cs_flag.h:217
const cs_eflag_t cs_flag_need_dfq
Definition: cs_flag.c:97
const cs_flag_t cs_flag_dual_vtx
Definition: cs_flag.c:58
Definition: cs_flag.h:199