| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2010 - 2025 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_types_h |
| 16 |
#define dealii_types_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <cstdint> |
| 22 |
#include <type_traits> // make_signed_t |
| 23 |
|
| 24 |
|
| 25 |
DEAL_II_NAMESPACE_OPEN |
| 26 |
|
| 27 |
/** |
| 28 |
* A namespace in which we declare alias for types used in deal.II, as well |
| 29 |
* as special values for these types. |
| 30 |
*/ |
| 31 |
namespace types |
| 32 |
{ |
| 33 |
/** |
| 34 |
* The type used to represent face and line orientations. |
| 35 |
* |
| 36 |
* See the |
| 37 |
* @ref GlossCombinedOrientation "glossary" |
| 38 |
* for more information. |
| 39 |
*/ |
| 40 |
using geometric_orientation = unsigned char; |
| 41 |
|
| 42 |
/** |
| 43 |
* The type used to denote subdomain_ids of cells. |
| 44 |
* |
| 45 |
* See the |
| 46 |
* @ref GlossSubdomainId "glossary" |
| 47 |
* for more information. |
| 48 |
* |
| 49 |
* There is a special value, numbers::invalid_subdomain_id that is used to |
| 50 |
* indicate an invalid value of this type. |
| 51 |
*/ |
| 52 |
using subdomain_id = unsigned int; |
| 53 |
|
| 54 |
/** |
| 55 |
* The type used for global indices of vertices. |
| 56 |
*/ |
| 57 |
using global_vertex_index = std::uint64_t; |
| 58 |
|
| 59 |
/** |
| 60 |
* An identifier that denotes the MPI type associated with |
| 61 |
* types::global_vertex_index. |
| 62 |
* |
| 63 |
* This preprocessor variable is deprecated. Use the variable |
| 64 |
* `Utilities::MPI::mpi_type_id_for_type<types::global_vertex_index>` |
| 65 |
* instead. |
| 66 |
*/ |
| 67 |
#define DEAL_II_VERTEX_INDEX_MPI_TYPE MPI_UINT64_T |
| 68 |
|
| 69 |
/** |
| 70 |
* The type in which we store the active and future FE indices. |
| 71 |
*/ |
| 72 |
using fe_index = unsigned short int; |
| 73 |
|
| 74 |
/** |
| 75 |
* The type used to denote the global index of degrees of freedom. This |
| 76 |
* type is then also used for querying the global *number* of degrees |
| 77 |
* of freedom, since the number is simply the largest index plus one. |
| 78 |
* |
| 79 |
* While in sequential computations the 4 billion indices of 32-bit unsigned |
| 80 |
* integers is plenty, parallel computations using (for example) the |
| 81 |
* parallel::distributed::Triangulation class can overflow this number and |
| 82 |
* consequently, deal.II chooses a larger integer type when |
| 83 |
* configured to use 64-bit indices. |
| 84 |
* |
| 85 |
* The data type always corresponds to an unsigned integer type. |
| 86 |
* |
| 87 |
* See the |
| 88 |
* @ref GlobalDoFIndex |
| 89 |
* page for guidance on when this type should or should not be used. |
| 90 |
*/ |
| 91 |
#ifdef DEAL_II_WITH_64BIT_INDICES |
| 92 |
using global_dof_index = std::uint64_t; |
| 93 |
#else |
| 94 |
using global_dof_index = unsigned int; |
| 95 |
#endif |
| 96 |
|
| 97 |
/** |
| 98 |
* Signed version of global_dof_index. |
| 99 |
* This is useful for interacting with Trilinos' Tpetra that only works well |
| 100 |
* with a signed global ordinal type. |
| 101 |
*/ |
| 102 |
#ifdef DEAL_II_WITH_64BIT_INDICES |
| 103 |
using signed_global_dof_index = long long; |
| 104 |
#else |
| 105 |
using signed_global_dof_index = int; |
| 106 |
#endif |
| 107 |
|
| 108 |
/** |
| 109 |
* An identifier that denotes the MPI type associated with |
| 110 |
* types::global_dof_index. |
| 111 |
* |
| 112 |
* This preprocessor variable is deprecated. Use the variable |
| 113 |
* `Utilities::MPI::mpi_type_id_for_type<types::global_dof_index>` |
| 114 |
* instead. |
| 115 |
*/ |
| 116 |
#ifdef DEAL_II_WITH_64BIT_INDICES |
| 117 |
# define DEAL_II_DOF_INDEX_MPI_TYPE MPI_UINT64_T |
| 118 |
#else |
| 119 |
# define DEAL_II_DOF_INDEX_MPI_TYPE MPI_UNSIGNED |
| 120 |
#endif |
| 121 |
|
| 122 |
/** |
| 123 |
* The type used to denote the global index of a cell. This type |
| 124 |
* is then also used for querying the global *number* of cells in |
| 125 |
* a triangulation since the number is simply the largest index plus one. |
| 126 |
* |
| 127 |
* While in sequential computations the 4 billion indices of 32-bit unsigned |
| 128 |
* integers is plenty, parallel computations using (for example) the |
| 129 |
* parallel::distributed::Triangulation class can overflow this number and |
| 130 |
* consequently, deal.II chooses a larger integer type when |
| 131 |
* configured to use 64-bit indices. |
| 132 |
* |
| 133 |
* The data type always corresponds to an unsigned integer type. |
| 134 |
*/ |
| 135 |
#ifdef DEAL_II_WITH_64BIT_INDICES |
| 136 |
using global_cell_index = std::uint64_t; |
| 137 |
#else |
| 138 |
using global_cell_index = unsigned int; |
| 139 |
#endif |
| 140 |
|
| 141 |
/** |
| 142 |
* The type used for coarse-cell ids. See the glossary |
| 143 |
* entry on |
| 144 |
* @ref GlossCoarseCellId "coarse cell IDs" |
| 145 |
* for more information. |
| 146 |
*/ |
| 147 |
using coarse_cell_id = global_cell_index; |
| 148 |
|
| 149 |
/** |
| 150 |
* The type used to denote boundary indicators associated with every piece |
| 151 |
* of the boundary of the domain. |
| 152 |
* |
| 153 |
* There is a special value, numbers::internal_face_boundary_id that is used |
| 154 |
* to indicate an invalid value of this type and that is used as the |
| 155 |
* boundary indicator for faces that are in the interior of the domain and |
| 156 |
* therefore not part of any addressable boundary component. |
| 157 |
* |
| 158 |
* @see |
| 159 |
* @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" |
| 160 |
*/ |
| 161 |
using boundary_id = unsigned int; |
| 162 |
|
| 163 |
/** |
| 164 |
* The type used to denote manifold indicators associated with every object |
| 165 |
* of the mesh. |
| 166 |
* |
| 167 |
* There is a special value, numbers::flat_manifold_id that is used to |
| 168 |
* indicate the standard cartesian manifold. |
| 169 |
* |
| 170 |
* @see |
| 171 |
* @ref GlossManifoldIndicator "Glossary entry on manifold indicators" |
| 172 |
*/ |
| 173 |
using manifold_id = unsigned int; |
| 174 |
|
| 175 |
/** |
| 176 |
* The type used to denote material indicators associated with every cell. |
| 177 |
* |
| 178 |
* There is a special value, numbers::invalid_material_id that is used to |
| 179 |
* indicate an invalid value of this type. |
| 180 |
* |
| 181 |
* @see |
| 182 |
* @ref GlossMaterialId "Glossary entry on material indicators" |
| 183 |
*/ |
| 184 |
using material_id = unsigned int; |
| 185 |
|
| 186 |
/** |
| 187 |
* The type used to denote geometric entity types. |
| 188 |
* |
| 189 |
* @deprecated This type was previously only used in library internals and is |
| 190 |
* deprecated without replacement. |
| 191 |
*/ |
| 192 |
using geometric_entity_type DEAL_II_DEPRECATED_EARLY = std::uint8_t; |
| 193 |
} // namespace types |
| 194 |
|
| 195 |
/** |
| 196 |
* Declare type used in Epetra. |
| 197 |
*/ |
| 198 |
using TrilinosScalar = double; |
| 199 |
|
| 200 |
|
| 201 |
namespace TrilinosWrappers |
| 202 |
{ |
| 203 |
namespace types |
| 204 |
{ |
| 205 |
/** |
| 206 |
* Declare type of 64 bit integer used in the Epetra package of Trilinos. |
| 207 |
*/ |
| 208 |
using int64_type = long long int; |
| 209 |
|
| 210 |
#ifdef DEAL_II_WITH_64BIT_INDICES |
| 211 |
/** |
| 212 |
* Declare type of integer used in the Epetra package of Trilinos. |
| 213 |
*/ |
| 214 |
using int_type = int64_type; |
| 215 |
#else |
| 216 |
/** |
| 217 |
* Declare type of integer used in the Epetra package of Trilinos. |
| 218 |
*/ |
| 219 |
using int_type = int; |
| 220 |
#endif |
| 221 |
} // namespace types |
| 222 |
} // namespace TrilinosWrappers |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
namespace numbers |
| 227 |
{ |
| 228 |
/** |
| 229 |
* Representation of the largest number that can be put into an unsigned |
| 230 |
* integer. This value is widely used throughout the library as a marker for |
| 231 |
* an invalid unsigned integer value, such as an invalid array index, an |
| 232 |
* invalid array size, and the like. |
| 233 |
* |
| 234 |
* This value is an example of an |
| 235 |
* @ref GlossInvalidValue "invalid value". |
| 236 |
* See there for more information. |
| 237 |
*/ |
| 238 |
constexpr unsigned int invalid_unsigned_int = static_cast<unsigned int>(-1); |
| 239 |
|
| 240 |
/** |
| 241 |
* Representation of the largest number that can be put into a size_type. |
| 242 |
* This value is used throughout the library as a marker for an invalid |
| 243 |
* size_type value, such as an invalid array index, an invalid array size, |
| 244 |
* and the like. Invalid_size_type is equivalent to invalid_dof_index. |
| 245 |
* |
| 246 |
* This value is an example of an |
| 247 |
* @ref GlossInvalidValue "invalid value". |
| 248 |
* See there for more information. |
| 249 |
*/ |
| 250 |
constexpr types::global_dof_index invalid_size_type = |
| 251 |
static_cast<types::global_dof_index>(-1); |
| 252 |
|
| 253 |
/** |
| 254 |
* An invalid value for active and future fe indices. |
| 255 |
* |
| 256 |
* This value is an example of an |
| 257 |
* @ref GlossInvalidValue "invalid value". |
| 258 |
* See there for more information. |
| 259 |
*/ |
| 260 |
constexpr types::fe_index invalid_fe_index = static_cast<types::fe_index>(-1); |
| 261 |
|
| 262 |
/** |
| 263 |
* An invalid value for indices of degrees of freedom. |
| 264 |
* |
| 265 |
* This value is an example of an |
| 266 |
* @ref GlossInvalidValue "invalid value". |
| 267 |
* See there for more information. |
| 268 |
*/ |
| 269 |
constexpr types::global_dof_index invalid_dof_index = |
| 270 |
static_cast<types::global_dof_index>(-1); |
| 271 |
|
| 272 |
/** |
| 273 |
* An invalid value for coarse cell ids. See the glossary |
| 274 |
* entry on |
| 275 |
* @ref GlossCoarseCellId "coarse cell IDs" |
| 276 |
* for more information. |
| 277 |
* |
| 278 |
* This value is an example of an |
| 279 |
* @ref GlossInvalidValue "invalid value". |
| 280 |
* See there for more information. |
| 281 |
*/ |
| 282 |
constexpr types::coarse_cell_id invalid_coarse_cell_id = |
| 283 |
static_cast<types::coarse_cell_id>(-1); |
| 284 |
|
| 285 |
/** |
| 286 |
* Invalid material_id which we need in several places as a default value. |
| 287 |
* We assume that all material_ids lie in the range `[0, |
| 288 |
* invalid_material_id)`. |
| 289 |
* |
| 290 |
* This value is an example of an |
| 291 |
* @ref GlossInvalidValue "invalid value". |
| 292 |
* See there for more information. |
| 293 |
*/ |
| 294 |
constexpr types::material_id invalid_material_id = |
| 295 |
static_cast<types::material_id>(-1); |
| 296 |
|
| 297 |
/** |
| 298 |
* Invalid boundary_id which we need in several places as a default value. |
| 299 |
* We assume that all valid boundary_ids lie in the range `[0, |
| 300 |
* invalid_boundary_id)`. |
| 301 |
* |
| 302 |
* This value is an example of an |
| 303 |
* @ref GlossInvalidValue "invalid value". |
| 304 |
* See there for more information. |
| 305 |
* |
| 306 |
* @see |
| 307 |
* @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" |
| 308 |
*/ |
| 309 |
constexpr types::boundary_id invalid_boundary_id = |
| 310 |
static_cast<types::boundary_id>(-1); |
| 311 |
|
| 312 |
/** |
| 313 |
* A boundary indicator number that we reserve for internal faces. We |
| 314 |
* assume that all valid boundary_ids lie in the range `[0, |
| 315 |
* internal_face_boundary_id)`. |
| 316 |
* |
| 317 |
* This is an indicator that is used internally (by the library) to |
| 318 |
* differentiate between faces that lie at the boundary of the domain and |
| 319 |
* faces that lie in the interior of the domain. You should never try to |
| 320 |
* assign this boundary indicator to anything in user code. |
| 321 |
* |
| 322 |
* This value is an example of an |
| 323 |
* @ref GlossInvalidValue "invalid value". |
| 324 |
* See there for more information. |
| 325 |
* |
| 326 |
* @see |
| 327 |
* @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" |
| 328 |
*/ |
| 329 |
constexpr types::boundary_id internal_face_boundary_id = |
| 330 |
static_cast<types::boundary_id>(-1); |
| 331 |
|
| 332 |
/** |
| 333 |
* A manifold_id we reserve for the default flat Cartesian manifold. |
| 334 |
* |
| 335 |
* This value is an example of an |
| 336 |
* @ref GlossInvalidValue "invalid value". |
| 337 |
* See there for more information. |
| 338 |
* |
| 339 |
* @see |
| 340 |
* @ref GlossManifoldIndicator "Glossary entry on manifold indicators" |
| 341 |
*/ |
| 342 |
constexpr types::manifold_id flat_manifold_id = |
| 343 |
static_cast<types::manifold_id>(-1); |
| 344 |
|
| 345 |
/** |
| 346 |
* Value indicating that a face or line is in its default orientation. |
| 347 |
* |
| 348 |
* See the |
| 349 |
* @ref GlossCombinedOrientation "glossary" |
| 350 |
* for more information. |
| 351 |
*/ |
| 352 |
constexpr types::geometric_orientation default_geometric_orientation = |
| 353 |
static_cast<types::geometric_orientation>(0b000); |
| 354 |
|
| 355 |
/** |
| 356 |
* Value indicating that a line is in the reverse orientation. Since lines can |
| 357 |
* only have two possible orientations, this value and |
| 358 |
* default_geometric_orientation completely encode the possible values for |
| 359 |
* line orientations. |
| 360 |
* |
| 361 |
* See the |
| 362 |
* @ref GlossCombinedOrientation "glossary" |
| 363 |
* for more information. |
| 364 |
*/ |
| 365 |
constexpr types::geometric_orientation reverse_line_orientation = |
| 366 |
static_cast<types::geometric_orientation>(0b001); |
| 367 |
|
| 368 |
/** |
| 369 |
* A special id for an invalid subdomain id. This value may not be used as a |
| 370 |
* valid id but is used, for example, for default arguments to indicate a |
| 371 |
* subdomain id that is not to be used. |
| 372 |
* |
| 373 |
* This value is an example of an |
| 374 |
* @ref GlossInvalidValue "invalid value". |
| 375 |
* See there for more information. |
| 376 |
* |
| 377 |
* See the |
| 378 |
* @ref GlossSubdomainId "glossary" |
| 379 |
* for more information. |
| 380 |
*/ |
| 381 |
constexpr types::subdomain_id invalid_subdomain_id = |
| 382 |
static_cast<types::subdomain_id>(-1); |
| 383 |
|
| 384 |
/** |
| 385 |
* The subdomain id assigned to a cell whose true subdomain id we don't |
| 386 |
* know, for example because it resides on a different processor on a mesh |
| 387 |
* that is kept distributed on many processors. Such cells are called |
| 388 |
* "artificial". |
| 389 |
* |
| 390 |
* See the glossary entries on |
| 391 |
* @ref GlossSubdomainId "subdomain ids" |
| 392 |
* and |
| 393 |
* @ref GlossArtificialCell "artificial cells" |
| 394 |
* as well as the |
| 395 |
* @ref distributed |
| 396 |
* topic for more information. |
| 397 |
* |
| 398 |
* This value is an example of an |
| 399 |
* @ref GlossInvalidValue "invalid value". |
| 400 |
* See there for more information. |
| 401 |
*/ |
| 402 |
constexpr types::subdomain_id artificial_subdomain_id = |
| 403 |
static_cast<types::subdomain_id>(-2); |
| 404 |
} // namespace numbers |
| 405 |
|
| 406 |
DEAL_II_NAMESPACE_CLOSE |
| 407 |
|
| 408 |
#endif |