26 #ifndef SCHNEK_HDFDIAGNOSTIC_HPP_ 27 #define SCHNEK_HDFDIAGNOSTIC_HPP_ 29 #include "../config.hpp" 30 #ifdef SCHNEK_HAVE_HDF5 32 #include "../grid/grid.hpp" 33 #include "diagnostic.hpp" 39 #if defined (H5_HAVE_PARALLEL) && defined (SCHNEK_USE_HDF_PARALLEL) 47 template<
typename TYPE>
49 static const hid_t type;
56 template<
typename FieldType>
63 typename FieldType::IndexType global_min;
66 typename FieldType::IndexType global_max;
69 typename FieldType::IndexType local_min;
72 typename FieldType::IndexType local_max;
80 struct HdfAttributes {
81 friend class HdfOStream;
88 typedef std::shared_ptr<Info> pInfo;
90 std::map<std::string, pInfo> attributes;
100 void set(std::string name,
const T *value, hsize_t dims = 1);
109 void set(std::string name,
const T &value, hsize_t dims = 1);
112 typedef std::shared_ptr<HdfAttributes> pHdfAttributes;
128 std::string blockname;
131 pHdfAttributes attributes;
144 HdfStream(
const HdfStream&);
146 virtual ~HdfStream();
149 virtual int open(
const char*)=0;
152 virtual void close();
155 virtual bool good()
const;
158 void setBlockName(std::string blockname_);
161 void setAttributes(pHdfAttributes attributes_);
164 HdfStream& operator = (
const HdfStream&);
166 void setActive(
bool active_) { active = active_; activeModified =
true; }
169 std::string getNextBlockName();
171 #if defined (H5_HAVE_PARALLEL) && defined (SCHNEK_USE_HDF_PARALLEL) 182 class HdfIStream :
public HdfStream {
190 HdfIStream(
const HdfIStream&);
193 HdfIStream(
const char* fname);
196 int open(
const char*);
199 template<
typename FieldType>
200 void readGrid(GridContainer<FieldType> &g);
205 class HdfOStream :
public HdfStream {
208 #if defined (H5_HAVE_PARALLEL) && defined (SCHNEK_USE_HDF_PARALLEL) 218 HdfOStream(
const HdfOStream&);
221 HdfOStream(
const char* fname);
224 int open(
const char*);
227 template<
typename FieldType>
228 void writeGrid(GridContainer<FieldType> &g);
233 template<
typename Type,
class DiagnosticType = IntervalDiagnostic >
234 class HDFGridDiagnostic :
public SimpleDiagnostic<Type, Type, DiagnosticType> {
236 typedef typename Type::IndexType IndexType;
239 GridContainer<Type> container;
242 void open(
const std::string &);
251 virtual IndexType getGlobalMin() = 0;
253 virtual IndexType getGlobalMax() = 0;
260 virtual std::string getDatasetName();
269 virtual pHdfAttributes getAttributes() {
270 return std::make_shared<HdfAttributes>();
273 virtual ~HDFGridDiagnostic() {}
281 template<
typename Type>
282 class HDFGridReader :
public Block
285 typedef typename Type::IndexType IndexType;
290 GridContainer<Type> container;
294 std::string fieldName;
296 std::string fileName;
301 virtual ~HDFGridReader() {}
326 virtual IndexType getGlobalMin() = 0;
329 virtual IndexType getGlobalMax() = 0;
336 virtual std::string getDatasetName();
339 void initParameters(BlockParameters &blockPars);
344 #include "hdfdiagnostic.t" 348 #endif // SCHNEK_HDFDIAGNOSTIC_HPP_