Debian Codegraph @

include/deal.II/meshworker/assemble_flags.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2017 - 2023 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_mesh_worker_assemble_flags_h
16 #define dealii_mesh_worker_assemble_flags_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <vector>
22
23
24 DEAL_II_NAMESPACE_OPEN
25
26 /**
27 * @addtogroup MeshWorker
28 * @{
29 */
30
31 namespace MeshWorker
32 {
33 /**
34 * The enum type given to the mesh_loop() function, telling that function
35 * which elements need to be assembled.
36 *
37 * You can select more than one flag by concatenation using the bitwise or
38 * <code>operator|(AssembleFlags,AssembleFlags)</code>.
39 */
40 enum AssembleFlags
41 {
42 /**
43 * Do Nothing.
44 */
45 assemble_nothing = 0,
46 /**
47 * Assemble on locally owned cells.
48 */
49 assemble_own_cells = 0x0001,
50 /**
51 * Assemble on ghost cells.
52 */
53 assemble_ghost_cells = 0x0002,
54 /**
55 * Assemble on interior faces between two locally owned cells,
56 * visiting each face only once.
57 */
58 assemble_own_interior_faces_once = 0x0004,
59 /**
60 * Assemble on interior faces between two locally owned cells,
61 * visiting each interior face twice, once from each of the two
62 * adjacent cells.
63 */
64 assemble_own_interior_faces_both = 0x0008,
65 /**
66 * Assemble on faces between a locally owned cell and a ghost cell, making
67 * sure that only one of the processes will assemble these faces (from the
68 * finer side or the process with the lower mpi rank).
69 */
70 assemble_ghost_faces_once = 0x0010,
71 /**
72 * Assemble on faces between a locally owned cell and a ghost cell. Both
73 * processes will assemble these faces. Note that they are never
74 * assembled from both sides on a single process.
75 */
76 assemble_ghost_faces_both = 0x0020,
77 /**
78 * Assemble on boundary faces of the locally owned cells.
79 */
80 assemble_boundary_faces = 0x0040,
81
82 /**
83 * By default we assemble cell integrals before face integrals. If this
84 * flag is specified, cells will be assembled after faces and boundaries.
85 */
86 cells_after_faces = 0x0080,
87
88 /**
89 * Combination of flags to determine if any work on cells is done.
90 */
91 work_on_cells = assemble_own_cells | assemble_ghost_cells,
92
93 /**
94 * Combination of flags to determine if any work is done on faces.
95 */
96 work_on_faces = assemble_own_interior_faces_once |
97 assemble_own_interior_faces_both |
98 assemble_ghost_faces_once | assemble_ghost_faces_both,
99
100 /**
101 * Combination of flags to determine if any work is done on the boundary
102 * faces.
103 */
104 work_on_boundary = assemble_boundary_faces,
105 };
106
107
108 /**
109 * Output operator which outputs assemble flags as a set of or'd text values.
110 *
111 * @ref AssembleFlags
112 */
113 template <typename StreamType>
114 inline StreamType &
115 operator<<(StreamType &s, AssembleFlags u)
116 {
117 s << " AssembleFlags";
118 if (u & assemble_own_cells)
119 s << "|own_cells";
120 if (u & assemble_own_interior_faces_once)
121 s << "|own_faces_once";
122 if (u & assemble_own_interior_faces_both)
123 s << "|own_faces_both";
124 if (u & assemble_ghost_cells)
125 s << "|ghost_cells";
126 if (u & assemble_ghost_faces_once)
127 s << "|ghost_faces_once";
128 if (u & assemble_ghost_faces_both)
129 s << "|ghost_faces_both";
130 if (u & assemble_boundary_faces)
131 s << "|boundary_faces";
132 return s;
133 }
134
135
136 /**
137 * Global operator which returns an object in which all bits are set which are
138 * either set in the first or the second argument. This operator exists since
139 * if it did not then the result of the bit-or <tt>operator |</tt> would be an
140 * integer which would in turn trigger a compiler warning when we tried to
141 * assign it to an object of type AssembleFlags.
142 *
143 * @ref AssembleFlags
144 */
145 inline AssembleFlags
146 operator|(AssembleFlags f1, AssembleFlags f2)
147 {
148 return static_cast<AssembleFlags>(static_cast<unsigned int>(f1) |
149 static_cast<unsigned int>(f2));
150 }
151
152
153
154 /**
155 * Global operator which sets the bits from the second argument also in the
156 * first one.
157 *
158 * @ref AssembleFlags
159 */
160 inline AssembleFlags &
161 operator|=(AssembleFlags &f1, AssembleFlags f2)
162 {
163 f1 = f1 | f2;
164 return f1;
165 }
166
167
168 /**
169 * Global operator which returns an object in which all bits are set which are
170 * set in the first as well as the second argument. This operator exists since
171 * if it did not then the result of the bit-and <tt>operator &</tt> would be
172 * an integer which would in turn trigger a compiler warning when we tried to
173 * assign it to an object of type AssembleFlags.
174 *
175 * @ref AssembleFlags
176 */
177 inline AssembleFlags
178 operator&(AssembleFlags f1, AssembleFlags f2)
179 {
180 return static_cast<AssembleFlags>(static_cast<unsigned int>(f1) &
181 static_cast<unsigned int>(f2));
182 }
183
184
185 /**
186 * Global operator which clears all the bits in the first argument if they are
187 * not also set in the second argument.
188 *
189 * @ref AssembleFlags
190 */
191 inline AssembleFlags &
192 operator&=(AssembleFlags &f1, AssembleFlags f2)
193 {
194 f1 = f1 & f2;
195 return f1;
196 }
197 } // namespace MeshWorker
198
199 /** @} */
200
201 DEAL_II_NAMESPACE_CLOSE
202
203 #endif