GEOS
DataTypes.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
23 #ifndef GEOS_COMMON_DATATYPES_HPP
24 #define GEOS_COMMON_DATATYPES_HPP
25 
26 // Source includes
27 #include "common/GeosxConfig.hpp"
28 
29 #include "BufferAllocator.hpp"
30 #include "DataLayouts.hpp"
31 #include "GeosxMacros.hpp"
32 #include "Path.hpp"
33 #include "StdContainerWrappers.hpp"
34 #include "Tensor.hpp"
35 
36 #include "LvArray/src/Macros.hpp"
37 #include "LvArray/src/Array.hpp"
38 #include "LvArray/src/ArrayOfArrays.hpp"
39 #include "LvArray/src/ArrayOfSets.hpp"
40 #include "LvArray/src/SparsityPattern.hpp"
41 #include "LvArray/src/CRSMatrix.hpp"
42 #include "LvArray/src/SortedArray.hpp"
43 #include "LvArray/src/StackBuffer.hpp"
44 #include "LvArray/src/ChaiBuffer.hpp"
45 
46 
47 // TPL includes
48 #include <camp/camp.hpp>
49 
50 // System includes
51 #ifdef GEOS_USE_MPI
52  #include <mpi.h>
53 #endif
54 
55 #include <cassert>
56 //#include <cmath>
57 #include <cstdint>
58 #include <iostream>
59 #include <optional>
60 #include <set>
61 #include <string>
62 #include <string_view>
63 #include <typeindex>
64 #include <typeinfo>
65 
66 /*
67  * top level geos namespace contains all code that is specific to GEOSX
68  */
69 namespace geos
70 {
71 
76 
78 using size_t = std::size_t;
79 
81 using integer = std::int32_t;
82 
85 
88 
90 using string = std::string;
91 
94 
96 using real32 = float;
98 using real64 = double;
99 
101 
102 
103 #if defined( GEOS_USE_BOUNDS_CHECK )
104 
105 #else
106 
107 #endif
108 
109 
110 
115 
117 using buffer_unit_type = signed char;
118 
119 #ifdef GEOS_USE_CHAI
122 #else
125 #endif
126 
128 
133 
135 using Timestamp = unsigned long long int;
136 
138 
139 //START_SPHINX_INCLUDE_00
140 
145 
147 template< typename T,
148  int NDIM,
149  typename PERMUTATION=camp::make_idx_seq_t< NDIM > >
150 using Array = LvArray::Array< T, NDIM, PERMUTATION, localIndex, LvArray::ChaiBuffer >;
151 
153 template< typename T,
154  int NDIM,
155  int USD = NDIM - 1 >
156 using ArrayView = LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer >;
157 
159 template< typename T, int NDIM, int USD = NDIM - 1 >
160 using ArraySlice = LvArray::ArraySlice< T, NDIM, USD, localIndex >;
161 
163 template< typename T, int NDIM, int MAXSIZE, typename PERMUTATION=camp::make_idx_seq_t< NDIM > >
164 using StackArray = LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZE >;
165 
167 
172 
177 
180 
181 
183 template< typename T >
185 
187 template< typename T >
189 
191 template< typename T, int USD = 0 >
193 
195 template< typename T, int MAXSIZE >
197 
199 template< typename T, typename PERMUTATION=camp::make_idx_seq_t< 2 > >
201 
203 template< typename T, int USD = 1 >
205 
207 template< typename T, int USD = 1 >
209 
211 template< typename T, int MAXSIZE >
213 
215 template< typename T, typename PERMUTATION=camp::make_idx_seq_t< 3 > >
217 
219 template< typename T, int USD=2 >
221 
223 template< typename T, int USD=2 >
225 
227 template< typename T, int MAXSIZE >
229 
231 template< typename T, typename PERMUTATION=camp::make_idx_seq_t< 4 > >
233 
235 template< typename T, int USD=3 >
237 
239 template< typename T, int USD=3 >
241 
243 template< typename T, int MAXSIZE >
245 
247 template< typename T, typename PERMUTATION=camp::make_idx_seq_t< 5 > >
249 
251 template< typename T, int USD=4 >
253 
255 template< typename T, int USD=4 >
257 
259 template< typename T, int MAXSIZE >
261 
263 
268 
270 template< typename T >
271 using set = std::set< T >;
272 
274 template< typename T >
275 using SortedArray = LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer >;
276 
278 template< typename T >
279 using SortedArrayView = LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer >;
280 
282 
287 
289 template< typename T, typename INDEX_TYPE=localIndex >
290 using ArrayOfArrays = LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer >;
291 
293 template< typename T, typename INDEX_TYPE=localIndex, bool CONST_SIZES=std::is_const< T >::value >
294 using ArrayOfArraysView = LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer >;
295 
297 template< typename T, typename INDEX_TYPE=localIndex >
298 using ArrayOfSets = LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer >;
299 
301 template< typename T, typename INDEX_TYPE=localIndex >
302 using ArrayOfSetsView = LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer >;
303 
305 template< typename COL_INDEX, typename INDEX_TYPE=localIndex >
306 using SparsityPattern = LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer >;
307 
309 template< typename COL_INDEX, typename INDEX_TYPE=localIndex >
310 using SparsityPatternView = LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer >;
311 
313 template< typename T, typename COL_INDEX=globalIndex >
314 using CRSMatrix = LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer >;
315 
317 template< typename T, typename COL_INDEX=globalIndex >
318 using CRSMatrixView = LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer >;
319 
321 
322 //END_SPHINX_INCLUDE_00
323 
328 
335 template< typename TKEY, typename TVAL, typename SORTED >
336 class mapBase
337 {};
338 
340 template< typename TKEY, typename TVAL >
341 class mapBase< TKEY, TVAL, std::integral_constant< bool, true > > : public std::map< TKEY, TVAL >
342 {
343  using std::map< TKEY, TVAL >::map; // enable list initialization
344 };
345 
346 template< typename TKEY, typename TVAL >
347 class mapBase< TKEY, TVAL, std::integral_constant< bool, false > > : public std::unordered_map< TKEY, TVAL >
348 {
349  using std::unordered_map< TKEY, TVAL >::unordered_map; // enable list initialization
350 };
352 
362 template< typename K, typename V, typename SORTED >
363 inline
364 std::ostream & operator<< ( std::ostream & stream, mapBase< K, V, SORTED > const & map )
365 {
366  stream << "{\n";
367  for( auto const & pair : map )
368  {
369  stream << pair.first << " : " << pair.second << "\n";
370  }
371  stream << "}";
372  return stream;
373 }
374 
376 template< typename TKEY, typename TVAL >
378 
380 template< typename TKEY, typename TVAL >
382 
384 
389 
392 
395 
398 
400 //using string_array = string_array;
402 
405 
408 
411 
412 
415 
418 
421 
424 
427 
428 
431 
434 
437 
440 
443 
444 
447 
450 
453 
456 
459 
461 
463 constexpr static auto GLOBALINDEX_MAX = std::numeric_limits< globalIndex >::max();
464 
466 constexpr static auto LOCALINDEX_MAX = std::numeric_limits< localIndex >::max();
467 
469 constexpr static localIndex unmappedLocalIndexValue = -1;
470 
471 } /* namespace geos */
472 
473 #endif /* GEOS_COMMON_DATATYPES_HPP */
#define GEOS_LOCALINDEX_TYPE
The type that localIndex will be aliased to.
#define GEOS_GLOBALINDEX_TYPE
The type that globalIndex will be aliased to.
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:337
array2d< real32 > real32_array2d
A 2-dimensional array of geos::real32 types.
Definition: DataTypes.hpp:417
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:188
stdVector< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:401
LvArray::Array< T, NDIM, PERMUTATION, localIndex, LvArray::ChaiBuffer > Array
Multidimensional array type. See LvArray:Array for details.
Definition: DataTypes.hpp:150
StackArray< T, 2, MAXSIZE > stackArray2d
Alias for 2D stack array.
Definition: DataTypes.hpp:212
float real32
32-bit floating point type.
Definition: DataTypes.hpp:96
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:407
unsigned long long int Timestamp
Timestamp type (used to perform actions such a sparsity pattern computation after mesh modifications)
Definition: DataTypes.hpp:135
array2d< globalIndex > globalIndex_array2d
A 2-dimensional array of geos::globalIndex types.
Definition: DataTypes.hpp:426
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:200
StackArray< T, 4, MAXSIZE > stackArray4d
Alias for 4D stack array.
Definition: DataTypes.hpp:244
Array< T, 5, PERMUTATION > array5d
Alias for 5D array.
Definition: DataTypes.hpp:248
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:318
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
array1d< globalIndex > globalIndex_array
A 1-dimensional array of geos::globalIndex types.
Definition: DataTypes.hpp:410
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:216
std::string string
String type.
Definition: DataTypes.hpp:90
constexpr static auto GLOBALINDEX_MAX
A variable for the maximum value of a geos::globalIndex.
Definition: DataTypes.hpp:463
LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer > ArrayOfSetsView
View of array of variable-sized sets. See LvArray::ArrayOfSetsView for details.
Definition: DataTypes.hpp:302
array1d< integer > integer_array
A 1-dimensional array of geos::integer types.
Definition: DataTypes.hpp:391
constexpr static auto LOCALINDEX_MAX
A variable for the maximum value of a geos::localIndex.
Definition: DataTypes.hpp:466
array4d< integer > integer_array4d
A 4-dimensional array of geos::integer types.
Definition: DataTypes.hpp:446
mapBase< TKEY, TVAL, std::integral_constant< bool, false > > unordered_map
Unordered map type.
Definition: DataTypes.hpp:381
LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZE > StackArray
Multidimensional stack-based array type. See LvArray:StackArray for details.
Definition: DataTypes.hpp:164
constexpr static localIndex unmappedLocalIndexValue
A global variable for the value of a object that has not been assigned a geos::globalIndex.
Definition: DataTypes.hpp:469
LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > SparsityPatternView
Alias for Sparsity pattern View.
Definition: DataTypes.hpp:310
array4d< localIndex > localIndex_array4d
A 4-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:455
LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer > SparsityPattern
Alias for Sparsity pattern class.
Definition: DataTypes.hpp:306
array4d< real64 > real64_array4d
A 4-dimensional array of geos::real64 types.
Definition: DataTypes.hpp:452
StackArray< T, 1, MAXSIZE > stackArray1d
Alias for 1D stack array.
Definition: DataTypes.hpp:196
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
Definition: DataTypes.hpp:294
array4d< globalIndex > globalIndex_array4d
A 4-dimensional array of geos::globalIndex types.
Definition: DataTypes.hpp:458
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:208
ArraySlice< T, 3, USD > arraySlice3d
Alias for 3D array slice.
Definition: DataTypes.hpp:224
array1d< Path > path_array
A 1-dimensional array of geos::Path types.
Definition: DataTypes.hpp:404
std::set< T > set
A set of local indices.
Definition: DataTypes.hpp:271
ArrayView< T, 5, USD > arrayView5d
Alias for 5D array view.
Definition: DataTypes.hpp:252
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
array3d< globalIndex > globalIndex_array3d
A 3-dimensional array of geos::globalIndex types.
Definition: DataTypes.hpp:442
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:192
array3d< real32 > real32_array3d
A 3-dimensional array of geos::real32 types.
Definition: DataTypes.hpp:433
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:81
stdVector< buffer_unit_type > buffer_type
Type of storage for communication buffers.
Definition: DataTypes.hpp:124
array3d< localIndex > localIndex_array3d
A 3-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:439
LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer > CRSMatrix
Alias for CRS Matrix class.
Definition: DataTypes.hpp:314
array3d< integer > integer_array3d
A 3-dimensional array of geos::integer types.
Definition: DataTypes.hpp:430
array2d< integer > integer_array2d
A 2-dimensional array of geos::integer types.
Definition: DataTypes.hpp:414
array1d< real64 > real64_array
A 1-dimensional array of geos::real64 types.
Definition: DataTypes.hpp:397
ArraySlice< T, 4, USD > arraySlice4d
Alias for 4D array slice.
Definition: DataTypes.hpp:240
array2d< real64 > real64_array2d
A 2-dimensional array of geos::real64 types.
Definition: DataTypes.hpp:420
ArraySlice< T, 5, 4 > arraySlice5d
Alias for 5D array slice.
Definition: DataTypes.hpp:256
std::size_t size_t
Unsigned size type.
Definition: DataTypes.hpp:78
mapBase< TKEY, TVAL, std::integral_constant< bool, true > > map
Ordered map type.
Definition: DataTypes.hpp:377
std::ostream & operator<<(std::ostream &stream, mapBase< K, V, SORTED > const &map)
Stream output operator for map types.
Definition: DataTypes.hpp:364
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:275
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
Definition: DataTypes.hpp:298
Array< T, 4, PERMUTATION > array4d
Alias for 4D array.
Definition: DataTypes.hpp:232
array1d< real32 > real32_array
A 1-dimensional array of geos::real32 types.
Definition: DataTypes.hpp:394
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:279
std::vector< T, Allocator > stdVector
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
Definition: DataTypes.hpp:236
LvArray::ArraySlice< T, NDIM, USD, localIndex > ArraySlice
Multidimensional array slice type. See LvArray:ArraySlice for details.
Definition: DataTypes.hpp:160
StackArray< T, 3, MAXSIZE > stackArray3d
Alias for 3D stack array.
Definition: DataTypes.hpp:228
array4d< real32 > real32_array4d
A 4-dimensional array of geos::real32 types.
Definition: DataTypes.hpp:449
array3d< real64 > real64_array3d
A 3-dimensional array of geos::real64 types.
Definition: DataTypes.hpp:436
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:117
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:204
StackArray< T, 5, MAXSIZE > stackArray5d
Alias for 5D stack array.
Definition: DataTypes.hpp:260
array2d< localIndex > localIndex_array2d
A 2-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:423
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:184
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
Definition: DataTypes.hpp:290
std::string_view string_view
String type.
Definition: DataTypes.hpp:93
LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer > ArrayView
Multidimensional array view type. See LvArray:ArrayView for details.
Definition: DataTypes.hpp:156
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:220