19 #ifndef GEOS_DATAREPOSITORY_HISTORYDATASPEC_HPP_
20 #define GEOS_DATAREPOSITORY_HISTORYDATASPEC_HPP_
22 #include "codingUtilities/traits.hpp"
24 #include "LvArray/src/Array.hpp"
29 template<
typename T >
30 constexpr
bool can_history_io = std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
char >::value ||
31 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
signed char >::value ||
32 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
float >::value ||
33 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
double >::value ||
34 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
int >::value ||
35 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
long >::value ||
36 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
long long >::value;
52 m_type( std::type_index( typeid( nullptr ) ) )
65 m_dims( dims, dims+rank ),
77 m_dims( &count, &count+1 ),
139 std::vector< localIndex >
const &
getDims( )
const
155 std::vector< localIndex > m_dims;
156 std::type_index m_type;
163 template<
typename T >
176 template<
typename T >
182 localIndex size = sizeOverride < 0 ? arr.size( ) : sizeOverride;
196 template<
typename T >
198 typename std::enable_if< can_history_io< T >, HistoryMetadata >::type
202 localIndex size = sizeOverride < 0 ? arr.size( ) : sizeOverride;
216 template<
typename ARRAY_T >
218 typename std::enable_if< ( traits::is_array_type< ARRAY_T >) && (ARRAY_T::NDIM > 1) && can_history_io< typename ARRAY_T::value_type >, HistoryMetadata >::type
222 localIndex const numIndices = sizeOverride >= 0 ? sizeOverride : arr.size( ) / numComps;
223 localIndex sizes[2] = { numIndices, numComps };
224 return HistoryMetadata( name, 2, &sizes[0], std::type_index(
typeid(
typename ARRAY_T::value_type)));
237 template<
typename T >
238 inline typename std::enable_if< can_history_io< T >, HistoryMetadata >::type
242 localIndex size = sizeOverride < 0 ? 0 : sizeOverride;
255 template<
typename T >
256 inline typename std::enable_if< can_history_io_container< T > && !can_history_io< typename T::value_type >, HistoryMetadata >::type
259 GEOS_ERROR(
"Trying to use time history output on an unsupported type." );
273 template<
typename T >
274 inline typename std::enable_if< !can_history_io_container< T > && !can_history_io< T >, HistoryMetadata >::type
277 GEOS_ERROR(
"Trying to use time history output on an unsupported type." );
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
A minimal class to specify information about time history information being collected and output.
HistoryMetadata(const string &name, localIndex rank, localIndex *dims, std::type_index type)
Constructor for multi-dimensional array types.
void setType(std::type_index type)
Set the type. Typically used for metadata collectors where local metadata is used to produce and outp...
HistoryMetadata(const string &name, localIndex count, std::type_index type)
Constructor for one-dimensional array types.
localIndex size(localIndex dim) const
Get the size of the specified dimension.
void setName(const string &name)
Set the name. Typically used for metadata collectors to avoid writing data with the same name to the ...
localIndex getRank() const
Get the rank of the array data to be collected.
std::type_index getType() const
Get the type of the collected data.
const string & getName() const
Get the name.
HistoryMetadata()
Default constructor.
std::vector< localIndex > const & getDims() const
Get a pointer to the extent of each dimension.
localIndex size() const
Get the total data count for the data being collected.
constexpr bool can_history_io
A constexpr bool to determine wether a type is compatible with the history collected and IO operation...
constexpr bool can_history_io_container
Whether the type is a supported container for history collection and io operations.
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::enable_if< can_history_io< T >, HistoryMetadata >::type getHistoryMetadata(string const &name, ArrayView< T const, 1, 0 > const &arr, localIndex const numComps, localIndex sizeOverride=-1)
Produce a HistoryMetadata object for a supported one-dimensional array type.
LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer > ArrayView
Multidimensional array view type. See LvArray:ArrayView for details.