61 : isMultiBunch_m(false)
68 : isMultiBunch_m(numBunch > 1)
72 "Can not restart when HDF5 is disabled");
75 this->
init(restart, h5wrapper, numBunch);
83 :
DataSink(h5wrapper, false, numBunch)
95 double refPr,
double refPt,
double refPz,
96 double refR,
double refTheta,
double refZ,
97 double azimuth,
double elevation,
bool local)
const
101 return h5Writer_m->writePhaseSpace(beam, FDext, meanEnergy, refPr, refPt, refPz,
102 refR, refTheta, refZ, azimuth, elevation, local);
107 const double& azimuth)
const
114 const losses_t& losses,
const double& azimuth)
const
118 size_t npOutside = 0;
124 statWriter_m->write(beam, FDext, losses, azimuth, npOutside);
158 size_t numberOfFieldEmittedParticles,
bool nEmissionMode, std::string fn) {
162 double Npart_d = 0.0;
163 if (!nEmissionMode) {
171 std::string ffn = fn + std::string(
".dat");
176 fid << std::setiosflags(std::ios::scientific);
178 if (!nEmissionMode) {
181 fid <<
"#Time/ns" << std::setw(18) <<
"#Geometry impacts" << std::setw(18) <<
"tot_sey" << std::setw(18)
182 <<
"TotalCharge" << std::setw(18) <<
"PartNum" <<
" numberOfFieldEmittedParticles " <<
endl;
184 fid << t << std::setw(18) << impact << std::setw(18) << sey_num << std::setw(18) << charge
185 << std::setw(18) << Npart_d << std::setw(18) << numberOfFieldEmittedParticles <<
endl;
189 fid <<
"#Time/ns" << std::setw(18) <<
"#Geometry impacts" << std::setw(18) <<
"tot_sey" << std::setw(18)
190 <<
"ParticleNumber" <<
" numberOfFieldEmittedParticles " <<
endl;
192 fid << t << std::setw(18) << impact << std::setw(18) << sey_num
193 << std::setw(18) << double(Npart) << std::setw(18) << numberOfFieldEmittedParticles <<
endl;
204 for (
short b = 0; b < mbhandler_p->
getNumBunch(); ++b) {
221 for (
short b = 0; b < mbhandler_p->
getNumBunch(); ++b) {
235 unsigned int linesToRewind = 0;
246 for (std::vector<mbWriter_t>::reverse_iterator rit =
mbWriter_m.rbegin();
249 if ((*rit)->exists()) {
250 linesToRewind = (*rit)->rewindToSpos(spos);
251 (*rit)->replaceVersionString();
262 if ( linesToRewind > 0 ) {
317 while (bunch < numBunch) {
318 std::string fname = fn + std::string(
"-bunch-") +
static OpalData * getInstance()
void initMultiBunchDump(short numBunch)
std::unique_ptr< SDDSWriter > sddsWriter_t
bool enableHDF5
If true HDF5 files are written.
statWriter_t statWriter_m
DataSink()
Default constructor.
short getNumBunch() const
bool inRestartRun()
true if we do a restart run
void calcBeamParameters()
Vector_t get_rrms() const
bool enableVTK
If true VTK files are written.
Inform & endl(Inform &inf)
IpplTimings::TimerRef StatMarkerTimer_m
Timer to track statistics write time.
void storeCavityInformation()
Write cavity information from H5 file.
void setMultiBunchInitialPathLengh(MultiBunchHandler *mbhandler_p)
static void startTimer(TimerRef t)
void writeImpactStatistics(const PartBunchBase< double, 3 > *beam, long long int &step, size_t &impact, double &sey_num, size_t numberOfFieldEmittedParticles, bool nEmissionMode, std::string fn)
void writeMultiBunchStatistics(PartBunchBase< double, 3 > *beam, MultiBunchHandler *mbhandler)
unsigned int lossWrCounter_m
needed to create index for vtk file
std::vector< mbWriter_t > mbWriter_m
size_t getTotalNum() const
The base class for all OPAL exceptions.
std::vector< sddsWriter_t > sddsWriter_m
bool calcBunchBeamParameters(PartBunchBase< double, 3 > *beam, short bunchNr)
static std::string convertToString(int number, int setw=5)
void dumpH5(PartBunchBase< double, 3 > *beam, Vector_t FDext[]) const
std::unique_ptr< H5Writer > h5Writer_t
void writeGeomToVtk(BoundaryGeometry &bg, const std::string &fn)
void init(bool restart=false, H5PartWrapper *h5wrapper=nullptr, short numBunch=1)
beaminfo_t & getBunchInfo(short bunchNr)
double getChargePerParticle() const
get the macro particle charge
void dumpSDDS(PartBunchBase< double, 3 > *beam, Vector_t FDext[], const double &azimuth=-1) const
bool amr
Enable AMR if true.
void gatherLoadBalanceStatistics()
std::unique_ptr< MultiBunchDump > mbWriter_t
std::string getInputBasename()
get input file name without extension
void changeH5Wrapper(H5PartWrapper *h5wrapper)
static TimerRef getTimer(const char *nm)
double getCharge() const
get the total charge per simulation particle
StatWriter::losses_t losses_t
const bool isMultiBunch_m
size_t calcNumPartsOutside(Vector_t x)
returns the number of particles outside of a box defined by x
static void stopTimer(TimerRef t)
void writeGeomToVtk(std::string fn)
std::unique_ptr< StatWriter > statWriter_t