Hdf5DataWriter.hpp
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 <string>
00032 #include <vector>
00033
00034 #include "Hdf5DataReader.hpp"
00035 #include "DataWriterVariable.hpp"
00036 #include "DistributedVectorFactory.hpp"
00037
00038
00039
00043 class Hdf5DataWriter
00044 {
00045 private:
00047 DistributedVectorFactory& mrVectorFactory;
00048 std::string mDirectory;
00049 std::string mBaseName;
00050 bool mCleanDirectory;
00051 bool mIsInDefineMode;
00052 bool mIsFixedDimensionSet;
00053 bool mIsUnlimitedDimensionSet;
00054 std::string mUnlimitedDimensionName;
00055 std::string mUnlimitedDimensionUnit;
00056 unsigned mFileFixedDimensionSize;
00057 unsigned mDataFixedDimensionSize;
00058 unsigned mLo;
00059 unsigned mHi;
00060 unsigned mNumberOwned;
00061 unsigned mOffset;
00062 bool mIsDataComplete;
00063 bool mNeedExtend;
00064 std::vector<unsigned> mIncompleteNodeIndices;
00066 std::vector<DataWriterVariable> mVariables;
00073 void CheckVariableName(const std::string& rName);
00074
00080 void CheckUnitsName(const std::string& rName);
00081
00082 hid_t mFileId;
00083 hid_t mDatasetId;
00084 hid_t mTimeDatasetId;
00086 long mCurrentTimeStep;
00088 const static unsigned DATASET_DIMS=3;
00089 hsize_t mDatasetDims[DATASET_DIMS];
00094 void ComputeIncompleteOffset();
00095
00096 public:
00097
00111 Hdf5DataWriter(DistributedVectorFactory& rVectorFactory,
00112 const std::string& rDirectory,
00113 const std::string& rBaseName,
00114 bool cleanDirectory=true,
00115 bool extendData=false);
00116
00120 virtual ~Hdf5DataWriter();
00121
00127 void DefineFixedDimension(long dimensionSize);
00128
00135 void DefineFixedDimension(const std::vector<unsigned>& rNodesToOuput, long vecSize);
00136
00144 void DefineUnlimitedDimension(const std::string& rVariableName, const std::string& rVariableUnits);
00145
00150 void AdvanceAlongUnlimitedDimension();
00151
00160 int DefineVariable(const std::string& rVariableName, const std::string& rVariableUnits);
00161
00165 virtual void EndDefineMode();
00166
00170 void PossiblyExtend();
00171
00178 void PutVector(int variableID, Vec petscVector);
00179
00187 void PutStripedVector(int firstVariableID, int secondVariableID, Vec petscVector);
00188
00194 void PutUnlimitedVariable(double value);
00195
00199 void Close();
00200
00208 int GetVariableByName(const std::string& rVariableName);
00209 };
00210
00211 #endif