#include <OutputFileHandler.hpp>
Public Member Functions | |
OutputFileHandler (const std::string &rDirectory, bool cleanOutputDirectory=true) | |
std::string | GetOutputDirectoryFullPath (const std::string &rDirectory) |
std::string | GetOutputDirectoryFullPath () |
void | SetArchiveDirectory () |
out_stream | OpenOutputFile (const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) |
out_stream | OpenOutputFile (const std::string &rFileName, unsigned number, const std::string &rFileFormat, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) |
bool | IsMaster () |
Static Public Member Functions | |
static std::string | GetChasteTestOutputDirectory () |
Private Attributes | |
std::string | mDirectory |
The directory to store output files in (always ends in "/"). | |
bool | mAmMaster |
Are we the master process? |
Definition at line 47 of file OutputFileHandler.hpp.
OutputFileHandler::OutputFileHandler | ( | const std::string & | rDirectory, | |
bool | cleanOutputDirectory = true | |||
) |
Create an OutputFileHandler that will create output files in the given directory. The directory name should be relative to the place where Chaste test output is stored. If the user needs to know where this is, use the GetChasteTestOutputDirectory method.
Will check that the directory exists and create it if needed.
rDirectory | the directory to put output files in. | |
cleanOutputDirectory | whether to remove any existing files in the output directory |
Definition at line 44 of file OutputFileHandler.cpp.
References PetscTools::AmMaster(), GetOutputDirectoryFullPath(), mAmMaster, and mDirectory.
std::string OutputFileHandler::GetChasteTestOutputDirectory | ( | ) | [static] |
Static method for getting the test output directory (the directory where chaste stores test out, which is the environment variable CHASTE_TESTOUTPUT
Static so an output file handler does not have to be created if the test output directory is wanted for, say, reading a file
Definition at line 74 of file OutputFileHandler.cpp.
Referenced by TissueSimulationArchiver< DIM, SIM >::GetArchivePathname(), ArchiveLocationInfo::GetArchiveRelativePath(), and GetOutputDirectoryFullPath().
std::string OutputFileHandler::GetOutputDirectoryFullPath | ( | const std::string & | rDirectory | ) |
Check that the desired output directory exists and is writable by us. Create it if needed. Return the full pathname of the output directory.
The environment variable CHASTE_TEST_OUTPUT will be examined. If it is set and non-empty it is taken to be a directory where test output should be stored. Otherwise the current directory is used.
rDirectory | pathname of the output directory, relative to where Chaste output will be stored (user shouldn't care about this). |
Definition at line 97 of file OutputFileHandler.cpp.
References GetChasteTestOutputDirectory(), and mAmMaster.
Referenced by ColumnDataReader::ColumnDataReader(), CuboidMeshConstructor< DIM >::Construct(), AbstractConvergenceTester< CELL, CARDIAC_PROBLEM, DIM, PROBLEM_DIM >::Converge(), Hdf5DataWriter::EndDefineMode(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::GetOutputDirectory(), ColumnDataWriter::GetOutputDirectory(), Hdf5DataReader::Hdf5DataReader(), HoneycombMeshGenerator::HoneycombMeshGenerator(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisBinaryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodesWithMetisBinaries(), QuadraticMesh< DIM >::QuadraticMesh(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), TissueSimulationArchiver< DIM, SIM >::Save(), AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), and HeartConfig::Write().
std::string OutputFileHandler::GetOutputDirectoryFullPath | ( | ) |
Return the full pathname to the directory this object will create files in.
Definition at line 116 of file OutputFileHandler.cpp.
References mDirectory.
Referenced by OutputFileHandler(), and SetArchiveDirectory().
void OutputFileHandler::SetArchiveDirectory | ( | ) |
Helper method to set up ArchiveLocationInfo.
Definition at line 148 of file OutputFileHandler.cpp.
References GetOutputDirectoryFullPath(), and ArchiveLocationInfo::SetArchiveDirectory().
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::Solve().
out_stream OutputFileHandler::OpenOutputFile | ( | const std::string & | rFileName, | |
std::ios_base::openmode | mode = std::ios::out | std::ios::trunc | |||
) |
Open an output file in our directory, and check it was opened successfully. Throws an Exception if not.
rFileName | the name of the file to open, relative to the output directory. | |
mode | optionally, flags to use when opening the file (defaults are as for std::ofstream). |
Definition at line 121 of file OutputFileHandler.cpp.
References mDirectory.
Referenced by AbstractConvergenceTester< CELL, CARDIAC_PROBLEM, DIM, PROBLEM_DIM >::Converge(), ColumnDataWriter::CreateFixedDimensionFile(), ColumnDataWriter::CreateInfoFile(), MeshBasedTissue< DIM >::CreateOutputFiles(), AbstractTissue< DIM >::CreateOutputFiles(), CardiacElectroMechanicsProblem< DIM >::DetermineWatchedNodes(), ColumnDataWriter::EndDefineMode(), StreeterFibreGenerator< SPACE_DIM >::GenerateOrthotropicFibreOrientation(), Hdf5ToMeshalyzerConverter::Hdf5ToMeshalyzerConverter(), HoneycombMeshGenerator::Make2dPeriodicCryptMesh(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisBinaryNodePartitioning(), OpenOutputFile(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodesWithMetisBinaries(), ProgressReporter::ProgressReporter(), QuadraticMesh< DIM >::QuadraticMesh(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), InventorVoronoiWriter::ScaleAndWrite(), LogFile::Set(), CryptSimulation2d::SetupWriteBetaCatenin(), SimpleDataWriter::SimpleDataWriter(), TissueSimulation< DIM >::Solve(), InventorVoronoiWriter::Write(), Hdf5ToMeshalyzerConverter::Write(), PostProcessingWriter::WriteApdMapFile(), QuadraticMesh< DIM >::WriteBoundaryElementFile(), PostProcessingWriter::WriteConductionVelocityMap(), TrianglesMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteElementsAsFaces(), TrianglesMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFacesAsEdges(), TrianglesMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFiles(), MeshalyzerMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFiles(), CmguiWriter::WriteFiles(), HeartGeometryInformation< SPACE_DIM >::WriteLayerForEachNode(), PostProcessingWriter::WriteMaxUpstrokeVelocityMap(), AbstractNonlinearElasticityAssembler< DIM >::WriteOutput(), and PostProcessingWriter::WriteUpstrokeTimeMap().
out_stream OutputFileHandler::OpenOutputFile | ( | const std::string & | rFileName, | |
unsigned | number, | |||
const std::string & | rFileFormat, | |||
std::ios_base::openmode | mode = std::ios::out | std::ios::trunc | |||
) |
This just calls the other OpenOutputFile after concatenating the first three arguments together to make the full filename. For example OpenOutputFile("results_", 3, ".dat") creates results_3.dat. See documentation for OpenOutputFile(std::string, std::ios_base::openmode).
rFileName | the root name of the file to open | |
number | the number to append to the root name of the file | |
rFileFormat | the file format | |
mode | optionally, flags to use when opening the file (defaults are as for std::ofstream). |
Definition at line 133 of file OutputFileHandler.cpp.
References OpenOutputFile().
bool OutputFileHandler::IsMaster | ( | ) |
Returns true if this process is the master, or if running without Petsc i.e. in serial
Definition at line 143 of file OutputFileHandler.cpp.
References mAmMaster.
Referenced by CuboidMeshConstructor< DIM >::Construct(), AbstractConvergenceTester< CELL, CARDIAC_PROBLEM, DIM, PROBLEM_DIM >::Converge(), HoneycombMeshGenerator::Make2dPeriodicCryptMesh(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisBinaryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodesWithMetisBinaries(), and MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh().