EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
|
A simple run control object for advanced EGSnrc C++ applications. More...
#include <egs_run_control.h>
Public Types | |
enum | RCOType { simple, uniform, balanced } |
Define RCO types. More... | |
Public Member Functions | |
EGS_RunControl (EGS_Application *app) | |
Creates an RCO for the application app. More... | |
virtual | ~EGS_RunControl () |
Destructor. | |
void | setNcase (EGS_I64 n) |
Set the number of particles to be simulated to n. | |
void | setNbatch (int n) |
Set the number of batches to n. | |
void | setMaxTime (EGS_Float t) |
Set the maximum CPU time for the simulation to t. | |
void | setRequiredUncertainty (EGS_Float a) |
Set the required statistical uncertainty to a. | |
EGS_I64 | getNcase () const |
Returns the total number of particles to be simulated. | |
int | getNbatch () const |
Returns the number of batches per simulation chunk. | |
int | getNchunk () const |
Returns the number of simulation chunks. | |
virtual int | startSimulation () |
Starts the simulation. More... | |
virtual EGS_I64 | getNextChunk () |
Returns the number of histories to run in the next simulation chunk. More... | |
virtual int | finishSimulation () |
Finish the simulation. More... | |
virtual bool | startBatch (int, EGS_I64) |
Start a new batch. More... | |
virtual bool | finishBatch () |
Finish a batch. More... | |
virtual void | describeRCO () |
virtual bool | storeState (ostream &data) |
virtual bool | setState (istream &data) |
virtual bool | addState (istream &data) |
virtual void | resetCounter () |
virtual bool | getCombinedResult (double &, double &) const |
virtual EGS_I64 | getNdone () const |
virtual void | setNdone (EGS_I64 Ndone) |
virtual void | incrementNdone () |
virtual EGS_Float | getCPUTime () const |
Static Public Member Functions | |
static EGS_RunControl * | getRunControlObject (EGS_Application *) |
Public Attributes | |
int | geomErrorCount |
int | geomErrorMax |
Protected Attributes | |
EGS_Application * | app |
EGS_Input * | input |
EGS_I64 | ncase |
EGS_I64 | ndone |
EGS_Float | maxt |
EGS_Float | accu |
int | nbatch |
int | restart |
int | nchunk |
RCOType | rco_type |
RCO type to use. | |
EGS_Timer | timer |
EGS_Float | cpu_time |
EGS_Float | previous_cpu_time |
A simple run control object for advanced EGSnrc C++ applications.
In EGSnrc applications derived from EGS_AdvancedApplication the program execution is controlled by a 'run control object' (RCO). The purpose of the RCO is to tell the shower loop into how many 'chunks' the simulation should be split, how many particles to run per simulation chunk, into how many batches to split a simulation chunk, etc. In this way it is easy for EGSnrc C++ application developers to either use one of the RCO's provided with egspp or to implement their own RCO's with alternative implementations or strategies for {e.g.} parallel job processing.
Terminology
Three RCO's are provided with egspp:
Definition at line 94 of file egs_run_control.h.
Define RCO types.
Enumerator | |
---|---|
simple |
single job or multiple independent jobs |
uniform |
parallel jobs with same numbe of histories |
balanced |
parallel jobs with balanced load via JCF |
Definition at line 224 of file egs_run_control.h.
EGS_RunControl::EGS_RunControl | ( | EGS_Application * | app | ) |
Creates an RCO for the application app.
This constructors obtains the user input to the application (available to the application as an EGS_Input object) and looks for
Definition at line 54 of file egs_run_control.cpp.
References egsFatal, egsWarning, EGS_Input::getInput(), EGS_Application::getInput(), EGS_Application::getNparallel(), and EGS_Input::takeInputItem().
|
virtual |
Starts the simulation.
Returns zero if the simulation was successfully started, a positive value if no error occured but no histories are to be run (e.g. combine and analyze runs) and a negative value if some error occured.
Definition at line 182 of file egs_run_control.cpp.
References EGS_Application::combineResults(), EGS_Application::describeSimulation(), egsInformation, EGS_Application::readData(), and EGS_Timer::start().
Referenced by EGS_Application::runSimulation().
|
virtual |
Returns the number of histories to run in the next simulation chunk.
In a simple run this is simply the number of histories specified in the input file. For parallel runs the simulation is split into smaller 'chunks' and this function returns how many histories are in such a chunk. This function is called from within the runSimulation() function of EGS_Application.
Definition at line 166 of file egs_run_control.h.
Referenced by EGS_Application::runSimulation().
|
virtual |
Finish the simulation.
This function is called from within the finishSimulation() method of EGS_Application and should return 1 of the follwoing 3 exit codes:
Reimplemented in EGS_UniformRunControl.
Definition at line 823 of file egs_run_control.cpp.
References egsInformation, EGS_Application::getElectronSteps(), EGS_Application::getFirstParallel(), EGS_Application::getIparallel(), EGS_Application::getNparallel(), EGS_Application::randomNumbersUsed(), and EGS_Timer::time().
Referenced by EGS_AdvancedApplication::finishSimulation(), EGS_Application::finishSimulation(), and EGS_UniformRunControl::finishSimulation().
|
virtual |
Start a new batch.
This function is called from within the shower loop before starting each new batch. Returns true
, if the simulation is to proceed, false
if the simulation is to be terminated immediately.
Definition at line 216 of file egs_run_control.cpp.
References egsInformation, and egsWarning.
Referenced by EGS_Application::runSimulation().
|
virtual |
Finish a batch.
This function is called from within the shower loop after a batch has been finished. Returns true
, if the simulation is to proceed, false
if the simulation is to be terminated immediately.
Definition at line 234 of file egs_run_control.cpp.
References egsInformation, egsWarning, EGS_Application::getCurrentResult(), EGS_Application::outputData(), and EGS_Timer::time().
Referenced by EGS_Application::runSimulation().