GEOS
ConduitRestart.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 Total, S.A
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 
20 #ifndef GEOS_DATAREPOSITORY_CONDUITRESTART_HPP_
21 #define GEOS_DATAREPOSITORY_CONDUITRESTART_HPP_
22 
23 // Source includes
24 #include "common/GeosxConfig.hpp"
25 #include "common/DataTypes.hpp"
26 
27 // TPL includes
28 #include <conduit.hpp>
29 
30 // System includes
31 
32 
34 
35 #define CONDUIT_TYPE_INFO( T, CONDUIT_TYPE ) \
36  template<> \
37  struct conduitTypeInfo< T > \
38  { \
39  using type = CONDUIT_TYPE; \
40  static constexpr int id = CONDUIT_TYPE ## _ID; \
41  static constexpr int sizeOfConduitType = sizeof( type ); \
42  static constexpr int numConduitValues = sizeof( T ) / sizeOfConduitType; \
43  static_assert( sizeof( T ) % sizeOfConduitType == 0, #T " cannot be made made up of " #CONDUIT_TYPE "." ); \
44  }
45 
46 namespace geos
47 {
48 namespace dataRepository
49 {
50 
51 namespace internal
52 {
53 
54 template< typename T, typename ENABLE = void >
55 struct conduitTypeInfo
56 {};
57 
58 // Native integer types
59 CONDUIT_TYPE_INFO( char, CONDUIT_NATIVE_CHAR );
60 CONDUIT_TYPE_INFO( signed char, CONDUIT_NATIVE_SIGNED_CHAR );
61 CONDUIT_TYPE_INFO( unsigned char, CONDUIT_NATIVE_UNSIGNED_CHAR );
62 
63 CONDUIT_TYPE_INFO( short, CONDUIT_NATIVE_SHORT );
64 CONDUIT_TYPE_INFO( int, CONDUIT_NATIVE_INT );
65 CONDUIT_TYPE_INFO( long, CONDUIT_NATIVE_LONG );
66 CONDUIT_TYPE_INFO( long long, CONDUIT_NATIVE_LONG_LONG );
67 
68 CONDUIT_TYPE_INFO( unsigned short, CONDUIT_NATIVE_UNSIGNED_SHORT );
69 CONDUIT_TYPE_INFO( unsigned int, CONDUIT_NATIVE_UNSIGNED_INT );
70 CONDUIT_TYPE_INFO( unsigned long, CONDUIT_NATIVE_UNSIGNED_LONG );
71 CONDUIT_TYPE_INFO( unsigned long long, CONDUIT_NATIVE_UNSIGNED_LONG_LONG );
72 
73 // Native floating point types
74 CONDUIT_TYPE_INFO( float, CONDUIT_NATIVE_FLOAT );
75 CONDUIT_TYPE_INFO( double, CONDUIT_NATIVE_DOUBLE );
76 
77 // Enum types forward to underlying integer types
78 template< typename T >
79 struct conduitTypeInfo< T, std::enable_if_t< std::is_enum< T >::value > > : public conduitTypeInfo< std::underlying_type_t< T > >
80 {};
81 
82 // Tensor types
83 CONDUIT_TYPE_INFO( R1Tensor, CONDUIT_NATIVE_DOUBLE );
84 CONDUIT_TYPE_INFO( R1Tensor32, CONDUIT_NATIVE_FLOAT );
85 CONDUIT_TYPE_INFO( R2SymTensor, CONDUIT_NATIVE_DOUBLE );
86 
87 } // namespace internal
88 
89 template< typename T >
90 using conduitTypeInfo = internal::conduitTypeInfo< std::remove_const_t< std::remove_pointer_t< T > > >;
91 
92 string writeRootFile( conduit::Node & root, string const & rootPath );
93 
94 void writeTree( string const & path, conduit::Node & root );
95 
96 void loadTree( string const & path, conduit::Node & root );
97 
98 } // namespace dataRepository
99 } // namespace geos
100 
102 
103 #endif /* GEOS_DATAREPOSITORY_CONDUITRESTART_HPP_ */
Tensor< real32, 3 > R1Tensor32
Alias for a local (stack-based) rank-1 tensor type using 32 bits integers.
Definition: DataTypes.hpp:168
Tensor< real64, 3 > R1Tensor
Alias for a local (stack-based) rank-1 tensor type.
Definition: DataTypes.hpp:166
Tensor< real64, 6 > R2SymTensor
Alias for a local (stack-based) rank-2 Voigt tensor type.
Definition: DataTypes.hpp:171