criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
criptic::CheckpointManager Class Reference

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< RealphotEn
 
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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ CheckpointManager()

CheckpointManager::CheckpointManager ( const ParmParser pp,
const propagation::Propagation prop,
const Losses &  loss 
)

Start up the checkpoint manager.

Parameters
ppThe ParmParser containing the input deck
propCR propagation model
lossCR loss model

Member Function Documentation

◆ lastStep()

int criptic::CheckpointManager::lastStep ( ) const
inline

Step number at which the last checkpoint was written.

Returns
Step number at which the last checkpoint was written

◆ lastTime()

Real criptic::CheckpointManager::lastTime ( ) const
inline

Time at which the last checkpoint was written.

Returns
Time at which the last checkpoint was written

◆ nextStep()

int criptic::CheckpointManager::nextStep ( ) const
inline

Step number at which the next checkpoint will be written.

Returns
Step number at which the next checkpoint will be written

◆ nextTime()

Real criptic::CheckpointManager::nextTime ( ) const
inline

Time at which the next checkpoint will be written.

Returns
Time at which the next checkpoint will be written

◆ readCheckpoint()

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.

Parameters
filenameName of checkpoint file to read
stepStep number stored in checkpoint
tTime stored in checkpoint
dtTime step stored in checkpoint
treeCRTree to fill with checkpoint data
probProblem setup class; provides problem-specific IO
restoreRngIf 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.

◆ sendCheckpointData()

void CheckpointManager::sendCheckpointData ( const Real t,
const CRTree tree 
) const
private

Send checkpoint data to be written to the rank doing IO.

Parameters
tCurrent simulation time
treeThe CRTree containing the current state

◆ syncCounts()

void CheckpointManager::syncCounts ( std::vector< IdxType > &  nPkt,
std::vector< IdxType > &  nSrc,
std::vector< IdxType > &  nDel,
const CRTree tree 
) const
private

Sync packet, souce, and deleted packet counts to IO rank.

Parameters
nPktNumber of packets on each rank
nSrcNumber of sources on each rank
nDelNumber of deleted packets on each rank
treeThe 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.

◆ writeCheckpoint()

void CheckpointManager::writeCheckpoint ( const int  step,
const Real  t,
const Real  dt,
const CRTree tree,
Prob prob 
)

Function to write a checkpoint.

Parameters
stepThe step number at which the checkpoint is written
tThe time at which the checkpoint is written
dtThe size of the next time step
treeThe CRTree containing the current state
probProblem setup class; provides problem-specific IO

◆ writeDelPackets()

void CheckpointManager::writeDelPackets ( hid_t &  fileID,
const std::vector< IdxType > &  nDel,
const CRTree tree 
) const
private

Write deleted packet data to file.

Parameters
fileIDThe HDF5 handle for the output file
nDelNumber of deleted packets on each rank
treeThe CRTree containing the current state

◆ writeFieldQty()

void CheckpointManager::writeFieldQty ( hid_t &  fileID,
const std::vector< IdxType > &  nPkt,
const CRTree tree 
) const
private

Write field quantity data to file.

Parameters
fileIDThe HDF5 handle for the output file
nPktNumber of packets on each rank
treeThe CRTree containing the current state

◆ writeIonization()

void CheckpointManager::writeIonization ( hid_t &  fileID,
const std::vector< IdxType > &  nPkt,
const Real t,
const CRTree tree 
) const
private

Write ionization rate data to file.

Parameters
fileIDThe HDF5 handle for the output file
nPktNumber of packets on each rank
tCurrent simulation time
treeThe CRTree containing the current state

◆ writeLoss()

void CheckpointManager::writeLoss ( hid_t &  fileID,
const std::vector< IdxType > &  nPkt,
const Real t,
const CRTree tree 
) const
private

Write loss rate data to file.

Parameters
fileIDThe HDF5 handle for the output file
nPktNumber of packets on each rank
tCurrent simulation time
treeThe CRTree containing the current state

◆ writePackets()

void CheckpointManager::writePackets ( hid_t &  fileID,
const std::vector< IdxType > &  nPkt,
const int &  step,
const Real t,
const Real dt,
const CRTree tree 
) const
private

Write packet data to file.

Parameters
fileIDThe HDF5 handle for the output file
nPktNumber of packets on each rank
stepCurrent simulation step number
tCurrent simulation time
dtCurrent time step
treeThe CRTree containing the current state

◆ writePdot()

void CheckpointManager::writePdot ( hid_t &  fileID,
const std::vector< IdxType > &  nPkt,
const Real t,
const CRTree tree 
) const
private

Write non-loss dp/dt terms to file.

Parameters
fileIDThe HDF5 handle for the output file
nPktNumber of packets on each rank
tCurrent simulation time
treeThe CRTree containing the current state

