MercuryDPM
Beta
|
It is publicly inherited from class Files. It defines an awesome feature that is ideal when doing a parameter study. Below are the routines that manipulate a counter file, called COUNTER_DONOTDEL, to store run numbers. More...
#include <FilesAndRunNumber.h>
Public Member Functions | |
FilesAndRunNumber () | |
Constructor. More... | |
FilesAndRunNumber (const FilesAndRunNumber &other) | |
Copy constructor. More... | |
virtual | ~FilesAndRunNumber () |
Constructor. More... | |
void | constructor () |
a function called by the FilesAndRunNumber() (constructor) More... | |
void | incrementRunNumberInFile () |
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store the new value in the counter file. More... | |
int | readRunNumberFromFile () |
Read the run number or the counter from the counter file (COUNTER_DONOTDEL) More... | |
void | autoNumber () |
The autoNumber() function is the trigger. It calls three functions. setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile(). More... | |
std::vector< int > | get2DParametersFromRunNumber (int size_x, int size_y) |
This turns a counter into two indices which is an amazing feature for doing two dimensional parameter studies. The indices run from 1:size_x and 1:size_y, while the study number starts at 0 ( initially the counter=1 in COUNTER_DONOTDEL) More... | |
int | launchNewRun (const char *name, bool quick=false) |
This launches a code from within this code. Please pass the name of the code to run. More... | |
void | setRunNumber (int runNumber) |
This sets the counter/Run number, overriding the defaults. More... | |
int | getRunNumber () const |
This returns the current value of the counter (runNumber_) More... | |
void | read (std::istream &is) |
Accepts an input stream std::istream. More... | |
void | write (std::ostream &os) const |
Accepts an output stream read function, which accepts an input stream std::ostream. More... | |
Public Member Functions inherited from Files | |
Files () | |
A constructor. More... | |
virtual | ~Files () |
A destructor, watch out its a virtual destructor. More... | |
Files (const Files &other) | |
Copy constructor. More... | |
MERCURY_DEPRECATED File & | getDataFile () |
The non const version. Allows one to edit the File::dataFile. More... | |
MERCURY_DEPRECATED File & | getEneFile () |
The non const version. Allows to edit the File::eneFile. More... | |
MERCURY_DEPRECATED File & | getFStatFile () |
The non const version. Allows to edit the File::fStatFile. More... | |
MERCURY_DEPRECATED File & | getRestartFile () |
The non const version. Allows to edit the File::restartFile. More... | |
MERCURY_DEPRECATED File & | getStatFile () |
The non const version. Allows to edit the File::statFile. More... | |
MERCURY_DEPRECATED const File & | getDataFile () const |
The const version. Does not allow for any editing of the File::dataFile. More... | |
MERCURY_DEPRECATED const File & | getEneFile () const |
The const version. Does not allow for any editing of the File::eneFile. More... | |
MERCURY_DEPRECATED const File & | getFStatFile () const |
The const version. Does not allow for any editing of the File::fStatFile. More... | |
MERCURY_DEPRECATED const File & | getRestartFile () const |
The const version. Does not allow for any editing of the File::restartFile. More... | |
MERCURY_DEPRECATED const File & | getStatFile () const |
The const version. Does not allow for any editing of the File::statFile. More... | |
const std::string & | getName () const |
Returns the name of the file. Does not allow to change it though. More... | |
void | setName (const std::string &name) |
Allows to set the name of all the files (ene, data, fstat, restart, stat) More... | |
void | setName (const char *name) |
Calls setName(std::string) More... | |
void | setSaveCount (unsigned int saveCount) |
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat) More... | |
void | setFileType (FileType fileType) |
Sets File::fileType_ for all files (ene, data, fstat, restart, stat) More... | |
void | setOpenMode (std::fstream::openmode openMode) |
Sets File::openMode_ for all files (ene, data, fstat, restart, stat) More... | |
void | resetFileCounter () |
Resets the file counter for each file i.e. for ene, data, fstat, restart, stat) More... | |
void | read (std::istream &is) |
Extracts data from the input stream (which is basically a file you want to read from) into name_, restartFile .... More... | |
void | write (std::ostream &os) const |
Writes data into a file from the member variables name_, restartFile, dataFile etc. More... | |
void | openFiles () |
Opens all the files (ene, data, fstat, restart, stat) for reading and writing purposes. More... | |
void | closeFiles () |
Closes all files (ene, data, fstat, restart, stat) that were opened to read or write. More... | |
void | setNextSavedTimeStep (unsigned int nextSavedTimeStep) |
Sets the next time step for all the files (ene, data, fstat, restart, stat) at which the data is to be written or saved. More... | |
Private Attributes | |
int | runNumber_ |
This stores the run number for saving. More... | |
Additional Inherited Members | |
Public Attributes inherited from Files | |
File | dataFile |
An instance of class File to handle in- and output into a .data file. More... | |
File | fStatFile |
An instance of class File to handle in- and output into a .fstat file. More... | |
File | eneFile |
An instance of class File to handle in- and output into a .ene file. More... | |
File | restartFile |
An instance of class File to handle in- and output into a .restart file. More... | |
File | statFile |
An instance of class File to handle in- and output into a .stat file. More... | |
It is publicly inherited from class Files. It defines an awesome feature that is ideal when doing a parameter study. Below are the routines that manipulate a counter file, called COUNTER_DONOTDEL, to store run numbers.
For a paramater study, a particular DPM simulation is run several times. Each time the code is executed, the run number or counter, in the COUNTER_DONOTDEL, gets incremented. Based on the counter your file name is named as problemName.1.data, problemName.2.data... If the File::fileType_ is chosen as Multiple files, then the your data files will have the name as problemName.runNumber.0, problemName.runNumber.1 ...
Definition at line 52 of file FilesAndRunNumber.h.
FilesAndRunNumber::FilesAndRunNumber | ( | ) |
Constructor.
Definition at line 38 of file FilesAndRunNumber.cc.
References constructor().
FilesAndRunNumber::FilesAndRunNumber | ( | const FilesAndRunNumber & | other | ) |
Copy constructor.
[in] | other |
Definition at line 49 of file FilesAndRunNumber.cc.
References runNumber_.
|
virtual |
Constructor.
Definition at line 61 of file FilesAndRunNumber.cc.
void FilesAndRunNumber::autoNumber | ( | ) |
The autoNumber() function is the trigger. It calls three functions. setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile().
Definition at line 79 of file FilesAndRunNumber.cc.
References incrementRunNumberInFile(), readRunNumberFromFile(), and setRunNumber().
Referenced by DPMBase::readNextArgument().
void FilesAndRunNumber::constructor | ( | ) |
a function called by the FilesAndRunNumber() (constructor)
Initialises the runNumber_ = 0
Definition at line 71 of file FilesAndRunNumber.cc.
References runNumber_.
Referenced by FilesAndRunNumber().
std::vector< int > FilesAndRunNumber::get2DParametersFromRunNumber | ( | int | size_x, |
int | size_y | ||
) |
This turns a counter into two indices which is an amazing feature for doing two dimensional parameter studies. The indices run from 1:size_x and 1:size_y, while the study number starts at 0 ( initially the counter=1 in COUNTER_DONOTDEL)
Lets say size_x = 2 and size_y = 5, counter stored in COUNTER_DONOTDEL =1. The study_size = 10. Substituting these values into the below algorithm implies that study_num = 0 or 1, everytime the code is executed the counter gets incremented and hence determined the values of study_num, i and j which is returned as a std::vector<int>
[in] | size_x | |
[in] | size_y |
Definition at line 193 of file FilesAndRunNumber.cc.
References getRunNumber().
int FilesAndRunNumber::getRunNumber | ( | ) | const |
This returns the current value of the counter (runNumber_)
Definition at line 143 of file FilesAndRunNumber.cc.
References runNumber_.
Referenced by get2DParametersFromRunNumber(), and DPMBase::solve().
void FilesAndRunNumber::incrementRunNumberInFile | ( | ) |
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store the new value in the counter file.
In order to increment the counter stored in COUNTER_DONOTDEL, we initialise two fstream objects counter_file, counter_file2 and an integer type temp_counter. First we open the file COUNTER_DONOTDEL, check if everything went fine with the opening. If yes, we extract the runNumber (counter) into the temp_counter. Increment the temp_counter and then write it into COUNTER_DONOTDEL. This is how we increment the counter in the file.
Definition at line 154 of file FilesAndRunNumber.cc.
Referenced by autoNumber().
int FilesAndRunNumber::launchNewRun | ( | const char * | name, |
bool quick | UNUSED = false |
||
) |
This launches a code from within this code. Please pass the name of the code to run.
[in] | name | |
[in] | quick |
Definition at line 220 of file FilesAndRunNumber.cc.
void FilesAndRunNumber::read | ( | std::istream & | is | ) |
Accepts an input stream std::istream.
[in,out] | is |
Definition at line 230 of file FilesAndRunNumber.cc.
References Files::read(), and runNumber_.
Referenced by DPMBase::read().
int FilesAndRunNumber::readRunNumberFromFile | ( | ) |
Read the run number or the counter from the counter file (COUNTER_DONOTDEL)
The procedure below reads the counter in from a file stored on the disk. Increments the number stored on the disk and then returns the current counter.
Definition at line 89 of file FilesAndRunNumber.cc.
Referenced by autoNumber().
void FilesAndRunNumber::setRunNumber | ( | int | runNumber | ) |
This sets the counter/Run number, overriding the defaults.
[in] | runNumber |
Definition at line 135 of file FilesAndRunNumber.cc.
References runNumber_.
Referenced by autoNumber(), and DPMBase::readNextArgument().
void FilesAndRunNumber::write | ( | std::ostream & | os | ) | const |
Accepts an output stream read function, which accepts an input stream std::ostream.
[in,out] | os |
Definition at line 242 of file FilesAndRunNumber.cc.
References runNumber_, and Files::write().
Referenced by DPMBase::write().
|
private |
This stores the run number for saving.
Definition at line 131 of file FilesAndRunNumber.h.
Referenced by constructor(), FilesAndRunNumber(), getRunNumber(), read(), setRunNumber(), and write().