Hdf5DataWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #ifndef HDF5DATAWRITER_HPP_
00029 #define HDF5DATAWRITER_HPP_
00030 
00031 #include <string>
00032 #include <vector>
00033 
00034 #include <hdf5.h>
00035 #include <petscvec.h>
00036 
00037 //#include "AbstractDataWriter.hpp"
00038 #include "DataWriterVariable.hpp"
00039 #include "DistributedVectorFactory.hpp"
00040 
00041 
00042 
00046 class Hdf5DataWriter//  : public AbstractDataWriter
00047 {
00048 private:
00050     DistributedVectorFactory& mrVectorFactory;
00051     std::string mDirectory; 
00052     std::string mBaseName; 
00053     bool mCleanDirectory;   
00054     bool mIsInDefineMode; 
00055     bool mIsFixedDimensionSet; 
00056     bool mIsUnlimitedDimensionSet; 
00057     std::string mUnlimitedDimensionName; 
00058     std::string mUnlimitedDimensionUnit; 
00059     unsigned mFileFixedDimensionSize; 
00060     unsigned mDataFixedDimensionSize; 
00061     unsigned mLo; 
00062     unsigned mHi; 
00063     unsigned mNumberOwned; 
00064     unsigned mOffset; 
00065     bool mIsDataComplete; 
00066     bool mNeedExtend; 
00067     std::vector<unsigned> mIncompleteNodeIndices; 
00069     std::vector<DataWriterVariable> mVariables; 
00076     void CheckVariableName(const std::string& rName);
00077 
00083     void CheckUnitsName(const std::string& rName);
00084 
00085     hid_t mFileId; 
00086     hid_t mDatasetId; 
00087     hid_t mTimeDatasetId; 
00089     long mCurrentTimeStep; 
00091     const static unsigned DATASET_DIMS=3; 
00092     hsize_t mDatasetDims[DATASET_DIMS]; 
00094 public:
00095 
00104     Hdf5DataWriter(DistributedVectorFactory& rVectorFactory,
00105                    const std::string& rDirectory,
00106                    const std::string& rBaseName,
00107                    bool cleanDirectory=true);
00108 
00112     virtual ~Hdf5DataWriter();
00113 
00119     void DefineFixedDimension(long dimensionSize);
00120 
00127     void DefineFixedDimension(const std::vector<unsigned>& rNodesToOuput, long vecSize);
00128 
00137     void DefineUnlimitedDimension(const std::string& rVariableName, const std::string& rVariableUnits);
00138 
00143     void AdvanceAlongUnlimitedDimension();
00144 
00153     int DefineVariable(const std::string& rVariableName, const std::string& rVariableUnits);
00154 
00158     virtual void EndDefineMode();
00159 
00163     void PossiblyExtend();
00164 
00171     void PutVector(int variableID, Vec petscVector);
00172 
00180     void PutStripedVector(int firstVariableID, int secondVariableID, Vec petscVector);
00181 
00187     void PutUnlimitedVariable(double value);
00188 
00192     void Close();
00193 };
00194 
00195 #endif /*HDF5DATAWRITER_HPP_*/

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5