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
00030 #include "AbstractHdf5Converter.hpp"
00031 #include "HeartConfig.hpp"
00032 #include "Version.hpp"
00033
00034
00035 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00036 AbstractHdf5Converter<ELEMENT_DIM, SPACE_DIM>::AbstractHdf5Converter(std::string inputDirectory,
00037 std::string fileBaseName,
00038 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM> *pMesh,
00039 std::string subdirectoryName) :
00040 mFileBaseName(fileBaseName),
00041 mpMesh(pMesh)
00042 {
00043
00044 this->mpReader = new Hdf5DataReader(inputDirectory, this->mFileBaseName);
00045
00046 mpOutputFileHandler = new OutputFileHandler(HeartConfig::Instance()->GetOutputDirectory() + "/" + subdirectoryName, false);
00047
00048 std::vector<std::string> variable_names = this->mpReader->GetVariableNames();
00049 mNumVariables = variable_names.size();
00050
00051 if (mpReader->GetNumberOfRows() != mpMesh->GetNumNodes())
00052 {
00053 delete mpReader;
00054 delete mpOutputFileHandler;
00055 EXCEPTION("Mesh and HDF5 file have a different number of nodes");
00056 }
00057
00058
00059 if (PetscTools::AmMaster())
00060 {
00061
00062 out_stream p_file = this->mpOutputFileHandler->OpenOutputFile(this->mFileBaseName + "_times.info");
00063 unsigned num_timesteps = this->mpReader->GetUnlimitedDimensionValues().size();
00064 *p_file << "Number of timesteps " << num_timesteps << std::endl;
00065 *p_file << "timestep " << HeartConfig::Instance()->GetPrintingTimeStep() << std::endl;
00066 double first_timestep=this->mpReader->GetUnlimitedDimensionValues().front();
00067 *p_file << "First timestep " << first_timestep << std::endl;
00068 double last_timestep=this->mpReader->GetUnlimitedDimensionValues().back();
00069 *p_file << "Last timestep " << last_timestep << std::endl;
00070 *p_file << ChasteBuildInfo::GetProvenanceString();
00071 p_file->close();
00072 }
00073
00074 HeartConfig::Instance()->Write(false, subdirectoryName);
00075
00076 }
00077 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00078 AbstractHdf5Converter<ELEMENT_DIM,SPACE_DIM>::~AbstractHdf5Converter()
00079 {
00080 delete mpReader;
00081 delete mpOutputFileHandler;
00082 }
00083
00085
00087
00088 template class AbstractHdf5Converter<1,1>;
00089 template class AbstractHdf5Converter<1,2>;
00090 template class AbstractHdf5Converter<2,2>;
00091 template class AbstractHdf5Converter<1,3>;
00092 template class AbstractHdf5Converter<2,3>;
00093 template class AbstractHdf5Converter<3,3>;
00094