51#define MAX_NUM_INSTANCES 10
153 mainDirectory(), referenceMomentum(0), modified(false), itsTitle_m(),
154 hasPriorRun_m(false),
157 hasRestartFile_m(false),
158 restart_dump_freq_m(1), last_step_m(0),
159 hasBunchAllocated_m(false),
160 hasDataSinkAllocated_m(false),
163 isInOPALCyclMode_m(false),
164 isInOPALTMode_m(false),
165 isOptimizerFlag_m(false),
166 isInPrepState_m(false)
216 "too many OpalData instances stashed");
226 "no OpalData instances stashed");
466 return p->
bg_m !=
nullptr;
481 if (oldObject !=
nullptr) {
483 "You cannot replace the object \"" +
name +
"\".");
494 if (oldObject !=
nullptr && oldObject != newObject) {
498 "You cannot replace the object \"" +
name +
"\".");
510 const std::string &tableName = table->
getOpalName();
514 std::cerr <<
std::endl <<
"Erasing dependent table \""
528 (*i).second->replace(oldObject, newObject);
552 if (oldObject !=
nullptr) {
556 Object *child = &*i->second;
582 os <<
std::endl <<
"Object names matching the pattern \""
587 const std::string
name = (*index).first;
593 column +=
name.length();
598 }
while((column % 20) != 0);
611 std::vector<std::string> name_list;
614 const std::string
name = (*index).first;
615 name_list.push_back(
name);
671 int const pdot = fn.rfind(
".");
672 return fn.substr(0, pdot);
680 "OpalData::checkAndAddOutputFileName",
681 "Duplicate file name for output, '" + outfn +
"', detected");
703 (*i).second->update();
712 std::map<std::string, std::string> udata;
714 for (
auto& uvar : uvars) {
718 udata[uvar] = std::to_string(variable->
getReal());
724 "Type of '" + uvar +
"' not supported. "
725 "Only support for REAL and STRING.");
732 std::vector<std::string> result;
736 std::string tmpName = (*index).first;
737 if (!tmpName.empty()) {
740 if (!tmpObject || tmpObject->
isBuiltin())
743 result.push_back(tmpName);
765 for (
int i = 0; i < argc; ++ i) {
#define MAX_NUM_INSTANCES
std::map< double, double > energyEvolution_t
std::pair< std::string, double > MaxPhasesT
Inform & endl(Inform &inf)
std::string::iterator iterator
Abstract base class for attribute values of different types.
A map of string versus pointer to Object.
void erase()
Delete all entries.
ObjectDir::iterator end()
Last object in alphabetic order of name.
ObjectDir::iterator begin()
First object in alphabetic order of name.
Object * find(const std::string &name) const
Find entry.
void insert(const std::string &name, Object *newObject)
Define new object.
The base class for all OPAL objects.
void setParent(Object *)
Set parent object.
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Object * getParent() const
Return parent pointer.
const std::string & getOpalName() const
Return object name.
void setDirty(bool)
Set/reset the [b]modified[/b] flag.
virtual const std::string getCategory() const =0
Return the object category as a string.
bool isBuiltin() const
True, if [b]this[/b] is a built-in object.
Abstract base class for functor objects whose argument is an Object.
std::list< Table * > tableDirectory
PartBunchBase< double, 3 > * bunch_m
energyEvolution_t energyEvolution_m
std::set< AttributeBase * > exprDirectory
std::list< Table * >::iterator tableIterator
std::map< std::string, unsigned int > problemSize_m
std::set< std::string > outFiles_m
std::vector< std::string > arguments_m
bool hasDataSinkAllocated_m
OpalData::OpenMode openMode_m
Mode for writing files.
ValueDefinition * referenceMomentum
std::set< AttributeBase * >::iterator exprIterator
unsigned long long maxTrackSteps_m
std::vector< MaxPhasesT > maxPhases_m
The global OPAL structure.
void addEnergyData(double spos, double ekin)
void storeTitle(const std::string &)
Store the page title.
double getP0() const
Return value of global reference momentum.
int getLastStep() const
get the last step from a possible previous run
void registerExpression(AttributeBase *)
Register expression.
int getNumberOfMaxPhases()
unsigned long long getMaxTrackSteps()
void storeInputFn(const std::string &fn)
store opals input filename
void setRestartDumpFreq(const int &N)
set the dump frequency as found in restart file
std::vector< MaxPhasesT >::iterator getLastMaxPhases()
void erase(const std::string &name)
Delete existing entry.
std::string getInputBasename()
get input file name without extension
void makeDirty(Object *object)
Invalidate expressions.
void setP0(ValueDefinition *p0)
Set the global momentum.
double getGlobalPhaseShift()
units: (sec)
std::map< std::string, std::string > getVariableData()
std::string getTitle()
Get the title string.
void checkAndAddOutputFileName(const std::string &outfn)
checks the output file names of all items to avoid duplicates
void setPartBunch(PartBunchBase< double, 3 > *p)
std::vector< MaxPhasesT >::iterator getFirstMaxPhases()
void printNames(std::ostream &stream, const std::string &pattern)
Print all objects.
void update()
Update all objects.
void apply(const ObjectFunction &)
Apply a function to all objects.
bool hasRestartFile()
true if we do a restart from specified h5 file
void setRestartRun(const bool &value=true)
set OPAL in restart mode
void setMaxPhase(std::string elName, double phi)
void setLastStep(const int &step)
set the last step in a run for possible follow-up run
std::vector< std::string > getArguments()
static void stashInstance()
int getRestartDumpFreq() const
get the dump frequency as found in restart file
std::string getRestartFileName()
get opals restart h5 format filename
std::string getInputFn()
get opals input filename
void unregisterExpression(AttributeBase *)
Unregister expression.
Object * find(const std::string &name)
Find entry.
bool hasPriorTrack()
true if in follow-up track
static std::stack< OpalData * > stashedInstances
int getRestartStep()
get the step where to restart
void create(Object *newObject)
Create new object.
static OpalData * instance
void printTitle(std::ostream &)
Print the page title.
static void deleteInstance()
void setRestartFileName(std::string s)
store opals restart h5 format filename
void setInPrepState(bool state)
void setPriorTrack(const bool &value=true)
true if in follow-up track
void setDataSink(DataSink *s)
OpenMode getOpenMode() const
std::vector< std::string > getAllNames() const
Get a list of all objects.
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
void setGlobalPhaseShift(double shift)
units: (sec)
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
energyEvolution_t::iterator getFirstEnergyData()
void unregisterTable(Table *t)
Unregister table.
void reset()
reset object for consecutive runs
static OpalData * getInstance()
void setMaxTrackSteps(unsigned long long s)
void storeArguments(int argc, char *argv[])
static bool isInstantiated
BoundaryGeometry * getGlobalGeometry()
void define(Object *newObject)
Define a new object.
energyEvolution_t::iterator getLastEnergyData()
OpenMode
Enum for writing to files.
void setRestartStep(int s)
store the location where to restart
void setGlobalGeometry(BoundaryGeometry *bg)
void incMaxTrackSteps(unsigned long long s)
static OpalData * popInstance()
void registerTable(Table *t)
Register table.
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
void setOpenMode(OpenMode openMode)
bool inRestartRun()
true if we do a restart run
const std::map< std::string, unsigned int > & getProblemCharacteristicValues() const
PartBunchBase< double, 3 > * getPartBunch()
std::vector< std::string > getVariableNames()
virtual void operator()(Object *) const
The function to be executed.
The base class for all OPAL tables.
virtual bool isDependent(const std::string &name) const =0
Find out if table depends on the object identified by [b]name[/b].
The base class for all OPAL value definitions.
virtual double getReal() const
Return real value.
The base class for all OPAL exceptions.
bool match(const std::string &s) const
Match a string against the pattern.
virtual double getReal() const
Return value.
virtual std::string getString() const
Return value.