criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
CRTree.H
Go to the documentation of this file.
1
10#ifndef _CRTREE_H_
11#define _CRTREE_H_
12
13#include <cassert>
14#include <vector>
15#include "CRPacket.H"
16#include "CRSource.H"
17#include "CRTreeNode.H"
18#include "FieldQty.H"
19#include "Geometry.H"
20#include "../Gas/Gas.H"
21#include "../Losses/Ionization.H"
22#include "../Losses/Losses.H"
23#include "../MPI/CRTreeCommunicator.H"
24#include "../MPI/MPIUtil.H"
25#include "../Propagation/Propagation.H"
26#include "../Utils/RealBox.H"
27#include "../Utils/RealTensor2.H"
28#include "../Utils/RngThread.H"
29#include "../Utils/Types.H"
30#include "../Utils/Vec3.H"
31
32namespace criptic {
33
44 class CRTree {
45
46 public:
47
49 // Constructor
51
61 CRTree(const ParmParser& pp,
62 const Geometry& geom_,
63 const gas::Gas& gasBG_,
64 const propagation::Propagation& prop_,
65 const Losses& loss_,
66 RngThread& rng_);
67
69 // Methods to add or remove packets and sources to the tree
71
79 void addPacketsAndSources(const std::vector<RealVec>& x_,
80 const std::vector<CRPacket>& pd_,
81 const std::vector<RealVec>& xSrc_,
82 const std::vector<CRSource>& src_);
83
84
90 void addPackets(const std::vector<RealVec>& x_,
91 const std::vector<CRPacket>& pd_);
92
98 void addSources(const std::vector<RealVec>& xSrc_,
99 const std::vector<CRSource>& src_);
100
116 void deletePacketsAndSources(std::vector<IdxType>& pIdx,
117 std::vector<IdxType>& sIdx,
118 const Real t);
119
128 void deletePackets(std::vector<IdxType>& pIdx, const Real t) {
129 std::vector<IdxType> sIdx;
130 deletePacketsAndSources(pIdx, sIdx, t);
131 }
132
140 void deleteSources(std::vector<IdxType>& sIdx) {
141 std::vector<IdxType> pIdx;
142 Real t = 0;
143 deletePacketsAndSources(pIdx, sIdx, t);
144 }
145
147 // Methods to retrieve data from the tree
149
150 // Counts of objects
155 IdxType nPacket() const { return totPacket; }
160 IdxType nPacketLoc() const { return x.size() + xBuf.size(); }
170 IdxType nSource() const { return totSrc; }
175 IdxType nSourceLoc() const { return src.size(); }
180 IdxType getUniqueID() const { return uniqueID; }
184 void setUniqueID(const IdxType uniqueID_) { uniqueID = uniqueID_; }
185
186 // Packets
191 std::vector<RealVec>& getPacketPos() { return x; }
200 const std::vector<RealVec>& getPacketPos() const { return x; }
211 assert(i < nPacketLoc());
212 if (i < x.size()) return x[i];
213 else return xBuf[i-x.size()];
214 }
224 const RealVec& getPacketPos(const IdxType i) const {
225 assert(i < nPacketLoc());
226 if (i < x.size()) return x[i];
227 else return xBuf[i-x.size()];
228 }
233 std::vector<CRPacket>& getPacketData() { return pd; }
238 const std::vector<CRPacket>& getPacketData() const { return pd; }
250 assert(i < pd.size() + pdBuf.size());
251 if (i < pd.size()) return pd[i];
252 else return pdBuf[i - pd.size()];
253 }
264 const CRPacket& getPacketData(const IdxType i) const {
265 assert(i < pd.size() + pdBuf.size());
266 if (i < pd.size()) return pd[i];
267 else return pdBuf[i - pd.size()];
268 }
269
270 // Deleted packets
275 std::vector<RealVec>& getDeletedPacketPos() { return xDel; }
284 const std::vector<RealVec>& getDeletedPacketPos() const { return xDel; }
290 assert(i < xDel.size());
291 return xDel[i];
292 }
297 const RealVec& getDeletedPacketPos(const IdxType i) const {
298 assert(i < xDel.size());
299 return xDel[i];
300 }
305 std::vector<CRPacket>& getDeletedPacketData() { return pdDel; }
310 const std::vector<CRPacket>& getDeletedPacketData() const { return pdDel; }
317 assert(i < pdDel.size());
318 return pdDel[i];
319 }
325 const CRPacket& getDeletedPacketData(const IdxType i) const {
326 assert(i < pdDel.size());
327 return pdDel[i];
328 }
333 std::vector<Real>& getDeletedPacketTime() { return tDel; }
338 const std::vector<Real>& getDeletedPacketTime() const { return tDel; }
345 return tDel[i];
346 }
352 const Real& getDeletedPacketTime(const IdxType i) const {
353 return tDel[i];
354 }
355
356 // Sources
361 std::vector<RealVec>& getSourcePos() { return xSrc; }
366 const std::vector<RealVec>& getSourcePos() const { return xSrc; }
373 assert(i < xSrc.size());
374 return xSrc[i];
375 }
381 const RealVec& getSourcePos(const IdxType i) const {
382 assert(i < xSrc.size());
383 return xSrc[i];
384 }
389 std::vector<CRSource>& getSourceData() { return src; }
394 const std::vector<CRSource>& getSourceData() const { return src; }
401 assert(i < src.size());
402 return src[i];
403 }
409 const CRSource& getSourceData(const IdxType i) const {
410 assert(i < src.size());
411 return src[i];
412 }
413
418 const std::vector<CRSource>& getSourceBufData() const { return srcBuf; }
419
420
421 // Scale lengths
432 assert(i < nPacketLoc());
433 if (!needFQ) return h[0];
434 else if (i < h.size()) return h[i];
435 else return hBuf[i-h.size()];
436 }
437
438 // Field quantities
443 std::vector<FieldQty>& getPacketQty() { return qty; }
448 const std::vector<FieldQty>& getPacketQty() const { return qty; }
460 assert(i < nPacketLoc());
461 if (!needFQ) return qty[0];
462 else if (i < qty.size()) return qty[i];
463 else return qtyBuf[i-qty.size()];
464 }
475 const FieldQty& getPacketQty(const IdxType i) const {
476 assert(i < nPacketLoc());
477 if (!needFQ) return qty[0];
478 else if (i < qty.size()) return qty[i];
479 else return qtyBuf[i-qty.size()];
480 }
481
482 // Field quantity gradients
487 std::vector<FieldQtyGrad>& getPacketQtyGrad() { return qtyGrad; }
492 const std::vector<FieldQtyGrad>& getPacketQtyGrad() const {
493 return qtyGrad;
494 }
506 assert(i < nPacketLoc());
507 if (!needFQG) return qtyGrad[0];
508 else if (i < qtyGrad.size()) return qtyGrad[i];
509 else return qtyGradBuf[i-qtyGrad.size()];
510 }
521 const FieldQtyGrad& getPacketQtyGrad(const IdxType i) const {
522 assert(i < nPacketLoc());
523 if (!needFQG) return qtyGrad[0];
524 else if (i < qtyGrad.size()) return qtyGrad[i];
525 else return qtyGradBuf[i-qtyGrad.size()];
526 }
527
528 // Loss information
529
538 const Losses& getLoss() const { return loss; }
539
546 void getLossRates(const Real t,
547 std::vector<Real>& dpdt,
548 std::vector<Real>& lossRate) const {
549 dpdt.resize(pd.size());
550 lossRate.resize(pd.size());
551#ifdef _OPENMP
552#pragma omp parallel for
553#endif
554 for (IdxType i = 0; i < pd.size(); i++) {
555 Real wSec;
556 Losses::MechMatrix<Real> pSec;
557 gas::GasData gd = gasBG.gasData(x[i], t);
558 loss.computeLoss(gd, pd[i], dpdt[i], lossRate[i], wSec, pSec);
559 }
560 }
561
569 void getLossRates(const IdxType i,
570 const Real t,
571 Real& dpdt,
572 Real& lossRate) const {
573 const RealVec& x_ = getPacketPos(i);
574 const CRPacket& pd_ = getPacketData(i);
575 gas::GasData gd = gasBG.gasData(x_, t);
576 Losses::MechMatrix<Real> pSec;
577 Real wSec;
578 loss.computeLoss(gd, pd_, dpdt, lossRate, wSec, pSec);
579 }
580
587 void getLossRatesMech(const Real t,
588 std::vector<Losses::MechArr<Real> >& dpdt,
589 std::vector<Losses::MechArr<Real> >& lossRate)
590 const {
591 dpdt.resize(pd.size());
592 lossRate.resize(pd.size());
593#ifdef _OPENMP
594#pragma omp parallel for
595#endif
596 for (IdxType i = 0; i < pd.size(); i++) {
597 gas::GasData gd = gasBG.gasData(x[i], t);
598 dpdt[i] = loss.dpdtMech(gd, pd[i]);
599 lossRate[i] = loss.lossRateMech(gd, pd[i]);
600 }
601 }
602
614 const Real t,
615 Losses::MechArr<Real>& dpdt,
616 Losses::MechArr<Real>& lossRate) const {
617 const RealVec& x_ = getPacketPos(i);
618 const CRPacket& pd_ = getPacketData(i);
619 gas::GasData gd = gasBG.gasData(x_, t);
620 dpdt = loss.dpdtMech(gd, pd_);
621 lossRate = loss.lossRateMech(gd, pd_);
622 }
623
624 // Radiation from packets
625
640 std::vector<Real> photLum(const Real t,
641 const std::vector<Real>& en) const {
642 IdxType packetSize = lossMech::nMech * en.size();
643 std::vector<Real> out(pd.size() * packetSize);
644#ifdef _OPENMP
645#pragma omp parallel for
646#endif
647 for (IdxType i = 0; i < pd.size(); i++) {
648 gas::GasData gd = gasBG.gasData(x[i], t);
649 std::vector<Real> dLdE = loss.photLum(gd, pd[i], en);
650 memcpy(out.data() + i*packetSize,
651 dLdE.data(),
652 packetSize * sizeof(Real));
653 }
654 return out;
655 }
656
684 std::vector<Real> photLumSummary(const Real t,
685 const std::vector<Real>& en,
686 const int rank = 0) const;
687
688 // Ionization from packets
689
703 std::vector<Real> ionRate(const Real t) const {
704 std::vector<Real> out(pd.size() * ionData::nTarget);
705#ifdef _OPENMP
706#pragma omp parallel for
707#endif
708 for (IdxType i = 0; i < pd.size(); i++) {
709 gas::GasData gd = gasBG.gasData(x[i], t);
710 out[i * ionData::nTarget] =
711 gd.xH0 * gd.nH() * loss.ionRate(pd[i], ionData::targetH);
712 out[i * ionData::nTarget + 1] =
713 gd.xH2() * gd.nH() * loss.ionRate(pd[i], ionData::targetH2);
714 out[i * ionData::nTarget + 2] =
715 gd.xHe0 * gd.nH() * loss.ionRate(pd[i], ionData::targetHe);
716 }
717 return out;
718 }
719
720#ifndef TRACK_PITCH_ANGLE
736 std::vector<Real> computePdot(const Real t) const;
737#endif
738
739 // Pass-through routines allowing getting and setting of the
740 // RNG state
741
748 std::string getRngState() const {
749 return rng.getState();
750 }
751
758 void setRngState(std::string &buf) const {
759 rng.setState(buf);
760 }
761
763 // Method to flush deleted packets from memory
765
773 xDel.resize(0);
774 pdDel.resize(0);
775 }
776
778 // Public constants
780
781 static constexpr int
783 static constexpr int
787 // Methods that form part of the update cycle
789
797 void rebuild();
798
814 if (x.size() == 0) return; // If no packets, return immediately
815 std::vector<IdxType> start(leafList.size());
816 std::vector<IdxType> count(leafList.size());
817 for (IdxType i = 0; i < leafList.size(); i++) {
818 start[i] = nodes[leafList[i]].start;
819 count[i] = nodes[leafList[i]].count;
820 }
821 fillFieldQty(start, count, leafList);
822 }
823
829 void injectPackets(const Real tStart,
830 const Real tStop);
831
838 Real advancePackets(const Real tStart,
839 const Real tStop);
840
841 private:
842
844 // Steps carried out by rebuild
846
854 void setupDomain();
855
864 void buildGlobalTree();
865
872 void buildLocalTree();
873
883 void computeSplit(GlobalNode& nd);
884
900 template <class U>
902 const IdxType start,
903 const IdxType count,
904 std::vector<RealVec>& x_,
905 std::vector<U>& dat);
906
914 void partitionNode(LocalNode& nd);
915
926 void sumTree();
927
928#ifdef ENABLE_MPI
936 void exchange();
937#endif
938
940 // Methods used by fillFieldQty
942
960 void fillFieldQty(std::vector<IdxType>& start,
961 std::vector<IdxType>& count,
962 std::vector<IdxType>& leafList_);
963
991 void fillFieldQtyRange(const IdxType start,
992 const IdxType count,
993 const RealVec x_[],
994 const Real R[],
995 const RealTensor2& h2Inv,
996 const RealTensor2& h2InvGrad,
997 const Real& hScale,
998 FieldQty q[],
999 FieldQtyGrad qGrad[]
1000#ifdef ENABLE_MPI
1001 , const int nrank = 0,
1002 const FieldQty* qOwner = nullptr
1003#endif
1004 );
1005
1031 void addNodeToField(const IdxType& nodeIdx,
1032 const IdxType& start,
1033 const IdxType& count,
1034 const RealVec x_[],
1035 const Real R[],
1036 const RealTensor2& h2Inv,
1037 const RealTensor2& h2InvGrad,
1038 FieldQty q[],
1039 FieldQty qErr[],
1040 FieldQtyGrad qGrad[],
1041 FieldQtyGrad qGradErr[]);
1042
1065 void nodeWgtLimits(const RealVec& x_,
1066 const RealBox& bnd,
1067 const RealTensor2& h2Inv,
1068 const RealTensor2& h2InvGrad,
1069 Real& wMin,
1070 Real& wMax,
1071 RealVec& wGradMin,
1072 RealVec& wGradMax) const;
1073
1075 // Internal data
1077
1078 // References to other objects
1083 const Losses& loss;
1086 // Helper classes
1087#ifdef ENABLE_MPI
1090#endif
1091
1092 // Internal counters
1095 // Problem run parameters read or computed from input deck
1118 std::vector<Real> samplingRatio;
1119 bool needFQ;
1120 bool needFQG;
1123 // CR packet data
1125 std::vector<RealVec> x;
1126 std::vector<CRPacket> pd;
1127 std::vector<FieldQty> qty;
1128 std::vector<Real> h;
1129 std::vector<FieldQtyGrad> qtyGrad;
1130 std::vector<RealVec> xBuf;
1131 std::vector<CRPacket> pdBuf;
1132 std::vector<FieldQty> qtyBuf;
1134 std::vector<FieldQtyGrad> qtyGradBuf;
1136 std::vector<Real> hBuf;
1138 // Data on deleted CR packets
1140 std::vector<RealVec> xDel;
1141 std::vector<CRPacket> pdDel;
1142 std::vector<Real> tDel;
1145 // CR source data
1148 std::vector<Real> totSrcWgtSpec;
1149 std::vector<RealVec> xSrc;
1150 std::vector<CRSource> src;
1151 std::vector<RealVec> xSrcBuf;
1152 std::vector<CRSource> srcBuf;
1153 std::vector<IdxType> srcLeaf;
1157 // Data describing the domain
1168 // Data describing the tree
1179 std::vector<IdxType> locTreeOffsets;
1184 std::vector<IdxType> locTreeMaxLev;
1188 std::vector<IdxType> locTreeLeafStart;
1192 std::vector<IdxType> locTreeNLeaf;
1194 std::vector<IdxType> leafList;
1196 std::vector<GlobalNode> globNodes;
1197 std::vector<LocalNode> nodes;
1198 std::vector<RealTensor2> h2InvLeaf;
1202 std::vector<RealTensor2> h2InvGradLeaf;
1206 std::vector<Real> hScaleLeaf;
1207 };
1208
1209}
1210
1211#endif
1212// _CRTREE_H_
Class to hold data on a CR packet.
Class to define a source of CRs.
Data structures to describe nodes in the CR tree.
#define TREE_LEAF_SIZE
Maximum number of packets per leaf in the CR tree.
Definition Definitions.H:76
#define TREE_RIGIDITY_BINS
Number of rigidity bins to use in the CR tree.
Definition Definitions.H:85
Define classes for field quantities and their gradients.
A class to describe the geometry of a calculation.
A class that holds data to describe a CR packet.
Definition CRPacket.H:28
A class to describe a source of CR packets.
Definition CRSource.H:33
Class to manage communications during tree walks.
Definition CRTreeCommunicator.H:48
A class to manage CR packets and sources.
Definition CRTree.H:44
bool needFQ
Definition CRTree.H:1119
static constexpr int nRigidBin
Definition CRTree.H:784
std::vector< RealVec > & getDeletedPacketPos()
Retrieve deleted packet position data.
Definition CRTree.H:275
void nodeWgtLimits(const RealVec &x_, const RealBox &bnd, const RealTensor2 &h2Inv, const RealTensor2 &h2InvGrad, Real &wMin, Real &wMax, RealVec &wGradMin, RealVec &wGradMax) const
Compute min and max weight functions over a node.
Definition CRTree.cpp:2661
std::vector< IdxType > srcLeaf
Definition CRTree.H:1153
Real kdeTol
Definition CRTree.H:1103
const Real & getDeletedPacketTime(const IdxType i) const
Retrieve deletion time of a single deleted packet as const.
Definition CRTree.H:352
const std::vector< Real > & getDeletedPacketTime() const
Retrieve deleted packet deletion times as const.
Definition CRTree.H:338
RealVec domLo
Definition CRTree.H:1158
std::vector< IdxType > leafList
Definition CRTree.H:1194
std::vector< CRPacket > & getDeletedPacketData()
Retrieve deleted packet data.
Definition CRTree.H:305
const Geometry & geom
Definition CRTree.H:1079
std::vector< RealTensor2 > h2InvLeaf
Definition CRTree.H:1198
Real advancePackets(const Real tStart, const Real tStop)
Advance all packets through one time step.
Definition CRTree.cpp:2929
IdxType globTreeLeafPtr
Definition CRTree.H:1172
void buildLocalTree()
Build the local KD tree.
Definition CRTree.cpp:1331
std::vector< CRSource > srcBuf
Definition CRTree.H:1152
std::vector< FieldQtyGrad > qtyGradBuf
Definition CRTree.H:1134
std::vector< RealVec > xSrc
Definition CRTree.H:1149
std::vector< RealVec > x
Definition CRTree.H:1125
const CRPacket & getPacketData(const IdxType i) const
Retrieve data on a packet as const.
Definition CRTree.H:264
Real packetDtMin
Definition CRTree.H:1117
std::vector< RealTensor2 > h2InvGradLeaf
Definition CRTree.H:1202
const CRSource & getSourceData(const IdxType i) const
Retrieve data on a source as const.
Definition CRTree.H:409
Real TMin
Definition CRTree.H:1116
int globTreeExtLev
Definition CRTree.H:1097
void buildGlobalTree()
Build the global KD tree.
Definition CRTree.cpp:458
IdxType uniqueID
Definition CRTree.H:1093
std::vector< FieldQtyGrad > qtyGrad
Definition CRTree.H:1129
std::vector< RealVec > xDel
Definition CRTree.H:1140
std::vector< CRSource > src
Definition CRTree.H:1150
std::vector< Real > ionRate(const Real t) const
Compute ionization rate from all packets.
Definition CRTree.H:703
Real qSamp
Definition CRTree.H:1105
IdxType nSourceLoc() const
Number of sources on this MPI rank.
Definition CRTree.H:175
void fillFieldQty()
Compute the field quantities for packets in the tree.
Definition CRTree.H:813
const std::vector< CRPacket > & getDeletedPacketData() const
Retrieve deleted packet data as const.
Definition CRTree.H:310
void setupDomain()
Find the global bounding box and total number of packets.
Definition CRTree.cpp:360
IdxType getUniqueID() const
Current value of the uniqueID counter.
Definition CRTree.H:180
Real cMinWgt
Definition CRTree.H:1108
RngThread & rng
Definition CRTree.H:1084
IdxType globTreeMaxLev
Definition CRTree.H:1169
std::vector< CRPacket > pdBuf
Definition CRTree.H:1131
IdxType nDeletedPacket() const
Number of deleted packets across all MPI ranks.
Definition CRTree.H:165
IdxType totSrc
Definition CRTree.H:1146
void getLossRatesMech(const IdxType i, const Real t, Losses::MechArr< Real > &dpdt, Losses::MechArr< Real > &lossRate) const
Compute mechanism-by-mechanism loss rates for specified packet.
Definition CRTree.H:613
std::vector< IdxType > locTreeNLeaf
Definition CRTree.H:1192
bool needFQG
Definition CRTree.H:1120
std::vector< CRPacket > pd
Definition CRTree.H:1126
std::vector< Real > hBuf
Definition CRTree.H:1136
std::vector< Real > & getDeletedPacketTime()
Retrieve deleted packet deletion times.
Definition CRTree.H:333
std::vector< FieldQty > qtyBuf
Definition CRTree.H:1132
IdxType globTreeMyLeafPtr
Definition CRTree.H:1175
const RealVec & getSourcePos(const IdxType i) const
Retrieve position of a source as const.
Definition CRTree.H:381
const std::vector< FieldQtyGrad > & getPacketQtyGrad() const
Retrieve field quantity gradients for all packets as const.
Definition CRTree.H:492
std::vector< Real > hScaleLeaf
Definition CRTree.H:1206
Real wFracMin
Definition CRTree.H:1113
std::vector< FieldQtyGrad > & getPacketQtyGrad()
Retrieve field quantity gradients for all packets.
Definition CRTree.H:487
int equalSampling
Definition CRTree.H:1102
std::vector< Real > photLum(const Real t, const std::vector< Real > &en) const
Compute photon emission from all packets by all mechanisms.
Definition CRTree.H:640
void addPackets(const std::vector< RealVec > &x_, const std::vector< CRPacket > &pd_)
Add CR packets to the tree.
Definition CRTree.cpp:211
IdxType nPacket() const
Number of packets across all MPI ranks.
Definition CRTree.H:155
const std::vector< FieldQty > & getPacketQty() const
Retrieve field quantities for all packets as const.
Definition CRTree.H:448
void deleteSources(std::vector< IdxType > &sIdx)
Delete CR packets.
Definition CRTree.H:140
std::vector< CRSource > & getSourceData()
Retrieve source data.
Definition CRTree.H:389
int partitionSamples
Definition CRTree.H:1099
IdxType nSource() const
Number of sources across all MPI ranks.
Definition CRTree.H:170
const std::vector< CRSource > & getSourceBufData() const
Retrieve source buffer data as const.
Definition CRTree.H:418
CRPacket & getDeletedPacketData(const IdxType i)
Retrieve data on a deleted packet.
Definition CRTree.H:316
int verbosity
Definition CRTree.H:1096
Real totSrcWgt
Definition CRTree.H:1147
IdxType globTreeNLeaf
Definition CRTree.H:1170
RealVec & getSourcePos(const IdxType i)
Retrieve position of a source.
Definition CRTree.H:372
void getLossRatesMech(const Real t, std::vector< Losses::MechArr< Real > > &dpdt, std::vector< Losses::MechArr< Real > > &lossRate) const
Compute mechanism-by-mechanism loss rates for all packets.
Definition CRTree.H:587
std::vector< Real > totSrcWgtSpec
Definition CRTree.H:1148
std::vector< RealVec > xSrcBuf
Definition CRTree.H:1151
Real hDither
Definition CRTree.H:1104
std::vector< Real > h
Definition CRTree.H:1128
Real cStep
Definition CRTree.H:1110
FieldQty & getPacketQty(const IdxType i)
Retrieve field quantities for a specific packet.
Definition CRTree.H:459
std::vector< RealVec > xBuf
Definition CRTree.H:1130
CRSource & getSourceData(const IdxType i)
Retrieve data on a source.
Definition CRTree.H:400
std::vector< GlobalNode > globNodes
Definition CRTree.H:1196
const FieldQty & getPacketQty(const IdxType i) const
Retrieve field quantities for a specific packet as const.
Definition CRTree.H:475
const propagation::Propagation & prop
Definition CRTree.H:1081
FieldQtyGrad & getPacketQtyGrad(const IdxType i)
Retrieve field quantity gradients for a specific packet.
Definition CRTree.H:505
const FieldQtyGrad & getPacketQtyGrad(const IdxType i) const
Retrieve field quantity gradients for a specific packet as const.
Definition CRTree.H:521
std::vector< Real > computePdot(const Real t) const
Compute non-loss dp/dt terms for all packets.
Definition CRTree.cpp:3283
const std::vector< CRSource > & getSourceData() const
Retrieve source data as const.
Definition CRTree.H:394
void partitionNode(LocalNode &nd)
Partition a local node at the median point.
Definition CRTree.cpp:1509
const CRPacket & getDeletedPacketData(const IdxType i) const
Retrieve data on a deleted packet as const.
Definition CRTree.H:325
std::vector< Real > tDel
Definition CRTree.H:1142
Real errTol
Definition CRTree.H:1111
const RealVec & getDeletedPacketPos(const IdxType i) const
Retrieve position of a deleted packet as const.
Definition CRTree.H:297
void computeSplit(GlobalNode &nd)
Figure out how to split a global tree node.
Definition CRTree.cpp:572
void clearDeletedPackets()
Remove deleted packets.
Definition CRTree.H:772
RealVec & getDeletedPacketPos(const IdxType i)
Retrieve position of a deleted packet.
Definition CRTree.H:289
Real dlogR
Definition CRTree.H:1166
IdxType nPacketLoc() const
Number of packets on this MPI rank.
Definition CRTree.H:160
IdxType partitionGlobalNode(const GlobalNode &nd, const IdxType start, const IdxType count, std::vector< RealVec > &x_, std::vector< U > &dat)
Partition a node global node using a pre-computed split.
Definition CRTree.cpp:740
const std::vector< CRPacket > & getPacketData() const
Retrieve packet data as const.
Definition CRTree.H:238
const Losses & loss
Definition CRTree.H:1083
void rebuild()
Rebuild the tree.
Definition CRTree.cpp:301
void injectPackets(const Real tStart, const Real tStop)
Inject new CR packets from sources.
Definition CRTree.cpp:2761
const std::vector< RealVec > & getPacketPos() const
Retrieve position of a packet.
Definition CRTree.H:200
std::vector< RealVec > & getSourcePos()
Retrieve source position data.
Definition CRTree.H:361
std::vector< Real > photLumSummary(const Real t, const std::vector< Real > &en, const int rank=0) const
Compute total photon emission, summing by type and mechanism.
Definition CRTree.cpp:3212
void addNodeToField(const IdxType &nodeIdx, const IdxType &start, const IdxType &count, const RealVec x_[], const Real R[], const RealTensor2 &h2Inv, const RealTensor2 &h2InvGrad, FieldQty q[], FieldQty qErr[], FieldQtyGrad qGrad[], FieldQtyGrad qGradErr[])
Add contribution of node to field quantities of packets.
Definition CRTree.cpp:2535
std::vector< LocalNode > nodes
Definition CRTree.H:1197
int nNgbEff
Definition CRTree.H:1101
std::vector< IdxType > locTreeLeafStart
Definition CRTree.H:1188
Real pMin
Definition CRTree.H:1115
std::vector< IdxType > locTreeMaxLev
Definition CRTree.H:1184
std::vector< RealVec > & getPacketPos()
Retrieve packet position data.
Definition CRTree.H:191
Real & getPacketScale(const IdxType i)
Retrieve scale length for specified packet.
Definition CRTree.H:431
CRTreeCommunicator comm
Definition CRTree.H:1088
const std::vector< RealVec > & getSourcePos() const
Retrieve source position data as const.
Definition CRTree.H:366
const gas::Gas & gasBG
Definition CRTree.H:1080
Real logR0
Definition CRTree.H:1162
void exchange()
Exchange packets and sources across MPI ranks.
Definition CRTree.cpp:785
Real logR1
Definition CRTree.H:1164
void setUniqueID(const IdxType uniqueID_)
Set value of the uniqueID counter.
Definition CRTree.H:184
void setRngState(std::string &buf) const
Set RNG state from serialized buffer.
Definition CRTree.H:758
std::string getRngState() const
Get serialized RNG state.
Definition CRTree.H:748
void addSources(const std::vector< RealVec > &xSrc_, const std::vector< CRSource > &src_)
Add CR sources to the tree.
Definition CRTree.cpp:219
const Losses & getLoss() const
Return reference to the loss calculator.
Definition CRTree.H:538
IdxType totDeletedPacket
Definition CRTree.H:1139
Real & getDeletedPacketTime(const IdxType i)
Retrieve deletion time of a single deleted packet.
Definition CRTree.H:344
void deletePacketsAndSources(std::vector< IdxType > &pIdx, std::vector< IdxType > &sIdx, const Real t)
Delete CR packets and sources from the tree.
Definition CRTree.cpp:230
RealVec domHi
Definition CRTree.H:1160
void sumTree()
Sum weights and bounding boxes in local tree.
Definition CRTree.cpp:1559
std::vector< FieldQty > & getPacketQty()
Retrieve field quantities for all packets.
Definition CRTree.H:443
IdxType globTreeNOwned
Definition CRTree.H:1177
std::vector< CRPacket > & getPacketData()
Retrieve packet data.
Definition CRTree.H:233
std::vector< IdxType > locTreeOffsets
Definition CRTree.H:1179
void getLossRates(const Real t, std::vector< Real > &dpdt, std::vector< Real > &lossRate) const
Total continuous and catastropic loss rates for all packets.
Definition CRTree.H:546
void getLossRates(const IdxType i, const Real t, Real &dpdt, Real &lossRate) const
Total continuous and catastropic loss rates for specified packet.
Definition CRTree.H:569
void fillFieldQtyRange(const IdxType start, const IdxType count, const RealVec x_[], const Real R[], const RealTensor2 &h2Inv, const RealTensor2 &h2InvGrad, const Real &hScale, FieldQty q[], FieldQtyGrad qGrad[], const int nrank=0, const FieldQty *qOwner=nullptr)
Fill the field quantities for a set of packets.
Definition CRTree.cpp:2076
IdxType totPacket
Definition CRTree.H:1124
Real packetRate
Definition CRTree.H:1106
std::vector< FieldQty > qty
Definition CRTree.H:1127
RealVec & getPacketPos(const IdxType i)
Retrieve position of a packet.
Definition CRTree.H:210
void addPacketsAndSources(const std::vector< RealVec > &x_, const std::vector< CRPacket > &pd_, const std::vector< RealVec > &xSrc_, const std::vector< CRSource > &src_)
Add CR packets and sources to the tree.
Definition CRTree.cpp:157
const RealVec & getPacketPos(const IdxType i) const
Retrieve position of a packet as const.
Definition CRTree.H:224
const std::vector< RealVec > & getDeletedPacketPos() const
Retrieve position of a deleted packet.
Definition CRTree.H:284
void deletePackets(std::vector< IdxType > &pIdx, const Real t)
Delete CR packets.
Definition CRTree.H:128
std::vector< Real > samplingRatio
Definition CRTree.H:1118
CRPacket & getPacketData(const IdxType i)
Retrieve data on a packet.
Definition CRTree.H:249
static constexpr int leafSize
Definition CRTree.H:782
std::vector< CRPacket > pdDel
Definition CRTree.H:1141
Class to hold and compute gradients of field quantities.
Definition FieldQty.H:293
Class to hold and compute field quantities.
Definition FieldQty.H:53
A class that describes the geometry of a calculation.
Definition Geometry.H:32
Class to parse the criptic input deck.
Definition ParmParser.H:37
Class that represents a 3D rectangular prism.
Definition RealBox.H:30
Class that represents a rank 2 tensor.
Definition RealTensor2.H:34
Thread-safe random number generator.
Definition RngThread.H:39
const std::string getState() const
Get a serialized buffer holding the RNG state.
Definition RngThread.cpp:53
void setState(const std::string &buf)
Restore the RNG state from a buffer.
Definition RngThread.cpp:71
Trivial class to hold gas data.
Definition GasData.H:29
constexpr Real nH() const
Compute number density of H nuclei.
Definition GasData.H:148
constexpr Real xH2() const
Compute H2 abundance.
Definition GasData.H:84
Real xHe0
Definition GasData.H:50
Real xH0
Definition GasData.H:48
Interface class to describe background gas.
Definition Gas.H:44
virtual GasData gasData(const RealVec &x, const Real t) const =0
Return background gas state.
Interface to describe the CR propagation model.
Definition Propagation.H:79
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38
Struct representing a node of the global KD tree.
Definition CRTreeNode.H:40
Struct representing a node of the local KD tree.
Definition CRTreeNode.H:58