Commit 1c087b04 authored by kraus's avatar kraus

std::regex does not seem to work properly on merlin; switching to...

std::regex does not seem to work properly on merlin; switching to boost::regex; don't write to H5 file if there are no particles in the bunch
parent 0bcff536
......@@ -344,20 +344,21 @@ double AutophaseTracker::optimizeCavityPhase(const std::shared_ptr<Component> &c
}
}
}
Phimax = initialPhase;
Phimax = std::fmod(initialPhase, 2 * Physics::pi);
if(cavity->getType() == ElementBase::TRAVELINGWAVE) {
TravelingWave *element = static_cast<TravelingWave *>(cavity.get());
originalPhase = element->getPhasem();
element->updatePhasem(Phimax + originalPhase);
double newPhase = std::fmod(originalPhase + Phimax, 2 * Physics::pi);
element->updatePhasem(newPhase);
} else {
RFCavity *element = static_cast<RFCavity *>(cavity.get());
originalPhase = element->getPhasem();
element->updatePhasem(Phimax + originalPhase);
double newPhase = std::fmod(originalPhase + Phimax, 2 * Physics::pi);
element->updatePhasem(newPhase);
}
PhiAstra = (Phimax * Physics::rad2deg) + 90.0;
PhiAstra -= floor(PhiAstra / 360.) * 360.;
PhiAstra = std::fmod((Phimax * Physics::rad2deg) + 90.0, 360.0);
INFOMSG(cavity->getName() << "_phi = " << Phimax << " rad / "
<< Phimax *Physics::rad2deg << " deg, AstraPhi = " << PhiAstra << " deg,\n"
......
......@@ -18,9 +18,9 @@
#include "H5hut.h"
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
#include <queue>
#include <regex>
#include <sstream>
extern Inform *gmsg;
......@@ -1056,10 +1056,10 @@ unsigned int DataSink::rewindLinesSDDS(const std::string &fileName, double maxSP
unsigned int sposColumnNr = 0;
double spos, lastSPos = -1.0;
std::regex parameters("^&parameter name=");
std::regex column("^&column name=([a-zA-Z0-9\\$_]+),");
std::regex data("^&data mode=ascii");
std::smatch match;
boost::regex parameters("^&parameter name=");
boost::regex column("^&column name=([a-zA-Z0-9\\$_]+),");
boost::regex data("^&data mode=ascii");
boost::smatch match;
std::istringstream linestream;
fs.open (fileName.c_str(), std::fstream::in);
......@@ -1080,15 +1080,15 @@ unsigned int DataSink::rewindLinesSDDS(const std::string &fileName, double maxSP
line = allLines.front();
allLines.pop();
fs << line << "\n";
if (std::regex_search(line, match, parameters)) {
if (boost::regex_search(line, match, parameters)) {
++numParameters;
} else if (std::regex_search(line, match, column)) {
} else if (boost::regex_search(line, match, column)) {
++numColumns;
if (match[1] == "s") {
sposColumnNr = numColumns;
}
}
} while (!std::regex_search(line, match, data));
} while (!boost::regex_search(line, match, data));
for (unsigned int i = 0; i < numParameters; ++ i) {
fs << allLines.front() << "\n";
......
......@@ -268,6 +268,8 @@ void H5PartWrapperForPC::writeHeader() {
}
void H5PartWrapperForPC::writeStep(PartBunch& bunch, const std::map<std::string, double> &additionalStepAttributes) {
if (bunch.getTotalNum() == 0) return;
writeStepHeader(bunch, additionalStepAttributes);
writeStepData(bunch);
......
......@@ -226,6 +226,8 @@ void H5PartWrapperForPS::writeHeader() {
}
void H5PartWrapperForPS::writeStep(PartBunch& bunch, const std::map<std::string, double> &additionalStepAttributes) {
if (static_cast<EnvelopeBunch*>(&bunch)->getTotalNum() == 0) return;
writeStepHeader(bunch, additionalStepAttributes);
writeStepData(bunch);
}
......
......@@ -247,6 +247,8 @@ void H5PartWrapperForPT::writeHeader() {
}
void H5PartWrapperForPT::writeStep(PartBunch& bunch, const std::map<std::string, double> &additionalStepAttributes) {
if (bunch.getTotalNum() == 0) return;
writeStepHeader(bunch, additionalStepAttributes);
writeStepData(bunch);
}
......@@ -260,8 +262,6 @@ void H5PartWrapperForPT::writeStepHeader(PartBunch& bunch, const std::map<std::s
Vector_t rmax = bunch.get_maxExtend();
Vector_t centroid = bunch.get_centroid();
size_t numLocalParticles = bunch.getLocalNum();
Vector_t maxP(0.0);
Vector_t minP(0.0);
......@@ -293,7 +293,6 @@ void H5PartWrapperForPT::writeStepHeader(PartBunch& bunch, const std::map<std::s
/* ------------------------------------------------------------------------ */
REPORTONERROR(H5SetStep(file_m, numSteps_m));
REPORTONERROR(H5PartSetNumParticles(file_m, numLocalParticles));
char const *OPALFlavour = "opal-t";
WRITESTRINGSTEPATTRIB(file_m, "OPAL_flavour", OPALFlavour);
......@@ -381,6 +380,8 @@ void H5PartWrapperForPT::writeStepHeader(PartBunch& bunch, const std::map<std::s
void H5PartWrapperForPT::writeStepData(PartBunch& bunch) {
size_t numLocalParticles = bunch.getLocalNum();
REPORTONERROR(H5PartSetNumParticles(file_m, numLocalParticles));
std::vector<char> buffer(numLocalParticles * sizeof(h5_float64_t));
h5_float64_t *f64buffer = reinterpret_cast<h5_float64_t*>(&buffer[0]);
h5_int32_t *i32buffer = reinterpret_cast<h5_int32_t*>(&buffer[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment