|
criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
|
A class to manage CR packets and sources. More...
#include <CRTree.H>
Public Member Functions | |
| CRTree (const ParmParser &pp, const Geometry &geom_, const gas::Gas &gasBG_, const propagation::Propagation &prop_, const Losses &loss_, RngThread &rng_) | |
| Construct an empty CRTree. | |
| 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. | |
| void | addPackets (const std::vector< RealVec > &x_, const std::vector< CRPacket > &pd_) |
| Add CR packets to the tree. | |
| void | addSources (const std::vector< RealVec > &xSrc_, const std::vector< CRSource > &src_) |
| Add CR sources to the tree. | |
| void | deletePacketsAndSources (std::vector< IdxType > &pIdx, std::vector< IdxType > &sIdx, const Real t) |
| Delete CR packets and sources from the tree. | |
| void | deletePackets (std::vector< IdxType > &pIdx, const Real t) |
| Delete CR packets. | |
| void | deleteSources (std::vector< IdxType > &sIdx) |
| Delete CR packets. | |
| IdxType | nPacket () const |
| Number of packets across all MPI ranks. | |
| IdxType | nPacketLoc () const |
| Number of packets on this MPI rank. | |
| IdxType | nDeletedPacket () const |
| Number of deleted packets across all MPI ranks. | |
| IdxType | nSource () const |
| Number of sources across all MPI ranks. | |
| IdxType | nSourceLoc () const |
| Number of sources on this MPI rank. | |
| IdxType | getUniqueID () const |
| Current value of the uniqueID counter. | |
| void | setUniqueID (const IdxType uniqueID_) |
| Set value of the uniqueID counter. | |
| std::vector< RealVec > & | getPacketPos () |
| Retrieve packet position data. | |
| const std::vector< RealVec > & | getPacketPos () const |
| Retrieve position of a packet. | |
| RealVec & | getPacketPos (const IdxType i) |
| Retrieve position of a packet. | |
| const RealVec & | getPacketPos (const IdxType i) const |
| Retrieve position of a packet as const. | |
| std::vector< CRPacket > & | getPacketData () |
| Retrieve packet data. | |
| const std::vector< CRPacket > & | getPacketData () const |
| Retrieve packet data as const. | |
| CRPacket & | getPacketData (const IdxType i) |
| Retrieve data on a packet. | |
| const CRPacket & | getPacketData (const IdxType i) const |
| Retrieve data on a packet as const. | |
| std::vector< RealVec > & | getDeletedPacketPos () |
| Retrieve deleted packet position data. | |
| const std::vector< RealVec > & | getDeletedPacketPos () const |
| Retrieve position of a deleted packet. | |
| RealVec & | getDeletedPacketPos (const IdxType i) |
| Retrieve position of a deleted packet. | |
| const RealVec & | getDeletedPacketPos (const IdxType i) const |
| Retrieve position of a deleted packet as const. | |
| std::vector< CRPacket > & | getDeletedPacketData () |
| Retrieve deleted packet data. | |
| const std::vector< CRPacket > & | getDeletedPacketData () const |
| Retrieve deleted packet data as const. | |
| CRPacket & | getDeletedPacketData (const IdxType i) |
| Retrieve data on a deleted packet. | |
| const CRPacket & | getDeletedPacketData (const IdxType i) const |
| Retrieve data on a deleted packet as const. | |
| std::vector< Real > & | getDeletedPacketTime () |
| Retrieve deleted packet deletion times. | |
| const std::vector< Real > & | getDeletedPacketTime () const |
| Retrieve deleted packet deletion times as const. | |
| Real & | getDeletedPacketTime (const IdxType i) |
| Retrieve deletion time of a single deleted packet. | |
| const Real & | getDeletedPacketTime (const IdxType i) const |
| Retrieve deletion time of a single deleted packet as const. | |
| std::vector< RealVec > & | getSourcePos () |
| Retrieve source position data. | |
| const std::vector< RealVec > & | getSourcePos () const |
| Retrieve source position data as const. | |
| RealVec & | getSourcePos (const IdxType i) |
| Retrieve position of a source. | |
| const RealVec & | getSourcePos (const IdxType i) const |
| Retrieve position of a source as const. | |
| std::vector< CRSource > & | getSourceData () |
| Retrieve source data. | |
| const std::vector< CRSource > & | getSourceData () const |
| Retrieve source data as const. | |
| CRSource & | getSourceData (const IdxType i) |
| Retrieve data on a source. | |
| const CRSource & | getSourceData (const IdxType i) const |
| Retrieve data on a source as const. | |
| const std::vector< CRSource > & | getSourceBufData () const |
| Retrieve source buffer data as const. | |
| Real & | getPacketScale (const IdxType i) |
| Retrieve scale length for specified packet. | |
| std::vector< FieldQty > & | getPacketQty () |
| Retrieve field quantities for all packets. | |
| const std::vector< FieldQty > & | getPacketQty () const |
| Retrieve field quantities for all packets as const. | |
| FieldQty & | getPacketQty (const IdxType i) |
| Retrieve field quantities for a specific packet. | |
| const FieldQty & | getPacketQty (const IdxType i) const |
| Retrieve field quantities for a specific packet as const. | |
| std::vector< FieldQtyGrad > & | getPacketQtyGrad () |
| Retrieve field quantity gradients for all packets. | |
| const std::vector< FieldQtyGrad > & | getPacketQtyGrad () const |
| Retrieve field quantity gradients for all packets as const. | |
| FieldQtyGrad & | getPacketQtyGrad (const IdxType i) |
| Retrieve field quantity gradients for a specific packet. | |
| const FieldQtyGrad & | getPacketQtyGrad (const IdxType i) const |
| Retrieve field quantity gradients for a specific packet as const. | |
| const Losses & | getLoss () const |
| Return reference to the loss calculator. | |
| void | getLossRates (const Real t, std::vector< Real > &dpdt, std::vector< Real > &lossRate) const |
| Total continuous and catastropic loss rates for all packets. | |
| void | getLossRates (const IdxType i, const Real t, Real &dpdt, Real &lossRate) const |
| Total continuous and catastropic loss rates for specified packet. | |
| 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. | |
| 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. | |
| std::vector< Real > | photLum (const Real t, const std::vector< Real > &en) const |
| Compute photon emission from all packets by all mechanisms. | |
| 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. | |
| std::vector< Real > | ionRate (const Real t) const |
| Compute ionization rate from all packets. | |
| std::vector< Real > | computePdot (const Real t) const |
| Compute non-loss dp/dt terms for all packets. | |
| std::string | getRngState () const |
| Get serialized RNG state. | |
| void | setRngState (std::string &buf) const |
| Set RNG state from serialized buffer. | |
| void | clearDeletedPackets () |
| Remove deleted packets. | |
| void | rebuild () |
| Rebuild the tree. | |
| void | fillFieldQty () |
| Compute the field quantities for packets in the tree. | |
| void | injectPackets (const Real tStart, const Real tStop) |
| Inject new CR packets from sources. | |
| Real | advancePackets (const Real tStart, const Real tStop) |
| Advance all packets through one time step. | |
Static Public Attributes | |
| static constexpr int | leafSize = TREE_LEAF_SIZE |
| static constexpr int | nRigidBin = TREE_RIGIDITY_BINS |
Private Member Functions | |
| void | setupDomain () |
| Find the global bounding box and total number of packets. | |
| void | buildGlobalTree () |
| Build the global KD tree. | |
| void | buildLocalTree () |
| Build the local KD tree. | |
| void | computeSplit (GlobalNode &nd) |
| Figure out how to split a global tree node. | |
| template<class U > | |
| 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. | |
| void | partitionNode (LocalNode &nd) |
| Partition a local node at the median point. | |
| void | sumTree () |
| Sum weights and bounding boxes in local tree. | |
| void | exchange () |
| Exchange packets and sources across MPI ranks. | |
| void | fillFieldQty (std::vector< IdxType > &start, std::vector< IdxType > &count, std::vector< IdxType > &leafList_) |
| Compute the field quantities for packets in the tree. | |
| 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. | |
| 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. | |
| 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. | |
Friends | |
| class | CRTreeCommunicator |
A class to manage CR packets and sources.
This is the primary simulation class in criptic. The CRTree stores the packets and sources, and is responsible for distributing them across MPI ranks, building the tree to allow fast kernel density estimation, and farming out the work of updating CR packet positions and properties to the update routines.
| CRTree::CRTree | ( | const ParmParser & | pp, |
| const Geometry & | geom_, | ||
| const gas::Gas & | gasBG_, | ||
| const propagation::Propagation & | prop_, | ||
| const Losses & | loss_, | ||
| RngThread & | rng_ | ||
| ) |
Construct an empty CRTree.
| pp | criptic::ParmParser object containg input deck |
| geom_ | criptic::Geometry object containing problem geometry |
| gasBG_ | criptic::gas::Gas object describing background gas |
| prop_ | criptic::propagation::Propagation object describing CR propagation |
| loss_ | criptic::Losses object describing loss mechanisms |
| rng_ | criptic::RngThread random number generator object |
|
private |
Add contribution of node to field quantities of packets.
| nodeIdx | Index of node to add |
| start | Starting index of packets to fill, or maxIdx if external |
| count | Number of packets to fill |
| x_ | Positions of packets to fill |
| R | Rigidities of packets to fill |
| h2Inv | Inverse of bandwidth squared matrix |
| h2InvGrad | Same as h2Inv, but for computation of gradients |
| q | Contributions of nodes to field quantities |
| qErr | Uncertainties in contributions of nodes to field quantities |
| qGrad | Contribution of nodes to field quantity gradients |
| qGradErr | Uncertainties in contribution of nodes to gradients |
The arguments h2InvGrad, qGrad, and errGrad are used only if the propagation model needs gradients of field quantities; they are ignored otherwise. The action of this function depends on whether the node on which it is called is a leaf or not. If it is a leaf, then the contributions of the packets in that leaf are added to q and qGrad, and qErr and qGradErr are not altered (since contributions from leaves have no errors). If the node is not a leaf, then q, qGrad, qErr, and qGradErr are set equal to estimates of the contribution of the node, and uncertainties on that estimate, resectively.
Add CR packets to the tree.
| x_ | Positions of packets to add |
| pd_ | Packet data for packets to add |
| void CRTree::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.
| x_ | Positions of packets to add |
| pd_ | Packet data for packets to add |
| xSrc_ | Positions of sources to add |
| src_ | Source data to add |
| void CRTree::addSources | ( | const std::vector< RealVec > & | xSrc_, |
| const std::vector< CRSource > & | src_ | ||
| ) |
Add CR sources to the tree.
| xSrc_ | Positions of sources to add |
| src_ | Source data for sources to add |
Advance all packets through one time step.
| tStart | Start of time step |
| tStop | End of time step |
|
private |
Build the global KD tree.
This method builds the global KD tree, which organizes the data across all MPI ranks. Note that, even if MPI is not enabled, we still build a global tree, though it will generally consist of only a single node.
|
private |
Build the local KD tree.
This method builds the local KD tree, which organizes the data across on a single MPI rank.
|
inline |
Remove deleted packets.
Calling this routine flushes the deleted packet buffer. This is intended to be used after writing those data to a checkpoint.
Compute non-loss dp/dt terms for all packets.
| t | Current time |
This routine computes all the non-loss terms that contribute to dp/dt for each packet. The three terms included are, in order, dK_pp/dp + 2 K_pp/p, -(p/3) dv_i/dx_i, and -p/3 (dw/dx_i t_i + w dt_i/dx_i), which physically represent changes in momentum due to momentum diffusion (second-order Fermi acceleration), adiabatic expansion or compression, and streaming. Data are packed into a single vector, with all three terms for packet 0 coming first, then all 3 terms for packet 1, and so forth. Loss rates are in code units.
|
private |
Figure out how to split a global tree node.
| nd | The node whose split is to be computed |
This routine computes the split dimension and value for a node in the global tree. It has the effect of setting the splitDim and splitVal fields for the node. It does not partition the packets or initialize the child nodes.
Delete CR packets.
| pIdx | Indices of packets to delete |
| t | Current time |
This is a thin wrapper around deletePacketsAndSources, with the list of source indices left empty.
| void CRTree::deletePacketsAndSources | ( | std::vector< IdxType > & | pIdx, |
| std::vector< IdxType > & | sIdx, | ||
| const Real | t | ||
| ) |
Delete CR packets and sources from the tree.
| pIdx | Indices of packets to delete |
| sIdx | Indices of sources to delete |
| t | Current time |
This function is provided for users to manually add or remove packets and sources as part of userWork or similar functions. pIdx and sIdx give the indices (not IDs) of the packets and sources to be deleted, and must be non-repeating; on return they will be sorted. Packets that are marked for deletion will be moved to the deleted packets list, but sources that are deleted will not be recorded automatically; it is up to users to log these deletions if they wish to do so.
|
inline |
Delete CR packets.
| sIdx | Indices of sources to delete |
This is a thin wrapper around deletePacketsAndSources, with the list of packet indices left empty and the time not used.
|
private |
Exchange packets and sources across MPI ranks.
This method is called after buildGlobalTree; its purpose is to exchange packets and sources between ranks, so that each MPI rank owns the packets and sources on its leaves and no others
|
inline |
Compute the field quantities for packets in the tree.
This routine does kernel density estimation to compute the field quantities (and gradients if field quantities) for packets in the tree. Only things needed by the propagation model are computed, so if the propagation model does not require field quantities or their gradients, this function has no effect. Note that the public version is a thin wrapper around the private version; the public version defaults to operating on packets in the main tree, while the private version can operate on the main tree or the buffer, depending on the arguments supplied.
|
private |
Compute the field quantities for packets in the tree.
| start | Starting indices of packets in each leaf to fill |
| count | Number of packets in each leaf |
| leafList_ | Indices of leaves to which packets belong |
This routine does kernel density estimation to compute the field quantities (and gradients if field quantities) for packets in the tree. Only things needed by the propagation model are computed, so if the propagation model does not require field quantities or their gradients, this function has no effect. This differs from the public version in that it accepts explicit arguments to specify packet and leaf indices on which to operate; this capability allows it to be used to fill field quantities in the buffer of packets waiting to be added to the tree as well as in the main tree.
|
private |
Fill the field quantities for a set of packets.
| start | Starting index of packets to fill |
| count | Number of packets to fill |
| x_ | Positions of packets to fill |
| R | Rigidities of packets to fill |
| h2Inv | Inverse squared bandwidth matrix |
| h2InvGrad | Inverse squared bandwidth matrix for gradients |
| hScale | Length scale for gradient errors |
| q | Array of field quantities to fill |
| qGrad | Array of field quantity gradients to fill |
| nrank | Number of MPI ranks contributing to this packet |
| qOwner | Estimate q from the rank that owns each packet |
If field quantity gradients are not needed, as indicated by needFQG being false, then qGrad, h2InvGrad, and hScale are not used. This method can operate in two modes: if start is equal to nullPacket, the packets passed to it are assumed to reside on another MPI rank, and we only compute the contribution to field quantities from this rank. If start is not equal to nullPacket, the packets passed are assumed to reside on this MPI rank, and the routine attempts to compute the total contribution across all ranks. If this requires data not available because it is held on another rank, the routine launches the required communication requests to gather the data, allowing completion of the estimate later.
|
inline |
Retrieve deleted packet data.
|
inline |
Retrieve deleted packet data as const.
Retrieve data on a deleted packet.
| i | Index of deleted packet to return |
Retrieve data on a deleted packet as const.
| i | Index of deleted packet to return |
|
inline |
Retrieve deleted packet position data.
|
inline |
Retrieve position of a deleted packet.
Retrieve deleted packet position data as const
Retrieve position of a deleted packet.
Retrieve position of a deleted packet as const.
|
inline |
Retrieve deleted packet deletion times.
|
inline |
Retrieve deleted packet deletion times as const.
Retrieve deletion time of a single deleted packet.
| i | Index of deleted packet time to return |
Retrieve deletion time of a single deleted packet as const.
| i | Index of deleted packet time to return |
|
inline |
Return reference to the loss calculator.
This exposes a const reference to the losses object. It is provided so user-provided routines can have access to the loss and photon emission calculation machinery.
|
inline |
Total continuous and catastropic loss rates for specified packet.
| i | Packet index |
| t | Current time |
| dpdt | Vector of continuous loss rates |
| lossRate | Vector of catastrophic loss rates |
|
inline |
Total continuous and catastropic loss rates for all packets.
| t | Current time |
| dpdt | Vector of continuous loss rates |
| lossRate | Vector of catastrophic loss rates |
|
inline |
Compute mechanism-by-mechanism loss rates for specified packet.
| i | Packet index |
| t | Current time |
| dpdt | Vector of continuous loss rates |
| lossRate | Vector of catastrophic loss rates |
dpdt and lossRate follow the same order as returned by getLossMechNames
|
inline |
Compute mechanism-by-mechanism loss rates for all packets.
| t | Current time |
| dpdt | Vector of continuous loss rates |
| lossRate | Vector of catastrophic loss rates |
|
inline |
Retrieve packet data.
|
inline |
Retrieve packet data as const.
Retrieve data on a packet.
| i | Index of packet to return |
This method can retrieve the positions of packets in the buffer, as well as those in the main tree. If i >= pd.size(), then the packet returned will be packet i - pd.size() from the buffer.
Retrieve data on a packet as const.
| i | Index of packet to return |
This method can retrieve the positions of packets in the buffer, as well as those in the main tree. If i >= pd.size(), then the packet returned will be packet i - pd.size() from the buffer.
|
inline |
Retrieve packet position data.
|
inline |
Retrieve position of a packet.
Retrieve packet position data as const
Retrieve position of a packet.
This method can retrieve the positions of packets in the buffer, as well as those in the main tree. If i >= x.size(), then the packet returned will be packet i - x.size() from the buffer.
Retrieve position of a packet as const.
This method can retrieve the positions of packets in the buffer, as well as those in the main tree. If i >= x.size(), then the packet returned will be packet i - x.size() from the buffer.
|
inline |
Retrieve field quantities for all packets.
|
inline |
Retrieve field quantities for all packets as const.
Retrieve field quantities for a specific packet.
| i | Index of packet to return |
This method can retrieve quantities for packets in the buffer, as well as those in the main tree. If i >= x.size(), then the quantities returned will be those for packet i - x.size() from the buffer.
Retrieve field quantities for a specific packet as const.
| i | Index of source to return |
This method can retrieve quantities for packets in the buffer, as well as those in the main tree. If i >= x.size(), then the quantities returned will be those for packet i - x.size() from the buffer.
|
inline |
Retrieve field quantity gradients for all packets.
|
inline |
Retrieve field quantity gradients for all packets as const.
|
inline |
Retrieve field quantity gradients for a specific packet.
| i | Index of source to return |
This method can retrieve quantity gradients for packets in the buffer, as well as those in the main tree. If i >= x.size(), then the quantity gradients returned will be those for packet i - x.size() from the buffer.
|
inline |
Retrieve field quantity gradients for a specific packet as const.
| i | Index of source to return |
This method can retrieve quantity gradients for packets in the buffer, as well as those in the main tree. If i >= x.size(), then the quantity gradients returned will be those for packet i - x.size() from the buffer.
Retrieve scale length for specified packet.
| i | Index of packet to return |
|
inline |
Get serialized RNG state.
This routine is a thin wrapper around RngThread::getState()
|
inline |
Retrieve source buffer data as const.
|
inline |
Retrieve source data.
|
inline |
Retrieve source data as const.
Retrieve data on a source.
| i | Index of source to return |
Retrieve data on a source as const.
| i | Index of source to return |
|
inline |
Retrieve source position data.
|
inline |
Retrieve source position data as const.
Retrieve position of a source.
| i | Index of source to return |
Retrieve position of a source as const.
| i | Index of source to return |
|
inline |
Current value of the uniqueID counter.
Inject new CR packets from sources.
| tStart | Start of time interval over which to inject |
| tStop | End of time interval over which to inject |
Compute ionization rate from all packets.
| t | Current time |
This routine computes the ionization rates for H, H2, and He. Data are packed into a single vector with ionization species as the fastest varying dimension, so elements 0 - 2 in the output are the ionization rates of H, H2, and He for the first packet, elements 3 - 5 are the rates for the second packet, and so forth. The quantity returned has units of volume per time.
|
inline |
Number of deleted packets across all MPI ranks.
|
private |
Compute min and max weight functions over a node.
| x_ | Location of the point |
| bnd | Tight bounding box for node |
| h2Inv | Inverse of bandwidth squared matrix |
| h2InvGrad | Same as h2Inv, but for computation of gradients |
| wMin | The minimum of the weight function |
| wMax | The maximum of the weight fucntion |
| wGradMin | The minimum of the gradient weight function |
| wGradMax | The maximum of the gradient weight function |
This function finds the maximum and minimum values assumed by the weight function w = exp( -r h2Inv r^T / 2) and the gradient weight function grad w = -r h2InvGrad exp( -r h2InvGrad r^T / 2) within the volume covered by the tight bounding box of the specified node, where r is a vector pointing from any point inside the bounding box to x. The minima and maxima for the gradient weight grad w are taken elementwise. The gradient weight is computed, and h2InvGrad, wGradMin, and wGradMax are used, only if the propagation model requires gradients of the field quantities.
|
inline |
Number of packets across all MPI ranks.
|
inline |
Number of packets on this MPI rank.
|
inline |
Number of sources across all MPI ranks.
|
inline |
Number of sources on this MPI rank.
|
private |
Partition a node global node using a pre-computed split.
| nd | The node to be partitioned |
| start | Starting index of objects to be partitioned |
| count | Number of objects to be partitioned |
| x_ | Vector object positions to be partitioned |
| dat | Vector of object data to be partitioned |
This routine is called after computeSplit, to partition packets or sources based on the computed split. This is a template function, allowing it to be called on both local and global nodes, and on both packets and sources
|
private |
Partition a local node at the median point.
| nd | The node to partition |
This routine partitions a node at the median point, and sets the properties of the partition
|
inline |
Compute photon emission from all packets by all mechanisms.
| t | Current time |
| en | Photon energies at which to compute emission rate |
Unlike other functions, this uses physical units. Specifically, en is the photon energy in GeV, and dL/dE is the specific luminosity in erg/s/GeV (if the code was compiled in CGS mode; J/s/GeV is compiled in MKS mode). The data are packed into a single vector, which represents a 3D array of nPacket * nMechanism * nEnergy, with energy as the fastest varying dimension and packet as the slowest varying dimension.
| vector< Real > CRTree::photLumSummary | ( | const Real | t, |
| const std::vector< Real > & | en, | ||
| const int | rank = 0 |
||
| ) | const |
Compute total photon emission, summing by type and mechanism.
| t | Current time |
| en | Photon energies at which to compute emission rate |
| rank | MPI rank onto which to reduce |
Unlike other functions, this uses physical units. Specifically, en is the photon energy in GeV, and dL/dE is the specific luminosity in erg/s/GeV (if the code was compiled in CGS mode; J/s/GeV is compiled in MKS mode). The data are packed into a single vector, which represents a 4D array of nPartType * 2 * nMechanism * nEnergy, with energy as the fastest varying dimension and particle as the slowest varying dimension. The two is for primaries and secondaries, so for example element (i,j,k,l) in the output vector represents emission by the ith type of particle, considering only primaries/secondaries of that particle type for j = 0/1, via the kth emission mechanism, and in the lth energy bin. The variable rank specifies how to reduce across MPI ranks. For a value >= 0, the sum will be reduced onto that rank; a value of -1 leads to an AllReduce (i.e., data are reduced across all ranks), while a value of -2 causes no reduction to be performed (sum is local to the rank invoking the method). For calls where rank has any value other than -2, this method must be invoked collectively across MPI ranks.
| void CRTree::rebuild | ( | ) |
Rebuild the tree.
Invoking this method rebuilds the tree. It redistributes all packets and sources across MPI ranks, and builds the search tree within each rank.
|
inline |
Set RNG state from serialized buffer.
| buf | A string containing the serialized state |
This routine is a thin wrapper around RngThread::setState()
|
inline |
Set value of the uniqueID counter.
|
private |
Find the global bounding box and total number of packets.
This method finds the global bounding box and total count of packets across all MPI ranks, as a first step to partitioning the domain between ranks.
|
private |
Sum weights and bounding boxes in local tree.
This routine is called after buildLocalTree; its purpose is to sum the contributions of each node to the field quantities, and also compute tight bounding boxes on the nodes. The routine starts with the leaves, then propagates that information up to the top of the tree, including doing exchanges between MPI ranks where required.
|
friend |
|
private |
Weight between mean and min time steps
|
private |
Communicator helper class
|
private |
Step size control parameter
|
private |
Size of rigidity grid spacing
|
private |
High corner of domain bounding box
|
private |
Low corner of domain bounding box
|
private |
Equal sampling for all injected species?
|
private |
Field line integrator error tolerance parameter
|
private |
Background gas descriptor
|
private |
Problem geometry
|
private |
Nodes of global tree
|
private |
Number of "extra levels" in global tree
|
private |
Index of leaves in global tree, regardless of which MPI rank owns them
|
private |
Maximum level in global tree
|
private |
Index of first leaf this MPI rank owns in the global tree
|
private |
Number of leaves in global tree
|
private |
Number of leaves of the global tree that this rank owns
|
private |
Scale length for packet
|
private |
Inverse squared bandwidth matrix to be used for gradient estimation in each leaf
|
private |
Inverse squared bandwidth matrix to be used for field quantity estimation in each leaf
|
private |
Scale length for buffer packet
|
private |
Dither size for sources
|
private |
Length scale factor for each leaf
|
private |
Kernel density estimation tolerance
|
private |
List of all local tree leaves
|
staticconstexpr |
Size of leaf
|
private |
List of nodes in local tree where leaves coming from a global tree leaf begin
|
private |
Maximum level of local trees; one entry per leaf in the global tree owned by this MPI rank
|
private |
Number of leaves in each local tree
|
private |
Pointers to locations in nodes array where local tree starts; one entry per leaf in global tree owned by this MPI rank
|
private |
Log of minimum CR rigidity in domain
|
private |
Log of maximum CR rigidity in domain
|
private |
Loss mechanisms
|
private |
Are field quantities needed?
|
private |
Are gradients of field quantities needed?
|
private |
Target effective neighbor number
|
private |
Nodes of the local tree
|
staticconstexpr |
Number of rigidity bins
|
private |
Minimum individual packet time step
|
private |
Rate per unit time at which sources inject new packets
|
private |
Number of samples per MPI rank used to partition the global tree
|
private |
CR packet data
|
private |
CR packet data buffer
|
private |
Deleted CR packet data
|
private |
Minimum packet momentum
|
private |
CR propagation descriptor
|
private |
Sampling index for CR packets
|
private |
CR field quantities
|
private |
Field quantities for buffer CRs
|
private |
CR field quantity gradients
|
private |
Field quantity gradients for buffer CRs
|
private |
Random number generator
|
private |
Sampling ratios of different species
|
private |
CR source data
|
private |
CR source data buffer
|
private |
Index of leaf to which sources belong in the array of local tree nodes
|
private |
Times at which packets were deleted
|
private |
Minimum packet kinetic energy
|
private |
Number of deleted packets
|
private |
Packet counter
|
private |
Source counter
|
private |
Total weight of all sources
|
private |
Total source weight by species
|
private |
Unique ID counter
|
private |
Level of verbosity
|
private |
Minimum statistical weight of packets relative to starting weight
|
private |
CR packet positions
|
private |
CR packet position buffer
|
private |
Deleted CR packet positions
|
private |
CR source positions
|
private |
CR source position buffer