2 #ifndef ANDRES_GRAPH_GRID_GRAPH_HDF5_HXX
3 #define ANDRES_GRAPH_GRID_GRAPH_HDF5_HXX
11 #include "../grid-graph.hxx"
18 template<
unsigned char D,
class VISITOR>
22 template<
unsigned char D,
class VISITOR>
23 const int GraphTraitsHDF5<GridGraph<D, VISITOR> >::ID = 10003;
25 template<
unsigned char D,
class VISITOR>
28 template<
unsigned char D,
class VISITOR>
31 template<
unsigned char D,
class VISITOR>
34 const hid_t parentHandle,
35 const std::string& graphName,
38 HandleCheck<ANDRES_GRAPH_HDF5_DEBUG> handleCheck;
39 hid_t groupHandle =
openGroup(parentHandle, graphName,
true);
45 std::array<std::size_t, D> shape;
46 for(std::size_t i=0; i<D; ++i) {
47 shape[i] = graph.
shape(i);
49 save(groupHandle,
"shape", {D}, &shape[0]);
50 }
catch(std::exception& e) {
55 throw std::runtime_error(
"error saving grid graph: " + sError);
59 template<
unsigned char D,
class VISITOR>
62 const hid_t parentHandle,
63 const std::string& graphName,
66 HandleCheck<ANDRES_GRAPH_HDF5_DEBUG> handleCheck;
67 hid_t groupHandle =
openGroup(parentHandle, graphName);
72 load(groupHandle,
"graph-type-id",
id);
74 sError =
"graph type id mismatch.";
78 std::vector<std::size_t> nDims;
79 std::vector<std::size_t> shape;
80 load(groupHandle,
"shape", nDims, shape);
81 if(nDims.size() != 1 || nDims[0] != D) {
82 sError =
"shape mismatch.";
87 std::copy(shape.begin(), shape.end(), vc.begin());
89 }
catch(std::exception& e) {
90 sError =
"failed to load grid graph: " + std::string(e.what());
97 throw std::runtime_error(
"error loading grid graph: " + sError);
105 #endif // #ifndef ANDRES_GRAPH_GRID_GRAPH_HDF5_HXX