◆ writePhotonsFull()

void CheckpointManager::writePhotonsFull ( hid_t &  fileID,
const std::vector< Real > &  photEn,
const std::vector< IdxType > &  nPkt,
const Real t,
const CRTree tree 
) const
private

Write packet-by-packet photon emission data to file.

Parameters
fileIDThe HDF5 handle for the output file
photEnPhoton energies at which emission is calculated
nPktNumber of packets on each rank
tCurrent simulation time
treeThe CRTree containing the current state

◆ writePhotonsSummary()

void CheckpointManager::writePhotonsSummary ( hid_t &  fileID,
const std::vector< Real > &  photEn,
const Real  t,
const CRTree tree 
) const
private

Write summary photon emission data to file.

Parameters
fileIDThe HDF5 handle for the output file
photEnPhoton energies at which emission is calculated
tCurrent simulation time
treeThe CRTree containing the current state

◆ writeRng()

void CheckpointManager::writeRng ( hid_t &  fileID,
const CRTree tree 
) const
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

◆ writeSources()

void CheckpointManager::writeSources ( hid_t &  fileID,
const std::vector< IdxType > &  nSrc,
const CRTree tree 
) const
private

Write source data to file.

Parameters
fileIDThe HDF5 handle for the output file
nSrcNumber of sources on each rank
treeThe CRTree containing the current state

Member Data Documentation

◆ baseChkName

std::string criptic::CheckpointManager::baseChkName
private

Base name for checkpoint files

◆ chkDt

Real criptic::CheckpointManager::chkDt
private

Time interval between checkpoints

◆ chkInt

int criptic::CheckpointManager::chkInt
private

Step interval between checkpoints

◆ chkNum

int criptic::CheckpointManager::chkNum
private

Checkpoint number counter

◆ CRPacket_HDF5

hid_t criptic::CheckpointManager::CRPacket_HDF5
private

HDF5 type corresponding to CRPacket

◆ CRSource_HDF5

hid_t criptic::CheckpointManager::CRSource_HDF5
private

HDF5 type corresponding to CRSource

◆ FieldQty_HDF5

hid_t criptic::CheckpointManager::FieldQty_HDF5
private

HDF5 type corresponding to FieldQty

◆ FieldQtyGrad_HDF5

hid_t criptic::CheckpointManager::FieldQtyGrad_HDF5
private

HDF5 type corresponding to FieldQtyGrad

◆ fWidth

const int criptic::CheckpointManager::fWidth = 15
static

Field width in ASCII output

◆ lastChkStep

int criptic::CheckpointManager::lastChkStep
private

Step at which last checkpoint was written

◆ lastChkTime

Real criptic::CheckpointManager::lastChkTime
private

Time at which last checkpoint was written

◆ needFQ

bool criptic::CheckpointManager::needFQ
private

Field quantities needed for this run?

◆ needFQG

bool criptic::CheckpointManager::needFQG
private

Field qty gradients needed for this run?

◆ nextChkStep

int criptic::CheckpointManager::nextChkStep
private

Step at which next checkpoint will be written

◆ nextChkTime

Real criptic::CheckpointManager::nextChkTime
private

Time at which next checkpoint will be written

◆ photEn

std::vector<Real> criptic::CheckpointManager::photEn
private

Energies for photon emission calculation (always in GeV)

◆ RealTensor2_HDF5

hid_t criptic::CheckpointManager::RealTensor2_HDF5
private

HDF5 type corresponding to RealTensor2

◆ RealVec_HDF5

hid_t criptic::CheckpointManager::RealVec_HDF5
private

HDF5 type corresponding to RealVec

◆ RngState_HDF5

hid_t criptic::CheckpointManager::RngState_HDF5
private

HDF5 type corresponding to Rng state

◆ verbosity

int criptic::CheckpointManager::verbosity
private

Level of verbosity

◆ writeDelPackets_

bool criptic::CheckpointManager::writeDelPackets_
private

Write deleted packets to checkpoints?

◆ writeFieldQty_

bool criptic::CheckpointManager::writeFieldQty_
private

Write field quantities to checkpoints?

◆ writeIonization_

bool criptic::CheckpointManager::writeIonization_
private

Write out ionization rates?

◆ writeLoss_

bool criptic::CheckpointManager::writeLoss_
private

Write packet loss rates to checkpoints?

◆ writePdot_

bool criptic::CheckpointManager::writePdot_
private

Write out non-loss dp/dt terms?

◆ writePhotons_

bool criptic::CheckpointManager::writePhotons_
private

Write photon emission to checkpoints?

◆ writePhotonsFull_

bool criptic::CheckpointManager::writePhotonsFull_
private

Write packet-by-packet photon data?


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