Commit 08b07e10 authored by kraus's avatar kraus
Browse files

Merge branch 'iostream_instances_not_movable_in_old_gcc' into 'master'

iostream instances aren't movable in older gcc.

See merge request OPAL/src!73
parents 9bb22a86 8b8cbd64
......@@ -246,9 +246,9 @@ void ParallelCyclotronTracker::bgf_main_collision_test() {
*
* @param fn Base file name
*/
void ParallelCyclotronTracker::openFiles(std::string SfileName) {
void ParallelCyclotronTracker::openFiles(size_t numFiles, std::string SfileName) {
for (unsigned int i=0; i<outfTheta_m.size(); i++) {
for (unsigned int i=0; i<numFiles; i++) {
std::string SfileName2 = SfileName;
if (i<=2) {
SfileName2 += std::string("-Angle" + std::to_string(int(i)) + ".dat");
......@@ -258,12 +258,12 @@ void ParallelCyclotronTracker::openFiles(std::string SfileName) {
SfileName2 += std::string("-afterEachTurn.dat");
}
outfTheta_m[i].precision(8);
outfTheta_m[i].setf(std::ios::scientific, std::ios::floatfield);
outfTheta_m[i].open(SfileName2.c_str());
outfTheta_m[i] << "# r [mm] beta_r*gamma "
<< "theta [deg] beta_theta*gamma "
<< "z [mm] beta_z*gamma" << std::endl;
outfTheta_m.emplace_back(new std::ofstream(SfileName2.c_str()));
outfTheta_m.back()->precision(8);
outfTheta_m.back()->setf(std::ios::scientific, std::ios::floatfield);
*outfTheta_m.back() << "# r [mm] beta_r*gamma "
<< "theta [deg] beta_theta*gamma "
<< "z [mm] beta_z*gamma" << std::endl;
}
}
......@@ -274,7 +274,7 @@ void ParallelCyclotronTracker::openFiles(std::string SfileName) {
*/
void ParallelCyclotronTracker::closeFiles() {
for (auto & file : outfTheta_m) {
file.close();
file->close();
}
}
......@@ -2890,7 +2890,6 @@ std::tuple<double, double, double> ParallelCyclotronTracker::initializeTracking_
azimuth_angle_m[0] = 0.0;
azimuth_angle_m[1] = 22.5 * Physics::deg2rad;
azimuth_angle_m[2] = 45.0 * Physics::deg2rad;
outfTheta_m.resize(azimuth_angle_m.size() + 1); // 1 more for file after every turn
double harm = getHarmonicNumber();
double dt = itsBunch_m->getdT() * 1.0e9 * harm; // time step size (s --> ns)
......@@ -2973,7 +2972,7 @@ std::tuple<double, double, double> ParallelCyclotronTracker::initializeTracking_
"SINGLE PARTICLE MODE ONLY WORKS SERIALLY ON A SINGLE NODE!");
// For single particle mode open output files
openFiles(OpalData::getInstance()->getInputBasename());
openFiles(azimuth_angle_m.size() + 1, OpalData::getInstance()->getInputBasename());
break;
case MODE::BUNCH:
break;
......@@ -3327,16 +3326,16 @@ void ParallelCyclotronTracker::dumpAzimuthAngles_m(const double& t,
for (unsigned int i=0; i<=2; i++) {
if ((oldReferenceTheta < azimuth_angle_m[i] - setup_m.deltaTheta) &&
( temp_meanTheta >= azimuth_angle_m[i] - setup_m.deltaTheta)) {
outfTheta_m[i] << "#Turn number = " << turnnumber_m
<< ", Time = " << t << " [ns]" << std::endl
<< " " << std::hypot(R(0), R(1))
<< " " << P(0) * std::cos(temp_meanTheta) + P(1) * std::sin(temp_meanTheta)
<< " " << temp_meanTheta * Physics::rad2deg
<< " " << - P(0) * std::sin(temp_meanTheta) + P(1) * std::cos(temp_meanTheta)
<< " " << R(2)
<< " " << P(2) << std::endl;
*(outfTheta_m[i]) << "#Turn number = " << turnnumber_m
<< ", Time = " << t << " [ns]" << std::endl
<< " " << std::hypot(R(0), R(1))
<< " " << P(0) * std::cos(temp_meanTheta) + P(1) * std::sin(temp_meanTheta)
<< " " << temp_meanTheta * Physics::rad2deg
<< " " << - P(0) * std::sin(temp_meanTheta) + P(1) * std::cos(temp_meanTheta)
<< " " << R(2)
<< " " << P(2) << std::endl;
}
}
}
}
void ParallelCyclotronTracker::dumpThetaEachTurn_m(const double& t,
......@@ -3353,16 +3352,16 @@ void ParallelCyclotronTracker::dumpThetaEachTurn_m(const double& t,
*gmsg << "* SPT: Finished turn " << turnnumber_m - 1 << endl;
outfTheta_m[3] << "#Turn number = " << turnnumber_m
<< ", Time = " << t << " [ns]" << std::endl
<< " " << std::sqrt(R(0) * R(0) + R(1) * R(1))
<< " " << P(0) * std::cos(temp_meanTheta) +
P(1) * std::sin(temp_meanTheta)
<< " " << temp_meanTheta / Physics::deg2rad
<< " " << - P(0) * std::sin(temp_meanTheta) +
P(1) * std::cos(temp_meanTheta)
<< " " << R(2)
<< " " << P(2) << std::endl;
*(outfTheta_m[3]) << "#Turn number = " << turnnumber_m
<< ", Time = " << t << " [ns]" << std::endl
<< " " << std::sqrt(R(0) * R(0) + R(1) * R(1))
<< " " << P(0) * std::cos(temp_meanTheta) +
P(1) * std::sin(temp_meanTheta)
<< " " << temp_meanTheta / Physics::deg2rad
<< " " << - P(0) * std::sin(temp_meanTheta) +
P(1) * std::cos(temp_meanTheta)
<< " " << R(2)
<< " " << P(2) << std::endl;
}
}
......@@ -3595,4 +3594,4 @@ void ParallelCyclotronTracker::injectBunch_m(bool& flagTransition) {
// After this, numBunch_m is wrong but not needed anymore...
numBunch_m--;
}
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@
#include "AbsBeamline/ElementBase.h"
#include <vector>
#include <tuple>
#include <memory>
#include "Steppers/Steppers.h"
......@@ -326,11 +327,11 @@ private:
const size_t initialTotalNum_m;
/// output coordinates at different azimuthal angles and one after every turn
std::vector<std::ofstream> outfTheta_m;
std::vector<std::unique_ptr<std::ofstream> > outfTheta_m;
/// the different azimuthal angles for the outfTheta_m output files
std::vector<double> azimuth_angle_m;
///@ open / close output coordinate files
void openFiles(std::string fn);
void openFiles(size_t numFiles, std::string fn);
void closeFiles();
///@}
/// output file for six dimensional phase space
......@@ -563,4 +564,4 @@ inline
double ParallelCyclotronTracker::calculateAngle2(double x, double y)
{ return atan2(y,x); }
#endif // OPAL_ParallelCyclotronTracker_HH
#endif // OPAL_ParallelCyclotronTracker_HH
\ No newline at end of file
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