40 #ifndef EGS_RUN_CONTROL_
41 #define EGS_RUN_CONTROL_
53 inline void addRunControlBlock(shared_ptr<EGS_InputStruct> blockPtr) {
54 shared_ptr<EGS_BlockInput> runBlock = blockPtr->addBlockInput(
"run control");
55 runBlock->addSingleInput(
"ncase",
true,
"The number of histories to simulate.");
56 runBlock->addSingleInput(
"nbatch",
false,
"The number of batches to divide the simulation into. After each batch, a checkpoint is created to allow resuming the simulation. For simulations with very large intermediate data (like a high resolution dose grid), reducing nbatch to 1 can speed up the simulation. Defaults to 10.");
57 runBlock->addSingleInput(
"nchunk",
false,
"For parallel runs, each job splits its portion of the simulation into nchunk serial chunks, and each of those chunks is divided into nbatch batches. After each chunk, the parallel job grabs a new portion of the simulation to work on. Defaults to 10.");
58 runBlock->addSingleInput(
"max cpu hours allowed",
false,
"The number hours after which the simulation will be haulted. Defaults to -1, which is no limit.");
59 runBlock->addSingleInput(
"statistical accuracy sought",
false,
"The statistical uncertainty for a particular quantity of interest, below which the simulation will be haulted. Note that the quantity must be defined by the application (e.g. the cavity dose in egs_chamber), and in general is undefined (e.g. this input does nothing for egs_app).");
60 runBlock->addSingleInput(
"geometry error limit",
false,
"The number of geometry errors that will be allowed to occur, before haulting the simulation. Defaults to 0.");
61 runBlock->addSingleInput(
"calculation",
false,
"The calculation type: first (default, runs a new simulation), resume (continue a crashed simulation), analyze (prints results), combine (combines results from a parallel run). Defaults to 'first'.", {
"first",
"resume",
"analyze",
"combine"});
64 inline string addRunControlExample() {
69 nbatch = 10 #[optional]
70 nchunk = 10 #[optional]
71 statistical accuracy sought = 5 #[optional]
72 max cpu hours allowed = 0.5 #[optional]
73 calculation = first #[optional]
74 geometry error limit = 2 #[optional]
140 void setNcase(EGS_I64 n) {
147 void setNbatch(
int n) {
154 void setMaxTime(EGS_Float t) {
159 void setRequiredUncertainty(EGS_Float a) {
164 EGS_I64 getNcase()
const {
169 int getNbatch()
const {
174 int getNchunk()
const {
185 virtual int startSimulation();
196 virtual EGS_I64 getNextChunk() {
197 return getNcase() - ndone;
210 virtual int finishSimulation();
218 virtual bool startBatch(
int,EGS_I64);
226 virtual bool finishBatch();
228 virtual void describeRCO();
229 virtual bool storeState(ostream &data);
230 virtual bool setState(istream &data);
231 virtual bool addState(istream &data);
232 virtual void resetCounter();
233 virtual bool getCombinedResult(
double &,
double &)
const {
237 virtual EGS_I64 getNdone()
const {
241 virtual void setNdone(EGS_I64 Ndone) {
245 virtual void incrementNdone() {
249 virtual EGS_Float getCPUTime()
const {
250 return cpu_time+previous_cpu_time;
262 int geomErrorCount, geomErrorMax;
284 EGS_Float previous_cpu_time;
288 class EGS_FileLocking;
313 void setNchunkForParallel(
int n) {
318 int startSimulation();
319 EGS_I64 getNextChunk();
320 int finishSimulation();
321 bool getCombinedResult(
double &,
double &)
const;
326 double tsum, tsum2, tcount, norm;
327 double last_sum, last_sum2, last_count;
328 unsigned long start_time;
340 bool createControlFile();
341 bool openControlFile();
342 bool closeControlFile();
343 bool lockControlFile();
344 bool unlockControlFile();
345 bool rewindControlFile();
346 bool readControlFile();
347 bool writeControlFile();
348 virtual bool writeControlString();
349 virtual bool readControlString();
404 int startSimulation();
414 int finishSimulation();
Base class for advanced EGSnrc C++ applications.
A 'job control file' (JCF) RCO.
A simple run control object for advanced EGSnrc C++ applications.
A simple class for measuring CPU time.
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_Timer class header file.