criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
CheckpointManager.H
Go to the documentation of this file.
1
10#ifndef _CHECKPOINTMANAGER_H_
11#define _CHECKPOINTMANAGER_H_
12
13#include <string>
14#include "ParmParser.H"
15#include "../Core/CRTree.H"
16#include "../Losses/Losses.H"
17#include "../Prob/Prob.H"
18#include "../Propagation/Propagation.H"
19#include "../Utils/RngThread.H"
20#include "../Utils/Types.H"
21#include "hdf5.h"
22
23namespace criptic {
24
34
35 public:
36
44 const propagation::Propagation& prop,
45 const Losses& loss);
46
55 void writeCheckpoint(const int step,
56 const Real t,
57 const Real dt,
58 const CRTree& tree,
59 Prob* prob);
60
78 void readCheckpoint(const std::string& filename,
79 int& step,
80 Real& t,
81 Real& dt,
82 CRTree& tree,
83 Prob* prob,
84 bool restoreRng = true
85 );
86
91 int lastStep() const { return lastChkStep; }
92
97 int nextStep() const { return nextChkStep; }
98
103 Real lastTime() const { return lastChkTime; }
104
109 Real nextTime() const { return nextChkTime; }
110
111 static const int fWidth = 15;
113 private:
114
133 void syncCounts(std::vector<IdxType>& nPkt,
134 std::vector<IdxType>& nSrc,
135 std::vector<IdxType>& nDel,
136 const CRTree& tree) const;
137
138#ifdef ENABLE_MPI
144 void sendCheckpointData(const Real& t,
145 const CRTree& tree) const;
146#endif
147
157 void writePackets(hid_t& fileID,
158 const std::vector<IdxType>& nPkt,
159 const int& step,
160 const Real& t,
161 const Real& dt,
162 const CRTree& tree) const;
163
170 void writeSources(hid_t& fileID,
171 const std::vector<IdxType>& nSrc,
172 const CRTree& tree) const;
173
180 void writeDelPackets(hid_t& fileID,
181 const std::vector<IdxType>& nDel,
182 const CRTree& tree) const;
183
190 void writeFieldQty(hid_t& fileID,
191 const std::vector<IdxType>& nPkt,
192 const CRTree& tree) const;
193
201 void writeLoss(hid_t& fileID,
202 const std::vector<IdxType>& nPkt,
203 const Real& t,
204 const CRTree& tree) const;
205
214 void writePhotonsFull(hid_t& fileID,
215 const std::vector<Real>& photEn,
216 const std::vector<IdxType>& nPkt,
217 const Real& t,
218 const CRTree& tree) const;
219
227 void writePhotonsSummary(hid_t& fileID,
228 const std::vector<Real>& photEn,
229 const Real t,
230 const CRTree& tree) const;
231
239 void writeIonization(hid_t& fileID,
240 const std::vector<IdxType>& nPkt,
241 const Real& t,
242 const CRTree& tree) const;
243
244#ifndef TRACK_PITCH_ANGLE
252 void writePdot(hid_t& fileID,
253 const std::vector<IdxType>& nPkt,
254 const Real& t,
255 const CRTree& tree) const;
256#endif
257
263 void writeRng(hid_t& fileID, const CRTree& tree) const;
264
265 // Internal data
266 std::string baseChkName;
267 bool needFQ;
268 bool needFQG;
275#ifndef TRACK_PITCH_ANGLE
277#endif
278 std::vector<Real> photEn;
281 int chkNum;
282 int chkInt;
299 };
300
301}
302
303// _CHECKPOINTMANAGER_H_
304#endif
Class to parse the input deck.
A class to manage CR packets and sources.
Definition CRTree.H:44
A class to write and read checkpoint files.
Definition CheckpointManager.H:33
int chkInt
Definition CheckpointManager.H:282
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.
Definition CheckpointManager.cpp:904
int verbosity
Definition CheckpointManager.H:280
bool needFQG
Definition CheckpointManager.H:268
hid_t FieldQtyGrad_HDF5
Definition CheckpointManager.H:297
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.
Definition CheckpointManager.cpp:1578
void writePhotonsSummary(hid_t &fileID, const std::vector< Real > &photEn, const Real t, const CRTree &tree) const
Write summary photon emission data to file.
Definition CheckpointManager.cpp:1674
Real chkDt
Definition CheckpointManager.H:287
hid_t FieldQty_HDF5
Definition CheckpointManager.H:296
bool writeFieldQty_
Definition CheckpointManager.H:270
hid_t RngState_HDF5
Definition CheckpointManager.H:298
bool writePhotonsFull_
Definition CheckpointManager.H:273
std::vector< Real > photEn
Definition CheckpointManager.H:278
void writeSources(hid_t &fileID, const std::vector< IdxType > &nSrc, const CRTree &tree) const
Write source data to file.
Definition CheckpointManager.cpp:1101
bool writeIonization_
Definition CheckpointManager.H:274
void readCheckpoint(const std::string &filename, int &step, Real &t, Real &dt, CRTree &tree, Prob *prob, bool restoreRng=true)
Function to read a checkpoint.
Definition CheckpointManager.cpp:398
int lastChkStep
Definition CheckpointManager.H:283
void writeDelPackets(hid_t &fileID, const std::vector< IdxType > &nDel, const CRTree &tree) const
Write deleted packet data to file.
Definition CheckpointManager.cpp:1219
bool writePhotons_
Definition CheckpointManager.H:272
Real nextTime() const
Time at which the next checkpoint will be written.
Definition CheckpointManager.H:109
void writeRng(hid_t &fileID, const CRTree &tree) const
Write the state of the random number generator to file.
Definition CheckpointManager.cpp:1931
hid_t CRPacket_HDF5
Definition CheckpointManager.H:294
bool writePdot_
Definition CheckpointManager.H:276
static const int fWidth
Definition CheckpointManager.H:111
Real lastTime() const
Time at which the last checkpoint was written.
Definition CheckpointManager.H:103
void writeIonization(hid_t &fileID, const std::vector< IdxType > &nPkt, const Real &t, const CRTree &tree) const
Write ionization rate data to file.
Definition CheckpointManager.cpp:1738
int nextChkStep
Definition CheckpointManager.H:285
Real nextChkTime
Definition CheckpointManager.H:290
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.
Definition CheckpointManager.cpp:1834
void writeCheckpoint(const int step, const Real t, const Real dt, const CRTree &tree, Prob *prob)
Function to write a checkpoint.
Definition CheckpointManager.cpp:302
int chkNum
Definition CheckpointManager.H:281
bool writeDelPackets_
Definition CheckpointManager.H:269
std::string baseChkName
Definition CheckpointManager.H:266
void writeLoss(hid_t &fileID, const std::vector< IdxType > &nPkt, const Real &t, const CRTree &tree) const
Write loss rate data to file.
Definition CheckpointManager.cpp:1472
bool needFQ
Definition CheckpointManager.H:267
hid_t CRSource_HDF5
Definition CheckpointManager.H:295
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.
Definition CheckpointManager.cpp:750
bool writeLoss_
Definition CheckpointManager.H:271
hid_t RealVec_HDF5
Definition CheckpointManager.H:292
hid_t RealTensor2_HDF5
Definition CheckpointManager.H:293
Real lastChkTime
Definition CheckpointManager.H:288
int nextStep() const
Step number at which the next checkpoint will be written.
Definition CheckpointManager.H:97
int lastStep() const
Step number at which the last checkpoint was written.
Definition CheckpointManager.H:91
void writeFieldQty(hid_t &fileID, const std::vector< IdxType > &nPkt, const CRTree &tree) const
Write field quantity data to file.
Definition CheckpointManager.cpp:1345
void sendCheckpointData(const Real &t, const CRTree &tree) const
Send checkpoint data to be written to the rank doing IO.
Definition CheckpointManager.cpp:810
Class to parse the criptic input deck.
Definition ParmParser.H:37
A class to manage user-defined problem setup and work.
Definition Prob.H:45
Interface to describe the CR propagation model.
Definition Propagation.H:79
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
double Real
Definition Types.H:38