22 #ifndef GEOS_COMMON_DATATYPES_HPP
23 #define GEOS_COMMON_DATATYPES_HPP
32 #include "LvArray/src/Macros.hpp"
33 #include "LvArray/src/Array.hpp"
34 #include "LvArray/src/ArrayOfArrays.hpp"
35 #include "LvArray/src/ArrayOfSets.hpp"
36 #include "LvArray/src/SparsityPattern.hpp"
37 #include "LvArray/src/CRSMatrix.hpp"
38 #include "LvArray/src/SortedArray.hpp"
39 #include "LvArray/src/StackBuffer.hpp"
40 #include "LvArray/src/ChaiBuffer.hpp"
45 #include <camp/camp.hpp>
61 #include <unordered_map>
64 #include <string_view>
79 template<
typename NEW_TYPE,
typename EXISTING_TYPE >
82 static_assert( std::is_pointer< NEW_TYPE >::value,
"NEW_TYPE must be a pointer." );
83 return dynamic_cast< NEW_TYPE
>( val );
93 template<
typename NEW_TYPE,
typename EXISTING_TYPE >
96 static_assert( std::is_reference< NEW_TYPE >::value,
"NEW_TYPE must be a reference." );
98 using POINTER_TO_NEW_TYPE = std::remove_reference_t< NEW_TYPE > *;
99 POINTER_TO_NEW_TYPE ptr = dynamicCast< POINTER_TO_NEW_TYPE >( &val );
100 GEOS_ERROR_IF( ptr ==
nullptr,
"Cast from " << LvArray::system::demangleType( val ) <<
" to " <<
101 LvArray::system::demangleType< NEW_TYPE >() <<
" failed." );
151 #ifdef GEOSX_USE_CHAI
153 using buffer_type = std::vector< buffer_unit_type, BufferAllocator< buffer_unit_type > >;
179 template<
typename T,
181 typename PERMUTATION=camp::make_idx_seq_t< NDIM > >
182 using Array = LvArray::Array< T, NDIM, PERMUTATION, localIndex, LvArray::ChaiBuffer >;
185 template<
typename T,
188 using ArrayView = LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer >;
191 template<
typename T,
int NDIM,
int USD = NDIM - 1 >
192 using ArraySlice = LvArray::ArraySlice< T, NDIM, USD, localIndex >;
195 template<
typename T,
int NDIM,
int MAXSIZE,
typename PERMUTATION=camp::make_
idx_seq_t< NDIM > >
196 using StackArray = LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZE >;
215 template<
typename T >
219 template<
typename T >
223 template<
typename T,
int USD = 0 >
227 template<
typename T,
int MAXSIZE >
231 template<
typename T,
typename PERMUTATION=camp::make_
idx_seq_t< 2 > >
235 template<
typename T,
int USD = 1 >
239 template<
typename T,
int USD = 1 >
243 template<
typename T,
int MAXSIZE >
247 template<
typename T,
typename PERMUTATION=camp::make_
idx_seq_t< 3 > >
251 template<
typename T,
int USD=2 >
255 template<
typename T,
int USD=2 >
259 template<
typename T,
int MAXSIZE >
263 template<
typename T,
typename PERMUTATION=camp::make_
idx_seq_t< 4 > >
267 template<
typename T,
int USD=3 >
271 template<
typename T,
int USD=3 >
275 template<
typename T,
int MAXSIZE >
279 template<
typename T,
typename PERMUTATION=camp::make_
idx_seq_t< 5 > >
283 template<
typename T,
int USD=4 >
287 template<
typename T,
int USD=4 >
291 template<
typename T,
int MAXSIZE >
302 template<
typename T >
303 using set = std::set< T >;
306 template<
typename T >
307 using SortedArray = LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer >;
310 template<
typename T >
311 using SortedArrayView = LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer >;
321 template<
typename T,
typename INDEX_TYPE=localIndex >
322 using ArrayOfArrays = LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer >;
325 template< typename T, typename INDEX_TYPE=localIndex, bool CONST_SIZES=std::is_const< T >::value >
326 using ArrayOfArraysView = LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer >;
329 template<
typename T,
typename INDEX_TYPE=localIndex >
330 using ArrayOfSets = LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer >;
333 template<
typename T,
typename INDEX_TYPE=localIndex >
334 using ArrayOfSetsView = LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer >;
337 template<
typename COL_INDEX,
typename INDEX_TYPE=localIndex >
338 using SparsityPattern = LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer >;
341 template<
typename COL_INDEX,
typename INDEX_TYPE=localIndex >
342 using SparsityPatternView = LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer >;
345 template<
typename T,
typename COL_INDEX=globalIndex >
346 using CRSMatrix = LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer >;
349 template<
typename T,
typename COL_INDEX=globalIndex >
350 using CRSMatrixView = LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer >;
367 template<
typename TKEY,
typename TVAL,
typename SORTED >
372 template<
typename TKEY,
typename TVAL >
373 class mapBase< TKEY, TVAL, std::integral_constant< bool, true > > :
public std::map< TKEY, TVAL >
378 template<
typename TKEY,
typename TVAL >
379 class mapBase< TKEY, TVAL, std::integral_constant< bool, false > > :
public std::unordered_map< TKEY, TVAL >
394 template<
typename K,
typename V,
typename SORTED >
399 for(
auto const & pair :
map )
401 stream << pair.first <<
" : " << pair.second <<
"\n";
408 template<
typename TKEY,
typename TVAL >
412 template<
typename TKEY,
typename TVAL >
544 template<
typename T,
typename ENABLE =
void >
575 static constexpr
string_view plotLevel =
"geos_dataRepository_PlotLevel";
576 static constexpr
string_view groupName =
"groupName";
577 static constexpr
string_view groupNameRef =
"groupNameRef";
578 static constexpr
string_view groupNameRefArray =
"groupNameRef_array";
593 template<
typename T >
595 {
return getTypeRegex< T >(
getTypeName(
typeid( T ) ) ); }
603 template<
typename T >
607 auto const it =
map.find(
string( typeName ) );
608 if( it !=
map.end() )
649 template<
typename T >
657 return ::LvArray::system::demangle(
typeid( T ).name() );
665 string const full_name =
full();
666 string::size_type
const pos = full_name.find_last_of(
"::" );
667 return ( pos == string::npos ) ? full_name : full_name.substr( pos );
#define GEOSX_GLOBALINDEX_TYPE
The type that globalIndex will be aliased to.
#define GEOSX_LOCALINDEX_TYPE
The type that localIndex will be aliased to.
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
Base template for ordered and unordered maps.
Static class to manage the type selection of types at runtime and obtain the regexes of these types....
std::map< string, Regex > RegexMapType
the regex map type to store and find the regexes by the associated rtTypeName.
static RegexMapType createBasicTypesRegexMap()
Construct the regexMap for all basic types (TypeRegex< T > extented types are not mentionned)
static string getTypeName(std::type_index const key)
Convert a std::type_index to a string.
static Regex const & getTypeRegex()
static Regex const & getTypeRegex(string_view typeName)
array2d< real32 > real32_array2d
A 2-dimensional array of geos::real32 types.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::Array< T, NDIM, PERMUTATION, localIndex, LvArray::ChaiBuffer > Array
Multidimensional array type. See LvArray:Array for details.
StackArray< T, 2, MAXSIZE > stackArray2d
Alias for 2D stack array.
float real32
32-bit floating point type.
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
unsigned long long int Timestamp
Timestamp type (used to perform actions such a sparsity pattern computation after mesh modifications)
array2d< globalIndex > globalIndex_array2d
A 2-dimensional array of geos::globalIndex types.
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
StackArray< T, 4, MAXSIZE > stackArray4d
Alias for 4D stack array.
Array< T, 5, PERMUTATION > array5d
Alias for 5D array.
int MPI_COMM_GEOSX
Global MPI communicator used by GEOSX.
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
array1d< globalIndex > globalIndex_array
A 1-dimensional array of geos::globalIndex types.
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
array1d< string > string_array
A 1-dimensional array of geos::string types.
std::string string
String type.
NEW_TYPE dynamicCast(EXISTING_TYPE *const val)
Perform a type cast of base to derived pointer.
constexpr static auto GLOBALINDEX_MAX
A variable for the maximum value of a geos::globalIndex.
LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer > ArrayOfSetsView
View of array of variable-sized sets. See LvArray::ArrayOfSetsView for details.
array1d< integer > integer_array
A 1-dimensional array of geos::integer types.
constexpr static auto LOCALINDEX_MAX
A variable for the maximum value of a geos::localIndex.
array4d< integer > integer_array4d
A 4-dimensional array of geos::integer types.
mapBase< TKEY, TVAL, std::integral_constant< bool, false > > unordered_map
Unordered map type.
LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZE > StackArray
Multidimensional stack-based array type. See LvArray:StackArray for details.
constexpr static localIndex unmappedLocalIndexValue
A global variable for the value of a object that has not been assigned a geos::globalIndex.
LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > SparsityPatternView
Alias for Sparsity pattern View.
array4d< localIndex > localIndex_array4d
A 4-dimensional array of geos::localIndex types.
LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer > SparsityPattern
Alias for Sparsity pattern class.
array4d< real64 > real64_array4d
A 4-dimensional array of geos::real64 types.
StackArray< T, 1, MAXSIZE > stackArray1d
Alias for 1D stack array.
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
array4d< globalIndex > globalIndex_array4d
A 4-dimensional array of geos::globalIndex types.
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
ArraySlice< T, 3, USD > arraySlice3d
Alias for 3D array slice.
array1d< Path > path_array
A 1-dimensional array of geos::Path types.
std::set< T > set
A set of local indices.
ArrayView< T, 5, USD > arrayView5d
Alias for 5D array view.
double real64
64-bit floating point type.
array3d< globalIndex > globalIndex_array3d
A 3-dimensional array of geos::globalIndex types.
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
array3d< real32 > real32_array3d
A 3-dimensional array of geos::real32 types.
std::int32_t integer
Signed integer type.
array3d< localIndex > localIndex_array3d
A 3-dimensional array of geos::localIndex types.
std::vector< buffer_unit_type > buffer_type
Type of storage for communication buffers.
LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer > CRSMatrix
Alias for CRS Matrix class.
array3d< integer > integer_array3d
A 3-dimensional array of geos::integer types.
array2d< integer > integer_array2d
A 2-dimensional array of geos::integer types.
array1d< real64 > real64_array
A 1-dimensional array of geos::real64 types.
ArraySlice< T, 4, USD > arraySlice4d
Alias for 4D array slice.
array2d< real64 > real64_array2d
A 2-dimensional array of geos::real64 types.
ArraySlice< T, 5, 4 > arraySlice5d
Alias for 5D array slice.
GEOSX_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
std::size_t size_t
Unsigned size type.
mapBase< TKEY, TVAL, std::integral_constant< bool, true > > map
Ordered map type.
std::ostream & operator<<(std::ostream &stream, mapBase< K, V, SORTED > const &map)
Stream output operator for map types.
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
Array< T, 4, PERMUTATION > array4d
Alias for 4D array.
array1d< real32 > real32_array
A 1-dimensional array of geos::real32 types.
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
void printTypeSummary()
Print a short summary of a few select type aliases.
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
LvArray::ArraySlice< T, NDIM, USD, localIndex > ArraySlice
Multidimensional array slice type. See LvArray:ArraySlice for details.
StackArray< T, 3, MAXSIZE > stackArray3d
Alias for 3D stack array.
array4d< real32 > real32_array4d
A 4-dimensional array of geos::real32 types.
array3d< real64 > real64_array3d
A 3-dimensional array of geos::real64 types.
signed char buffer_unit_type
Type stored in communication buffers.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
StackArray< T, 5, MAXSIZE > stackArray5d
Alias for 5D stack array.
array2d< localIndex > localIndex_array2d
A 2-dimensional array of geos::localIndex types.
Array< T, 1 > array1d
Alias for 1D array.
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
std::string_view string_view
String type.
LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer > ArrayView
Multidimensional array view type. See LvArray:ArrayView for details.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
The regular expression data for validating inputs. Use rtTypes to get the regex of a type,...
Regex()
Default constructor.
Regex(string_view regexStr, string_view formatDescription)
string m_regexStr
the regular expression string.
string m_formatDescription
the description of the expected format of the regular expression.
Utility class for querying type names at runtime.
Extension point for custom types to provide a validation regexp to schema. Do not use directly to obt...
static Regex get()
Get the type's regex (default implementation returns nothing).
Custom types are useful to customize the regexes of an existing type. The type name can be one of the...