mirror of
https://github.com/paboyle/Grid.git
synced 2025-07-29 02:37:07 +01:00
Revert "Lattice serialisation, just HDF5 for the moment"
This reverts commit 8a0cf0194f
.
This commit is contained in:
@@ -22,8 +22,6 @@
|
||||
|
||||
namespace Grid
|
||||
{
|
||||
template<class vobj> class Lattice;
|
||||
|
||||
class Hdf5Writer: public Writer<Hdf5Writer>
|
||||
{
|
||||
public:
|
||||
@@ -35,8 +33,6 @@ namespace Grid
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const U &x);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const Lattice<U> &field);
|
||||
template <typename U>
|
||||
typename std::enable_if<element<std::vector<U>>::is_number, void>::type
|
||||
writeDefault(const std::string &s, const std::vector<U> &x);
|
||||
template <typename U>
|
||||
@@ -64,8 +60,6 @@ namespace Grid
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, U &output);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, Lattice<U> &field);
|
||||
template <typename U>
|
||||
typename std::enable_if<element<std::vector<U>>::is_number, void>::type
|
||||
readDefault(const std::string &s, std::vector<U> &x);
|
||||
template <typename U>
|
||||
@@ -104,40 +98,7 @@ namespace Grid
|
||||
|
||||
template <>
|
||||
void Hdf5Writer::writeDefault(const std::string &s, const std::string &x);
|
||||
|
||||
|
||||
template <typename U>
|
||||
void Hdf5Writer::writeDefault(const std::string &s, const Lattice<U> &field)
|
||||
{
|
||||
// alias scalar types
|
||||
typedef std::vector<typename U::scalar_object> ScalarLattice;
|
||||
typedef typename U::scalar_type ScalarType;
|
||||
|
||||
ScalarLattice scalField;
|
||||
|
||||
unvectorizeToRevLexOrdArray(scalField, field);
|
||||
|
||||
std::vector<hsize_t> dim;
|
||||
std::vector<size_t> tDim;
|
||||
|
||||
tensorDim(tDim, scalField[0]);
|
||||
for (auto &d: field._grid->GlobalDimensions())
|
||||
{
|
||||
dim.push_back(d);
|
||||
}
|
||||
for (auto &d: tDim)
|
||||
{
|
||||
dim.push_back(d);
|
||||
}
|
||||
|
||||
// write to file
|
||||
H5NS::DataSpace dataSpace(dim.size(), dim.data());
|
||||
H5NS::DataSet dataSet;
|
||||
|
||||
dataSet = group_.createDataSet(s, Hdf5Type<ScalarType>::type(), dataSpace);
|
||||
dataSet.write(scalField.data(), Hdf5Type<ScalarType>::type());
|
||||
}
|
||||
|
||||
|
||||
template <typename U>
|
||||
typename std::enable_if<element<std::vector<U>>::is_number, void>::type
|
||||
Hdf5Writer::writeDefault(const std::string &s, const std::vector<U> &x)
|
||||
@@ -208,29 +169,6 @@ namespace Grid
|
||||
template <>
|
||||
void Hdf5Reader::readDefault(const std::string &s, std::string &x);
|
||||
|
||||
template <typename U>
|
||||
void Hdf5Reader::readDefault(const std::string &s, Lattice<U> &field)
|
||||
{
|
||||
// alias scalar types
|
||||
typedef std::vector<typename U::scalar_object> ScalarLattice;
|
||||
typedef typename U::scalar_type ScalarType;
|
||||
|
||||
ScalarLattice scalField;
|
||||
H5NS::DataSet dataSet;
|
||||
std::vector<hsize_t> dim;
|
||||
hsize_t size = 1;
|
||||
|
||||
dataSet = group_.openDataSet(s);
|
||||
for (auto &d: field._grid->GlobalDimensions())
|
||||
{
|
||||
dim.push_back(d);
|
||||
size *= d;
|
||||
}
|
||||
scalField.resize(size);
|
||||
dataSet.read(scalField.data(), Hdf5Type<ScalarType>::type());
|
||||
vectorizeFromRevLexOrdArray(scalField, field);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
typename std::enable_if<element<std::vector<U>>::is_number, void>::type
|
||||
Hdf5Reader::readDefault(const std::string &s, std::vector<U> &x)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define GRID_SERIALISATION_VECTORUTILS_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <Grid/tensors/Tensors.h>
|
||||
#include <Grid/tensors/Tensors.h>
|
||||
|
||||
namespace Grid {
|
||||
// Pair IO utilities /////////////////////////////////////////////////////////
|
||||
@@ -78,48 +78,6 @@ namespace Grid {
|
||||
typedef typename std::vector<std::vector<typename TensorToVec<T>::type>> type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void tensorDim(std::vector<size_t> &dim, const T &t, const bool wipe = true)
|
||||
{
|
||||
if (wipe)
|
||||
{
|
||||
dim.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tensorDim(std::vector<size_t> &dim, const iScalar<T> &t, const bool wipe = true)
|
||||
{
|
||||
if (wipe)
|
||||
{
|
||||
dim.clear();
|
||||
}
|
||||
tensorDim(dim, t._internal, false);
|
||||
}
|
||||
|
||||
template <typename T, int N>
|
||||
void tensorDim(std::vector<size_t> &dim, const iVector<T, N> &t, const bool wipe = true)
|
||||
{
|
||||
if (wipe)
|
||||
{
|
||||
dim.clear();
|
||||
}
|
||||
dim.push_back(N);
|
||||
tensorDim(dim, t._internal[0], false);
|
||||
}
|
||||
|
||||
template <typename T, int N>
|
||||
void tensorDim(std::vector<size_t> &dim, const iMatrix<T, N> &t, const bool wipe = true)
|
||||
{
|
||||
if (wipe)
|
||||
{
|
||||
dim.clear();
|
||||
}
|
||||
dim.push_back(N);
|
||||
dim.push_back(N);
|
||||
tensorDim(dim, t._internal[0][0], false);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename TensorToVec<T>::type tensorToVec(const T &t)
|
||||
{
|
||||
|
Reference in New Issue
Block a user