00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef HDF5DATAWRITER_HPP_
00029 #define HDF5DATAWRITER_HPP_
00030
00031 #include <hdf5.h>
00032 #include <petscvec.h>
00033 #include <cassert>
00034 #include <vector>
00035 #include "Exception.hpp"
00036 #include "AbstractDataWriter.hpp"
00037 #include "DataWriterVariable.hpp"
00038 #include "OutputFileHandler.hpp"
00039
00040 class Hdf5DataWriter
00041 {
00042 private:
00043 bool mAmMaster;
00045 std::string mDirectory;
00046 std::string mBaseName;
00047 bool mCleanDirectory;
00048 bool mIsInDefineMode;
00049 bool mIsFixedDimensionSet;
00050 bool mIsUnlimitedDimensionSet;
00051 std::string mUnlimitedDimensionName;
00052 std::string mUnlimitedDimensionUnit;
00053 unsigned mFileFixedDimensionSize;
00054 unsigned mDataFixedDimensionSize;
00055 unsigned mLo, mHi;
00056 unsigned mNumberOwned, mOffset;
00057 bool mIsDataComplete;
00058 bool mNeedExtend;
00059 std::vector<unsigned> mIncompleteNodeIndices;
00060
00061 std::vector<DataWriterVariable> mVariables;
00063 void CheckVariableName(std::string name);
00064 void CheckUnitsName(std::string name);
00066 hid_t mFileId;
00067 hid_t mDatasetId;
00068 hid_t mTimeDatasetId;
00069
00070 long mCurrentTimeStep;
00071
00072 const static unsigned DATASET_DIMS=3;
00073 hsize_t mDatasetDims[DATASET_DIMS];
00074
00075 public:
00076 Hdf5DataWriter(std::string directory, std::string baseName, bool cleanDirectory=true);
00077 virtual ~Hdf5DataWriter();
00078
00079 void DefineFixedDimension(long dimensionSize);
00080 void DefineFixedDimension(std::vector<unsigned> nodesToOuput, long vecSize);
00081 void DefineUnlimitedDimension(std::string variableName, std::string variableUnits);
00082 void AdvanceAlongUnlimitedDimension();
00083 int DefineVariable(std::string variableName, std::string variableUnits);
00084 virtual void EndDefineMode();
00085 void PossiblyExtend();
00086 void PutVector(int variableID, Vec petscVector);
00087 void PutStripedVector(int firstVariableID, int secondVariableID, Vec petscVector);
00088 void PutUnlimitedVariable(double value);
00089
00090 void Close();
00091 };
00092
00093 #endif