|
OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
|
#include <LossDataSink.h>
Public Member Functions | |
| LossDataSink ()=default | |
| LossDataSink (const std::string &outfn, bool hdf5Save, CollectionType=CollectionType::TEMPORAL) | |
| LossDataSink (const LossDataSink &rsh) | |
| ~LossDataSink () noexcept(false) | |
| bool | inH5Mode () |
| bool | save (unsigned int numSets=1, OpalData::OpenMode openMode=OpalData::OpenMode::UNDEFINED) |
| Returns whether the file was written; false (on all ranks) if there was nothing to save. | |
| void | addReferenceParticle (const Vector_t &x, const Vector_t &p, double time, double spos, long long globalTrackStep) |
| void | addParticle (const OpalParticle &, const std::optional< std::pair< int, short int > > &turnBunchNumPair=std::nullopt) |
| std::size_t | size () const |
| std::set< SetStatistics > | computeStatistics (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 () const |
| bool | hasTurnInformations () const |
| 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 | fileName_m |
| bool | h5hut_mode_m |
| std::ofstream | os_m |
| h5_file_t | H5file_m |
| used to write out data in H5hut mode | |
| std::string | outputName_m |
| h5_int64_t | H5call_m |
| Current record, or time step, of H5 file. | |
| std::vector< OpalParticle > | particles_m |
| std::vector< std::size_t > | bunchNumber_m |
| std::vector< std::size_t > | turnNumber_m |
| std::vector< Vector_t > | RefPartR_m |
| std::vector< Vector_t > | RefPartP_m |
| std::vector< h5_int64_t > | globalTrackStep_m |
| std::vector< double > | refTime_m |
| std::vector< double > | spos_m |
| std::vector< unsigned long > | startSet_m |
| CollectionType | collectionType_m |
Definition at line 80 of file LossDataSink.h.
|
default |
| LossDataSink::LossDataSink | ( | const std::string & | outfn, |
| bool | hdf5Save, | ||
| CollectionType | collectionType = CollectionType::TEMPORAL |
||
| ) |
Definition at line 192 of file LossDataSink.cpp.
References OpalData::APPEND, bunchNumber_m, OpalData::checkAndAddOutputFileName(), Options::enableHDF5, OpalData::getInstance(), h5hut_mode_m, outputName_m, particles_m, OpalData::setOpenMode(), and turnNumber_m.

| LossDataSink::LossDataSink | ( | const LossDataSink & | rsh | ) |
Definition at line 216 of file LossDataSink.cpp.
References bunchNumber_m, particles_m, and turnNumber_m.
| LossDataSink::~LossDataSink | ( | ) |
Definition at line 232 of file LossDataSink.cpp.
References CLOSE_FILE, and H5file_m.
| void LossDataSink::addParticle | ( | const OpalParticle & | , |
| const std::optional< std::pair< int, short int > > & | turnBunchNumPair = std::nullopt |
||
| ) |
Definition at line 326 of file LossDataSink.cpp.
References bunchNumber_m, particles_m, and turnNumber_m.
Referenced by Ring::apply().
| void LossDataSink::addReferenceParticle | ( | const Vector_t & | x, |
| const Vector_t & | p, | ||
| double | time, | ||
| double | spos, | ||
| long long | globalTrackStep | ||
| ) |
Definition at line 317 of file LossDataSink.cpp.
References globalTrackStep_m, RefPartP_m, RefPartR_m, refTime_m, and spos_m.
|
inlineprivate |
Definition at line 115 of file LossDataSink.h.
References fileName_m, IpplInfo::myNode(), and os_m.
Referenced by save().

|
inlineprivate |
Definition at line 127 of file LossDataSink.h.
References IpplInfo::myNode(), and os_m.
Referenced by save().

|
private |
Definition at line 717 of file LossDataSink.cpp.
References allreduce(), SetStatistics::eps2_m, SetStatistics::eps_norm_m, SetStatistics::fac_m, OpalParticle::getPx(), OpalParticle::getPy(), OpalParticle::getPz(), OpalParticle::getTime(), OpalParticle::getX(), OpalParticle::getY(), OpalParticle::getZ(), SetStatistics::nTotal_m, SetStatistics::outputName_m, outputName_m, particles_m, SetStatistics::pmean_m, SetStatistics::prms_m, SetStatistics::psqsum_m, SetStatistics::RefPartP_m, RefPartP_m, SetStatistics::RefPartR_m, RefPartR_m, SetStatistics::refTime_m, refTime_m, SetStatistics::rmax_m, SetStatistics::rmean_m, SetStatistics::rmin_m, SetStatistics::rprms_m, SetStatistics::rpsum_m, SetStatistics::rrms_m, SetStatistics::rsqsum_m, SetStatistics::spos_m, spos_m, startSet_m, Util::KahanAccumulation::sum, SetStatistics::tmean_m, and SetStatistics::trms_m.
Referenced by computeStatistics().

|
inline |
Definition at line 179 of file LossDataSink.h.
References computeSetStatistics(), and splitSets().

|
private |
Definition at line 403 of file LossDataSink.cpp.
References particles_m, and reduce().
Referenced by save().

|
private |
Definition at line 411 of file LossDataSink.cpp.
References allreduce(), and turnNumber_m.
Referenced by saveASCII(), saveH5(), and writeHeaderASCII().

|
inline |
Definition at line 90 of file LossDataSink.h.
References h5hut_mode_m.
|
inlineprivate |
Definition at line 108 of file LossDataSink.h.
References fileName_m, IpplInfo::myNode(), and os_m.
Referenced by save().

|
private |
Definition at line 239 of file LossDataSink.cpp.
References fileName_m, IpplInfo::getComm(), and OPEN_FILE.
Referenced by save().

|
private |
| bool LossDataSink::save | ( | unsigned int | numSets = 1, |
| OpalData::OpenMode | openMode = OpalData::OpenMode::UNDEFINED |
||
| ) |
Returns whether the file was written; false (on all ranks) if there was nothing to save.
clear and return memory
Definition at line 341 of file LossDataSink.cpp.
References appendASCII(), Communicate::barrier(), bunchNumber_m, CLOSE_FILE, closeASCII(), IpplInfo::Comm, endl(), fileName_m, GET_NUM_STEPS, OpalData::getInstance(), OpalData::getOpenMode(), globalTrackStep_m, gmsg, H5file_m, h5hut_mode_m, hasNoParticlesToDump(), level2(), openASCII(), openH5(), outputName_m, particles_m, RefPartP_m, RefPartR_m, refTime_m, saveASCII(), saveH5(), spos_m, turnNumber_m, OpalData::UNDEFINED, OpalData::WRITE, writeHeaderASCII(), and writeHeaderH5().
Referenced by Ring::finalise().

|
private |
Definition at line 557 of file LossDataSink.cpp.
References bunchNumber_m, IpplInfo::Comm, COMM_ANY_NODE, endl(), ERRORMSG, Message::get(), OpalParticle::getId(), IpplInfo::getNodes(), OpalParticle::getPx(), OpalParticle::getPy(), OpalParticle::getPz(), OpalParticle::getTime(), OpalParticle::getX(), OpalParticle::getY(), OpalParticle::getZ(), hasTurnInformations(), IPPL_APP_CYCLE, IPPL_APP_TAG3, TagMaker::next_tag(), os_m, particles_m, Message::put(), Communicate::receive_block(), Communicate::send(), and turnNumber_m.
Referenced by save().

|
private |
Set current record/time step.
Definition at line 419 of file LossDataSink.cpp.
References bunchNumber_m, DistributionMoments::compute(), Options::computePercentiles, DistributionMoments::get68Percentile(), DistributionMoments::get95Percentile(), DistributionMoments::get99_99Percentile(), DistributionMoments::get99Percentile(), OpalParticle::getCharge(), DistributionMoments::getGeometricEmittance(), OpalParticle::getId(), OpalParticle::getMass(), DistributionMoments::getMaxR(), DistributionMoments::getMeanKineticEnergy(), DistributionMoments::getMeanMomentum(), DistributionMoments::getMeanPosition(), DistributionMoments::getMeanTime(), IpplInfo::getNodes(), DistributionMoments::getNormalizedEmittance(), DistributionMoments::getNormalizedEmittance68Percentile(), DistributionMoments::getNormalizedEmittance95Percentile(), DistributionMoments::getNormalizedEmittance99_99Percentile(), DistributionMoments::getNormalizedEmittance99Percentile(), OpalParticle::getPx(), OpalParticle::getPy(), OpalParticle::getPz(), DistributionMoments::getStandardDeviationMomentum(), DistributionMoments::getStandardDeviationPosition(), DistributionMoments::getStdKineticEnergy(), DistributionMoments::getStdTime(), OpalParticle::getTime(), DistributionMoments::getTotalCharge(), DistributionMoments::getTotalMass(), OpalParticle::getX(), OpalParticle::getY(), OpalParticle::getZ(), globalTrackStep_m, H5call_m, hasTurnInformations(), IpplInfo::myNode(), particles_m, reduce(), RefPartP_m, RefPartR_m, refTime_m, SET_NUM_PARTICLES, SET_STEP, spos_m, startSet_m, turnNumber_m, WRITE_DATA_FLOAT64, WRITE_DATA_INT64, WRITE_STEPATTRIB_FLOAT64, and WRITE_STEPATTRIB_INT64.
Referenced by save().

|
inline |
Definition at line 174 of file LossDataSink.h.
References particles_m.
|
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.
| numSets | number of passes of the reference particle |
Definition at line 659 of file LossDataSink.cpp.
References allreduce(), particles_m, and startSet_m.
Referenced by computeStatistics().

|
private |
Definition at line 306 of file LossDataSink.cpp.
References hasTurnInformations(), IpplInfo::myNode(), and os_m.
Referenced by save().

|
private |
Definition at line 247 of file LossDataSink.cpp.
References collectionType_m, Options::computePercentiles, Util::getGitRevision(), TEMPORAL, and WRITE_FILEATTRIB_STRING.
Referenced by save().

|
private |
Definition at line 159 of file LossDataSink.h.
Referenced by addParticle(), LossDataSink(), LossDataSink(), save(), saveASCII(), and saveH5().
|
private |
Definition at line 170 of file LossDataSink.h.
Referenced by writeHeaderH5().
|
private |
Definition at line 141 of file LossDataSink.h.
Referenced by appendASCII(), openASCII(), openH5(), and save().
|
private |
Definition at line 164 of file LossDataSink.h.
Referenced by addReferenceParticle(), save(), and saveH5().
|
private |
Current record, or time step, of H5 file.
Definition at line 156 of file LossDataSink.h.
Referenced by saveH5().
|
private |
used to write out data in H5hut mode
Definition at line 150 of file LossDataSink.h.
Referenced by save(), and ~LossDataSink().
|
private |
Definition at line 144 of file LossDataSink.h.
Referenced by inH5Mode(), LossDataSink(), and save().
|
private |
Definition at line 147 of file LossDataSink.h.
Referenced by appendASCII(), closeASCII(), openASCII(), saveASCII(), and writeHeaderASCII().
|
private |
Definition at line 153 of file LossDataSink.h.
Referenced by computeSetStatistics(), LossDataSink(), and save().
|
private |
Definition at line 158 of file LossDataSink.h.
Referenced by addParticle(), computeSetStatistics(), hasNoParticlesToDump(), LossDataSink(), LossDataSink(), save(), saveASCII(), saveH5(), size(), and splitSets().
|
private |
Definition at line 163 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 162 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 165 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 166 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 168 of file LossDataSink.h.
Referenced by computeSetStatistics(), saveH5(), and splitSets().
|
private |
Definition at line 160 of file LossDataSink.h.
Referenced by addParticle(), hasTurnInformations(), LossDataSink(), LossDataSink(), save(), saveASCII(), and saveH5().