OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
PartBins Class Reference

#include <PartBins.h>

Inheritance diagram for PartBins:
Inheritance graph
[legend]

Public Member Functions

 PartBins (int bins, int sbins)
 
virtual ~PartBins ()
 
void fill (std::vector< double > &p)
 Add a particle to the temporary container. More...
 
size_t getNp ()
 get the number of particles in the temporary particle structure used for binning More...
 
void setPartNum (int bin, long long num)
 
bool doEmission ()
 Is true if we still have particles to emit. More...
 
bool isEmitted (int n, int)
 
bool getPart (size_t n, int bin, std::vector< double > &p)
 
void sortArray ()
 
void resetPartInBin_cyc (size_t newPartNum[], int binID)
 
void updatePartInBin_cyc (size_t countLost[])
 
void setGamma (double gamma)
 
double getGamma ()
 
Informprint (Inform &os)
 
int getSBins ()
 
virtual int getNBins ()
 
int getLastemittedBin ()
 
void resetBins ()
 If the bunch object rebins we need to call resetBins() More...
 
virtual bool weHaveBins ()
 
size_t getTotalNum ()
 How many particles are in all the bins. More...
 
size_t getTotalNumPerBin (int b)
 How many particles are in the bin b. More...
 

Protected Member Functions

int getBin (double x)
 

Protected Attributes

double gamma_m
 
int bins_m
 
int sBins_m
 
double xmin_m
 
double xmax_m
 
std::unique_ptr< double[]> xbinmin_m
 
std::unique_ptr< double[]> xbinmax_m
 
double hBin_m
 
std::vector< std::vector< double > > tmppart_m
 
std::vector< bool > isEmitted_m
 
std::unique_ptr< bool[]> binsEmitted_m
 
int nemittedBins_m
 
std::unique_ptr< size_t[]> nBin_m
 
std::unique_ptr< size_t[]> nDelBin_m
 
std::unique_ptr< gsl_histogram > h_m
 

Private Member Functions

void calcHBins ()
 
void calcExtrema ()
 
void setBinEmitted (int bin)
 

Detailed Description

Definition at line 30 of file PartBins.h.

Constructor & Destructor Documentation

◆ PartBins()

PartBins::PartBins ( int  bins,
int  sbins 
)

Definition of a bin: low <= x < hi Low water mark is included, high water is excluded.

Definition at line 31 of file PartBins.cpp.

References bins_m, binsEmitted_m, max(), nBin_m, nDelBin_m, xbinmax_m, and xbinmin_m.

Here is the call graph for this function:

◆ ~PartBins()

PartBins::~PartBins ( )
virtual

Definition at line 100 of file PartBins.cpp.

References isEmitted_m, and tmppart_m.

Member Function Documentation

◆ calcExtrema()

void PartBins::calcExtrema ( )
private

Definition at line 150 of file PartBins.cpp.

References Hypervolume::n, tmppart_m, xbinmax_m, and xbinmin_m.

Referenced by calcHBins().

◆ calcHBins()

void PartBins::calcHBins ( )
private

assigns the particles to the bins

Definition at line 143 of file PartBins.cpp.

References calcExtrema(), getBin(), Hypervolume::n, and tmppart_m.

Referenced by sortArray().

Here is the call graph for this function:

◆ doEmission()

bool PartBins::doEmission ( )
inline

Is true if we still have particles to emit.

Definition at line 67 of file PartBins.h.

References getNp().

Here is the call graph for this function:

◆ fill()

void PartBins::fill ( std::vector< double > &  p)
inline

Add a particle to the temporary container.

Definition at line 50 of file PartBins.h.

References isEmitted_m, and tmppart_m.

Referenced by Distribution::fillParticleBins().

◆ getBin()

int PartBins::getBin ( double  x)
protected

returns the index of the bin to which the particle with z = 'x' belongs. If getBin returns b < 0 || b >= bins_m, then x is out of range!

returns the index of the bin to which the particle with z = 'x' belongs. If getBin returns b < 0 || b >= bins_m, then is x out of range!

