Hdf5DataWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 "Hdf5DataReader.hpp" //For common definitions
00035 #include "DataWriterVariable.hpp"
00036 #include "DistributedVectorFactory.hpp"
00037 
00038 
00039 
00043 class Hdf5DataWriter//  : public AbstractDataWriter
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; 
00065     bool mUseMatrixForIncompleteData; 
00067     std::vector<DataWriterVariable> mVariables; 
00069     hid_t mFileId; 
00070     hid_t mDatasetId; 
00071     hid_t mTimeDatasetId; 
00073     long mCurrentTimeStep; 
00075     static const unsigned DATASET_DIMS=3; 
00076     hsize_t mDatasetDims[DATASET_DIMS]; 
00078     Mat mSinglePermutation; 
00079     Mat mDoublePermutation;
00081     Mat mSingleIncompleteOutputMatrix; 
00082     Mat mDoubleIncompleteOutputMatrix; 
00088     void CheckVariableName(const std::string& rName);
00089 
00095     void CheckUnitsName(const std::string& rName);
00096 
00100     void ComputeIncompleteOffset();
00101 
00102 public:
00103 
00117     Hdf5DataWriter(DistributedVectorFactory& rVectorFactory,
00118                    const std::string& rDirectory,
00119                    const std::string& rBaseName,
00120                    bool cleanDirectory=true,
00121                    bool extendData=false);
00122 
00126     virtual ~Hdf5DataWriter();
00127 
00133     void DefineFixedDimension(long dimensionSize);
00134 
00141     void DefineFixedDimension(const std::vector<unsigned>& rNodesToOuput, long vecSize);
00142 
00150     void DefineUnlimitedDimension(const std::string& rVariableName, const std::string& rVariableUnits);
00151 
00156     void AdvanceAlongUnlimitedDimension();
00157 
00166     int DefineVariable(const std::string& rVariableName, const std::string& rVariableUnits);
00167 
00171     virtual void EndDefineMode();
00172 
00176     void PossiblyExtend();
00177 
00184     void PutVector(int variableID, Vec petscVector);
00185 
00192     void PutStripedVector(std::vector<int> variableIDs, Vec petscVector);
00193 
00199     void PutUnlimitedVariable(double value);
00200 
00204     void Close();
00205 
00213     int GetVariableByName(const std::string& rVariableName);
00214     
00215     
00222     bool ApplyPermutation(const std::vector<unsigned>& rPermutation);
00223     
00231     void DefineFixedDimensionUsingMatrix(const std::vector<unsigned>& rNodesToOuput, long vecSize);
00232      
00233 };
00234 
00235 #endif /*HDF5DATAWRITER_HPP_*/

Generated on Mon Nov 1 12:35:17 2010 for Chaste by  doxygen 1.5.5