GEOSX
ConduitRestart.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_DATAREPOSITORY_CONDUITRESTART_HPP_
20 #define GEOSX_DATAREPOSITORY_CONDUITRESTART_HPP_
21 
22 // Source includes
23 #include "common/GeosxConfig.hpp"
24 #include "common/DataTypes.hpp"
25 
26 // TPL includes
27 #include <conduit.hpp>
28 
29 // System includes
30 #include <string>
31 
33 
34 #define CONDUIT_TYPE_INFO( T, CONDUIT_TYPE ) \
35  template<> \
36  struct conduitTypeInfo< T > \
37  { \
38  using type = CONDUIT_TYPE; \
39  static constexpr int id = CONDUIT_TYPE ## _ID; \
40  static constexpr int sizeOfConduitType = sizeof( type ); \
41  static constexpr int numConduitValues = sizeof( T ) / sizeOfConduitType; \
42  static_assert( sizeof( T ) % sizeOfConduitType == 0, #T " cannot be made made up of " #CONDUIT_TYPE "." ); \
43  }
44 
45 namespace geosx
46 {
47 namespace dataRepository
48 {
49 
50 namespace internal
51 {
52 
53 template< typename T, typename ENABLE = void >
54 struct conduitTypeInfo
55 {};
56 
57 // Native integer types
58 CONDUIT_TYPE_INFO( char, CONDUIT_NATIVE_CHAR );
59 CONDUIT_TYPE_INFO( signed char, CONDUIT_NATIVE_SIGNED_CHAR );
60 CONDUIT_TYPE_INFO( unsigned char, CONDUIT_NATIVE_UNSIGNED_CHAR );
61 
62 CONDUIT_TYPE_INFO( short, CONDUIT_NATIVE_SHORT );
63 CONDUIT_TYPE_INFO( int, CONDUIT_NATIVE_INT );
64 CONDUIT_TYPE_INFO( long, CONDUIT_NATIVE_LONG );
65 CONDUIT_TYPE_INFO( long long, CONDUIT_NATIVE_LONG_LONG );
66 
67 CONDUIT_TYPE_INFO( unsigned short, CONDUIT_NATIVE_UNSIGNED_SHORT );
68 CONDUIT_TYPE_INFO( unsigned int, CONDUIT_NATIVE_UNSIGNED_INT );
69 CONDUIT_TYPE_INFO( unsigned long, CONDUIT_NATIVE_UNSIGNED_LONG );
70 CONDUIT_TYPE_INFO( unsigned long long, CONDUIT_NATIVE_UNSIGNED_LONG_LONG );
71 
72 // Native floating point types
73 CONDUIT_TYPE_INFO( float, CONDUIT_NATIVE_FLOAT );
74 CONDUIT_TYPE_INFO( double, CONDUIT_NATIVE_DOUBLE );
75 
76 // Enum types forward to underlying integer types
77 template< typename T >
78 struct conduitTypeInfo< T, std::enable_if_t< std::is_enum< T >::value > > : public conduitTypeInfo< std::underlying_type_t< T > >
79 {};
80 
81 // Tensor types
82 CONDUIT_TYPE_INFO( R1Tensor, CONDUIT_NATIVE_DOUBLE );
83 
84 } // namespace internal
85 
86 template< typename T >
87 using conduitTypeInfo = internal::conduitTypeInfo< std::remove_const_t< std::remove_pointer_t< T > > >;
88 
89 extern conduit::Node rootConduitNode;
90 
91 std::string writeRootFile( conduit::Node & root, std::string const & rootPath );
92 
93 void writeTree( std::string const & path );
94 
95 void loadTree( std::string const & path );
96 
97 } // namespace dataRepository
98 } // namespace geosx
99 
101 
102 #endif /* GEOSX_DATAREPOSITORY_CONDUITRESTART_HPP_ */
Tensor< real64, 3 > R1Tensor
Alias for a local (stack-based) rank-1 tensor type.
Definition: DataTypes.hpp:193
std::string string
String type.
Definition: DataTypes.hpp:131