Commit 49eaa93e authored by frey_m's avatar frey_m
Browse files

Removal of PSDUMPLOCALFRAME option in favour of the more general option PSDUMPFRAME.

modified:   src/Algorithms/ParallelCyclotronTracker.cpp
modified:   src/BasicActions/Option.cpp
modified:   src/BasicActions/Option.h
modified:   src/Classic/Utilities/Options.cpp
modified:   src/Classic/Utilities/Options.h
modified:   src/Structure/H5PartWrapperForPC.cpp
parent 5eb2efba
......@@ -464,7 +464,7 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
// If the user wants to save the restarted run in local frame,
// make sure the previous h5 file was local too
if (Options::psDumpLocalFrame != Options::GLOBAL) {
if (Options::psDumpFrame != Options::GLOBAL) {
if (!previousH5Local) {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
"You are trying a local restart from a global h5 file!");
......@@ -2356,7 +2356,7 @@ void ParallelCyclotronTracker::initDistInGlobalFrame() {
// Do a local frame restart (we have already checked that the old h5 file was saved in local
// frame as well).
// Cave: Multi-bunch must not be done in the local frame! (TODO: Is this still true? -DW)
if((Options::psDumpLocalFrame != Options::GLOBAL)) {
if((Options::psDumpFrame != Options::GLOBAL)) {
*gmsg << "* Restart in the local frame" << endl;
......@@ -2598,7 +2598,7 @@ void ParallelCyclotronTracker::bunchDumpStatData(){
double const temp_t = itsBunch_m->getT() * 1e9; // s -> ns
Vector_t meanR;
Vector_t meanP;
if (Options::psDumpLocalFrame == Options::BUNCH_MEAN) {
if (Options::psDumpFrame == Options::BUNCH_MEAN) {
meanR = calcMeanR();
meanP = calcMeanP();
} else {
......@@ -2617,7 +2617,7 @@ void ParallelCyclotronTracker::bunchDumpStatData(){
// If we are saving in local frame, bunch and fields at the bunch center have to be rotated
// TODO: Make decision if we maybe want to always save statistics data in local frame? -DW
if(Options::psDumpLocalFrame != Options::GLOBAL) {
if(Options::psDumpFrame != Options::GLOBAL) {
// -------------------- ----------- Do Transformations ---------------------------------- //
// Bunch (local) azimuth at meanR w.r.t. y-axis
phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * pi;
......@@ -2645,7 +2645,7 @@ void ParallelCyclotronTracker::bunchDumpStatData(){
//itsBunch_m->R *= Vector_t(1000.0); // m -> mm
// If we are in local mode, transform back after saving
if(Options::psDumpLocalFrame != Options::GLOBAL) {
if(Options::psDumpFrame != Options::GLOBAL) {
localToGlobal(itsBunch_m->R, phi, psi);
localToGlobal(itsBunch_m->P, phi, psi);
}
......@@ -2668,7 +2668,7 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
Vector_t meanR;
Vector_t meanP;
if (Options::psDumpLocalFrame == Options::BUNCH_MEAN) {
if (Options::psDumpFrame == Options::BUNCH_MEAN) {
meanR = calcMeanR();
meanP = calcMeanP();
} else {
......@@ -2716,7 +2716,7 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
// -------------- If flag DumpLocalFrame is not set, dump bunch in global frame ------------- //
if (Options::psDumpFreq < std::numeric_limits<int>::max() ){
if (Options::psDumpLocalFrame == Options::GLOBAL) {
if (Options::psDumpFrame == Options::GLOBAL) {
FDext_m[0] = extB_m * 0.1; // kgauss --> T
FDext_m[1] = extE_m;
......
......@@ -55,7 +55,6 @@ namespace {
PSDUMPFREQ,
STATDUMPFREQ,
PSDUMPEACHTURN,
PSDUMPLOCALFRAME,
PSDUMPFRAME,
SPTDUMPFREQ,
REPARTFREQ,
......@@ -94,8 +93,8 @@ namespace {
Option::Option():
Action(SIZE, "OPTION",
"The \"OPTION\" statement defines OPAL execution options."),
psDumpLocalFrame_m(false) {
"The \"OPTION\" statement defines OPAL execution options.")
{
itsAttr[ECHO] = Attributes::makeBool
("ECHO", "If true, give echo of input", echo);
......@@ -132,9 +131,6 @@ Option::Option():
itsAttr[REMOTEPARTDEL] = Attributes::makeReal
("REMOTEPARTDEL", "Artifically delete the remote particle if its distance to the beam mass is larger than REMOTEPARTDEL times of the beam rms size, its default values is 0 (no delete) ",0.0);
itsAttr[PSDUMPLOCALFRAME] = Attributes::makeBool
("PSDUMPLOCALFRAME", "Deprecated; please use PSDUMPFRAME.");
itsAttr[PSDUMPFRAME] = Attributes::makeString
("PSDUMPFRAME", "Controls the frame of phase space dump in stat file and h5 file. If 'GLOBAL' OPAL will dump in the lab (global) Cartesian frame; if 'BUNCH_MEAN' OPAL will dump in the local Cartesian frame of the beam mean; if 'REFERENCE' OPAL will dump in the local Cartesian frame of the reference particle 0. Only aviable for OPAL-cycl, its default value is 'GLOBAL'");
......@@ -220,8 +216,7 @@ Option::Option():
Option::Option(const std::string &name, Option *parent):
Action(name, parent),
psDumpLocalFrame_m(parent->psDumpLocalFrame_m) {
Action(name, parent) {
Attributes::setBool(itsAttr[ECHO], echo);
Attributes::setBool(itsAttr[INFO], info);
Attributes::setBool(itsAttr[TRACE], mtrace);
......@@ -230,8 +225,7 @@ Option::Option(const std::string &name, Option *parent):
Attributes::setReal(itsAttr[PSDUMPFREQ], psDumpFreq);
Attributes::setReal(itsAttr[STATDUMPFREQ], statDumpFreq);
Attributes::setBool(itsAttr[PSDUMPEACHTURN], psDumpEachTurn);
Attributes::setBool(itsAttr[PSDUMPLOCALFRAME], psDumpLocalFrame_m);
Attributes::setString(itsAttr[PSDUMPFRAME], DumpFrameToString(psDumpLocalFrame));
Attributes::setString(itsAttr[PSDUMPFRAME], DumpFrameToString(psDumpFrame));
Attributes::setReal(itsAttr[SPTDUMPFREQ], sptDumpFreq);
Attributes::setReal(itsAttr[SCSOLVEFREQ], scSolveFreq);
Attributes::setReal(itsAttr[MTSSUBSTEPS], mtsSubsteps);
......@@ -313,8 +307,7 @@ void Option::execute() {
IpplInfo::Info->on(info);
IpplInfo::Warn->on(warn);
handlePsDumpFrame(Attributes::getBool(itsAttr[PSDUMPLOCALFRAME]),
Util::toUpper(Attributes::getString(itsAttr[PSDUMPFRAME])));
handlePsDumpFrame(Util::toUpper(Attributes::getString(itsAttr[PSDUMPFRAME])));
if(itsAttr[ASCIIDUMP]) {
asciidump = Attributes::getBool(itsAttr[ASCIIDUMP]);
......@@ -422,26 +415,13 @@ void Option::execute() {
}
}
void Option::handlePsDumpFrame(bool localFrame, const std::string &dumpFrame) {
psDumpLocalFrame_m = localFrame;
if (psDumpLocalFrame_m) {
if (dumpFrame == "GLOBAL") {
// psDumpFrame_m == "BUNCH_MEAN"; // What did you want to do here?
// This line always evalues to false
// and the result isn't stored.
// psDumpFrame_m = "BUNCH_MEAN"; // Did you mean this?
} else {
std::string msg = std::string("Either set 'PSDUMPLOCALFRAME' Option")+\
std::string(" or 'PSDUMPFRAME' Option but not both.");
throw OpalException("Option::handlePsDumpFrame", msg);
}
}
void Option::handlePsDumpFrame(const std::string &dumpFrame) {
if (dumpFrame == "GLOBAL") {
psDumpLocalFrame = GLOBAL;
psDumpFrame = GLOBAL;
} else if (dumpFrame == "BUNCH_MEAN") {
psDumpLocalFrame = BUNCH_MEAN;
psDumpFrame = BUNCH_MEAN;
} else if (dumpFrame == "REFERENCE") {
psDumpLocalFrame = REFERENCE;
psDumpFrame = REFERENCE;
} else {
std::string msg = std::string("Did not recognise PSDUMPFRAME '")+\
dumpFrame+std::string("'. It should be one of 'GLOBAL',")+\
......
......@@ -42,8 +42,7 @@ public:
virtual void execute();
private:
void handlePsDumpFrame(bool localFrame, const std::string &dumpFrame);
bool psDumpLocalFrame_m;
void handlePsDumpFrame(const std::string &dumpFrame);
// Not implemented.
Option(const Option &);
......
......@@ -29,7 +29,7 @@ namespace Options {
bool mtrace = false;
bool warn = true;
bool psDumpEachTurn = false;
DumpFrame psDumpLocalFrame = GLOBAL;
DumpFrame psDumpFrame = GLOBAL;
bool scan = false;
bool rhoDump = false;
bool ebDump = false;
......
......@@ -112,7 +112,7 @@ namespace Options {
// - GLOBAL, in Cartesian frame of the global particle
// - BUNCH_MEAN, in Cartesian frame of the bunch mean
// - REFERENCE, in Cartesian frame of the reference (0) particle
extern DumpFrame psDumpLocalFrame;
extern DumpFrame psDumpFrame;
/// The frequency to solve space charge fields.
extern int scSolveFreq;
......
......@@ -323,7 +323,7 @@ void H5PartWrapperForPC::writeStepHeader(PartBunchBase<double, 3>* bunch,
double mass = 1.0e-9 * bunch->getM();
double charge = bunch->getCharge();
h5_int64_t localFrame = Options::psDumpLocalFrame;
h5_int64_t localFrame = ( Options::psDumpFrame != Options::GLOBAL );
double sposHead = 0.0;
double sposRef = 0.0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment