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

Merge branch '647-add-option-to-write-vtk-file' into 'master'

Resolve "Add option to write VTK file"

Closes #647

See merge request !488
parents c1a4eba7 4afce1f2
......@@ -35,7 +35,7 @@
#include <limits>
#include <cstddef>
extern Inform *gmsg;
extern Inform* gmsg;
using namespace Options;
......@@ -64,13 +64,13 @@ namespace {
EBDUMP,
CSRDUMP,
AUTOPHASE,
SURFDUMPFREQ,
NUMBLOCKS,
RECYCLEBLOCKS,
NLHS,
CZERO,
RNGTYPE,
ENABLEHDF5,
ENABLEVTK,
ASCIIDUMP,
BOUNDPDESTROYFQ,
BEAMHALOBOUNDARY,
......@@ -105,7 +105,9 @@ Option::Option():
("INFO", "If true, print information messages", info);
itsAttr[TRACE] = Attributes::makeBool
("TRACE", "If true, print execution trace", mtrace);
("TRACE", "If true, print execution trace"
"Must be the first option in the inputfile in "
"order to render correct results", mtrace);
itsAttr[WARN] = Attributes::makeBool
("WARN", "If true, print warning messages", warn);
......@@ -136,14 +138,16 @@ Option::Option():
itsAttr[SCSOLVEFREQ] = Attributes::makeReal
("SCSOLVEFREQ", "The frequency to solve space charge fields. its default value is 1");
itsAttr[MTSSUBSTEPS] = Attributes::makeReal("MTSSUBSTEPS", "How many small timesteps "
itsAttr[MTSSUBSTEPS] = Attributes::makeReal
("MTSSUBSTEPS", "How many small timesteps "
"are inside the large timestep used in multiple "
"time stepping (MTS) integrator");
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);
("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) ",remotePartDel);
itsAttr[PSDUMPFRAME] = Attributes::makeUpperCaseString
("PSDUMPFRAME", "Controls the frame of phase space dump in "
......@@ -151,13 +155,13 @@ Option::Option():
"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 "
"frame of the reference particle 0. Only available for "
"OPAL-cycl, its default value is 'GLOBAL'");
itsAttr[SPTDUMPFREQ] = Attributes::makeReal
("SPTDUMPFREQ", "The frequency to dump single "
"particle trajectory of particles with ID = 0 & 1, "
"its default value is 1. ");
"its default value is 1.", sptDumpFreq);
itsAttr[REPARTFREQ] = Attributes::makeReal
("REPARTFREQ", "The frequency to do particles repartition "
......@@ -195,20 +199,14 @@ Option::Option():
"acceleration. Defines the number of refinements of the "
"search range", autoPhase);
itsAttr[SURFDUMPFREQ] = Attributes::makeReal
("SURFDUMPFREQ", "The frequency to dump surface-particle "
"interaction data, its default value is -1 (no dump).",
surfDumpFreq);
itsAttr[CZERO] = Attributes::makeBool
("CZERO", "If set to true a symmetric distribution is "
"created -> centroid == 0.0 ", cZero);
"created -> centroid == 0.0", cZero);
itsAttr[RNGTYPE] = Attributes::makeUpperCaseString
("RNGTYPE", "RANDOM (default), Quasi-random number "
"generators: HALTON, SOBOL, NIEDERREITER (Gsl ref manual 18.5)", rngtype);
itsAttr[CLOTUNEONLY] = Attributes::makeBool
("CLOTUNEONLY", "If set to true stop after "
"CLO and tune calculation ", cloTuneOnly);
......@@ -216,9 +214,11 @@ Option::Option():
itsAttr[NUMBLOCKS] = Attributes::makeReal
("NUMBLOCKS", "Maximum number of vectors in the Krylov "
"space (for RCGSolMgr). Default value is 0 and BlockCGSolMgr will be used.");
itsAttr[RECYCLEBLOCKS] = Attributes::makeReal
("RECYCLEBLOCKS", "Number of vectors in the recycle "
"space (for RCGSolMgr). Default value is 0 and BlockCGSolMgr will be used.");
itsAttr[NLHS] = Attributes::makeReal
("NLHS", "Number of stored old solutions for extrapolating "
"the new starting vector. Default value is 1 and just the last solution is used.");
......@@ -226,23 +226,30 @@ Option::Option():
itsAttr[ENABLEHDF5] = Attributes::makeBool
("ENABLEHDF5", "If true, HDF5 actions are enabled", enableHDF5);
itsAttr[ENABLEVTK] = Attributes::makeBool
("ENABLEVTK", "If true, writing of VTK files are enabled", enableVTK);
itsAttr[ASCIIDUMP] = Attributes::makeBool
("ASCIIDUMP", "If true, some of the elements dump in ASCII instead of HDF5", false);
("ASCIIDUMP", "If true, some of the elements dump in ASCII instead of HDF5", asciidump);
itsAttr[BOUNDPDESTROYFQ] = Attributes::makeReal
("BOUNDPDESTROYFQ", "The frequency to do boundp_destroy to delete lost particles. Default 10",10.0);
("BOUNDPDESTROYFQ", "The frequency to do boundp_destroy to "
"delete lost particles. Default 10", boundpDestroyFreq);
itsAttr[BEAMHALOBOUNDARY] = Attributes::makeReal
("BEAMHALOBOUNDARY", "Defines in terms of sigma where the halo starts. Default 0.0",0.0);
("BEAMHALOBOUNDARY", "Defines in terms of sigma where "
"the halo starts. Default 0.0", beamHaloBoundary);
itsAttr[IDEALIZED] = Attributes::makeBool
("IDEALIZED", "Using the hard edge model for the calculation of path length. Default: false", false);
("IDEALIZED", "Using the hard edge model for the calculation "
"of path length. Default: false", idealized);
itsAttr[LOGBENDTRAJECTORY] = Attributes::makeBool
("LOGBENDTRAJECTORY", "Writing the trajectory of every bend to disk. Default: false", false);
("LOGBENDTRAJECTORY", "Writing the trajectory of "
"every bend to disk. Default: false", writeBendTrajectories);
itsAttr[VERSION] = Attributes::makeReal
("VERSION", "Version of OPAL for which input file was written", 10000);
("VERSION", "Version of OPAL for which input file was written", version);
#ifdef ENABLE_AMR
itsAttr[AMR] = Attributes::makeBool
......@@ -258,6 +265,7 @@ Option::Option():
"in multi-bunch mode (default: 10)",
amrRegridFreq);
#endif
itsAttr[MEMORYDUMP] = Attributes::makeBool
("MEMORYDUMP", "If true, write memory to SDDS file", memoryDump);
......@@ -265,7 +273,8 @@ Option::Option():
("HALOSHIFT", "Constant parameter to shift halo value (default: 0.0)", haloShift);
itsAttr[DELPARTFREQ] = Attributes::makeReal
("DELPARTFREQ", "The frequency to delete particles, i.e. delete when step%delPartFreq == 0. Default: 1", delPartFreq);
("DELPARTFREQ", "The frequency to delete particles, "
"i.e. delete when step%delPartFreq == 0. Default: 1", delPartFreq);
registerOwnership(AttributeHandler::STATEMENT);
......@@ -273,7 +282,7 @@ Option::Option():
}
Option::Option(const std::string &name, Option *parent):
Option::Option(const std::string& name, Option* parent):
Action(name, parent) {
Attributes::setBool(itsAttr[ECHO], echo);
Attributes::setBool(itsAttr[INFO], info);
......@@ -296,7 +305,6 @@ Option::Option(const std::string &name, Option *parent):
Attributes::setBool(itsAttr[EBDUMP], ebDump);
Attributes::setBool(itsAttr[CSRDUMP], csrDump);
Attributes::setReal(itsAttr[AUTOPHASE], autoPhase);
Attributes::setReal(itsAttr[SURFDUMPFREQ], surfDumpFreq);
Attributes::setBool(itsAttr[CZERO], cZero);
Attributes::setBool(itsAttr[CLOTUNEONLY], cloTuneOnly);
Attributes::setUpperCaseString(itsAttr[RNGTYPE], std::string(rngtype));
......@@ -304,6 +312,7 @@ Option::Option(const std::string &name, Option *parent):
Attributes::setReal(itsAttr[RECYCLEBLOCKS], recycleBlocks);
Attributes::setReal(itsAttr[NLHS], nLHS);
Attributes::setBool(itsAttr[ENABLEHDF5], enableHDF5);
Attributes::setBool(itsAttr[ENABLEVTK], enableVTK);
Attributes::setBool(itsAttr[ASCIIDUMP], asciidump);
Attributes::setReal(itsAttr[BOUNDPDESTROYFQ], boundpDestroyFreq);
Attributes::setReal(itsAttr[BEAMHALOBOUNDARY], beamHaloBoundary);
......@@ -325,7 +334,7 @@ Option::~Option()
{}
Option *Option::clone(const std::string &name) {
Option* Option::clone(const std::string& name) {
return new Option(name, this);
}
......@@ -337,11 +346,18 @@ void Option::execute() {
mtrace = Attributes::getBool(itsAttr[TRACE]);
warn = Attributes::getBool(itsAttr[WARN]);
psDumpEachTurn = Attributes::getBool(itsAttr[PSDUMPEACHTURN]);
remotePartDel = Attributes::getReal(itsAttr[REMOTEPARTDEL]);
rhoDump = Attributes::getBool(itsAttr[RHODUMP]);
ebDump = Attributes::getBool(itsAttr[EBDUMP]);
csrDump = Attributes::getBool(itsAttr[CSRDUMP]);
enableHDF5 = Attributes::getBool(itsAttr[ENABLEHDF5]);
enableVTK = Attributes::getBool(itsAttr[ENABLEVTK]);
idealized = Attributes::getBool(itsAttr[IDEALIZED]);
asciidump = Attributes::getBool(itsAttr[ASCIIDUMP]);
version = Attributes::getReal(itsAttr[VERSION]);
seed = Attributes::getReal(itsAttr[SEED]);
writeBendTrajectories = Attributes::getBool(itsAttr[LOGBENDTRAJECTORY]);
#ifdef ENABLE_AMR
amr = Attributes::getBool(itsAttr[AMR]);
amrYtDumpFreq = int(Attributes::getReal(itsAttr[AMR_YT_DUMP_FREQ]));
......@@ -353,6 +369,7 @@ void Option::execute() {
amrRegridFreq = int(Attributes::getReal(itsAttr[AMR_REGRID_FREQ]));
amrRegridFreq = ( amrRegridFreq < 1 ) ? 1 : amrRegridFreq;
#endif
memoryDump = Attributes::getBool(itsAttr[MEMORYDUMP]);
haloShift = Attributes::getReal(itsAttr[HALOSHIFT]);
delPartFreq = Attributes::getReal(itsAttr[DELPARTFREQ]);
......@@ -363,8 +380,6 @@ void Option::execute() {
memory->sample();
}
seed = Attributes::getReal(itsAttr[SEED]);
/// note: rangen is used only for the random number generator in the OPAL language
/// not for the distributions
......@@ -373,19 +388,14 @@ void Option::execute() {
else
rangen.init55(seed);
IpplInfo::Info->on(info);
IpplInfo::Warn->on(warn);
handlePsDumpFrame(Attributes::getString(itsAttr[PSDUMPFRAME]));
if(itsAttr[ASCIIDUMP]) {
asciidump = Attributes::getBool(itsAttr[ASCIIDUMP]);
}
/// note: rangen is used only for the random number generator in the OPAL language
/// not for the distributions
if(itsAttr[SEED]) {
if (itsAttr[SEED]) {
seed = int(Attributes::getReal(itsAttr[SEED]));
if (seed == -1)
rangen.init55(time(0));
......@@ -393,41 +403,34 @@ void Option::execute() {
rangen.init55(seed);
}
if(itsAttr[PSDUMPFREQ]) {
if (itsAttr[PSDUMPFREQ]) {
psDumpFreq = int(Attributes::getReal(itsAttr[PSDUMPFREQ]));
if (psDumpFreq==0)
psDumpFreq = std::numeric_limits<int>::max();
}
if(itsAttr[STATDUMPFREQ]) {
if (itsAttr[STATDUMPFREQ]) {
statDumpFreq = int(Attributes::getReal(itsAttr[STATDUMPFREQ]));
if (statDumpFreq==0)
statDumpFreq = std::numeric_limits<int>::max();
}
if(itsAttr[SPTDUMPFREQ]) {
if (itsAttr[SPTDUMPFREQ]) {
sptDumpFreq = int(Attributes::getReal(itsAttr[SPTDUMPFREQ]));
if (sptDumpFreq==0)
sptDumpFreq = std::numeric_limits<int>::max();
}
if(itsAttr[SCSOLVEFREQ]) {
if (itsAttr[SCSOLVEFREQ]) {
scSolveFreq = int(Attributes::getReal(itsAttr[SCSOLVEFREQ]));
scSolveFreq = ( scSolveFreq < 1 ) ? 1 : scSolveFreq;
}
if(itsAttr[MTSSUBSTEPS]) {
if (itsAttr[MTSSUBSTEPS]) {
mtsSubsteps = int(Attributes::getReal(itsAttr[MTSSUBSTEPS]));
}
if(itsAttr[REMOTEPARTDEL]) {
remotePartDel = Attributes::getReal(itsAttr[REMOTEPARTDEL]);
}
if(itsAttr[REPARTFREQ]) {
if (itsAttr[REPARTFREQ]) {
repartFreq = int(Attributes::getReal(itsAttr[REPARTFREQ]));
}
......@@ -439,48 +442,43 @@ void Option::execute() {
minStepForRebin = int(Attributes::getReal(itsAttr[MINSTEPFORREBIN]));
}
if(itsAttr[REBINFREQ]) {
if (itsAttr[REBINFREQ]) {
rebinFreq = int(Attributes::getReal(itsAttr[REBINFREQ]));
}
if(itsAttr[AUTOPHASE]) {
if (itsAttr[AUTOPHASE]) {
autoPhase = int(Attributes::getReal(itsAttr[AUTOPHASE]));
}
if(itsAttr[SURFDUMPFREQ]) {
surfDumpFreq = int(Attributes::getReal(itsAttr[SURFDUMPFREQ]));
}
if(itsAttr[NUMBLOCKS]) {
if (itsAttr[NUMBLOCKS]) {
numBlocks = int(Attributes::getReal(itsAttr[NUMBLOCKS]));
}
if(itsAttr[RECYCLEBLOCKS]) {
if (itsAttr[RECYCLEBLOCKS]) {
recycleBlocks = int(Attributes::getReal(itsAttr[RECYCLEBLOCKS]));
}
if(itsAttr[NLHS]) {
if (itsAttr[NLHS]) {
nLHS = int(Attributes::getReal(itsAttr[NLHS]));
}
if(itsAttr[CZERO]) {
if (itsAttr[CZERO]) {
cZero = bool(Attributes::getBool(itsAttr[CZERO]));
}
if(itsAttr[RNGTYPE]) {
if (itsAttr[RNGTYPE]) {
rngtype = std::string(Attributes::getString(itsAttr[RNGTYPE]));
} else {
rngtype = std::string("RANDOM");
}
if(itsAttr[BEAMHALOBOUNDARY]) {
if (itsAttr[BEAMHALOBOUNDARY]) {
beamHaloBoundary = Attributes::getReal(itsAttr[BEAMHALOBOUNDARY]);
}
else {
} else {
beamHaloBoundary = 0;
}
idealized = Attributes::getBool(itsAttr[IDEALIZED]);
writeBendTrajectories = Attributes::getBool(itsAttr[LOGBENDTRAJECTORY]);
if(itsAttr[CLOTUNEONLY]) {
if (itsAttr[CLOTUNEONLY]) {
cloTuneOnly = bool(Attributes::getBool(itsAttr[CLOTUNEONLY]));
} else {
cloTuneOnly = false;
......@@ -489,7 +487,7 @@ void Option::execute() {
// Set message flags.
FileStream::setEcho(echo);
if(Attributes::getBool(itsAttr[TELL])) {
if (Attributes::getBool(itsAttr[TELL])) {
*gmsg << "\nCurrent settings of options:\n" << *this << endl;
}
......@@ -499,7 +497,7 @@ void Option::execute() {
}
}
void Option::handlePsDumpFrame(const std::string &dumpFrame) {
void Option::handlePsDumpFrame(const std::string& dumpFrame) {
if (dumpFrame == "GLOBAL") {
psDumpFrame = GLOBAL;
} else if (dumpFrame == "BUNCH_MEAN") {
......
......@@ -32,21 +32,21 @@ public:
virtual ~Option();
/// Make clone.
virtual Option *clone(const std::string &name);
virtual Option* clone(const std::string& name);
/// Execute the command.
virtual void execute();
private:
void handlePsDumpFrame(const std::string &dumpFrame);
void handlePsDumpFrame(const std::string& dumpFrame);
void update(const std::vector<Attribute>&);
// Not implemented.
Option(const Option &);
void operator=(const Option &);
Option(const Option&);
void operator=(const Option&);
// Clone constructor.
Option(const std::string &name, Option *parent);
Option(const std::string& name, Option* parent);
};
#endif // OPAL_Option_HH
......@@ -18,104 +18,86 @@
//
#include "OptionTypes.h"
#include "Utilities/ClassicRandom.h"
#include <string>
namespace Options {
// The global program options.
bool echo = false;
bool info = true;
int infoLevel = 1;
bool warn = true;
int warnLevel = 1;
bool csrDump = false;
// If true create symmetric distribution
bool cZero = false;
bool asciidump = false;
// If the distance of a particle to bunch mass larger than remotePartDel times of the rms size of the bunch in any dimension,
// the particle will be deleted artifically to hold the accuracy of space charge calculation. The default setting of -1 stands for no deletion.
double remotePartDel = 0.0;
double beamHaloBoundary = 0;
bool writeBendTrajectories = false;
// The global program options.
bool mtrace = false;
bool psDumpEachTurn = false;
DumpFrame psDumpFrame = GLOBAL;
bool rhoDump = false;
bool ebDump = false;
bool enableHDF5 = true;
bool warn = true;
int warnLevel = 1;
// The global random generator.
Random rangen;
// The current random seed.
int seed = 123456789;
// the number of refinements of the search range for the phase with maximum energy
// if eq 0 then no autophase
int autoPhase = 6;
// The frequency to dump the phase space, i.e.dump data when step%psDumpFreq==0
int psDumpFreq = 10;
// // The frequency to dump the phase space, i.e.dump data when step%psDumpFreq==0
// double rDump = 0.0;
// The frequency to dump statistical quantities such as beam RMS properties, i.e. dump
// when step%statDumpFreq == 0.
int statDumpFreq = 10;
// The frequency to dump single particle trajectory of particles with ID = 0 & 1
bool psDumpEachTurn = false;
DumpFrame psDumpFrame = GLOBAL;
int sptDumpFreq = 1;
// The frequency to do particles repartition for better load balance between nodes
int repartFreq = 10;
// The number of bins that have to be emitted before the bin are squashed into a single bin
int minBinEmitted = 10;
// The number of steps into the simulation before the bins are squashed into a single bin
int minStepForRebin = 200;
// The frequency to reset energy bin ID for all particles
int rebinFreq = 100;
/// The frequency to solve space charge fields.
int scSolveFreq = 1;
// How many small timesteps are inside the large timestep used in multiple time stepping (MTS) integrator
int mtsSubsteps = 1;
// The frequency to dump the particle-geometry surface interation data, -1 stands for no dump.
int surfDumpFreq = -1;
double remotePartDel = 0.0;
bool rhoDump = false;
bool ebDump = false;
bool csrDump = false;
int autoPhase = 6;
// Options for the Belos solver
int numBlocks = 0;
int recycleBlocks = 0;
int nLHS = 1;
bool cZero = false;
std::string rngtype = std::string("RANDOM");
bool cloTuneOnly = false;
bool enableHDF5 = true;
bool enableVTK = true;
bool asciidump = false;
// Governs how often boundp_destroy is called to destroy lost particles
// Mainly used in the CyclotronTracker as of now -DW
int boundpDestroyFreq = 10;
// Using hard edge model for calculation of path length
double beamHaloBoundary = 0;
bool cloTuneOnly = false;
bool idealized = false;
// opal version of input file
bool writeBendTrajectories = false;
int version = 10000;
bool amr = false;
/// The frequency to dump AMR grid data and particles into file
int amrYtDumpFreq = 10;
int amrRegridFreq = 10;
......
......@@ -22,6 +22,8 @@
#include "OptionTypes.h"
#include "Utilities/ClassicRandom.h"
#include <string>
namespace Options {
/// Echo flag.
// If true, print an input echo.
......@@ -30,40 +32,17 @@ namespace Options {
/// Info flag.
// If true, print informative messages.
extern bool info;
extern int infoLevel;
/// Trace flag.
// If true, print CPU time before and after each command.
extern bool mtrace;
/// Warn flag.
// If true, print warning messages.
extern bool warn;
extern int warnLevel;
extern bool csrDump;
/// if true create symmetric distribution
extern bool cZero;
/// If true HDF5 files are written
extern bool enableHDF5;
extern bool asciidump;
// If the distance of a particle to bunch mass larger than remotePartDel times of the rms size of the bunch in any dimension,
// the particle will be deleted artifically to hold the accuracy of space charge calculation. The default setting of -1 stands for no deletion.
extern double remotePartDel;
extern double beamHaloBoundary;
extern bool writeBendTrajectories;
extern bool idealized;
/// Trace flag.
// If true, print CPU time before and after each command.
extern bool mtrace;
/// Random generator.
// The global random generator.
extern Random rangen;
......@@ -76,6 +55,16 @@ namespace Options {
/// The frequency to dump statistical values, e.e. dump data when step%statDumpFreq==0
extern int statDumpFreq;
/// phase space dump flag for OPAL-cycl
// if true, dump phase space after each turn
extern bool psDumpEachTurn;
/// flag to decide in which coordinate frame the phase space will be dumped for OPAL-cycl
// - 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 psDumpFrame;
/// The frequency to dump single particle trajectory of particles with ID = 0 & 1
extern int sptDumpFreq;
......@@ -91,51 +80,63 @@ namespace Options {
/// The frequency to reset energy bin ID for all particles
extern int rebinFreq;
/// phase space dump flag for OPAL-cycl
// if true, dump phase space after each turn
extern bool psDumpEachTurn;
// Governs how often boundp_destroy is called to destroy lost particles
// Mainly used in the CyclotronTracker as of now -DW
extern int boundpDestroyFreq;
/// flag to decide in which coordinate frame the phase space will be dumped for OPAL-cycl
// - 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 psDumpFrame;
/// The frequency to solve space charge fields.
extern int scSolveFreq;
// How many small timesteps are inside the large timestep used in multiple time stepping (MTS) integrator