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
00029 #ifndef HDF5DATAWRITER_HPP_
00030 #define HDF5DATAWRITER_HPP_
00031
00032 #include <string>
00033 #include <vector>
00034
00035 #include "Hdf5DataReader.hpp"
00036 #include "DataWriterVariable.hpp"
00037 #include "DistributedVectorFactory.hpp"
00038
00042 class Hdf5DataWriter
00043 {
00044 private:
00045
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 mEstimatedUnlimitedLength;
00057 unsigned mFileFixedDimensionSize;
00058 unsigned mDataFixedDimensionSize;
00059 unsigned mLo;
00060 unsigned mHi;
00061 unsigned mNumberOwned;
00062 unsigned mOffset;
00063 bool mIsDataComplete;
00064 bool mNeedExtend;
00065 std::vector<unsigned> mIncompleteNodeIndices;
00066 bool mUseMatrixForIncompleteData;
00068 std::vector<DataWriterVariable> mVariables;
00070 hid_t mFileId;
00071 hid_t mDatasetId;
00072 hid_t mTimeDatasetId;
00074 long mCurrentTimeStep;
00076 static const unsigned DATASET_DIMS=3;
00077 hsize_t mDatasetDims[DATASET_DIMS];
00079 Mat mSinglePermutation;
00080 Mat mDoublePermutation;
00082 Mat mSingleIncompleteOutputMatrix;
00083 Mat mDoubleIncompleteOutputMatrix;
00085 bool mUseOptimalChunkSizeAlgorithm;
00086 unsigned mFixedChunkSize;
00093 void CheckVariableName(const std::string& rName);
00094
00100 void CheckUnitsName(const std::string& rName);
00101
00105 void ComputeIncompleteOffset();
00106
00107 public:
00108
00122 Hdf5DataWriter(DistributedVectorFactory& rVectorFactory,
00123 const std::string& rDirectory,
00124 const std::string& rBaseName,
00125 bool cleanDirectory=true,
00126 bool extendData=false);
00127
00131 virtual ~Hdf5DataWriter();
00132
00138 void DefineFixedDimension(long dimensionSize);
00139
00146 void DefineFixedDimension(const std::vector<unsigned>& rNodesToOuput, long vecSize);
00147
00156 void DefineUnlimitedDimension(const std::string& rVariableName, const std::string& rVariableUnits, unsigned estimatedLength = 1);
00157
00162 void AdvanceAlongUnlimitedDimension();
00163
00172 int DefineVariable(const std::string& rVariableName, const std::string& rVariableUnits);
00173
00177 virtual void EndDefineMode();
00178
00182 void PossiblyExtend();
00183
00190 void PutVector(int variableID, Vec petscVector);
00191
00198 void PutStripedVector(std::vector<int> variableIDs, Vec petscVector);
00199
00205 void PutUnlimitedVariable(double value);
00206
00210 void Close();
00211
00219 int GetVariableByName(const std::string& rVariableName);
00220
00221
00228 bool ApplyPermutation(const std::vector<unsigned>& rPermutation);
00229
00237 void DefineFixedDimensionUsingMatrix(const std::vector<unsigned>& rNodesToOuput, long vecSize);
00238
00245 void SetFixedChunkSize(unsigned chunkSize);
00246 };
00247
00248 #endif