| 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_grid_tria_info_cache_update_flags_h |
| 16 |
#define dealii_grid_tria_info_cache_update_flags_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
DEAL_II_NAMESPACE_OPEN |
| 22 |
|
| 23 |
namespace GridTools |
| 24 |
{ |
| 25 |
/** |
| 26 |
* The enum type given to the Cache class to select what |
| 27 |
* information to update. |
| 28 |
* |
| 29 |
* You can select more than one flag by concatenation using the bitwise or |
| 30 |
* <code>operator|(CacheUpdateFlags,CacheUpdateFlags)</code>. |
| 31 |
*/ |
| 32 |
enum CacheUpdateFlags |
| 33 |
{ |
| 34 |
/** |
| 35 |
* Update Nothing. |
| 36 |
*/ |
| 37 |
update_nothing = 0x000, |
| 38 |
|
| 39 |
/** |
| 40 |
* Update vertex_to_cell_map, as returned by |
| 41 |
* GridTools::vertex_to_cell_map(). |
| 42 |
*/ |
| 43 |
update_vertex_to_cell_map = 0x001, |
| 44 |
|
| 45 |
/** |
| 46 |
* Update vertex_to_cell_centers_directions, as returned by |
| 47 |
* GridTools::vertex_to_cell_centers_directions() |
| 48 |
*/ |
| 49 |
update_vertex_to_cell_centers_directions = |
| 50 |
update_vertex_to_cell_map | 0x002, |
| 51 |
|
| 52 |
/** |
| 53 |
* Update a mapping of used vertices. |
| 54 |
*/ |
| 55 |
update_used_vertices = 0x008, |
| 56 |
|
| 57 |
/** |
| 58 |
* Update an RTree of the used vertices. |
| 59 |
*/ |
| 60 |
update_used_vertices_rtree = 0x010, |
| 61 |
|
| 62 |
/** |
| 63 |
* Update an RTree of the cell bounding boxes. |
| 64 |
*/ |
| 65 |
update_cell_bounding_boxes_rtree = 0x020, |
| 66 |
|
| 67 |
/** |
| 68 |
* Update the covering rtree object, initialized with pairs |
| 69 |
* of a bounding box and an unsigned int. The bounding |
| 70 |
* boxes are used to describe approximately which portion |
| 71 |
* of the mesh contains locally owned cells by the |
| 72 |
* process of rank the second element of the pair. |
| 73 |
*/ |
| 74 |
update_covering_rtree = 0x040, |
| 75 |
|
| 76 |
/** |
| 77 |
* Update an RTree of locally owned cell bounding boxes. |
| 78 |
*/ |
| 79 |
update_locally_owned_cell_bounding_boxes_rtree = 0x080, |
| 80 |
|
| 81 |
/** |
| 82 |
* Update vertex to neighbor subdomain |
| 83 |
*/ |
| 84 |
update_vertex_to_neighbor_subdomain = 0x100, |
| 85 |
|
| 86 |
/** |
| 87 |
* Update the information about which subdomains are connected to each |
| 88 |
* vertex. |
| 89 |
*/ |
| 90 |
update_vertex_with_ghost_neighbors = 0x200, |
| 91 |
|
| 92 |
/** |
| 93 |
* Update all objects. |
| 94 |
*/ |
| 95 |
update_all = 0xFFF, |
| 96 |
}; |
| 97 |
|
| 98 |
|
| 99 |
/** |
| 100 |
* Output operator which outputs assemble flags as a set of or'd text values. |
| 101 |
* |
| 102 |
* @ref CacheUpdateFlags |
| 103 |
*/ |
| 104 |
template <typename StreamType> |
| 105 |
inline StreamType & |
| 106 |
operator<<(StreamType &s, const CacheUpdateFlags u) |
| 107 |
{ |
| 108 |
s << " CacheUpdateFlags"; |
| 109 |
if (u & update_vertex_to_cell_map) |
| 110 |
s << "|vertex_to_cell_map"; |
| 111 |
if (u & update_vertex_to_cell_centers_directions) |
| 112 |
s << "|vertex_to_cells_centers_directions"; |
| 113 |
if (u & update_covering_rtree) |
| 114 |
s << "|covering_rtree"; |
| 115 |
return s; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
/** |
| 120 |
* Global operator which returns an object in which all bits are set which are |
| 121 |
* either set in the first or the second argument. This operator exists since |
| 122 |
* if it did not then the result of the bit-or <tt>operator |</tt> would be an |
| 123 |
* integer which would in turn trigger a compiler warning when we tried to |
| 124 |
* assign it to an object of type CacheUpdateFlags. |
| 125 |
* |
| 126 |
* @ref CacheUpdateFlags |
| 127 |
*/ |
| 128 |
inline CacheUpdateFlags |
| 129 |
operator|(const CacheUpdateFlags f1, const CacheUpdateFlags f2) |
| 130 |
{ |
| 131 |
return static_cast<CacheUpdateFlags>(static_cast<unsigned int>(f1) | |
| 132 |
static_cast<unsigned int>(f2)); |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Global operator which returns an object in which all bits are set which are |
| 137 |
* not set in the argument. This operator exists since |
| 138 |
* if it did not then the result of the bit-negation <tt>operator ~</tt> would |
| 139 |
* be an integer which would in turn trigger a compiler warning when we tried |
| 140 |
* to assign it to an object of type CacheUpdateFlags. |
| 141 |
* |
| 142 |
* @ref CacheUpdateFlags |
| 143 |
*/ |
| 144 |
inline CacheUpdateFlags |
| 145 |
operator~(const CacheUpdateFlags f1) |
| 146 |
{ |
| 147 |
return static_cast<CacheUpdateFlags>(static_cast<unsigned int>(f1) ^ |
| 148 |
static_cast<unsigned int>(update_all)); |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
/** |
| 154 |
* Global operator which sets the bits from the second argument also in the |
| 155 |
* first one. |
| 156 |
* |
| 157 |
* @ref CacheUpdateFlags |
| 158 |
*/ |
| 159 |
inline CacheUpdateFlags & |
| 160 |
operator|=(CacheUpdateFlags &f1, const CacheUpdateFlags f2) |
| 161 |
{ |
| 162 |
f1 = f1 | f2; |
| 163 |
return f1; |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
/** |
| 168 |
* Global operator which returns an object in which all bits are set which are |
| 169 |
* set in the first as well as the second argument. This operator exists since |
| 170 |
* if it did not then the result of the bit-and <tt>operator &</tt> would be |
| 171 |
* an integer which would in turn trigger a compiler warning when we tried to |
| 172 |
* assign it to an object of type CacheUpdateFlags. |
| 173 |
* |
| 174 |
* @ref CacheUpdateFlags |
| 175 |
*/ |
| 176 |
inline CacheUpdateFlags |
| 177 |
operator&(const CacheUpdateFlags f1, const CacheUpdateFlags f2) |
| 178 |
{ |
| 179 |
return static_cast<CacheUpdateFlags>(static_cast<unsigned int>(f1) & |
| 180 |
static_cast<unsigned int>(f2)); |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
/** |
| 185 |
* Global operator which clears all the bits in the first argument if they are |
| 186 |
* not also set in the second argument. |
| 187 |
* |
| 188 |
* @ref CacheUpdateFlags |
| 189 |
*/ |
| 190 |
inline CacheUpdateFlags & |
| 191 |
operator&=(CacheUpdateFlags &f1, const CacheUpdateFlags f2) |
| 192 |
{ |
| 193 |
f1 = f1 & f2; |
| 194 |
return f1; |
| 195 |
} |
| 196 |
|
| 197 |
} // namespace GridTools |
| 198 |
DEAL_II_NAMESPACE_CLOSE |
| 199 |
|
| 200 |
#endif |