Definition at line 183 of file PartBins.cpp.

References abs(), floor(), hBin_m, nBin_m, and xmax_m.

Referenced by calcHBins().

Here is the call graph for this function:

◆ getGamma()

double PartBins::getGamma ( )
inline

Definition at line 95 of file PartBins.h.

References gamma_m.

◆ getLastemittedBin()

int PartBins::getLastemittedBin ( )
inline

the last emitted bin is always smaller or equal getNbins

Definition at line 136 of file PartBins.h.

References nemittedBins_m.

Referenced by getTotalNum(), MultiBunchHandler::MultiBunchHandler(), and print().

◆ getNBins()

virtual int PartBins::getNBins ( )
inlinevirtual

get the number of used bin

Reimplemented in PartBinsCyc.

Definition at line 133 of file PartBins.h.

References h_m, and sBins_m.

◆ getNp()

size_t PartBins::getNp ( )
inline

get the number of particles in the temporary particle structure used for binning

Definition at line 56 of file PartBins.h.

References tmppart_m.

Referenced by doEmission().

◆ getPart()

bool PartBins::getPart ( size_t  n,
int  bin,
std::vector< double > &  p 
)

assigns the proper position of particle n if it belongs to bin 'bin'

Definition at line 106 of file PartBins.cpp.

References Hypervolume::n, and tmppart_m.

◆ getSBins()

int PartBins::getSBins ( )
inline

Definition at line 130 of file PartBins.h.

References sBins_m.

◆ getTotalNum()

size_t PartBins::getTotalNum ( )

How many particles are in all the bins.

Definition at line 59 of file PartBins.cpp.

References getLastemittedBin(), nBin_m, nDelBin_m, and reduce().

Here is the call graph for this function:

◆ getTotalNumPerBin()

size_t PartBins::getTotalNumPerBin ( int  b)

How many particles are in the bin b.

Definition at line 73 of file PartBins.cpp.

References nBin_m, and reduce().

Referenced by PartBinsCyc::PartBinsCyc().

Here is the call graph for this function:

◆ isEmitted()

bool PartBins::isEmitted ( int  n,
int   
)
inline

Definition at line 69 of file PartBins.h.

References isEmitted_m, and Hypervolume::n.

◆ print()

Inform & PartBins::print ( Inform os)

Definition at line 160 of file PartBins.cpp.

References bins_m, endl(), getLastemittedBin(), h_m, hBin_m, sBins_m, and tmppart_m.

Referenced by operator<<().

Here is the call graph for this function:

◆ resetBins()

void PartBins::resetBins ( )
inline

If the bunch object rebins we need to call resetBins()

Definition at line 139 of file PartBins.h.

References h_m.

◆ resetPartInBin_cyc()

void PartBins::resetPartInBin_cyc ( size_t  newPartNum[],
int  binID 
)

update local particles number in bin after reset Bin ID of PartBunch

Definition at line 89 of file PartBins.cpp.

References nBin_m, nemittedBins_m, reduce(), and setBinEmitted().

Here is the call graph for this function:

◆ setBinEmitted()

void PartBins::setBinEmitted ( int  bin)
inlineprivate

assume we emit in monotonic increasing order

Definition at line 86 of file PartBins.h.

References binsEmitted_m.

Referenced by resetPartInBin_cyc(), and sortArray().

◆ setGamma()

void PartBins::setGamma ( double  gamma)
inline

Definition at line 94 of file PartBins.h.

References gamma_m.

Referenced by Distribution::setupParticleBins().

◆ setPartNum()

void PartBins::setPartNum ( int  bin,
long long  num 
)
inline

set particles number in given bin

Definition at line 64 of file PartBins.h.

References nBin_m.

◆ sortArray()

void PartBins::sortArray ( )

sort the vector of particles such that positions of the particles decrease with increasing index. Then push the particles back by xmax_m + jifactor * bunch_length. In order that the method getBin(double x) works xmin_m has to be lowered a bit more.

/brief There is only a local sort, no global yet

