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

#include <LossDataSink.h>

Public Member Functions

 LossDataSink ()
 
 LossDataSink (std::string elem, bool hdf5Save, ElementBase::ElementType type=ElementBase::ANY)
 
 LossDataSink (const LossDataSink &rsh)
 
 ~LossDataSink () noexcept(false)
 
bool inH5Mode ()
 
void save (unsigned int numSets=1, OpalData::OPENMODE openMode=OpalData::OPENMODE::UNDEFINED)
 
void addReferenceParticle (const Vector_t &x, const Vector_t &p, double time, double spos, long long globalTrackStep)
 
void addParticle (const Vector_t &x, const Vector_t &p, const size_t id)
 
void addParticle (const Vector_t &x, const Vector_t &p, const size_t id, const double time, const size_t turn, const size_t &bunchNum=0)
 
size_t size () const
 
std::set< SetStatisticscomputeStatistics (unsigned int numSets)
 

Private Member Functions

void openASCII ()
 
void openH5 (h5_int32_t mode=H5_O_WRONLY)
 
void appendASCII ()
 
void writeHeaderASCII ()
 
void writeHeaderH5 ()
 
void saveASCII ()
 
void saveH5 (unsigned int setIdx)
 
void closeASCII ()
 
bool hasNoParticlesToDump ()
 
bool hasTimeAttribute ()
 
void reportOnError (h5_int64_t rc, const char *file, int line)
 
void splitSets (unsigned int numSets)
 
SetStatistics computeSetStatistics (unsigned int setIdx)
 

Private Attributes

std::string fn_m
 
bool h5hut_mode_m
 
std::ofstream os_m
 
h5_file_t H5file_m
 used to write out data in H5hut mode More...
 
std::string element_m
 
h5_int64_t H5call_m
 Current record, or time step, of H5 file. More...
 
std::vector< long > id_m
 
std::vector< double > x_m
 
std::vector< double > y_m
 
std::vector< double > z_m
 
std::vector< double > px_m
 
std::vector< double > py_m
 
std::vector< double > pz_m
 
std::vector< size_t > bunchNum_m
 
std::vector< size_t > turn_m
 
std::vector< double > time_m
 
std::vector< Vector_tRefPartR_m
 
std::vector< Vector_tRefPartP_m
 
std::vector< h5_int64_t > globalTrackStep_m
 
std::vector< double > refTime_m
 
std::vector< double > spos_m
 
std::vector< unsigned long > startSet_m
 
ElementBase::ElementType type_m
 

Detailed Description

Definition at line 62 of file LossDataSink.h.

Constructor & Destructor Documentation

LossDataSink::LossDataSink ( )

Definition at line 173 of file LossDataSink.cpp.

LossDataSink::LossDataSink ( std::string  elem,
bool  hdf5Save,
ElementBase::ElementType  type = ElementBase::ANY 
)

Definition at line 130 of file LossDataSink.cpp.

References bunchNum_m, id_m, px_m, py_m, pz_m, time_m, turn_m, x_m, y_m, and z_m.

LossDataSink::LossDataSink ( const LossDataSink rsh)

Definition at line 149 of file LossDataSink.cpp.

References bunchNum_m, id_m, px_m, py_m, pz_m, time_m, turn_m, x_m, y_m, and z_m.

LossDataSink::~LossDataSink ( )
noexcept

Definition at line 177 of file LossDataSink.cpp.

References Communicate::barrier(), CLOSE_FILE, IpplInfo::Comm, and H5file_m.

Here is the call graph for this function:

Member Function Documentation

void LossDataSink::addParticle ( const Vector_t x,
const Vector_t p,
const size_t  id 
)

Definition at line 236 of file LossDataSink.cpp.

References id_m, px_m, py_m, pz_m, x_m, y_m, and z_m.

Referenced by addParticle(), and Ring::apply().

void LossDataSink::addParticle ( const Vector_t x,
const Vector_t p,
const size_t  id,
const double  time,
const size_t  turn,
const size_t &  bunchNum = 0 
)

Definition at line 247 of file LossDataSink.cpp.

References addParticle(), bunchNum_m, time_m, and turn_m.

Here is the call graph for this function:

void LossDataSink::addReferenceParticle ( const Vector_t x,
const Vector_t p,
double  time,
double  spos,
long long  globalTrackStep 
)

