|
criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
|
A class to write and read checkpoint files. More...
#include <CheckpointManager.H>
Public Member Functions | |
| CheckpointManager (const ParmParser &pp, const propagation::Propagation &prop, const Losses &loss) | |
| Start up the checkpoint manager. | |
| void | writeCheckpoint (const int step, const Real t, const Real dt, const CRTree &tree, Prob *prob) |
| Function to write a checkpoint. | |
| void | readCheckpoint (const std::string &filename, int &step, Real &t, Real &dt, CRTree &tree, Prob *prob, bool restoreRng=true) |
| Function to read a checkpoint. | |
| int | lastStep () const |
| Step number at which the last checkpoint was written. | |
| int | nextStep () const |
| Step number at which the next checkpoint will be written. | |
| Real | lastTime () const |
| Time at which the last checkpoint was written. | |
| Real | nextTime () const |
| Time at which the next checkpoint will be written. | |
Static Public Attributes | |
| static const int | fWidth = 15 |
Private Member Functions | |
| void | syncCounts (std::vector< IdxType > &nPkt, std::vector< IdxType > &nSrc, std::vector< IdxType > &nDel, const CRTree &tree) const |
| Sync packet, souce, and deleted packet counts to IO rank. | |
| void | sendCheckpointData (const Real &t, const CRTree &tree) const |
| Send checkpoint data to be written to the rank doing IO. | |
| void | writePackets (hid_t &fileID, const std::vector< IdxType > &nPkt, const int &step, const Real &t, const Real &dt, const CRTree &tree) const |
| Write packet data to file. | |
| void | writeSources (hid_t &fileID, const std::vector< IdxType > &nSrc, const CRTree &tree) const |
| Write source data to file. | |
| void | writeDelPackets (hid_t &fileID, const std::vector< IdxType > &nDel, const CRTree &tree) const |
| Write deleted packet data to file. | |
| void | writeFieldQty (hid_t &fileID, const std::vector< IdxType > &nPkt, const CRTree &tree) const |
| Write field quantity data to file. | |
| void | writeLoss (hid_t &fileID, const std::vector< IdxType > &nPkt, const Real &t, const CRTree &tree) const |
| Write loss rate data to file. | |
| void | writePhotonsFull (hid_t &fileID, const std::vector< Real > &photEn, const std::vector< IdxType > &nPkt, const Real &t, const CRTree &tree) const |
| Write packet-by-packet photon emission data to file. | |
| void | writePhotonsSummary (hid_t &fileID, const std::vector< Real > &photEn, const Real t, const CRTree &tree) const |
| Write summary photon emission data to file. | |
| void | writeIonization (hid_t &fileID, const std::vector< IdxType > &nPkt, const Real &t, const CRTree &tree) const |
| Write ionization rate data to file. | |
| void | writePdot (hid_t &fileID, const std::vector< IdxType > &nPkt, const Real &t, const CRTree &tree) const |
| Write non-loss dp/dt terms to file. | |
| void | writeRng (hid_t &fileID, const CRTree &tree) const |
| Write the state of the random number generator to file. | |
Private Attributes | |
| std::string | baseChkName |
| bool | needFQ |
| bool | needFQG |
| bool | writeDelPackets_ |
| bool | writeFieldQty_ |
| bool | writeLoss_ |
| bool | writePhotons_ |
| bool | writePhotonsFull_ |
| bool | writeIonization_ |
| bool | writePdot_ |
| std::vector< Real > | photEn |
| int | verbosity |
| int | chkNum |
| int | chkInt |
| int | lastChkStep |
| int | nextChkStep |
| Real | chkDt |
| Real | lastChkTime |
| Real | nextChkTime |
| hid_t | RealVec_HDF5 |
| hid_t | RealTensor2_HDF5 |
| hid_t | CRPacket_HDF5 |
| hid_t | CRSource_HDF5 |
| hid_t | FieldQty_HDF5 |
| hid_t | FieldQtyGrad_HDF5 |
| hid_t | RngState_HDF5 |
A class to write and read checkpoint files.
This class provides methods to write and read checkpoint files, and carry out related tasks such as keeping track of checkpoint numbers and times
| CheckpointManager::CheckpointManager | ( | const ParmParser & | pp, |
| const propagation::Propagation & | prop, | ||
| const Losses & | loss | ||
| ) |
Start up the checkpoint manager.
| pp | The ParmParser containing the input deck |
| prop | CR propagation model |
| loss | CR loss model |
|
inline |
Step number at which the last checkpoint was written.
|
inline |
Time at which the last checkpoint was written.
|
inline |
Step number at which the next checkpoint will be written.
|
inline |
Time at which the next checkpoint will be written.
| void CheckpointManager::readCheckpoint | ( | const std::string & | filename, |
| int & | step, | ||
| Real & | t, | ||
| Real & | dt, | ||
| CRTree & | tree, | ||
| Prob * | prob, | ||
| bool | restoreRng = true |
||
| ) |
Function to read a checkpoint.
| filename | Name of checkpoint file to read |
| step | Step number stored in checkpoint |
| t | Time stored in checkpoint |
| dt | Time step stored in checkpoint |
| tree | CRTree to fill with checkpoint data |
| prob | Problem setup class; provides problem-specific IO |
| restoreRng | If true, restore RNG state from checkpoint |
When run in parallel, the data to be read are divided between MPI ranks; if the number of ranks is equal to the number used in the checkpoint, the data will be divided between ranks exactly as it was when the checkpoint was written. Otherwise, this routine will divide the data between ranks as evenly as possible given the number of ranks present in the checkpoint.
Send checkpoint data to be written to the rank doing IO.
| t | Current simulation time |
| tree | The CRTree containing the current state |
|
private |
Sync packet, souce, and deleted packet counts to IO rank.
| nPkt | Number of packets on each rank |
| nSrc | Number of sources on each rank |
| nDel | Number of deleted packets on each rank |
| tree | The CRTree containing the current state |
This is a collective method that is to be invoked by all MPI ranks. On the IO rank, it has the effect of setting nPkt, nSrc, and nDel to vectors of MPIUtil::nRank elements, with each element containing the number of packets, sources, and deleted packets stored on each MPI rank. On all other ranks the arrays nPkt, nSrc, and nDel are unchanged and can be ignored. Note that, if this routine is invoked in a run where MPI is disabled, its effect is just to set nPkt, nSrc, and nDel to vectors of length 1 containing the packet, source, and deleted packets counts on the single MPI rank running.
| void CheckpointManager::writeCheckpoint | ( | const int | step, |
| const Real | t, | ||
| const Real | dt, | ||
| const CRTree & | tree, | ||
| Prob * | prob | ||
| ) |
Function to write a checkpoint.
| step | The step number at which the checkpoint is written |
| t | The time at which the checkpoint is written |
| dt | The size of the next time step |
| tree | The CRTree containing the current state |
| prob | Problem setup class; provides problem-specific IO |
|
private |
Write deleted packet data to file.
| fileID | The HDF5 handle for the output file |
| nDel | Number of deleted packets on each rank |
| tree | The CRTree containing the current state |
|
private |
Write field quantity data to file.
| fileID | The HDF5 handle for the output file |
| nPkt | Number of packets on each rank |
| tree | The CRTree containing the current state |
|
private |
Write ionization rate data to file.
| fileID | The HDF5 handle for the output file |
| nPkt | Number of packets on each rank |
| t | Current simulation time |
| tree | The CRTree containing the current state |
|
private |
Write loss rate data to file.
| fileID | The HDF5 handle for the output file |
| nPkt | Number of packets on each rank |
| t | Current simulation time |
| tree | The CRTree containing the current state |
|
private |
Write packet data to file.
| fileID | The HDF5 handle for the output file |
| nPkt | Number of packets on each rank |
| step | Current simulation step number |
| t | Current simulation time |
| dt | Current time step |
| tree | The CRTree containing the current state |
|
private |
Write non-loss dp/dt terms to file.
| fileID | The HDF5 handle for the output file |
| nPkt | Number of packets on each rank |
| t | Current simulation time |
| tree | The CRTree containing the current state |
|
private |
Write packet-by-packet photon emission data to file.
| fileID | The HDF5 handle for the output file |
| photEn | Photon energies at which emission is calculated |
| nPkt | Number of packets on each rank |
| t | Current simulation time |
| tree | The CRTree containing the current state |
|
private |
Write summary photon emission data to file.
| fileID | The HDF5 handle for the output file |
| photEn | Photon energies at which emission is calculated |
| t | Current simulation time |
| tree | The CRTree containing the current state |
|
private |
Write the state of the random number generator to file.
fileID The HDF5 handle for the output file
tree The CRTree containing the current state
|
private |
Write source data to file.
| fileID | The HDF5 handle for the output file |
| nSrc | Number of sources on each rank |
| tree | The CRTree containing the current state |
|
private |
Base name for checkpoint files
|
private |
Time interval between checkpoints
|
private |
Step interval between checkpoints
|
private |
Checkpoint number counter
|
private |
HDF5 type corresponding to CRPacket
|
private |
HDF5 type corresponding to CRSource
|
private |
HDF5 type corresponding to FieldQty
|
private |
HDF5 type corresponding to FieldQtyGrad
|
static |
Field width in ASCII output
|
private |
Step at which last checkpoint was written
|
private |
Time at which last checkpoint was written
|
private |
Field quantities needed for this run?
|
private |
Field qty gradients needed for this run?
|
private |
Step at which next checkpoint will be written
|
private |
Time at which next checkpoint will be written
|
private |
Energies for photon emission calculation (always in GeV)
|
private |
HDF5 type corresponding to RealTensor2
|
private |
HDF5 type corresponding to RealVec
|
private |
HDF5 type corresponding to Rng state
|
private |
Level of verbosity
|
private |
Write deleted packets to checkpoints?
|
private |
Write field quantities to checkpoints?
|
private |
Write out ionization rates?
|
private |
Write packet loss rates to checkpoints?
|
private |
Write out non-loss dp/dt terms?
|
private |
Write photon emission to checkpoints?
|
private |
Write packet-by-packet photon data?