Commit 60b2bf98 authored by frey_m's avatar frey_m

replace 'data/' with OpalData::getInstance()->getAuxiliaryOutputDirectory()"

parent dfea7a71
......@@ -9,6 +9,7 @@
#include <fstream>
#include <iostream>
#include <string>
extern Inform *gmsg;
......@@ -130,7 +131,11 @@ double CavityAutophaser::getPhaseAtMaxEnergy(const Vector_t &R,
auto opal = OpalData::getInstance();
if (!opal->isOptimizerRun()) {
std::ofstream out("data/" + itsCavity_m->getName() + "_AP.dat");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
itsCavity_m->getName() + "_AP.dat"
});
std::ofstream out(fname);
track(initialR_m, initialP_m, t + tErr, dt, newPhase, &out);
out.close();
} else {
......
......@@ -10,6 +10,7 @@
#include "AbsBeamline/Bend2D.h"
#include "Physics/Physics.h"
#include "Structure/ElementPositionWriter.h"
#include "Utilities/Util.h"
extern Inform *gmsg;
......@@ -275,7 +276,10 @@ void IndexMap::saveSDDS(double initialPathLength) const {
sectors.insert(sectors.end(), tmp.begin(), tmp.end());
}
std::string fileName("data/" + OpalData::getInstance()->getInputBasename() + "_ElementPositions.sdds");
std::string fileName = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_ElementPositions.sdds"
});
ElementPositionWriter writer(fileName);
for (auto sector: sectors) {
......
......@@ -48,7 +48,10 @@ OrbitThreader::OrbitThreader(const PartData &ref,
{
auto opal = OpalData::getInstance();
if (Ippl::myNode() == 0 && !opal->isOptimizerRun()) {
std::string fileName = "data/" + OpalData::getInstance()->getInputBasename() + "_DesignPath.dat";
std::string fileName = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_DesignPath.dat"
});
if (OpalData::getInstance()->getOpenMode() == OpalData::OPENMODE::WRITE ||
!boost::filesystem::exists(fileName)) {
logger_m.open(fileName);
......
......@@ -71,7 +71,8 @@ AmrYtWriter::AmrYtWriter(int step, int bin)
namespace fs = boost::filesystem;
fs::path dir = OpalData::getInstance()->getInputBasename();
boost::filesystem::path path = dir.parent_path() / "data" / "amr" / "yt";
std::string dataDir = OpalData::getInstance()->getAuxiliaryOutputDirectory();
boost::filesystem::path path = dir.parent_path() / dataDir / "amr" / "yt";
dir_m = amrex::Concatenate((path / "plt").string(), step, 10);
dir_m += "-";
dir_m = amrex::Concatenate(dir_m, bin, 3);
......
......@@ -510,7 +510,11 @@ void Bend2D::calculateRefTrajectory(double &angleX, double &/*angleY*/) {
std::ofstream trajectoryOutput;
if (Options::writeBendTrajectories && Ippl::myNode() == 0) {
trajectoryOutput.open("data/" + OpalData::getInstance()->getInputBasename() + "_" + getName() + "_traj.dat");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_" + getName() + "_traj.dat"
});
trajectoryOutput.open(fname);
trajectoryOutput.precision(12);
trajectoryOutput << "# " << std::setw(18) << "s"
<< std::setw(20) << "x"
......@@ -1370,7 +1374,11 @@ std::vector<Vector_t> Bend2D::getOutline() const {
std::ofstream outlineOutput;
if (Options::writeBendTrajectories && Ippl::myNode() == 0) {
outlineOutput.open("data/" + OpalData::getInstance()->getInputBasename() + "_" + getName() + "_outline.dat");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_" + getName() + "_outline.dat"
});
outlineOutput.open(fname);
outlineOutput.precision(8);
for (auto a: outline) {
......
......@@ -25,6 +25,7 @@
//
#include "AbsBeamline/Cyclotron.h"
#include "AbstractObjects/OpalData.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunchBase.h"
#include "Fields/Fieldmap.h"
......@@ -33,6 +34,7 @@
#include "TrimCoils/TrimCoil.h"
#include "Utilities/Options.h"
#include "Utilities/GeneralClassicException.h"
#include "Utilities/Util.h"
#include <fstream>
#include <cstring>
......@@ -1164,7 +1166,11 @@ void Cyclotron::getFieldFromFile_FFA(const double &/*scaleFactor*/) {
int count = 0;
if ((Ippl::getNodes()) == 1 && Options::info) {
std::fstream fp;
fp.open("data/gnu.out", std::ios::out);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"gnu.out"
});
fp.open(fname, std::ios::out);
for (int r = 0; r < Bfield.nrad; r++) {
for (int k = 0; k < Bfield.ntet; k++) {
......@@ -1255,8 +1261,13 @@ void Cyclotron::getFieldFromFile_AVFEQ(const double &scaleFactor) {
*gmsg << "* Rescaling of the magnetic fields with factor: " << BP.Bfact << endl;
std::fstream fp;
if ((Ippl::getNodes()) == 1 && Options::info)
fp.open("data/gnu.out", std::ios::out);
if ((Ippl::getNodes()) == 1 && Options::info) {
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"gnu.out"
});
fp.open(fname, std::ios::out);
}
double tmp;
int count = 0;
......@@ -1344,8 +1355,16 @@ void Cyclotron::getFieldFromFile_Carbon(const double &scaleFactor) {
if ((Ippl::getNodes()) == 1 && Options::info) {
std::fstream fp1, fp2;
fp1.open("data/gnu.out", std::ios::out);
fp2.open("data/eb.out", std::ios::out);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"gnu.out"
});
fp1.open(fname, std::ios::out);
fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"eb.out"
});
fp2.open(fname, std::ios::out);
for (int i = 0; i < Bfield.nrad; i++) {
for (int k = 0; k < Bfield.ntet; k++) {
fp1 << BP.rmin + (i * BP.delr) << " \t "
......
......@@ -258,11 +258,16 @@ void FlexibleCollimator::setDescription(const std::string &desc) {
void FlexibleCollimator::writeHolesAndQuadtree(const std::string &baseFilename) const {
if (Ippl::myNode() == 0) {
std::ofstream out("data/" + baseFilename + "_quadtree.gpl");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
baseFilename
});
std::ofstream out(fname + "_quadtree.gpl");
tree_m.writeGnuplot(out);
out.close();
out.open("data/" + baseFilename + "_holes.gpl");
out.open(fname + "_holes.gpl");
for (const std::shared_ptr<mslang::Base> &obj: holes_m) {
obj->writeGnuplot(out);
}
......
......@@ -22,6 +22,7 @@
#include "Utilities/Options.h"
#include "Structure/MeshGenerator.h"
#include "Physics/Physics.h"
#include "Utilities/Util.h"
#include <iostream>
#include <fstream>
......@@ -273,7 +274,11 @@ double RBend3D::trackRefParticleThrough(double dt, bool print) {
std::ofstream trajectoryOutput;
if (print) {
trajectoryOutput.open("data/" + OpalData::getInstance()->getInputBasename() + "_" + getName() + "_traj.dat");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_" + getName() + "_traj.dat"
});
trajectoryOutput.open(fname);
trajectoryOutput.precision(12);
trajectoryOutput << "# " << std::setw(18) << "s"
<< std::setw(20) << "x"
......
......@@ -2118,14 +2118,6 @@ void PartBunchBase<T, Dim>::setup(AbstractParticle<T, Dim>* pb) {
globalPartPerNode_m = std::unique_ptr<size_t[]>(new size_t[Ippl::getNodes()]);
pmsg_m.release();
// f_stream.release();
/*
if(Ippl::getNodes() == 1) {
f_stream = std::unique_ptr<ofstream>(new ofstream);
f_stream->open("data/dist.dat", ios::out);
pmsg_m = std::unique_ptr<Inform>(new Inform(0, *f_stream, 0));
}
*/
// set the default IPPL behaviour
setMinimumNumberOfParticlesPerCore(0);
......
......@@ -370,7 +370,11 @@ void FM3DDynamic::getOnaxisEz(std::vector<std::pair<double, double> > & F) {
auto opal = OpalData::getInstance();
if (opal->isOptimizerRun()) return;
std::ofstream out("data/" + Filename_m);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
Filename_m
});
std::ofstream out(fname);
for(unsigned int i = 0; i < num_gridpz_m; ++ i) {
Vector_t R(0,0,zbegin_m + F[i].first), B(0.0), E(0.0);
getFieldstrength(R, E, B);
......
......@@ -150,8 +150,6 @@ void FM3DMagnetoStaticExtended::readMap() {
smoothData(FieldstrengthBy_m, j);
}
// saveField("data/" + Filename_m + ".ext", num_gridpy_m - 1);
INFOMSG(level3 << typeset_msg("read in fieldmap '" + Filename_m + "'", "info") << endl);
}
}
......
......@@ -25,6 +25,7 @@
#include "Fields/FMDummy.h"
#include "Utilities/GeneralClassicException.h"
#include "Utilities/Options.h"
#include "Utilities/Util.h"
#include "AbstractObjects/OpalData.h"
#include "Physics/Physics.h"
......@@ -473,7 +474,11 @@ void Fieldmap::checkMap(unsigned int accuracy,
auto opal = OpalData::getInstance();
std::ofstream out;
if (Ippl::myNode() == 0 && !opal->isOptimizerRun()) {
out.open("data/" + Filename_m.substr(lastSlash, lastDot) + ".check");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
Filename_m.substr(lastSlash, lastDot) + ".check"
});
out.open(fname);
out << "# z original reproduced\n";
}
auto it = zSampling.begin();
......@@ -623,7 +628,9 @@ void Fieldmap::lowResolutionWarning(double squareError, double maxError) {
<< "the ratio (max_i(|e_i - E_i|) / max_i(|E_i|) is " << std::to_string(maxError) << ".\n"
<< "Here E_i is the field as in the field map and e_i is the reconstructed field.\n"
<< "The lower limit for the two ratios is 1e-2\n"
<< "Have a look into the directory data/ for a reconstruction of the field map.\n";
<< "Have a look into the directory "
<< OpalData::getInstance()->getAuxiliaryOutputDirectory()
<< " for a reconstruction of the field map.\n";
std::string errormsg_str = typeset_msg(errormsg.str(), "warning");
ERRORMSG(errormsg_str << "\n" << endl);
......@@ -733,8 +740,12 @@ void Fieldmap::write3DField(unsigned int nx,
(ef.size() != numpoints && bf.size() != numpoints)) return;
size_t extensionStart = Filename_m.find_last_of('.');
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
Filename_m.substr(0,extensionStart) + ".vtk"
});
std::ofstream of;
of.open (std::string ("data/" + Filename_m.substr(0,extensionStart) + ".vtk").c_str ());
of.open (fname);
assert (of.is_open ());
of.precision (6);
......
#include "AbstractObjects/OpalData.h"
#include "Solvers/CSRIGFWakeFunction.hh"
#include "Solvers/RootFinderForCSR.h"
#include "Algorithms/PartBunchBase.h"
......@@ -88,8 +89,14 @@ void CSRIGFWakeFunction::apply(PartBunchBase<double, 3> *bunch) {
double spos = bunch->get_sPos();
if (Ippl::myNode() == 0) {
std::stringstream filename_str;
filename_str << "data/" << bendName_m << "-CSRWake" << std::setw(5) << std::setfill('0') << file_number << ".txt";
std::ofstream csr(filename_str.str().c_str());
filename_str << bendName_m << "-CSRWake" << std::setw(5) << std::setfill('0') << file_number << ".txt";
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
filename_str.str()
});
std::ofstream csr(fname);
csr << spos << ", " << FieldBegin_m << ", " << smin(2) << ", " << smax(2) << ", " << meshSpacing*64 << std::endl;
for (unsigned int i = 0; i < lineDensity_m.size(); ++ i) {
csr << i *meshSpacing << "\t"
......@@ -97,7 +104,7 @@ void CSRIGFWakeFunction::apply(PartBunchBase<double, 3> *bunch) {
<< lineDensity_m[i] << std::endl;
}
csr.close();
msg << "** wrote " << filename_str.str() << endl;
msg << "** wrote " << fname << endl;
}
++ file_number;
}
......
#include "Solvers/CSRWakeFunction.hh"
#include "Solvers/RootFinderForCSR.h"
#include "AbstractObjects/OpalData.h"
#include "Algorithms/PartBunchBase.h"
#include "Filters/Filter.h"
#include "Filters/SavitzkyGolay.h"
......@@ -91,9 +92,13 @@ void CSRWakeFunction::apply(PartBunchBase<double, 3> *bunch) {
if (counter == 0) file_number = 0;
if (Ippl::myNode() == 0) {
std::stringstream filename_str;
filename_str << "data/" << bendName_m << "-CSRWake" << std::setw(5) << std::setfill('0') << file_number << ".txt";
filename_str << bendName_m << "-CSRWake" << std::setw(5) << std::setfill('0') << file_number << ".txt";
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
filename_str.str()
});
std::ofstream csr(filename_str.str().c_str());
std::ofstream csr(fname);
csr << std::setprecision(8);
csr << "# " << sPos + smin(2) - FieldBegin_m << "\t" << sPos + smax(2) - FieldBegin_m << std::endl;
for (unsigned int i = 0; i < lineDensity_m.size(); ++ i) {
......@@ -103,7 +108,7 @@ void CSRWakeFunction::apply(PartBunchBase<double, 3> *bunch) {
<< dlineDensitydz_m[i] << std::endl;
}
csr.close();
msg << "** wrote " << filename_str.str() << endl;
msg << "** wrote " << fname << endl;
}
++ file_number;
}
......
......@@ -4,6 +4,7 @@
#include "AbsBeamline/Bend2D.h"
#include "AbsBeamline/RBend3D.h"
#include "AbsBeamline/Multipole.h"
#include "AbstractObjects/OpalData.h"
#include <iostream>
#include <fstream>
......@@ -100,7 +101,11 @@ void MeshGenerator::add(const ElementBase &element) {
#include <boost/iostreams/filter/zlib.hpp>
void MeshGenerator::write(const std::string &fname) {
std::ofstream out("data/" + fname + "_ElementPositions.py");
std::string filename = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
fname + "_ElementPositions.py"
});
std::ofstream out(filename);
const char *buffer;
const std::string indent(" ");
......
......@@ -452,7 +452,7 @@ bool ClosedOrbitFinder<Value_type, Size_type, Stepper>::findOrbit(value_type acc
namespace fs = boost::filesystem;
fs::path dir = OpalData::getInstance()->getInputBasename();
dir = dir.parent_path() / "data";
dir = dir.parent_path() / OpalData::getInstance()->getAuxiliaryOutputDirectory();
std::string tunefile = (dir / "tunes.dat").string();
if ( isTuneMode ) {
......
......@@ -4104,7 +4104,11 @@ void Distribution::writeOutFileHeader() {
if (Ippl::myNode() != 0)
return;
std::string fname = "data/" + OpalData::getInstance()->getInputBasename() + "_" + getOpalName() + ".dat";
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_" + getOpalName() + ".dat"
});
*gmsg << "\n"
<< std::left << std::setw(84) << std::setfill('*') << "* " << "\n"
<< "* Write initial distribution to file \"" << fname << "\"\n"
......@@ -4204,7 +4208,13 @@ void Distribution::writeOutFileEmission() {
Ippl::Comm->raw_send(&(msgbuf[0]), totalSendBits, 0, tag);
}
} else {
std::string fname = "data/" + OpalData::getInstance()->getInputBasename() + "_" + getOpalName() + ".dat";
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_" + getOpalName() + ".dat"
});
std::ofstream outputFile(fname, std::fstream::app);
if (outputFile.bad()) {
ERRORMSG(level1 << "Unable to write to file \"" << fname << "\"" << endl);
......@@ -4280,7 +4290,10 @@ void Distribution::writeOutFileInjection() {
if (Attributes::getBool(itsAttr[Attrib::Distribution::WRITETOFILE]) == false)
return;
std::string fname = "data/" + OpalData::getInstance()->getInputBasename() + "_" + getOpalName() + ".dat";
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_" + getOpalName() + ".dat"
});
// Nodes take turn writing particles to file.
for (int nodeIndex = 0; nodeIndex < Ippl::getNodes(); nodeIndex++) {
......
......@@ -10,16 +10,19 @@
//
// ------------------------------------------------------------------------
#include "AbstractObjects/OpalData.h"
#include "Distribution/LaserProfile.h"
#include "Utility/Inform.h"
#include "Utilities/OpalException.h"
#include "Utilities/PortableGraymapReader.h"
#include "Utilities/Util.h"
#include <boost/filesystem.hpp>
#include <fstream>
#include <iostream>
#include <cmath>
#include <cstdio>
//#define TESTLASEREMISSION
......@@ -332,7 +335,12 @@ void LaserProfile::printInfo() {
}
void LaserProfile::saveData(const std::string &fname, unsigned short *image) {
std::ofstream out("data/" + fname + ".pgm");
std::ofstream out(
Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
fname + ".pgm"}
));
out << "P2" << std::endl;
out << sizeX_m << " " << sizeY_m << std::endl;
out << getProfileMax(image) << std::endl;
......@@ -346,13 +354,22 @@ void LaserProfile::saveData(const std::string &fname, unsigned short *image) {
}
void LaserProfile::saveHistogram() {
FILE *fh = fopen("data/LaserHistogram.dat", "w");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"LaserHistogram.dat"
});
FILE *fh = std::fopen(fname.c_str(), "w");
gsl_histogram2d_fprintf(fh, hist2d_m, "%g", "%g");
fclose(fh);
std::fclose(fh);
}
void LaserProfile::sampleDist() {
std::ofstream fh("data/LaserEmissionSampled.dat");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"LaserEmissionSampled.dat"
});
std::ofstream fh(fname);
double x, y;
for(int i = 0; i < 1000000; i++) {
......
......@@ -49,6 +49,7 @@
#include "Utilities/Options.h"
#include "Utilities/Options.h"
#include "Utilities/OpalException.h"
#include "Utilities/Util.h"
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
......@@ -532,9 +533,26 @@ template<typename Value_type, typename Size_type>
std::string energy = float2string(E_m);
writeMturn.open("data/OneTurnMapForEnergy"+energy+"MeV.dat",std::ios::app);
writeMsc.open("data/SpaceChargeMapPerAngleForEnergy"+energy+"MeV.dat",std::ios::app);
writeMcyc.open("data/CyclotronMapPerAngleForEnergy"+energy+"MeV.dat",std::ios::app);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"OneTurnMapForEnergy" + energy + "MeV.dat"
});
writeMturn.open(fname, std::ios::app);
fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"SpaceChargeMapPerAngleForEnergy" + energy + "MeV.dat"
});
writeMsc.open(fname, std::ios::app);
fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"CyclotronMapPerAngleForEnergy" + energy + "MeV.dat"
});
writeMcyc.open(fname, std::ios::app);
writeMturn << "--------------------------------" << std::endl;
writeMturn << "Iteration: 0 " << std::endl;
......@@ -663,7 +681,12 @@ template<typename Value_type, typename Size_type>
if ( converged_m && write_m ) {
// write tunes
std::ofstream writeSigmaMatched("data/MatchedDistributions.dat", std::ios::app);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"MatchedDistributions.dat"
});
std::ofstream writeSigmaMatched(fname, std::ios::app);
std::array<double,3> emit = this->getEmittances();
......@@ -1041,8 +1064,14 @@ void SigmaGenerator<Value_type, Size_type>::initialize(value_type nuz,
if (write_m) {
std::string energy = float2string(E_m);
std::ofstream writeInit("data/maps/InitialSigmaPerAngleForEnergy" +
energy + "MeV.dat", std::ios::app);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"maps",
"InitialSigmaPerAngleForEnergy" + energy + "MeV.dat"
});
std::ofstream writeInit(fname, std::ios::app);
writeInit << sigma << std::endl;
writeInit.close();
}
......@@ -1106,8 +1135,14 @@ SigmaGenerator<Value_type, Size_type>::updateInitialSigma(const matrix_type& /*M
if (write_m) {
std::string energy = float2string(E_m);
std::ofstream writeSigma("data/maps/SigmaPerAngleForEnergy" +
energy + "MeV.dat", std::ios::app);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"maps",
"SigmaPerAngleForEnergy" + energy + "MeV.dat"
});
std::ofstream writeSigma(fname, std::ios::app);
writeSigma << "--------------------------------" << std::endl;
writeSigma << "Iteration: " << niterations_m + 1 << std::endl;
......@@ -1130,7 +1165,14 @@ void SigmaGenerator<Value_type, Size_type>::updateSigma(const std::vector<matrix
if (write_m) {
std::string energy = float2string(E_m);
writeSigma.open("data/maps/SigmaPerAngleForEnergy"+energy+"MeV.dat",std::ios::app);
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"maps",
"SigmaPerAngleForEnergy" + energy + "MeV.dat"
});
writeSigma.open(fname,std::ios::app);
}
// initial sigma is already computed
......@@ -1203,8 +1245,13 @@ void SigmaGenerator<Value_type, Size_type>::writeOrbitOutput_m(
const container_type& fidx_turn,
const container_type& ds_turn)
{
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"Tunes.dat"
});
// write tunes
std::ofstream writeTunes("data/Tunes.dat", std::ios::app);
std::ofstream writeTunes(fname, std::ios::app);
if(writeTunes.tellp() == 0) // if nothing yet written --> write description
writeTunes << "energy [MeV]" << std::setw(15)
......@@ -1216,7 +1263,11 @@ void SigmaGenerator<Value_type, Size_type>::writeOrbitOutput_m(
<< tunes.second << std::endl;
// write average radius
std::ofstream writeAvgRadius("data/AverageValues.dat", std::ios::app);
fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"AverageValues.dat"
});
std::ofstream writeAvgRadius(fname, std::ios::app);
if (writeAvgRadius.tellp() == 0) // if nothing yet written --> write description
writeAvgRadius << "energy [MeV]" << std::setw(15)
......@@ -1230,7 +1281,11 @@ void SigmaGenerator<Value_type, Size_type>::writeOrbitOutput_m(
<< peo[0] << std::endl;
// write frequency error
std::ofstream writePhase("data/FrequencyError.dat",std::ios::app);
fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"FrequencyError.dat"
});
std::ofstream writePhase(fname, std::ios::app);
if(writePhase.tellp() == 0) // if nothing yet written --> write description
writePhase << "energy [MeV]" << std::setw(15)
......@@ -1241,7 +1296,11 @@ void SigmaGenerator<Value_type, Size_type>::writeOrbitOutput_m(
// write other properties
std::string energy = float2string(E_m);
std::ofstream writeProperties("data/PropertiesForEnergy"+energy+"MeV.dat", std::ios::out);
fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
"PropertiesForEnergy" + energy + "MeV.dat"
});
std::ofstream writeProperties(fname, std::ios::out);
writeProperties << std::left
<< std::setw(25) << "orbit radius"
<< std::setw(25) << "orbit momentum"
......
......@@ -361,7 +361,10 @@ void OpalBeamline::save3DLattice() {
FieldList::iterator end = elements_m.end();
std::ofstream pos;
std::string fileName = "data/" + OpalData::getInstance()->getInputBasename() + "_ElementPositions.txt";
std::string fileName = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_ElementPositions.txt"
});
if (OpalData::getInstance()->getOpenMode() == OpalData::OPENMODE::APPEND &&
boost::filesystem::exists(fileName)) {
pos.open(fileName, std::ios_base::app);
......@@ -516,7 +519,11 @@ void OpalBeamline::save3DInput() {
FieldList::iterator end = elements_m.end();
std::string input = parseInput();
std::ofstream pos("data/" + OpalData::getInstance()->getInputBasename() + "_3D.opal");
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_3D.opal"
});
std::ofstream pos(fname);
for (; it != end; ++ it) {
std::string element = (*it).getElement()->getName();
......
......@@ -18,6 +18,7 @@
#include "Elements/OpalBeamline.h"
#include "Utilities/Options.h"
#include "Utilities/OpalException.h"
#include "Utilities/Util.h"
#include <gsl/gsl_sys.h>
extern Inform* gmsg;
......@@ -98,7 +99,11 @@ static void write_voxel_mesh (
/*----------------------------------------------------------------------*/
const size_t numpoints = 8 * ids.size ();