Definition at line 223 of file LossDataSink.cpp.

References globalTrackStep_m, RefPartP_m, RefPartR_m, refTime_m, and spos_m.

void LossDataSink::appendASCII ( )
inlineprivate

Definition at line 98 of file LossDataSink.h.

References fn_m, IpplInfo::myNode(), and os_m.

Referenced by save().

Here is the call graph for this function:

void LossDataSink::closeASCII ( )
inlineprivate

Definition at line 119 of file LossDataSink.h.

References IpplInfo::myNode(), and os_m.

Referenced by save().

Here is the call graph for this function:

SetStatistics LossDataSink::computeSetStatistics ( unsigned int  setIdx)
private
std::set< SetStatistics > LossDataSink::computeStatistics ( unsigned int  numSets)
inline

Definition at line 179 of file LossDataSink.h.

References computeSetStatistics(), and splitSets().

Here is the call graph for this function:

bool LossDataSink::hasNoParticlesToDump ( )
private

Definition at line 322 of file LossDataSink.cpp.

References reduce(), and x_m.

Referenced by save().

Here is the call graph for this function:

bool LossDataSink::hasTimeAttribute ( )
private

Definition at line 331 of file LossDataSink.cpp.

References reduce(), and time_m.

Referenced by saveASCII(), saveH5(), and writeHeaderH5().

Here is the call graph for this function:

bool LossDataSink::inH5Mode ( )
inline

Definition at line 71 of file LossDataSink.h.

References h5hut_mode_m.

void LossDataSink::openASCII ( )
inlineprivate

Definition at line 91 of file LossDataSink.h.

References fn_m, IpplInfo::myNode(), and os_m.

Referenced by save().

Here is the call graph for this function:

void LossDataSink::openH5 ( h5_int32_t  mode = H5_O_WRONLY)
private

Definition at line 185 of file LossDataSink.cpp.

References fn_m, IpplInfo::getComm(), and OPEN_FILE.

Referenced by save().

Here is the call graph for this function:

void LossDataSink::reportOnError ( h5_int64_t  rc,
const char *  file,
int  line 
)
private
void LossDataSink::save ( unsigned int  numSets = 1,
OpalData::OPENMODE  openMode = OpalData::OPENMODE::UNDEFINED 
)
void LossDataSink::saveASCII ( )
private
void LossDataSink::saveH5 ( unsigned int  setIdx)
private

Set current record/time step.

Write particle id numbers.

Definition at line 340 of file LossDataSink.cpp.

References bunchNum_m, IpplInfo::getNodes(), globalTrackStep_m, H5call_m, hasTimeAttribute(), id_m, IpplInfo::myNode(), px_m, py_m, pz_m, reduce(), RefPartP_m, RefPartR_m, refTime_m, SET_NUM_PARTICLES, SET_STEP, spos_m, startSet_m, time_m, turn_m, WRITE_DATA_FLOAT64, WRITE_DATA_INT64, WRITE_STEPATTRIB_FLOAT64, WRITE_STEPATTRIB_INT64, x_m, y_m, and z_m.

Referenced by save().

Here is the call graph for this function:

size_t LossDataSink::size ( ) const
inline

Definition at line 174 of file LossDataSink.h.

References x_m.

void LossDataSink::splitSets ( unsigned int  numSets)
private

In Opal-T monitors can be traversed several times. We know how many times the bunch passes because we register the passage of the reference particle. This code tries to determine to which bunch (same bunch but different times) a particle belongs. For this we could use algorithms from data science such as k-means or dbscan. But they are an overkill for this application because the bunches are well separated.

In a first step we a assign to each bunch the same number of particles and compute the mean time of passage and with it a time range. Of course this is only an approximation. So we reassign the particles to the bunches using the time ranges compute a better approximation. Two iterations should be sufficient for Opal-T where the temporal separation is large.

Parameters
numSetsnumber of passes of the reference particle

Definition at line 504 of file LossDataSink.cpp.

References allreduce(), max(), startSet_m, time_m, and x_m.

Referenced by computeStatistics().

Here is the call graph for this function:

void LossDataSink::writeHeaderASCII ( )
inlineprivate

Definition at line 104 of file LossDataSink.h.

