Chaste Commit::f2ff7ee04e70ac9d06c57344df8d017dbb12b97b
ExecutableSupport Class Reference

#include <ExecutableSupport.hpp>

+ Collaboration diagram for ExecutableSupport:

Static Public Member Functions

static void InitializePetsc (int *pArgc, char ***pArgv)
 
static void ShowCopyright ()
 
static void ShowParallelLaunching ()
 
static void SetOutputDirectory (const std::string &rOutputDirectory)
 
static void WriteMachineInfoFile (std::string fileBaseName)
 
static void WriteProvenanceInfoFile ()
 
static void GetBuildInfo (std::string &rInfo)
 
static void StandardStartup (int *pArgc, char ***pArgv)
 
static void StartupWithoutShowingCopyright (int *pArgc, char ***pArgv)
 
static void PrintError (const std::string &rMessage, bool masterOnly=false)
 
static void Print (const std::string &rMessage)
 
static void FinalizePetsc ()
 

Static Public Attributes

static const int EXIT_OK = 0
 
static const int EXIT_ERROR = 1
 
static const int EXIT_BAD_ARGUMENTS = 2
 

Static Private Attributes

static FileFinder mOutputDirectory
 

Detailed Description

Various helpful static methods for people writing their own executables within the Chaste framework.

Most executables will just need to call StandardStartup as the first thing in their main() function, and FinalizePetsc before quitting. The other methods allow you to fine-tune what output is presented to users.

Definition at line 51 of file ExecutableSupport.hpp.

Member Function Documentation

◆ FinalizePetsc()

void ExecutableSupport::FinalizePetsc ( )
static

Shut down PETSc so we exit cleanly.

Definition at line 498 of file ExecutableSupport.cpp.

References PetscSetupUtils::CommonFinalize().

◆ GetBuildInfo()

◆ InitializePetsc()

void ExecutableSupport::InitializePetsc ( int *  pArgc,
char ***  pArgv 
)
static

Initialise PETSc from the command line arguments.

Parameters
pArgcpointer to the number of arguments
pArgvpointer to the argument list

Definition at line 109 of file ExecutableSupport.cpp.

References RelativeTo::ChasteTestOutput, CommandLineArguments::Instance(), FileFinder::IsPathSet(), mOutputDirectory, CommandLineArguments::p_argc, CommandLineArguments::p_argv, and FileFinder::SetPath().

Referenced by StandardStartup(), and StartupWithoutShowingCopyright().

◆ Print()

void ExecutableSupport::Print ( const std::string &  rMessage)
static

Display an informative message to the user, on stdout. Message is only displayed by master process

Parameters
rMessagethe message to display

Definition at line 488 of file ExecutableSupport.cpp.

References PetscTools::AmMaster().

◆ PrintError()

void ExecutableSupport::PrintError ( const std::string &  rMessage,
bool  masterOnly = false 
)
static

Display an error message to the user, on stderr.

Parameters
rMessagethe message to display
masterOnlywhether only the master process should display the error

Definition at line 466 of file ExecutableSupport.cpp.

References PetscTools::AmMaster(), RelativeTo::ChasteTestOutput, PetscTools::GetMyRank(), FileFinder::IsPathSet(), mOutputDirectory, OutputFileHandler::OpenOutputFile(), and FileFinder::SetPath().

◆ SetOutputDirectory()

void ExecutableSupport::SetOutputDirectory ( const std::string &  rOutputDirectory)
static

Set the directory to which the files created by WriteMachineInfoFile, and WriteProvenanceInfoFile will be written. By default they will write to the CHASTE_TEST_OUTPUT folder.

Parameters
rOutputDirectorythe directory to write to

Definition at line 97 of file ExecutableSupport.cpp.

References RelativeTo::Absolute, RelativeTo::ChasteTestOutput, FileFinder::IsAbsolutePath(), mOutputDirectory, and FileFinder::SetPath().

Referenced by CardiacSimulation::CardiacSimulation(), and AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::OutputSimulationSetup().

◆ ShowCopyright()

void ExecutableSupport::ShowCopyright ( )
static

◆ ShowParallelLaunching()

void ExecutableSupport::ShowParallelLaunching ( )
static

Output extra diagnostics when Chaste is launched in parallel.

Definition at line 144 of file ExecutableSupport.cpp.

References PetscTools::BeginRoundRobin(), PetscTools::EndRoundRobin(), PetscTools::GetMyRank(), PetscTools::GetNumProcs(), and PetscTools::IsParallel().

Referenced by StandardStartup(), and StartupWithoutShowingCopyright().

◆ StandardStartup()

void ExecutableSupport::StandardStartup ( int *  pArgc,
char ***  pArgv 
)
static

Call InitializePetsc, ShowCopyright, then ShowParallelLaunching.

Parameters
pArgcpointer to the number of arguments
pArgvpointer to the argument list

Definition at line 453 of file ExecutableSupport.cpp.

References InitializePetsc(), ShowCopyright(), and ShowParallelLaunching().

◆ StartupWithoutShowingCopyright()

void ExecutableSupport::StartupWithoutShowingCopyright ( int *  pArgc,
char ***  pArgv 
)
static

Call InitializePetsc, then ShowParallelLaunching. Omit ShowCopyright.

Parameters
pArgcpointer to the number of arguments
pArgvpointer to the argument list

Definition at line 460 of file ExecutableSupport.cpp.

References InitializePetsc(), and ShowParallelLaunching().

◆ WriteMachineInfoFile()

void ExecutableSupport::WriteMachineInfoFile ( std::string  fileBaseName)
static

Write to log files information about the machine that ran the code. Each process will output its own file.

Parameters
fileBaseNamebase name of the file to write to

Definition at line 157 of file ExecutableSupport.cpp.

References RelativeTo::ChasteTestOutput, PetscTools::GetMyRank(), PetscTools::GetNumProcs(), FileFinder::IsPathSet(), mOutputDirectory, OutputFileHandler::OpenOutputFile(), and FileFinder::SetPath().

Referenced by CardiacSimulation::CardiacSimulation(), and AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::OutputSimulationSetup().

◆ WriteProvenanceInfoFile()

void ExecutableSupport::WriteProvenanceInfoFile ( )
static

Member Data Documentation

◆ EXIT_BAD_ARGUMENTS

const int ExecutableSupport::EXIT_BAD_ARGUMENTS = 2
static

Standard exit codes for executables to return from main(): bad arguments passed on command line.

Definition at line 154 of file ExecutableSupport.hpp.

◆ EXIT_ERROR

const int ExecutableSupport::EXIT_ERROR = 1
static

Standard exit codes for executables to return from main(): exception thrown during execution.

Definition at line 148 of file ExecutableSupport.hpp.

◆ EXIT_OK

const int ExecutableSupport::EXIT_OK = 0
static

Standard exit codes for executables to return from main(): successful termination.

Definition at line 142 of file ExecutableSupport.hpp.

◆ mOutputDirectory

FileFinder ExecutableSupport::mOutputDirectory
staticprivate

The output directory to put machine provenance information into.

Definition at line 158 of file ExecutableSupport.hpp.

Referenced by InitializePetsc(), PrintError(), SetOutputDirectory(), WriteMachineInfoFile(), and WriteProvenanceInfoFile().


The documentation for this class was generated from the following files: