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

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(): ...@@ -50,7 +50,7 @@ IndexMap::IndexMap():
void IndexMap::print(std::ostream &out) const { void IndexMap::print(std::ostream &out) const {
if (mapRange2Element_m.size() == 0) return; 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); out << std::fixed << std::setprecision(6);
auto mapIti = mapRange2Element_m.begin(); auto mapIti = mapRange2Element_m.begin();
auto mapItf = mapRange2Element_m.end(); auto mapItf = mapRange2Element_m.end();
...@@ -61,14 +61,14 @@ void IndexMap::print(std::ostream &out) const { ...@@ -61,14 +61,14 @@ void IndexMap::print(std::ostream &out) const {
for (; mapIti != mapItf; mapIti++) { for (; mapIti != mapItf; mapIti++) {
const key_t key = (*mapIti).first; const key_t key = (*mapIti).first;
const value_t val = (*mapIti).second; 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.begin
<< " - " << " - "
<< std::setw(numDigits + 7) << std::right << key.end << std::setw(numDigits + 7) << std::right << key.end
<< ") number of overlapping elements " << val.size() << "\n"; << ") number of overlapping elements " << val.size() << "\n";
for (auto element: val) { 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 ...@@ -410,4 +410,4 @@ IndexMap::value_t IndexMap::getTouchingElements(const IndexMap::key_t &range) co
bool IndexMap::almostEqual(double x, double y) { bool IndexMap::almostEqual(double x, double y) {
return (std::abs(x - y) < std::numeric_limits<double>::epsilon() * std::abs(x + y) * 2 || return (std::abs(x - y) < std::numeric_limits<double>::epsilon() * std::abs(x + y) * 2 ||
std::abs(x - y) < std::numeric_limits<double>::min()); std::abs(x - y) < std::numeric_limits<double>::min());
} }
\ No newline at end of file
This diff is collapsed.
...@@ -30,30 +30,28 @@ ...@@ -30,30 +30,28 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "AbsBeamline/Monitor.h"
#include "AbstractObjects/OpalData.h"
#include "Algorithms/OrbitThreader.h" #include "Algorithms/OrbitThreader.h"
#include "Algorithms/CavityAutophaser.h" #include "Algorithms/CavityAutophaser.h"
#include "BasicActions/Option.h"
#ifdef ENABLE_OPAL_FEL
#include "BeamlineCore/UndulatorRep.h"
#endif
#include "Beamlines/Beamline.h" #include "Beamlines/Beamline.h"
#include "Beamlines/FlaggedBeamline.h" #include "Beamlines/FlaggedBeamline.h"
#include "Distribution/Distribution.h"
#include "Elements/OpalBeamline.h"
#include "Solvers/CSRWakeFunction.h" #include "Solvers/CSRWakeFunction.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "AbstractObjects/OpalData.h" #include "Structure/BoundaryGeometry.h"
#include "Utilities/OpalException.h"
#include "BasicActions/Option.h"
#include "Utilities/Options.h" #include "Utilities/Options.h"
#include "Utilities/Timer.h"
#include "Utilities/Util.h" #include "Utilities/Util.h"
#include "Distribution/Distribution.h"
#include "ValueDefinitions/RealVariable.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 extern Inform* gmsg;
#include "BeamlineCore/UndulatorRep.h"
#endif
class PartData; class PartData;
...@@ -268,15 +266,16 @@ void ParallelTTracker::execute() { ...@@ -268,15 +266,16 @@ void ParallelTTracker::execute() {
unsigned long long step = itsBunch_m->getGlobalTrackStep(); unsigned long long step = itsBunch_m->getGlobalTrackStep();
OPALTimer::Timer myt1; 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) << "zstart at: " << Util::getLengthString(pathLength_m)
<< endl; << endl;
prepareEmission(); prepareEmission();
*gmsg << level1 *gmsg << "* Executing ParallelTTracker\n"
<< "Executing ParallelTTracker, initial dt= " << Util::getTimeString(itsBunch_m->getdT()) << ";\n" << "* Initial dt = " << Util::getTimeString(itsBunch_m->getdT()) << "\n"
<< "max integration steps " << stepSizes_m.getMaxSteps() << ", next step= " << step << endl; << "* Max integration steps = " << stepSizes_m.getMaxSteps()
<< ", next step = " << step << endl << endl;
setOptionalVariables(); setOptionalVariables();
...@@ -359,7 +358,8 @@ void ParallelTTracker::execute() { ...@@ -359,7 +358,8 @@ void ParallelTTracker::execute() {
itsOpalBeamline_m.switchElementsOff(); itsOpalBeamline_m.switchElementsOff();
OPALTimer::Timer myt3; OPALTimer::Timer myt3;
*gmsg << "done executing ParallelTTracker at " << myt3.time() << endl; *gmsg << endl << "* Done executing ParallelTTracker at "
<< myt3.time() << endl << endl;
Monitor::writeStatistics(); Monitor::writeStatistics();
...@@ -1407,4 +1407,4 @@ void ParallelTTracker::evenlyDistributeParticles() { ...@@ -1407,4 +1407,4 @@ void ParallelTTracker::evenlyDistributeParticles() {
if (requests.size() > 0) { if (requests.size() > 0) {
MPI_Waitall(requests.size(), &(requests[0]), MPI_STATUSES_IGNORE); MPI_Waitall(requests.size(), &(requests[0]), MPI_STATUSES_IGNORE);
} }
} }
\ No newline at end of file
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <iostream> #include <iostream>
extern Inform* gmsg;
Call::Call(): Call::Call():
Action(1, "CALL", Action(1, "CALL",
...@@ -57,14 +58,11 @@ void Call::execute() { ...@@ -57,14 +58,11 @@ void Call::execute() {
std::string file = Attributes::getString(itsAttr[0]); std::string file = Attributes::getString(itsAttr[0]);
if (Options::info && Ippl::myNode() == 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)); OpalParser().run(new FileStream(file));
if (Options::info && Ippl::myNode() == 0) {
std::cerr << "End reading input stream \"" << file << "\"." << std::endl;
}
} }
......
/* //
* Copyright (c) 2016, Chris Rogers // Class DumpEMFields
* All rights reserved. // DumpEMFields dumps the dynamically changing fields of a Ring in a user-
* Redistribution and use in source and binary forms, with or without // defined grid.
* modification, are permitted provided that the following conditions are met: //
* 1. Redistributions of source code must retain the above copyright notice, // Copyright (c) 2017, Chris Rogers
* this list of conditions and the following disclaimer. // All rights reserved
* 2. Redistributions in binary form must reproduce the above copyright notice, //
* this list of conditions and the following disclaimer in the documentation // This file is part of OPAL.
* and/or other materials provided with the distribution. //
* 3. Neither the name of STFC nor the names of its contributors may be used to // OPAL is free software: you can redistribute it and/or modify
* endorse or promote products derived from this software without specific // it under the terms of the GNU General Public License as published by
* prior written permission. // the Free Software Foundation, either version 3 of the License, or
* // (at your option) any later version.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" //
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // You should have received a copy of the GNU General Public License
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE //
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR #include "BasicActions/DumpEMFields.h"
* 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.
*/
#include "AbsBeamline/Component.h"
#include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h"
#include "Fields/Interpolation/NDGrid.h"
#include "Physics/Physics.h"
#include "Utilities/OpalException.h"
#include "Utilities/Util.h"
#include <fstream> #include <fstream>
#include <cmath> #include <cmath>
#include "Fields/Interpolation/NDGrid.h" // classic
#include "AbsBeamline/Component.h" // classic
#include "Utilities/OpalException.h"
#include "Attributes/Attributes.h"
#include "BasicActions/DumpEMFields.h"
// extern Inform *gmsg; extern Inform* gmsg;
std::unordered_set<DumpEMFields*> DumpEMFields::dumpsSet_m; std::unordered_set<DumpEMFields*> DumpEMFields::dumpsSet_m;
std::string DumpEMFields::dumpemfields_docstring =
std::string("The \"DUMPEMFIELDS\" statement dumps a field map to a user-defined")+
std::string(" field file, for checking that fields are generated correctly.")+
std::string(" The fields are written out on a grid in space and time.");
DumpEMFields::DumpEMFields() : DumpEMFields::DumpEMFields() :
Action(20, "DUMPEMFIELDS", dumpemfields_docstring.c_str()), Action(SIZE, "DUMPEMFIELDS",
grid_m(NULL), filename_m("") { "The \"DUMPEMFIELDS\" statement dumps a field map to a user-defined "
"field file, for checking that fields are generated correctly. "
"The fields are written out on a grid in space and time."),
grid_m(NULL),
filename_m(""),
coordinates_m(CoordinateSystem::CARTESIAN) {
// would be nice if "steps" could be integer // would be nice if "steps" could be integer
itsAttr[0] = Attributes::makeReal itsAttr[FILE_NAME] = Attributes::makeString
("X_START", "(Cartesian) Start point in the grid in x [m]"); ("FILE_NAME", "Name of the file to which field data is dumped");
itsAttr[1] = Attributes::makeReal
("DX", "(Cartesian) Grid step size in x [m]"); itsAttr[COORDINATE_SYSTEM] = Attributes::makeUpperCaseString
itsAttr[2] = Attributes::makeReal ("COORDINATE_SYSTEM", "Choose to use CARTESIAN (default) or CYLINDRICAL coordinates", "CARTESIAN");
("X_STEPS", "(Cartesian) Number of steps in x");
itsAttr[3] = Attributes::makeReal itsAttr[X_START] = Attributes::makeReal
("Y_START", "(Cartesian) Start point in the grid in y [m]"); ("X_START", "(Cartesian) Start point in the grid in x [m]");
itsAttr[4] = Attributes::makeReal
("DY", "(Cartesian) Grid step size in y [m]"); itsAttr[DX] = Attributes::makeReal
itsAttr[5] = Attributes::makeReal ("DX", "(Cartesian) Grid step size in x [m]");
("Y_STEPS", "(Cartesian) Number of steps in y");
itsAttr[6] = Attributes::makeReal itsAttr[X_STEPS] = Attributes::makeReal
("Z_START", "Start point in the grid in z [m]"); ("X_STEPS", "(Cartesian) Number of steps in x");
itsAttr[7] = Attributes::makeReal
("DZ", "Grid step size in z [m]"); itsAttr[Y_START] = Attributes::makeReal
itsAttr[8] = Attributes::makeReal ("Y_START", "(Cartesian) Start point in the grid in y [m]");
("Z_STEPS", "Number of steps in z");
itsAttr[9] = Attributes::makeReal itsAttr[DY] = Attributes::makeReal
("T_START", "Start point in the grid in time [ns]"); ("DY", "(Cartesian) Grid step size in y [m]");
itsAttr[10] = Attributes::makeReal
("DT", "Grid step size in time [ns]"); itsAttr[Y_STEPS] = Attributes::makeReal
itsAttr[11] = Attributes::makeReal ("Y_STEPS", "(Cartesian) Number of steps in y");
("T_STEPS", "Number of steps in time");
itsAttr[12] = Attributes::makeString itsAttr[Z_START] = Attributes::makeReal
("FILE_NAME", "Name of the file to which field data is dumped"); ("Z_START", "Start point in the grid in z [m]");
itsAttr[13] = Attributes::makeString("COORDINATE_SYSTEM",
"Choose to use 'Cartesian' or 'Cylindrical' coordinates"); itsAttr[DZ] = Attributes::makeReal
itsAttr[14] = Attributes::makeReal ("DZ", "Grid step size in z [m]");
("R_START", "(Cylindrical) Start point in the grid in radius [m]");
itsAttr[15] = Attributes::makeReal itsAttr[Z_STEPS] = Attributes::makeReal
("DR", "(Cylindrical) Grid step size in radius [m]"); ("Z_STEPS", "Number of steps in z");
itsAttr[16] = Attributes::makeReal
("R_STEPS", "(Cylindrical) Number of steps in radius"); itsAttr[T_START] = Attributes::makeReal
itsAttr[17] = Attributes::makeReal ("T_START", "Start point in the grid in time [ns]");
("PHI_START", "(Cylindrical) Start point in the grid in phi [rad]");
itsAttr[18] = Attributes::makeReal itsAttr[DT] = Attributes::makeReal
("DPHI", "(Cylindrical) Grid step size in phi [rad]"); ("DT", "Grid step size in time [ns]");
itsAttr[19] = Attributes::makeReal
("PHI_STEPS", "(Cylindrical) Number of steps in phi"); itsAttr[T_STEPS] = Attributes::makeReal
("T_STEPS", "Number of steps in time");
itsAttr[R_START] = Attributes::makeReal
("R_START", "(Cylindrical) Start point in the grid in radius [m]");
itsAttr[DR] = Attributes::makeReal
("DR", "(Cylindrical) Grid step size in radius [m]");
itsAttr[R_STEPS] = Attributes::makeReal
("R_STEPS", "(Cylindrical) Number of steps in radius");
itsAttr[PHI_START] = Attributes::makeReal
("PHI_START", "(Cylindrical) Start point in the grid in phi [rad]");
itsAttr[DPHI] = Attributes::makeReal
("DPHI", "(Cylindrical) Grid step size in phi [rad]");
itsAttr[PHI_STEPS] = Attributes::makeReal
("PHI_STEPS", "(Cylindrical) Number of steps in phi");
registerOwnership(AttributeHandler::STATEMENT);
} }
DumpEMFields::DumpEMFields(const std::string& name, DumpEMFields* parent):
Action(name, parent)
{}
DumpEMFields::~DumpEMFields() { DumpEMFields::~DumpEMFields() {
delete grid_m; delete grid_m;
dumpsSet_m.erase(this); dumpsSet_m.erase(this);
} }
DumpEMFields* DumpEMFields::clone(const std::string &/*name*/) { DumpEMFields* DumpEMFields::clone(const std::string& name) {
DumpEMFields* dumper = new DumpEMFields(); DumpEMFields* dumper = new DumpEMFields(name, this);
if (grid_m != NULL) { if (grid_m != NULL) {
dumper->grid_m = grid_m->clone(); dumper->grid_m = grid_m->clone();
} }
...@@ -108,22 +129,16 @@ DumpEMFields* DumpEMFields::clone(const std::string &/*name*/) { ...@@ -108,22 +129,16 @@ DumpEMFields* DumpEMFields::clone(const std::string &/*name*/) {
} }
void DumpEMFields::parseCoordinateSystem() { void DumpEMFields::parseCoordinateSystem() {
if (!itsAttr[13]) {
coordinates_m = CARTESIAN; std::string coordStr = Attributes::getString(itsAttr[COORDINATE_SYSTEM]);
return; if (coordStr == "CYLINDRICAL") {
} coordinates_m = CoordinateSystem::CYLINDRICAL;
std::string coordStr = Attributes::getString(itsAttr[13]); } else if (coordStr == "CARTESIAN") {
for (size_t i = 0; i < coordStr.size(); ++i) { coordinates_m = CoordinateSystem::CARTESIAN;
coordStr[i] = std::tolower(coordStr[i]);
}
if (coordStr == "cylindrical") {
coordinates_m = CYLINDRICAL;
} else if (coordStr == "cartesian") {
coordinates_m = CARTESIAN;
} else { } else {
throw OpalException("DumpEMFields::parseCoordinateSystem", throw OpalException("DumpEMFields::parseCoordinateSystem",
std::string("Failed to parse '")+Attributes::getString(itsAttr[13])+ "Failed to parse '" + coordStr +
std::string("'. OPAL expected either 'cylindrical' or 'cartesian'.")); "'. OPAL expected either CYLINDRICAL or CARTESIAN.");
} }
} }
...@@ -142,40 +157,40 @@ void DumpEMFields::buildGrid() { ...@@ -142,40 +157,40 @@ void DumpEMFields::buildGrid() {
std::vector<int> gridSize(4); std::vector<int> gridSize(4);
parseCoordinateSystem(); parseCoordinateSystem();
if (coordinates_m == CYLINDRICAL) { if (coordinates_m == CoordinateSystem::CYLINDRICAL) {
origin[0] = Attributes::getReal(itsAttr[14]); origin[0] = Attributes::getReal(itsAttr[R_START]);
spacing[0] = Attributes::getReal(itsAttr[15]); spacing[0] = Attributes::getReal(itsAttr[DR]);
double nr = Attributes::getReal(itsAttr[16]); double nr = Attributes::getReal(itsAttr[R_STEPS]);
checkInt(nr, "R_STEPS"); checkInt(nr, "R_STEPS");
gridSize[0] = nr; gridSize[0] = nr;
origin[1] = Attributes::getReal(itsAttr[17]); origin[1] = Attributes::getReal(itsAttr[PHI_START]);
spacing[1] = Attributes::getReal(itsAttr[18]); spacing[1] = Attributes::getReal(itsAttr[DPHI]);
double nphi = Attributes::getReal(itsAttr[19]); double nphi = Attributes::getReal(itsAttr[PHI_STEPS]);
checkInt(nphi, "PHI_STEPS"); checkInt(nphi, "PHI_STEPS");
gridSize[1] = nphi; gridSize[1] = nphi;
} else { } else {
origin[0] = Attributes::getReal(itsAttr[0]); origin[0] = Attributes::getReal(itsAttr[X_START]);
spacing[0] = Attributes::getReal(itsAttr[1]); spacing[0] = Attributes::getReal(itsAttr[DX]);
double nx = Attributes::getReal(itsAttr[2]); double nx = Attributes::getReal(itsAttr[X_STEPS]);
checkInt(nx, "X_STEPS"); checkInt(nx, "X_STEPS");
gridSize[0] = nx; gridSize[0] = nx;
origin[1] = Attributes::getReal(itsAttr[3]); origin[1] = Attributes::getReal(itsAttr[Y_START]);
spacing[1] = Attributes::getReal(itsAttr[4]); spacing[1] = Attributes::getReal(itsAttr[DY]);
double ny = Attributes::getReal(itsAttr[5]); double ny = Attributes::getReal(itsAttr[Y_STEPS]);
checkInt(ny, "Y_STEPS"); checkInt(ny, "Y_STEPS");
gridSize[1] = ny; gridSize[1] = ny;
} }
origin[2] = Attributes::getReal(itsAttr[6]); origin[2] = Attributes::getReal(itsAttr[Z_START]);
spacing[2] = Attributes::getReal(itsAttr[7]); spacing[2] = Attributes::getReal(itsAttr[DZ]);
double nz = Attributes::getReal(itsAttr[8]); double nz = Attributes::getReal(itsAttr[Z_STEPS]);
checkInt(nz, "Z_STEPS"); checkInt(nz, "Z_STEPS");
gridSize[2] = nz; gridSize[2] = nz;
origin[3] = Attributes::getReal(itsAttr[9]); origin[3] = Attributes::getReal(itsAttr[T_START]);
spacing[3] = Attributes::getReal(itsAttr[10]); spacing[3] = Attributes::getReal(itsAttr[DT]);
double nt = Attributes::getReal(itsAttr[11]); double nt = Attributes::getReal(itsAttr[T_STEPS]);
checkInt(nt, "T_STEPS"); checkInt(nt, "T_STEPS");
gridSize[3] = nt; gridSize[3] = nt;
...@@ -185,7 +200,7 @@ void DumpEMFields::buildGrid() { ...@@ -185,7 +200,7 @@ void DumpEMFields::buildGrid() {
grid_m = new interpolation::NDGrid(4, &gridSize[0], &spacing[0], &origin[0]); grid_m = new interpolation::NDGrid(4, &gridSize[0], &spacing[0], &origin[0]);
filename_m = Attributes::getString(itsAttr[12]); filename_m = Attributes::getString(itsAttr[FILE_NAME]);
} }
void DumpEMFields::writeFields(Component* field) { void DumpEMFields::writeFields(Component* field) {
...@@ -210,7 +225,7 @@ void DumpEMFields::checkInt(double real, std::string name, double tolerance) { ...@@ -210,7 +225,7 @@ void DumpEMFields::checkInt(double real, std::string name, double tolerance) {
void DumpEMFields::writeHeader(std::ofstream& fout) const { void DumpEMFields::writeHeader(std::ofstream& fout) const {
fout << grid_m->end().toInteger() << "\n"; fout << grid_m->end().toInteger() << "\n";
if (coordinates_m == CYLINDRICAL) { if (coordinates_m == CoordinateSystem::CYLINDRICAL) {
fout << 1 << " r [mm]\n"; fout << 1 << " r [mm]\n";
fout << 2 << " phi [degree]\n"; fout << 2 << " phi [degree]\n";
} else { } else {
...@@ -219,7 +234,7 @@ void DumpEMFields::writeHeader(std::ofstream& fout) const { ...@@ -219,7 +234,7 @@ void DumpEMFields::writeHeader(std::ofstream& fout) const {
} }
fout << 3 << " z [mm]\n"; fout << 3 << " z [mm]\n";
fout << 4 << " t [ns]\n"; fout << 4 << " t [ns]\n";
if (coordinates_m == CYLINDRICAL) { if (coordinates_m == CoordinateSystem::CYLINDRICAL) {
fout << 5 << " Br [kGauss]\n"; fout << 5 << " Br [kGauss]\n";
fout << 6 << " Bphi [kGauss]\n"; fout << 6 << " Bphi [kGauss]\n";
fout << 7 << " Bz [kGauss]\n"; fout << 7 << " Bz [kGauss]\n";
...@@ -245,7 +260,7 @@ void DumpEMFields::writeFieldLine(Component* field, ...@@ -245,7 +260,7 @@ void DumpEMFields::writeFieldLine(Component* field,
Vector_t E(0., 0., 0.); Vector_t E(0., 0., 0.);
Vector_t B(0., 0., 0.); Vector_t B(0., 0., 0.);
Vector_t point = pointIn; Vector_t point = pointIn;
if (coordinates_m == CYLINDRICAL) { if (coordinates_m == CoordinateSystem::CYLINDRICAL) {
// pointIn is r, phi, z // pointIn is r, phi, z
point[0] = std::cos(pointIn[1])*pointIn[0]; point[0] = std::cos(pointIn[1])*pointIn[0];
point[1] = std::sin(pointIn[1])*pointIn[0]; point[1] = std::sin(pointIn[1])*pointIn[0];
...@@ -254,13 +269,13 @@ void DumpEMFields::writeFieldLine(Component* field, ...@@ -254,13 +269,13 @@ void DumpEMFields::writeFieldLine(Component* field,
field->apply(point, centroid, time, E, B); field->apply(point, centroid, time, E, B);
Vector_t Bout = B; Vector_t Bout = B;
Vector_t Eout = E; Vector_t Eout = E;
if (coordinates_m == CYLINDRICAL) { if (coordinates_m == CoordinateSystem::CYLINDRICAL) {
// pointIn is r, phi, z // pointIn is r, phi, z
Bout[0] = B[0]*std::cos(pointIn[1])+B[1]*std::sin(pointIn[1]); Bout[0] = B[0]*std::cos(pointIn[1])+B[1]*std::sin(pointIn[1]);
Bout[1] = -B[0]*std::sin(pointIn[1])+B[1]*std::cos(pointIn[1]); Bout[1] = -B[0]*std::sin(pointIn[1])+B[1]*std::cos(pointIn[1]);
Eout[0] = E[0]*std::cos(pointIn[1])+E[1]*std::sin(pointIn[1]); Eout[0] = E[0]*std::cos(pointIn[1])+E[1]*std::sin(pointIn[1]);
Eout[1] = -E[0]*std::sin(pointIn[1])+E[1]*std::cos(pointIn[1]); Eout[1] = -E[0]*std::sin(pointIn[1])+E[1]*std::cos(pointIn[1]);
fout << pointIn[0] << " " << pointIn[1]*DEGREE << " " << pointIn[2] << " " << time << " "; fout << pointIn[0] << " " << pointIn[1]*Physics::rad2deg << " " << pointIn[2] << " " << time << " ";
} else { } else {
fout << pointIn[0] << " " << pointIn[1] << " " << pointIn[2] << " " << time << " "; fout << pointIn[0] << " " << pointIn[1] << " " << pointIn[2] << " " << time << " ";
} }
...@@ -274,11 +289,17 @@ void DumpEMFields::writeFieldThis(Component* field) { ...@@ -274,11 +289,17 @@ void DumpEMFields::writeFieldThis(Component* field) {
throw OpalException("DumpEMFields::writeFieldThis", throw OpalException("DumpEMFields::writeFieldThis",
"The grid was NULL; there was a problem with the DumpEMFields initialisation."); "The grid was NULL; there was a problem with the DumpEMFields initialisation.");
}