Commit b0812f57 authored by ext-calvo_p's avatar ext-calvo_p

Merge branch '651-printing-info-of-dumpfields-and-dumpemfields' into 'master'

Resolve "Printing info of DumpFields and DumpEMFields"

Closes #651

See merge request !492
parents 66ea7642 58229c68
......@@ -50,7 +50,7 @@ IndexMap::IndexMap():
void IndexMap::print(std::ostream &out) const {
if (mapRange2Element_m.size() == 0) return;
out << "Size of map " << mapRange2Element_m.size() << " sections " << std::endl;
out << "* Size of map " << mapRange2Element_m.size() << " sections " << std::endl;
out << std::fixed << std::setprecision(6);
auto mapIti = mapRange2Element_m.begin();
auto mapItf = mapRange2Element_m.end();
......@@ -61,14 +61,14 @@ void IndexMap::print(std::ostream &out) const {
for (; mapIti != mapItf; mapIti++) {
const key_t key = (*mapIti).first;
const value_t val = (*mapIti).second;
out << "Key: ("
out << "* Key: ("
<< std::setw(numDigits + 7) << std::right << key.begin
<< " - "
<< std::setw(numDigits + 7) << std::right << key.end
<< ") number of overlapping elements " << val.size() << "\n";
for (auto element: val) {
out << std::setw(25 + 2 * numDigits) << " " << element->getName() << "\n";
out << "* " << std::setw(25 + 2 * numDigits) << " " << element->getName() << "\n";
}
}
}
......@@ -410,4 +410,4 @@ IndexMap::value_t IndexMap::getTouchingElements(const IndexMap::key_t &range) co
bool IndexMap::almostEqual(double x, double y) {
return (std::abs(x - y) < std::numeric_limits<double>::epsilon() * std::abs(x + y) * 2 ||
std::abs(x - y) < std::numeric_limits<double>::min());
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -30,30 +30,28 @@
#include <sstream>
#include <string>
#include "AbsBeamline/Monitor.h"
#include "AbstractObjects/OpalData.h"
#include "Algorithms/OrbitThreader.h"
#include "Algorithms/CavityAutophaser.h"
#include "BasicActions/Option.h"
#ifdef ENABLE_OPAL_FEL
#include "BeamlineCore/UndulatorRep.h"
#endif
#include "Beamlines/Beamline.h"
#include "Beamlines/FlaggedBeamline.h"
#include "Distribution/Distribution.h"
#include "Elements/OpalBeamline.h"
#include "Solvers/CSRWakeFunction.h"
#include "AbstractObjects/OpalData.h"
#include "BasicActions/Option.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Structure/BoundaryGeometry.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Timer.h"
#include "Utilities/Util.h"
#include "Distribution/Distribution.h"
#include "ValueDefinitions/RealVariable.h"
#include "Utilities/Timer.h"
#include "Utilities/OpalException.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Structure/BoundaryGeometry.h"
#include "AbsBeamline/Monitor.h"
#ifdef ENABLE_OPAL_FEL
#include "BeamlineCore/UndulatorRep.h"
#endif
extern Inform* gmsg;
class PartData;
......@@ -268,15 +266,16 @@ void ParallelTTracker::execute() {
unsigned long long step = itsBunch_m->getGlobalTrackStep();
OPALTimer::Timer myt1;
*gmsg << "Track start at: " << myt1.time() << ", t= " << Util::getTimeString(time) << "; "
*gmsg << "* Track start at: " << myt1.time() << ", t= " << Util::getTimeString(time) << "; "
<< "zstart at: " << Util::getLengthString(pathLength_m)
<< endl;
prepareEmission();
*gmsg << level1
<< "Executing ParallelTTracker, initial dt= " << Util::getTimeString(itsBunch_m->getdT()) << ";\n"
<< "max integration steps " << stepSizes_m.getMaxSteps() << ", next step= " << step << endl;
*gmsg << "* Executing ParallelTTracker\n"
<< "* Initial dt = " << Util::getTimeString(itsBunch_m->getdT()) << "\n"
<< "* Max integration steps = " << stepSizes_m.getMaxSteps()
<< ", next step = " << step << endl << endl;
setOptionalVariables();
......@@ -359,7 +358,8 @@ void ParallelTTracker::execute() {
itsOpalBeamline_m.switchElementsOff();
OPALTimer::Timer myt3;
*gmsg << "done executing ParallelTTracker at " << myt3.time() << endl;
*gmsg << endl << "* Done executing ParallelTTracker at "
<< myt3.time() << endl << endl;
Monitor::writeStatistics();
......@@ -1407,4 +1407,4 @@ void ParallelTTracker::evenlyDistributeParticles() {
if (requests.size() > 0) {
MPI_Waitall(requests.size(), &(requests[0]), MPI_STATUSES_IGNORE);
}
}
\ No newline at end of file
}
......@@ -27,6 +27,7 @@
#include <iostream>
extern Inform* gmsg;
Call::Call():
Action(1, "CALL",
......@@ -57,14 +58,11 @@ void Call::execute() {
std::string file = Attributes::getString(itsAttr[0]);
if (Options::info && Ippl::myNode() == 0) {
std::cerr << "Start reading input stream \"" << file << "\"." << std::endl;
*gmsg << "* Reading input stream \"" << file
<< "\" from CALL command.\n" << endl;
}
OpalParser().run(new FileStream(file));
if (Options::info && Ippl::myNode() == 0) {
std::cerr << "End reading input stream \"" << file << "\"." << std::endl;
}
}
......
This diff is collapsed.
/*
* Copyright (c) 2017, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
//
// Class DumpEMFields
// DumpEMFields dumps the dynamically changing fields of a Ring in a user-
// defined grid.
//
// Copyright (c) 2017, Chris Rogers
// All rights reserved
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef OPAL_BASICACTIONS_DUMPEMFIELDS_HH
#define OPAL_BASICACTIONS_DUMPEMFIELDS_HH
#include <unordered_set>
#include <string>
#include "AbsBeamline/Component.h"
#include "AbstractObjects/Action.h"
#include <string>
#include <unordered_set>
#include <vector>
namespace interpolation {
class NDGrid;
}
class Component;
/** DumpEMFields dumps the dynamically changing fields of a Ring in a user-
* defined grid.
*
* The idea is to print out the field map across a 4D grid in space-time for
* debugging purposes. The problem is to manage the DumpEMFields object through
* three phases of program execution; initial construction, parsing and then
* actual field map writing (where we need to somehow let DumpFields know what
* the field maps are). So for each DumpFields object created, we store in a
* set. When the execute() method is called, DumpFields builds a grid using
* the parsed information.
* debugging purposes. The problem is to manage the DumpEMFields object
* through three phases of program execution; initial construction, parsing
* and then actual field map writing (where we need to somehow let DumpFields
* know what the field maps are). So for each DumpEMFields object created, we
* store in a set. When the execute() method is called, DumpEMFields builds a
* grid using the parsed information.
*
* When the ParallelCyclotronTracker is about to start tracking, it calls
* writeFields method which loops over the static set of DumpFields and writes
* each one. It is not the cleanest implementation, but I can't see a better
* way.
* writeFields method which loops over the static set of DumpEMFields and
* writes each one. It is not the cleanest implementation, but I can't see a
* better way.
*
* The DumpEMFields themselves operate by iterating over a NDGrid object
* and looking up the field/writing it out on each grid point.
*
*/
class DumpEMFields : public Action {
public:
enum CoordinateSystem {CYLINDRICAL, CARTESIAN};
class DumpEMFields: public Action {
public:
/// The common attributes of DumpEMFields.
enum {
FILE_NAME,
COORDINATE_SYSTEM,
X_START,
DX,
X_STEPS,
Y_START,
DY,
Y_STEPS,
Z_START,
DZ,
Z_STEPS,
T_START,
DT,
T_STEPS,
R_START,
DR,
R_STEPS,
PHI_START,
DPHI,
PHI_STEPS,
SIZE
};
enum class CoordinateSystem {
CARTESIAN,
CYLINDRICAL
};
/** Constructor */
DumpEMFields();
/** Constructor */
DumpEMFields(const std::string& name, DumpEMFields* parent);
/** Destructor deletes grid_m and if in the dumps set, take it out */
virtual ~DumpEMFields();
......@@ -73,7 +98,7 @@ class DumpEMFields : public Action {
* If this is in the dumpsSet_m, so will the clone. Not sure how the
* itsAttr stuff works, so this may not get properly copied?
*/
virtual DumpEMFields *clone(const std::string &name);
virtual DumpEMFields* clone(const std::string& name);
/** Builds the grid but does not write the field map
*
......@@ -100,7 +125,10 @@ class DumpEMFields : public Action {
*/
static void writeFields(Component* field);
private:
/** Print the attributes of DumpEMFields to standard out */
void print(std::ostream& os) const;
private:
virtual void writeFieldThis(Component* field);
virtual void buildGrid();
void parseCoordinateSystem();
......@@ -113,15 +141,17 @@ class DumpEMFields : public Action {
interpolation::NDGrid* grid_m;
std::string filename_m;
CoordinateSystem coordinates_m = CARTESIAN;
CoordinateSystem coordinates_m = CoordinateSystem::CARTESIAN;
static std::unordered_set<DumpEMFields*> dumpsSet_m;
static std::string dumpemfields_docstring;
constexpr static double DEGREE = 180./M_PI;
DumpEMFields(const DumpEMFields& dump); // disabled
DumpEMFields& operator=(const DumpEMFields& dump); // disabled
};
#endif // ifdef OPAL_DUMPFIELDS_HH
inline std::ostream& operator<<(std::ostream& os, const DumpEMFields& b) {
b.print(os);
return os;
}
#endif // ifdef OPAL_DUMPFIELDS_HH
/*
* Copyright (c) 2016, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
//
// Class DumpFields
// DumpFields dumps the static magnetic field of a Ring in a user-defined grid
//
// Copyright (c) 2016, Chris Rogers
// All rights reserved
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#include "BasicActions/DumpFields.h"
#include "AbsBeamline/Component.h"
#include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h"
#include "Fields/Interpolation/ThreeDGrid.h"
#include "Utilities/OpalException.h"
#include "Utilities/Util.h"
#include <fstream>
#include "Fields/Interpolation/ThreeDGrid.h" // classic
#include "AbsBeamline/Component.h" // classic
#include "Utilities/OpalException.h"
#include "Attributes/Attributes.h"
#include "BasicActions/DumpFields.h"
extern Inform* gmsg;
std::unordered_set<DumpFields*> DumpFields::dumpsSet_m;
std::string DumpFields::dumpfields_docstring =
std::string("The \"DUMPFIELDS\" statement dumps a field map to a user-defined")+
std::string(" field file, for checking that fields are read in correctly")+
std::string(" from disk. The fields are written out on a Cartesian grid.");
DumpFields::DumpFields() :
Action(10, "DUMPFIELDS", dumpfields_docstring.c_str()) {
Action(SIZE, "DUMPFIELDS",
"The \"DUMPFIELDS\" statement dumps a field map to a user-defined "
"field file, for checking that fields are read in correctly "
"from disk. The fields are written out on a Cartesian grid.") {
// would be nice if "steps" could be integer
itsAttr[0] = Attributes::makeReal
("X_START", "Start point in the grid in x [m]");
itsAttr[1] = Attributes::makeReal
("DX", "Grid step size in x [m]");
itsAttr[2] = Attributes::makeReal
("X_STEPS", "Number of steps in x");
itsAttr[3] = Attributes::makeReal
("Y_START", "Start point in the grid in y [m]");
itsAttr[4] = Attributes::makeReal
("DY", "Grid step size in y [m]");
itsAttr[5] = Attributes::makeReal
("Y_STEPS", "Number of steps in y");
itsAttr[6] = Attributes::makeReal
("Z_START", "Start point in the grid in z [m]");
itsAttr[7] = Attributes::makeReal
("DZ", "Grid step size in z [m]");
itsAttr[8] = Attributes::makeReal
("Z_STEPS", "Number of steps in z");
itsAttr[9] = Attributes::makeString
("FILE_NAME", "Name of the file to which field data is dumped");
itsAttr[FILE_NAME] = Attributes::makeString
("FILE_NAME", "Name of the file to which field data is dumped");
itsAttr[X_START] = Attributes::makeReal
("X_START", "Start point in the grid in x [m]");
itsAttr[DX] = Attributes::makeReal
("DX", "Grid step size in x [m]");
itsAttr[X_STEPS] = Attributes::makeReal
("X_STEPS", "Number of steps in x");
itsAttr[Y_START] = Attributes::makeReal
("Y_START", "Start point in the grid in y [m]");
itsAttr[DY] = Attributes::makeReal
("DY", "Grid step size in y [m]");
itsAttr[Y_STEPS] = Attributes::makeReal
("Y_STEPS", "Number of steps in y");
itsAttr[Z_START] = Attributes::makeReal
("Z_START", "Start point in the grid in z [m]");
itsAttr[DZ] = Attributes::makeReal
("DZ", "Grid step size in z [m]");
itsAttr[Z_STEPS] = Attributes::makeReal
("Z_STEPS", "Number of steps in z");
registerOwnership(AttributeHandler::STATEMENT);
}
DumpFields::DumpFields(const std::string &name, DumpFields *parent):
DumpFields::DumpFields(const std::string& name, DumpFields* parent):
Action(name, parent)
{}
......@@ -77,7 +78,7 @@ DumpFields::~DumpFields() {
dumpsSet_m.erase(this);
}
DumpFields* DumpFields::clone(const std::string &name) {
DumpFields* DumpFields::clone(const std::string& name) {
DumpFields* dumper = new DumpFields(name, this);
if (grid_m != NULL) {
dumper->grid_m = grid_m->clone();
......@@ -99,17 +100,17 @@ void DumpFields::execute() {
}
void DumpFields::buildGrid() {
double x0 = Attributes::getReal(itsAttr[0]);
double dx = Attributes::getReal(itsAttr[1]);
double nx = Attributes::getReal(itsAttr[2]);
double x0 = Attributes::getReal(itsAttr[X_START]);
double dx = Attributes::getReal(itsAttr[DX]);
double nx = Attributes::getReal(itsAttr[X_STEPS]);
double y0 = Attributes::getReal(itsAttr[3]);
double dy = Attributes::getReal(itsAttr[4]);
double ny = Attributes::getReal(itsAttr[5]);
double y0 = Attributes::getReal(itsAttr[Y_START]);
double dy = Attributes::getReal(itsAttr[DY]);
double ny = Attributes::getReal(itsAttr[Y_STEPS]);
double z0 = Attributes::getReal(itsAttr[6]);
double dz = Attributes::getReal(itsAttr[7]);
double nz = Attributes::getReal(itsAttr[8]);
double z0 = Attributes::getReal(itsAttr[Z_START]);
double dz = Attributes::getReal(itsAttr[DZ]);
double nz = Attributes::getReal(itsAttr[Z_STEPS]);
checkInt(nx, "X_STEPS");
checkInt(ny, "Y_STEPS");
......@@ -120,7 +121,7 @@ void DumpFields::buildGrid() {
x0, y0, z0,
nx, ny, nz);
filename_m = Attributes::getString(itsAttr[9]);
filename_m = Attributes::getString(itsAttr[FILE_NAME]);
}
void DumpFields::writeFields(Component* field) {
......@@ -151,10 +152,17 @@ void DumpFields::writeFieldThis(Component* field) {
throw OpalException("DumpFields::writeFieldThis",
"The field to be written was NULL.");
}
*gmsg << *this << endl;
std::string fname = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
filename_m
});
double time = 0.;
Vector_t point(0., 0., 0.);
Vector_t centroid(0., 0., 0.);
std::ofstream fout(filename_m.c_str(), std::ofstream::out);
std::ofstream fout(fname.c_str(), std::ofstream::out);
if (!fout.good()) {
throw OpalException("DumpFields::writeFieldThis",
"Failed to open DumpFields file "+filename_m);
......@@ -183,4 +191,19 @@ void DumpFields::writeFieldThis(Component* field) {
"Something went wrong during writing "+filename_m);
}
fout.close();
}
\ No newline at end of file
}
void DumpFields::print(std::ostream& os) const {
os << "* ************* D U M P F I E L D S *********************************************** " << std::endl;
os << "* File name: " << Attributes::getString(itsAttr[FILE_NAME]) << '\n'
<< "* X_START = " << Attributes::getReal(itsAttr[X_START]) << " [m]\n"
<< "* DX = " << Attributes::getReal(itsAttr[DX]) << " [m]\n"
<< "* X_STEPS = " << Attributes::getReal(itsAttr[X_STEPS]) << '\n'
<< "* Y_START = " << Attributes::getReal(itsAttr[Y_START]) << " [m]\n"
<< "* DY = " << Attributes::getReal(itsAttr[DY]) << " [m]\n"
<< "* Y_STEPS = " << Attributes::getReal(itsAttr[Y_STEPS]) << '\n'
<< "* Z_START = " << Attributes::getReal(itsAttr[Z_START]) << " [m]\n"
<< "* DZ = " << Attributes::getReal(itsAttr[DZ]) << " [m]\n"
<< "* Z_STEPS = " << Attributes::getReal(itsAttr[Z_STEPS]) << '\n';
os << "* ********************************************************************************** " << std::endl;
}
/*
* Copyright (c) 2016, Chris Rogers
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STFC nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
//
// Class DumpFields
// DumpFields dumps the static magnetic field of a Ring in a user-defined grid
//
// Copyright (c) 2016, Chris Rogers
// All rights reserved
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef OPAL_DUMPFIELDS_HH
#define OPAL_DUMPFIELDS_HH
#include <unordered_set>
#include <string>
#include "AbsBeamline/Component.h"
#include "AbstractObjects/Action.h"
#include <string>
#include <unordered_set>
namespace interpolation {
class ThreeDGrid;
}
......@@ -44,7 +36,7 @@ class Component;
* debugging purposes. The problem is to manage the DumpFields object through
* three phases of program execution; initial construction, parsing and then
* actual field map writing (where we need to somehow let DumpFields know what
* the field maps are). So for each DumpFields object created, we store in a
* the field maps are). So for each DumpFields object created, we store in a
* set. When the execute() method is called, DumpFields builds a grid using
* the parsed information.
*
......@@ -56,16 +48,32 @@ class Component;
* The DumpFields themselves operate by iterating over a ThreeDGrid object
* and looking up the field/writing it out on each grid point.
*
* In order to dump time dependent fields, for example RF, see the DumpEMFields
* action.
* In order to dump time dependent fields, for example RF, see the
* DumpEMFields action.
*/
class DumpFields : public Action {
public:
class DumpFields: public Action {
public:
/// The common attributes of DumpFields.
enum {
FILE_NAME,
X_START,
DX,
X_STEPS,
Y_START,
DY,
Y_STEPS,
Z_START,
DZ,
Z_STEPS,
SIZE
};
/** Constructor */
DumpFields();
/** Constructor */
DumpFields(const std::string &name, DumpFields *parent);
DumpFields(const std::string& name, DumpFields* parent);
/** Destructor deletes grid_m and if in the dumps set, take it out */
virtual ~DumpFields();
......@@ -75,7 +83,7 @@ class DumpFields : public Action {
* If this is in the dumpsSet_m, so will the clone. Not sure how the
* itsAttr stuff works, so this may not get properly copied?
*/
virtual DumpFields *clone(const std::string &name);
virtual DumpFields* clone(const std::string& name);
/** Builds the grid but does not write the field map
*
......@@ -102,20 +110,27 @@ class DumpFields : public Action {
*/
static void writeFields(Component* field);
private:
/** Print the attributes of DumpFields to standard out */
void print(std::ostream& os) const;
private:
virtual void writeFieldThis(Component* field);
virtual void buildGrid();
static void checkInt(double value, std::string name, double tolerance = 1e-9);
interpolation::ThreeDGrid* grid_m = NULL;
std::string filename_m = "";
std::string filename_m;
static std::unordered_set<DumpFields*> dumpsSet_m;
static std::string dumpfields_docstring;
DumpFields(const DumpFields& dump); // disabled
DumpFields& operator=(const DumpFields& dump); // disabled
};
#endif // ifdef OPAL_DUMPFIELDS_HH
inline std::ostream& operator<<(std::ostream& os, const DumpFields& b) {
b.print(os);
return os;
}
#endif // ifdef OPAL_DUMPFIELDS_HH
......@@ -28,6 +28,7 @@
#include <iostream>