Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 589c0ad2 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Merge branch '779-no-lbal-output-file-with-enable_amr' into 'master'

Resolve "No lbal output file with ENABLE_AMR"

Closes #779

See merge request OPAL/src!635
parents ffbef536 8d3079a2
No related branches found
No related tags found
No related merge requests found
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
#include "Utility/FieldDebugFunctions.h" #include "Utility/FieldDebugFunctions.h"
#ifdef __linux__ #ifdef __linux__
#include "MemoryProfiler.h" #include "Structure/MemoryProfiler.h"
#else #else
#include "MemoryWriter.h" #include "Structure/MemoryWriter.h"
#endif #endif
#ifdef ENABLE_AMR #ifdef ENABLE_AMR
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <sstream> #include <sstream>
DataSink::DataSink() DataSink::DataSink()
: isMultiBunch_m(false) : isMultiBunch_m(false)
{ {
...@@ -63,7 +64,7 @@ DataSink::DataSink() ...@@ -63,7 +64,7 @@ DataSink::DataSink()
} }
DataSink::DataSink(H5PartWrapper *h5wrapper, bool restart, short numBunch) DataSink::DataSink(H5PartWrapper* h5wrapper, bool restart, short numBunch)
: isMultiBunch_m(numBunch > 1) : isMultiBunch_m(numBunch > 1)
{ {
if (restart && !Options::enableHDF5) { if (restart && !Options::enableHDF5) {
...@@ -78,7 +79,7 @@ DataSink::DataSink(H5PartWrapper *h5wrapper, bool restart, short numBunch) ...@@ -78,7 +79,7 @@ DataSink::DataSink(H5PartWrapper *h5wrapper, bool restart, short numBunch)
} }
DataSink::DataSink(H5PartWrapper *h5wrapper, short numBunch) DataSink::DataSink(H5PartWrapper* h5wrapper, short numBunch)
: DataSink(h5wrapper, false, numBunch) : DataSink(h5wrapper, false, numBunch)
{ } { }
...@@ -90,7 +91,7 @@ void DataSink::dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[]) const { ...@@ -90,7 +91,7 @@ void DataSink::dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[]) const {
} }
int DataSink::dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[], double meanEnergy, int DataSink::dumpH5(PartBunchBase<double, 3>* beam, Vector_t FDext[], double meanEnergy,
double refPr, double refPt, double refPz, double refPr, double refPt, double refPz,
double refR, double refTheta, double refZ, double refR, double refTheta, double refZ,
double azimuth, double elevation, bool local) const double azimuth, double elevation, bool local) const
...@@ -102,15 +103,15 @@ int DataSink::dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[], double me ...@@ -102,15 +103,15 @@ int DataSink::dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[], double me
} }
void DataSink::dumpSDDS(PartBunchBase<double, 3> *beam, Vector_t FDext[], void DataSink::dumpSDDS(PartBunchBase<double, 3>* beam, Vector_t FDext[],
const double& azimuth) const const double& azimuth) const
{ {
this->dumpSDDS(beam, FDext, losses_t(), azimuth); this->dumpSDDS(beam, FDext, losses_t(), azimuth);
} }
void DataSink::dumpSDDS(PartBunchBase<double, 3> *beam, Vector_t FDext[], void DataSink::dumpSDDS(PartBunchBase<double, 3>* beam, Vector_t FDext[],
const losses_t &losses, const double& azimuth) const const losses_t& losses, const double& azimuth) const
{ {
beam->calcBeamParameters(); beam->calcBeamParameters();
...@@ -124,8 +125,9 @@ void DataSink::dumpSDDS(PartBunchBase<double, 3> *beam, Vector_t FDext[], ...@@ -124,8 +125,9 @@ void DataSink::dumpSDDS(PartBunchBase<double, 3> *beam, Vector_t FDext[],
beam->gatherLoadBalanceStatistics(); beam->gatherLoadBalanceStatistics();
for (size_t i = 0; i < sddsWriter_m.size(); ++i) for (size_t i = 0; i < sddsWriter_m.size(); ++i) {
sddsWriter_m[i]->write(beam); sddsWriter_m[i]->write(beam);
}
IpplTimings::stopTimer(StatMarkerTimer_m); IpplTimings::stopTimer(StatMarkerTimer_m);
} }
...@@ -138,34 +140,34 @@ void DataSink::storeCavityInformation() { ...@@ -138,34 +140,34 @@ void DataSink::storeCavityInformation() {
} }
void DataSink::changeH5Wrapper(H5PartWrapper *h5wrapper) { void DataSink::changeH5Wrapper(H5PartWrapper* h5wrapper) {
if (!Options::enableHDF5) return; if (!Options::enableHDF5) return;
h5Writer_m->changeH5Wrapper(h5wrapper); h5Writer_m->changeH5Wrapper(h5wrapper);
} }
void DataSink::writeGeomToVtk(BoundaryGeometry &bg, std::string fn) { void DataSink::writeGeomToVtk(BoundaryGeometry& bg, const std::string& fn) {
if (Ippl::myNode() == 0 && Options::enableVTK) { if (Ippl::myNode() == 0 && Options::enableVTK) {
bg.writeGeomToVtk (fn); bg.writeGeomToVtk(fn);
} }
} }
void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long long &step, size_t &impact, double &sey_num, void DataSink::writeImpactStatistics(const PartBunchBase<double, 3>* beam, long long& step, size_t& impact, double& sey_num,
size_t numberOfFieldEmittedParticles, bool nEmissionMode, std::string fn) { size_t numberOfFieldEmittedParticles, bool nEmissionMode, std::string fn) {
double charge = 0.0; double charge = 0.0;
size_t Npart = 0; size_t Npart = 0;
double Npart_d = 0.0; double Npart_d = 0.0;
if(!nEmissionMode) { if (!nEmissionMode) {
charge = -1.0 * beam->getCharge(); charge = -1.0 * beam->getCharge();
//reduce(charge, charge, OpAddAssign()); //reduce(charge, charge, OpAddAssign());
Npart_d = -1.0 * charge / beam->getChargePerParticle(); Npart_d = -1.0 * charge / beam->getChargePerParticle();
} else { } else {
Npart = beam->getTotalNum(); Npart = beam->getTotalNum();
} }
if(Ippl::myNode() == 0) { if (Ippl::myNode() == 0) {
std::string ffn = fn + std::string(".dat"); std::string ffn = fn + std::string(".dat");
std::unique_ptr<Inform> ofp(new Inform(nullptr, ffn.c_str(), Inform::APPEND, 0)); std::unique_ptr<Inform> ofp(new Inform(nullptr, ffn.c_str(), Inform::APPEND, 0));
...@@ -173,9 +175,9 @@ void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long ...@@ -173,9 +175,9 @@ void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long
fid.precision(6); fid.precision(6);
fid << std::setiosflags(std::ios::scientific); fid << std::setiosflags(std::ios::scientific);
double t = beam->getT() * Units::s2ns; double t = beam->getT() * Units::s2ns;
if(!nEmissionMode) { if (!nEmissionMode) {
if(step == 0) { if (step == 0) {
fid << "#Time/ns" << std::setw(18) << "#Geometry impacts" << std::setw(18) << "tot_sey" << std::setw(18) fid << "#Time/ns" << std::setw(18) << "#Geometry impacts" << std::setw(18) << "tot_sey" << std::setw(18)
<< "TotalCharge" << std::setw(18) << "PartNum" << " numberOfFieldEmittedParticles " << endl; << "TotalCharge" << std::setw(18) << "PartNum" << " numberOfFieldEmittedParticles " << endl;
} }
...@@ -183,7 +185,7 @@ void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long ...@@ -183,7 +185,7 @@ void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long
<< std::setw(18) << Npart_d << std::setw(18) << numberOfFieldEmittedParticles << endl; << std::setw(18) << Npart_d << std::setw(18) << numberOfFieldEmittedParticles << endl;
} else { } else {
if(step == 0) { if (step == 0) {
fid << "#Time/ns" << std::setw(18) << "#Geometry impacts" << std::setw(18) << "tot_sey" << std::setw(18) fid << "#Time/ns" << std::setw(18) << "#Geometry impacts" << std::setw(18) << "tot_sey" << std::setw(18)
<< "ParticleNumber" << " numberOfFieldEmittedParticles " << endl; << "ParticleNumber" << " numberOfFieldEmittedParticles " << endl;
} }
...@@ -194,7 +196,7 @@ void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long ...@@ -194,7 +196,7 @@ void DataSink::writeImpactStatistics(const PartBunchBase<double, 3> *beam, long
} }
void DataSink::writeMultiBunchStatistics(PartBunchBase<double, 3> *beam, void DataSink::writeMultiBunchStatistics(PartBunchBase<double, 3>* beam,
MultiBunchHandler* mbhandler_p) { MultiBunchHandler* mbhandler_p) {
/// Start timer. /// Start timer.
IpplTimings::startTimer(StatMarkerTimer_m); IpplTimings::startTimer(StatMarkerTimer_m);
......
...@@ -52,7 +52,7 @@ private: ...@@ -52,7 +52,7 @@ private:
typedef std::unique_ptr<SDDSWriter> sddsWriter_t; typedef std::unique_ptr<SDDSWriter> sddsWriter_t;
typedef std::unique_ptr<H5Writer> h5Writer_t; typedef std::unique_ptr<H5Writer> h5Writer_t;
typedef std::unique_ptr<MultiBunchDump> mbWriter_t; typedef std::unique_ptr<MultiBunchDump> mbWriter_t;
public: public:
/** \brief Default constructor. /** \brief Default constructor.
* *
...@@ -63,45 +63,44 @@ public: ...@@ -63,45 +63,44 @@ public:
DataSink(H5PartWrapper *h5wrapper, bool restart, short numBunch); DataSink(H5PartWrapper *h5wrapper, bool restart, short numBunch);
DataSink(H5PartWrapper *h5wrapper, short numBunch); DataSink(H5PartWrapper *h5wrapper, short numBunch);
void dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[]) const; void dumpH5(PartBunchBase<double, 3>* beam, Vector_t FDext[]) const;
int dumpH5(PartBunchBase<double, 3> *beam, Vector_t FDext[], double meanEnergy, int dumpH5(PartBunchBase<double, 3>* beam, Vector_t FDext[], double meanEnergy,
double refPr, double refPt, double refPz, double refPr, double refPt, double refPz,
double refR, double refTheta, double refZ, double refR, double refTheta, double refZ,
double azimuth, double elevation, bool local) const; double azimuth, double elevation, bool local) const;
void dumpSDDS(PartBunchBase<double, 3> *beam, Vector_t FDext[], void dumpSDDS(PartBunchBase<double, 3>* beam, Vector_t FDext[],
const double& azimuth = -1) const; const double& azimuth = -1) const;
void dumpSDDS(PartBunchBase<double, 3> *beam, Vector_t FDext[], void dumpSDDS(PartBunchBase<double, 3>* beam, Vector_t FDext[],
const losses_t &losses = losses_t(), const double& azimuth = -1) const; const losses_t& losses = losses_t(), const double& azimuth = -1) const;
/** \brief Write cavity information from H5 file /** \brief Write cavity information from H5 file
*/ */
void storeCavityInformation(); void storeCavityInformation();
void changeH5Wrapper(H5PartWrapper *h5wrapper); void changeH5Wrapper(H5PartWrapper* h5wrapper);
/** /**
* Write geometry points and surface triangles to vtk file * Write geometry points and surface triangles to vtk file
* *
* @param fn specifies the name of vtk file contains the geometry * @param fn specifies the name of vtk file contains the geometry
* *
*/ */
void writeGeomToVtk(BoundaryGeometry &bg, std::string fn); void writeGeomToVtk(BoundaryGeometry& bg, const std::string& fn);
//void writeGeoContourToVtk(BoundaryGeometry &bg, std::string fn); //void writeGeoContourToVtk(BoundaryGeometry& bg, std::string fn);
/** /**
* Write impact number and outgoing secondaries in each time step * Write impact number and outgoing secondaries in each time step
* *
* @param fn specifies the name of vtk file contains the geometry * @param fn specifies the name of vtk file contains the geometry
* *
*/ */
void writeImpactStatistics(const PartBunchBase<double, 3> *beam, void writeImpactStatistics(const PartBunchBase<double, 3>* beam,
long long int &step, long long int& step,
size_t &impact, size_t& impact,
double &sey_num, double& sey_num,
size_t numberOfFieldEmittedParticles, size_t numberOfFieldEmittedParticles,
bool nEmissionMode, bool nEmissionMode,
std::string fn); std::string fn);
...@@ -110,7 +109,7 @@ public: ...@@ -110,7 +109,7 @@ public:
* @param beam * @param beam
* @param mbhandler is the multi-bunch handler * @param mbhandler is the multi-bunch handler
*/ */
void writeMultiBunchStatistics(PartBunchBase<double, 3> *beam, void writeMultiBunchStatistics(PartBunchBase<double, 3>* beam,
MultiBunchHandler* mbhandler); MultiBunchHandler* mbhandler);
/** /**
...@@ -130,7 +129,6 @@ private: ...@@ -130,7 +129,6 @@ private:
H5PartWrapper* h5wrapper = nullptr, H5PartWrapper* h5wrapper = nullptr,
short numBunch = 1); short numBunch = 1);
h5Writer_t h5Writer_m; h5Writer_t h5Writer_m;
statWriter_t statWriter_m; statWriter_t statWriter_m;
std::vector<sddsWriter_t> sddsWriter_m; std::vector<sddsWriter_t> sddsWriter_m;
...@@ -157,5 +155,4 @@ std::string DataSink::convertToString(int number, int setw) { ...@@ -157,5 +155,4 @@ std::string DataSink::convertToString(int number, int setw) {
return ss.str(); return ss.str();
} }
#endif // DataSink_H_ #endif // DataSink_H_
...@@ -16,18 +16,18 @@ ...@@ -16,18 +16,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
#include "LBalWriter.h" #include "Structure/LBalWriter.h"
#include "OPALconfig.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Utilities/Util.h"
#include "Utilities/Timer.h"
#include "Algorithms/PartBunchBase.h"
#include "Physics/Units.h"
#ifdef ENABLE_AMR #ifdef ENABLE_AMR
#include "Algorithms/AmrPartBunch.h" #include "Algorithms/AmrPartBunch.h"
#endif #endif
#include "Algorithms/PartBunchBase.h"
#include "OPALconfig.h"
#include "Physics/Units.h"
#include "Utilities/Timer.h"
#include "Utilities/Util.h"
LBalWriter::LBalWriter(const std::string& fname, bool restart) LBalWriter::LBalWriter(const std::string& fname, bool restart)
: SDDSWriter(fname, restart) : SDDSWriter(fname, restart)
...@@ -35,7 +35,7 @@ LBalWriter::LBalWriter(const std::string& fname, bool restart) ...@@ -35,7 +35,7 @@ LBalWriter::LBalWriter(const std::string& fname, bool restart)
#ifdef ENABLE_AMR #ifdef ENABLE_AMR
void LBalWriter::fillHeader(PartBunchBase<double, 3> * beam) { void LBalWriter::fillHeader(PartBunchBase<double, 3>* beam) {
#else #else
void LBalWriter::fillHeader() { void LBalWriter::fillHeader() {
#endif #endif
...@@ -71,11 +71,11 @@ void LBalWriter::fillHeader() { ...@@ -71,11 +71,11 @@ void LBalWriter::fillHeader() {
} }
#endif #endif
if ( mode_m == std::ios::app ) if ( mode_m == std::ios::app ) {
return; return;
}
OPALTimer::Timer simtimer; OPALTimer::Timer simtimer;
std::string dateStr(simtimer.date()); std::string dateStr(simtimer.date());
std::string timeStr(simtimer.time()); std::string timeStr(simtimer.time());
...@@ -88,24 +88,18 @@ void LBalWriter::fillHeader() { ...@@ -88,24 +88,18 @@ void LBalWriter::fillHeader() {
this->addDefaultParameters(); this->addDefaultParameters();
this->addInfo("ascii", 1); this->addInfo("ascii", 1);
} }
void LBalWriter::write(PartBunchBase<double, 3>* beam) {
#ifdef ENABLE_AMR #ifdef ENABLE_AMR
void LBalWriter::write(PartBunchBase<double, 3> *beam) {
if ( AmrPartBunch* amrbeam = dynamic_cast<AmrPartBunch*>(beam) ) { if ( AmrPartBunch* amrbeam = dynamic_cast<AmrPartBunch*>(beam) ) {
amrbeam->gatherLevelStatistics(); amrbeam->gatherLevelStatistics();
} }
#else
void LBalWriter::write(const PartBunchBase<double, 3> *beam) {
#endif #endif
if ( Ippl::myNode() != 0 ) {
if ( Ippl::myNode() != 0 )
return; return;
}
#ifdef ENABLE_AMR #ifdef ENABLE_AMR
this->fillHeader(beam); this->fillHeader(beam);
#else #else
...@@ -116,7 +110,7 @@ void LBalWriter::write(const PartBunchBase<double, 3> *beam) { ...@@ -116,7 +110,7 @@ void LBalWriter::write(const PartBunchBase<double, 3> *beam) {
this->writeHeader(); this->writeHeader();
columns_m.addColumnValue("t", beam->getT() * Units::s2ns); // 1 columns_m.addColumnValue("t", beam->getT() * Units::s2ns);
size_t nProcs = Ippl::getNodes(); size_t nProcs = Ippl::getNodes();
for (size_t p = 0; p < nProcs; ++ p) { for (size_t p = 0; p < nProcs; ++ p) {
......
...@@ -19,26 +19,21 @@ ...@@ -19,26 +19,21 @@
#ifndef OPAL_LBAL_WRITER_H #ifndef OPAL_LBAL_WRITER_H
#define OPAL_LBAL_WRITER_H #define OPAL_LBAL_WRITER_H
#include "SDDSWriter.h" #include "Structure/SDDSWriter.h"
class LBalWriter : public SDDSWriter { class LBalWriter: public SDDSWriter {
public: public:
LBalWriter(const std::string& fname, bool restart); LBalWriter(const std::string& fname, bool restart);
#ifdef ENABLE_AMR void write(PartBunchBase<double, 3>* beam) override;
void write(PartBunchBase<double, 3> *beam);
#else
void write(const PartBunchBase<double, 3> *beam) override;
#endif
private: private:
#ifdef ENABLE_AMR #ifdef ENABLE_AMR
void fillHeader(PartBunchBase<double, 3> *beam); void fillHeader(PartBunchBase<double, 3>* beam);
#else #else
void fillHeader(); void fillHeader();
#endif #endif
}; };
#endif
#endif
\ No newline at end of file
...@@ -18,23 +18,22 @@ ...@@ -18,23 +18,22 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
#include "MemoryProfiler.h" #include "Structure/MemoryProfiler.h"
#ifdef __linux__
#include <sys/types.h>
#include <unistd.h>
#endif
#include "Utilities/Timer.h"
#include "Utilities/OpalException.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Algorithms/PartBunchBase.h" #include "Algorithms/PartBunchBase.h"
#include "Physics/Units.h" #include "Physics/Units.h"
#include "Utilities/Timer.h"
#include <boost/filesystem.hpp> #include "Utilities/OpalException.h"
#include "Ippl.h" #include "Ippl.h"
#include <boost/filesystem.hpp>
#ifdef __linux__
#include <sys/types.h>
#include <unistd.h>
#endif
#include <sstream> #include <sstream>
MemoryProfiler::MemoryProfiler(const std::string& fname, bool restart) MemoryProfiler::MemoryProfiler(const std::string& fname, bool restart)
...@@ -197,7 +196,7 @@ void MemoryProfiler::compute(vm_t& vmMin, ...@@ -197,7 +196,7 @@ void MemoryProfiler::compute(vm_t& vmMin,
} }
void MemoryProfiler::write(const PartBunchBase<double, 3> *beam) { void MemoryProfiler::write(PartBunchBase<double, 3>* beam) {
this->update(); this->update();
......
...@@ -21,23 +21,24 @@ ...@@ -21,23 +21,24 @@
#ifndef OPAL_MEMORY_PROFILER_H #ifndef OPAL_MEMORY_PROFILER_H
#define OPAL_MEMORY_PROFILER_H #define OPAL_MEMORY_PROFILER_H
#include "Structure/SDDSWriter.h"
#include <fstream> #include <fstream>
#include <string>
#include <map> #include <map>
#include <string>
#include <vector> #include <vector>
#include "SDDSWriter.h"
class MemoryProfiler : public SDDSWriter { class MemoryProfiler: public SDDSWriter {
/* Pay attention with units. /proc/[pid]/status returns values in /* Pay attention with units. /proc/[pid]/status returns values in
* KiB (Kibibyte) although the units say kB. * KiB (Kibibyte) although the units say kB.
* KiB has base 2 not base 10 * KiB has base 2 not base 10
*/ */
public: public:
typedef std::vector<long double> vm_t; typedef std::vector<long double> vm_t;
typedef std::vector<std::string> units_t; typedef std::vector<std::string> units_t;
MemoryProfiler(const std::string& fname, bool restart); MemoryProfiler(const std::string& fname, bool restart);
enum VirtualMemory { enum VirtualMemory {
...@@ -57,14 +58,14 @@ public: ...@@ -57,14 +58,14 @@ public:
VMSWAP // VmSwap: Swapped-out virtual memory size by anonymous private pages; shmem swap usage is not VMSWAP // VmSwap: Swapped-out virtual memory size by anonymous private pages; shmem swap usage is not
// included (since Linux 2.6.34). // included (since Linux 2.6.34).
}; };
void write(const PartBunchBase<double, 3> *beam) override; void write(PartBunchBase<double, 3>* beam) override;
private: private:
void header(); void header();
void update(); void update();
void compute(vm_t& vmMin, vm_t& vmMax, vm_t& vmAvg); void compute(vm_t& vmMin, vm_t& vmMax, vm_t& vmAvg);
private: private:
std::map<std::string, int> procinfo_m; std::map<std::string, int> procinfo_m;
vm_t vmem_m; vm_t vmem_m;
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
#include "MemoryWriter.h" #include "Structure/MemoryWriter.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Algorithms/PartBunchBase.h" #include "Algorithms/PartBunchBase.h"
#include "Utilities/Timer.h"
#include "Physics/Units.h" #include "Physics/Units.h"
#include "Utilities/Timer.h"
#include "Ippl.h" #include "Ippl.h"
MemoryWriter::MemoryWriter(const std::string& fname, bool restart) MemoryWriter::MemoryWriter(const std::string& fname, bool restart)
...@@ -61,7 +62,6 @@ void MemoryWriter::fillHeader() { ...@@ -61,7 +62,6 @@ void MemoryWriter::fillHeader() {
std::string dateStr(simtimer.date()); std::string dateStr(simtimer.date());
std::string timeStr(simtimer.time()); std::string timeStr(simtimer.time());
std::stringstream ss; std::stringstream ss;
ss << "Memory statistics '" ss << "Memory statistics '"
...@@ -72,13 +72,12 @@ void MemoryWriter::fillHeader() { ...@@ -72,13 +72,12 @@ void MemoryWriter::fillHeader() {
this->addDefaultParameters(); this->addDefaultParameters();
this->addInfo("ascii", 1); this->addInfo("ascii", 1);
} }
void MemoryWriter::write(const PartBunchBase<double, 3> *beam) void MemoryWriter::write(PartBunchBase<double, 3>* beam) {
{
IpplMemoryUsage::IpplMemory_p memory = IpplMemoryUsage::getInstance(); IpplMemoryUsage::IpplMemory_p memory = IpplMemoryUsage::getInstance();
memory->sample(); memory->sample();
...@@ -114,4 +113,4 @@ void MemoryWriter::write(const PartBunchBase<double, 3> *beam) ...@@ -114,4 +113,4 @@ void MemoryWriter::write(const PartBunchBase<double, 3> *beam)
this->writeRow(); this->writeRow();
this->close(); this->close();
} }
\ No newline at end of file
...@@ -21,17 +21,17 @@ ...@@ -21,17 +21,17 @@
#ifndef OPAL_MEMORY_WRITER_H #ifndef OPAL_MEMORY_WRITER_H
#define OPAL_MEMORY_WRITER_H #define OPAL_MEMORY_WRITER_H
#include "SDDSWriter.h" #include "Structure/SDDSWriter.h"
class MemoryWriter : public SDDSWriter { class MemoryWriter: public SDDSWriter {
public: public:
MemoryWriter(const std::string& fname, bool restart); MemoryWriter(const std::string& fname, bool restart);
void write(const PartBunchBase<double, 3> *beam) override; void write(PartBunchBase<double, 3>* beam) override;
private: private:
void fillHeader(); void fillHeader();
}; };
#endif #endif
\ No newline at end of file
...@@ -63,7 +63,6 @@ void SDDSWriter::rewindLines(size_t numberOfLines) { ...@@ -63,7 +63,6 @@ void SDDSWriter::rewindLines(size_t numberOfLines) {
} }
fs.close(); fs.close();
fs.open (fname_m.c_str(), std::fstream::out); fs.open (fname_m.c_str(), std::fstream::out);
if (!fs.is_open()) return; if (!fs.is_open()) return;
...@@ -99,7 +98,6 @@ void SDDSWriter::replaceVersionString() { ...@@ -99,7 +98,6 @@ void SDDSWriter::replaceVersionString() {
} }
fs.close(); fs.close();
fs.open (fname_m.c_str(), std::fstream::out); fs.open (fname_m.c_str(), std::fstream::out);
if (!fs.is_open()) return; if (!fs.is_open()) return;
...@@ -228,4 +226,4 @@ void SDDSWriter::addDefaultParameters() { ...@@ -228,4 +226,4 @@ void SDDSWriter::addDefaultParameters() {
addParameter("revision", "string", "git revision of opal", revision.str()); addParameter("revision", "string", "git revision of opal", revision.str());
addParameter("flavor", "string", "OPAL flavor that wrote file", flavor); addParameter("flavor", "string", "OPAL flavor that wrote file", flavor);
} }
\ No newline at end of file
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
#define OPAL_SDDS_WRITER_H #define OPAL_SDDS_WRITER_H
#include <fstream> #include <fstream>
#include <string> #include <iomanip>
#include <queue>
#include <map> #include <map>
#include <vector>
#include <tuple>
#include <utility>
#include <ostream> #include <ostream>
#include <iomanip> #include <queue>
#include <sstream> #include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
...@@ -58,12 +58,11 @@ public: ...@@ -58,12 +58,11 @@ public:
std::string, std::string,
std::string> cols_t; std::string> cols_t;
SDDSWriter(const std::string& fname, bool restart); SDDSWriter(const std::string& fname, bool restart);
virtual ~SDDSWriter() { }; virtual ~SDDSWriter() { };
virtual void write(const PartBunchBase<double, 3>* /*beam*/) { }; virtual void write(PartBunchBase<double, 3>* /*beam*/) { };
/** \brief /** \brief
* delete the last 'numberOfLines' lines of the file 'fileName' * delete the last 'numberOfLines' lines of the file 'fileName'
...@@ -77,7 +76,6 @@ public: ...@@ -77,7 +76,6 @@ public:
bool exists() const; bool exists() const;
protected: protected:
void addDescription(const std::string& text, void addDescription(const std::string& text,
const std::string& content); const std::string& content);
...@@ -131,7 +129,6 @@ protected: ...@@ -131,7 +129,6 @@ protected:
bool hasColumns() const; bool hasColumns() const;
private: private:
void writeDescription(); void writeDescription();
void writeParameters(); void writeParameters();
...@@ -162,8 +159,7 @@ bool SDDSWriter::exists() const { ...@@ -162,8 +159,7 @@ bool SDDSWriter::exists() const {
inline inline
void SDDSWriter::addDescription(const std::string& text, void SDDSWriter::addDescription(const std::string& text,
const std::string& content) const std::string& content) {
{
desc_m = std::make_pair(text, content); desc_m = std::make_pair(text, content);
} }
...@@ -172,8 +168,7 @@ template<typename T> ...@@ -172,8 +168,7 @@ template<typename T>
void SDDSWriter::addParameter(const std::string& name, void SDDSWriter::addParameter(const std::string& name,
const std::string& type, const std::string& type,
const std::string& desc, const std::string& desc,
const T& value) const T& value) {
{
params_m.push(std::make_tuple(name, type, desc)); params_m.push(std::make_tuple(name, type, desc));
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
...@@ -208,4 +203,4 @@ bool SDDSWriter::hasColumns() const { ...@@ -208,4 +203,4 @@ bool SDDSWriter::hasColumns() const {
return columns_m.hasColumns(); return columns_m.hasColumns();
} }
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment