20 #ifndef GEOS_DATAREPOSITORY_HISTORYDATASPEC_HPP_
21 #define GEOS_DATAREPOSITORY_HISTORYDATASPEC_HPP_
23 #include "codingUtilities/traits.hpp"
26 #include "LvArray/src/Array.hpp"
31 template<
typename T >
32 constexpr
bool can_history_io = std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
char >::value ||
33 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
signed char >::value ||
34 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
float >::value ||
35 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
double >::value ||
36 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
int >::value ||
37 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
long >::value ||
38 std::is_same< std::remove_reference_t< std::remove_const_t< T > >,
long long >::value;
54 m_type( std::type_index( typeid( nullptr ) ) )
67 m_dims( dims, dims+rank ),
79 m_dims( &count, &count+1 ),
158 std::type_index m_type;
165 template<
typename T >
178 template<
typename T >
184 localIndex size = sizeOverride < 0 ? arr.size( ) : sizeOverride;
198 template<
typename T >
200 typename std::enable_if< can_history_io< T >, HistoryMetadata >::type
204 localIndex size = sizeOverride < 0 ? arr.size( ) : sizeOverride;
218 template<
typename ARRAY_T >
220 typename std::enable_if< ( traits::is_array_type< ARRAY_T >) && (ARRAY_T::NDIM > 1) && can_history_io< typename ARRAY_T::value_type >, HistoryMetadata >::type
224 localIndex const numIndices = sizeOverride >= 0 ? sizeOverride : arr.size( ) / numComps;
225 localIndex sizes[2] = { numIndices, numComps };
226 return HistoryMetadata( name, 2, &sizes[0], std::type_index(
typeid(
typename ARRAY_T::value_type)));
239 template<
typename T >
240 inline typename std::enable_if< can_history_io< T >, HistoryMetadata >::type
244 localIndex size = sizeOverride < 0 ? 0 : sizeOverride;
257 template<
typename T >
258 inline typename std::enable_if< can_history_io_container< T > && !can_history_io< typename T::value_type >, HistoryMetadata >::type
261 GEOS_ERROR(
"Trying to use time history output on an unsupported type." );
275 template<
typename T >
276 inline typename std::enable_if< !can_history_io_container< T > && !can_history_io< T >, HistoryMetadata >::type
279 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 ...
stdVector< localIndex > const & getDims() const
Get a pointer to the extent of each dimension.
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.
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.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
std::vector< T, Allocator > stdVector
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.