sort the vector of particles such that position of the particles decrease with increasing index. Then push the particles back by 1e-13 s * beta * c (approximately one step). In order that the method getBin(double x) works xmin_m has to be lowered a bit more.

Definition at line 116 of file PartBins.cpp.

References abs(), bins_m, Physics::c, calcHBins(), gamma_m, hBin_m, Hypervolume::n, nBin_m, Units::ps2s, reduce(), setBinEmitted(), sqrt(), tmppart_m, xmax_m, and xmin_m.

Referenced by Distribution::fillParticleBins().

Here is the call graph for this function:

◆ updatePartInBin_cyc()

void PartBins::updatePartInBin_cyc ( size_t  countLost[])

update local particles number in bin after particle deletion

Definition at line 81 of file PartBins.cpp.

References nBin_m, and nemittedBins_m.

◆ weHaveBins()

virtual bool PartBins::weHaveBins ( )
inlinevirtual

Reimplemented in PartBinsCyc.

Definition at line 143 of file PartBins.h.

References h_m.

Member Data Documentation

◆ bins_m

int PartBins::bins_m
protected

◆ binsEmitted_m

std::unique_ptr<bool[]> PartBins::binsEmitted_m
protected

holds information whether all particles of a bin are emitted

Definition at line 124 of file PartBins.h.

Referenced by PartBins(), PartBinsCyc::PartBinsCyc(), and setBinEmitted().

◆ gamma_m

double PartBins::gamma_m
protected

Definition at line 99 of file PartBins.h.

Referenced by getGamma(), setGamma(), and sortArray().

◆ h_m

std::unique_ptr<gsl_histogram> PartBins::h_m
protected

Definition at line 165 of file PartBins.h.

Referenced by getNBins(), print(), resetBins(), and weHaveBins().

◆ hBin_m

double PartBins::hBin_m
protected

bin size

Definition at line 118 of file PartBins.h.

Referenced by getBin(), print(), and sortArray().

◆ isEmitted_m

std::vector< bool > PartBins::isEmitted_m
protected

Definition at line 122 of file PartBins.h.

Referenced by fill(), isEmitted(), and ~PartBins().

◆ nBin_m

std::unique_ptr<size_t[]> PartBins::nBin_m
protected

number of particles in the bins, the sum of all the nodes

Definition at line 160 of file PartBins.h.

Referenced by getBin(), getTotalNum(), getTotalNumPerBin(), PartBins(), PartBinsCyc::PartBinsCyc(), resetPartInBin_cyc(), setPartNum(), sortArray(), and updatePartInBin_cyc().

◆ nDelBin_m

std::unique_ptr<size_t[]> PartBins::nDelBin_m
protected

number of deleted particles in the bins

Definition at line 163 of file PartBins.h.

Referenced by getTotalNum(), and PartBins().

◆ nemittedBins_m

int PartBins::nemittedBins_m
protected

◆ sBins_m

int PartBins::sBins_m
protected

Definition at line 107 of file PartBins.h.

Referenced by getNBins(), getSBins(), and print().

◆ tmppart_m

std::vector< std::vector<double> > PartBins::tmppart_m
protected

holds the particles not yet in the bunch

Definition at line 121 of file PartBins.h.

Referenced by calcExtrema(), calcHBins(), fill(), getNp(), getPart(), print(), sortArray(), and ~PartBins().

◆ xbinmax_m

std::unique_ptr<double[]> PartBins::xbinmax_m
protected

Definition at line 115 of file PartBins.h.

Referenced by calcExtrema(), and PartBins().

◆ xbinmin_m

std::unique_ptr<double[]> PartBins::xbinmin_m
protected

extremal particle position within the bins

Definition at line 114 of file PartBins.h.

Referenced by calcExtrema(), and PartBins().

◆ xmax_m

double PartBins::xmax_m
protected

Definition at line 111 of file PartBins.h.

Referenced by getBin(), and sortArray().

◆ xmin_m

double PartBins::xmin_m
protected

extremal particle positions

Definition at line 110 of file PartBins.h.

Referenced by sortArray().


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