References element_m, endl(), IpplInfo::myNode(), os_m, and time_m.

Referenced by save().

Here is the call graph for this function:

void LossDataSink::writeHeaderH5 ( )
private

in case of circular machines

Definition at line 194 of file LossDataSink.cpp.

References ADD_ATTACHMENT, Util::getGitRevision(), OpalData::getInstance(), hasTimeAttribute(), OPAL_PROJECT_NAME, OPAL_PROJECT_VERSION, and WRITE_FILEATTRIB_STRING.

Referenced by save().

Here is the call graph for this function:

Member Data Documentation

std::vector<size_t> LossDataSink::bunchNum_m
private

Definition at line 157 of file LossDataSink.h.

Referenced by addParticle(), LossDataSink(), save(), saveASCII(), and saveH5().

std::string LossDataSink::element_m
private

Definition at line 145 of file LossDataSink.h.

Referenced by computeSetStatistics(), save(), saveASCII(), and writeHeaderASCII().

std::string LossDataSink::fn_m
private

Definition at line 134 of file LossDataSink.h.

Referenced by appendASCII(), openASCII(), openH5(), and save().

std::vector<h5_int64_t> LossDataSink::globalTrackStep_m
private

Definition at line 164 of file LossDataSink.h.

Referenced by addReferenceParticle(), save(), and saveH5().

h5_int64_t LossDataSink::H5call_m
private

Current record, or time step, of H5 file.

Definition at line 148 of file LossDataSink.h.

Referenced by saveH5().

h5_file_t LossDataSink::H5file_m
private

used to write out data in H5hut mode

Definition at line 143 of file LossDataSink.h.

Referenced by save(), and ~LossDataSink().

bool LossDataSink::h5hut_mode_m
private

Definition at line 137 of file LossDataSink.h.

Referenced by inH5Mode(), and save().

std::vector<long> LossDataSink::id_m
private

Definition at line 150 of file LossDataSink.h.

Referenced by addParticle(), LossDataSink(), save(), saveASCII(), and saveH5().

std::ofstream LossDataSink::os_m
private

Definition at line 140 of file LossDataSink.h.

Referenced by appendASCII(), closeASCII(), openASCII(), saveASCII(), and writeHeaderASCII().

std::vector<double> LossDataSink::px_m
private

Definition at line 154 of file LossDataSink.h.

Referenced by addParticle(), computeSetStatistics(), LossDataSink(), save(), saveASCII(), and saveH5().

std::vector<double> LossDataSink::py_m
private

Definition at line 155 of file LossDataSink.h.

Referenced by addParticle(), computeSetStatistics(), LossDataSink(), save(), saveASCII(), and saveH5().

std::vector<double> LossDataSink::pz_m
private

Definition at line 156 of file LossDataSink.h.

Referenced by addParticle(), computeSetStatistics(), LossDataSink(), save(), saveASCII(), and saveH5().

std::vector<Vector_t> LossDataSink::RefPartP_m
private

Definition at line 163 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

std::vector<Vector_t> LossDataSink::RefPartR_m
private

Definition at line 162 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

std::vector<double> LossDataSink::refTime_m
private

Definition at line 165 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

std::vector<double> LossDataSink::spos_m
private

Definition at line 166 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

std::vector<unsigned long> LossDataSink::startSet_m
private

Definition at line 168 of file LossDataSink.h.

Referenced by computeSetStatistics(), saveH5(), and splitSets().

std::vector<double> LossDataSink::time_m
private
std::vector<size_t> LossDataSink::turn_m
private

Definition at line 159 of file LossDataSink.h.

Referenced by addParticle(), LossDataSink(), save(), saveASCII(), and saveH5().

ElementBase::ElementType LossDataSink::type_m
private

Definition at line 170 of file LossDataSink.h.

std::vector<double> LossDataSink::x_m
private
std::vector<double> LossDataSink::y_m
private

Definition at line 152 of file LossDataSink.h.

Referenced by addParticle(), computeSetStatistics(), LossDataSink(), save(), saveASCII(), and saveH5().

std::vector<double> LossDataSink::z_m
private

Definition at line 153 of file LossDataSink.h.

Referenced by addParticle(), computeSetStatistics(), LossDataSink(), save(), saveASCII(), and saveH5().


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