19 #ifndef GEOSX_HISTORY_DATA_SPEC_HPP_ 20 #define GEOSX_HISTORY_DATA_SPEC_HPP_ 22 #include "codingUtilities/traits.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 >
175 template<
typename T >
193 template<
typename T >
211 template<
typename ARRAY_T >
213 typename std::enable_if< ( traits::is_array_type< ARRAY_T >) && (ARRAY_T::NDIM > 1) && can_history_io< typename ARRAY_T::value_type >,
HistoryMetadata >::type
217 localIndex numIndices = ( sizeOverride >= 0 ? sizeOverride : arr.size( ) / perIndexSize );
218 localIndex sizes[2] = { numIndices, perIndexSize };
219 return HistoryMetadata( name, 2, &sizes[0], std::type_index(
typeid(
typename ARRAY_T::value_type)));
231 template<
typename T >
232 inline typename std::enable_if< can_history_io< T >,
HistoryMetadata >::type
248 template<
typename T >
249 inline typename std::enable_if< can_history_io_container< T > && !can_history_io< typename T::value_type >,
HistoryMetadata >::type
252 GEOSX_ERROR(
"Trying to use time history output on an unsupported type." );
267 template<
typename T >
268 inline typename std::enable_if< !can_history_io_container< T > && !can_history_io< T >,
HistoryMetadata >::type
271 GEOSX_ERROR(
"Trying to use time history output on an unsupported type." );
INDEX_TYPE size() const noexcept
void setName(const string &name)
Set the name. Typically used for metadata collectors to avoid writing data with the same name to the ...
constexpr bool can_history_io_container
Whether the type is a supported container for history collection and io operations.
This class serves to provide a "view" of a multidimensional array.
HistoryMetadata(const string &name, localIndex count, std::type_index type)
Constructor for one-dimensional array types.
HistoryMetadata(const string &name, localIndex rank, localIndex *dims, std::type_index type)
Constructor for multi-dimensional array types.
constexpr bool can_history_io
A constexpr bool to determine wether a type is compatible with the history collected and IO operation...
localIndex getRank() const
Get the rank of the array data to be collected.
Contains the implementation of LvArray::Array.
constexpr INDEX_TYPE size() const
void setType(std::type_index type)
Set the type. Typically used for metadata collectors where local metadata is used to produce and outp...
localIndex size(localIndex dim) const
Get the size of the specified dimension.
std::vector< localIndex > const & getDims() const
Get a pointer to the extent of each dimension.
#define GEOSX_ERROR(msg)
Raise a hard error and terminate the program.
#define GEOSX_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
localIndex size() const
Get the total data count for the data being collected.
std::type_index getType() const
Get the type of the collected data.
std::string string
String type.
std::enable_if< can_history_io< T >, HistoryMetadata >::type getHistoryMetadata(string const &name, ArrayView< T const, 1, 0 > const &arr, localIndex sizeOverride=-1)
Produce a HistoryMetadata object for a supported one-dimensional array type.
const string & getName() const
Get the name.
HistoryMetadata()
Default constructor.
A minimal class to specify information about time history information being collected and output...
This class provides a view into a SortedArray.