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) {
499 "\" is protected and can't be used to name an object.");
502 "You cannot replace the already defined object \""
507 INFOMSG(
"Replacing the object \"" << name <<
"\"." <<
endl);
516 const std::string &tableName = table->
getOpalName();
520 std::cerr <<
std::endl <<
"Erasing dependent table \""
534 (*i).second->replace(oldObject, newObject);
548 if (
ValueDefinition *p0 = dynamic_cast<ValueDefinition *>(newObject)) {
557 if (oldObject !=
nullptr) {
561 Object *child = &*i->second;
587 os <<
std::endl <<
"Object names matching the pattern \""
592 const std::string
name = (*index).first;
594 if (! name.empty() && regex.
match(name)) {
598 column += name.length();
603 }
while((column % 20) != 0);
616 std::vector<std::string> name_list;
619 const std::string
name = (*index).first;
620 name_list.push_back(name);
676 int const pdot = fn.rfind(
".");
677 return fn.substr(0, pdot);
685 "OpalData::checkAndAddOutputFileName",
686 "Duplicate file name for output, '" + outfn +
"', detected");
708 (*i).second->update();
717 std::map<std::string, std::string> udata;
719 for (
auto& uvar : uvars) {
721 if (dynamic_cast<RealVariable*>(tmpObject)) {
723 udata[uvar] = std::to_string(variable->
getReal());
724 }
else if (dynamic_cast<StringConstant*>(tmpObject)) {
729 "Type of '" + uvar +
"' not supported. "
730 "Only support for REAL and STRING.");
737 std::vector<std::string>
result;
741 std::string tmpName = (*index).first;
742 if (!tmpName.empty()) {
745 if (!tmpObject || tmpObject->
isBuiltin())
748 result.push_back(tmpName);
770 for (
int i = 0; i < argc; ++ i) {
void setOpenMode(OpenMode openMode)
int getRestartStep()
get the step where to restart
int getLastStep() const
get the last step from a possible previous run
The global OPAL structure.
void setMaxTrackSteps(unsigned long long s)
static OpalData * getInstance()
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
void setP0(ValueDefinition *p0)
Set the global momentum.
The base class for all OPAL objects.
void setInPrepState(bool state)
double getGlobalPhaseShift()
units: (sec)
std::vector< std::string > getVariableNames()
void setGlobalPhaseShift(double shift)
units: (sec)
void update()
Update all objects.
void setLastStep(const int &step)
set the last step in a run for possible follow-up run
energyEvolution_t::iterator getFirstEnergyData()
A map of string versus pointer to Object.
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
bool isBuiltin() const
True, if [b]this[/b] is a built-in object.
void define(Object *newObject)
Define a new object.
static OpalData * popInstance()
void setGlobalGeometry(BoundaryGeometry *bg)
void setMaxPhase(std::string elName, double phi)
void printTitle(std::ostream &)
Print the page title.
std::string getTitle()
Get the title string.
void makeDirty(Object *object)
Invalidate expressions.
Object * find(const std::string &name) const
Find entry.
void setParent(Object *)
Set parent object.
unsigned long long maxTrackSteps_m
std::vector< std::string > getArguments()
The base class for all OPAL tables.
std::map< std::string, unsigned int > problemSize_m
static void deleteInstance()
std::list< Table * > tableDirectory
std::string getInputFn()
get opals input filename
void setRestartStep(int s)
store the location where to restart
std::string getRestartFileName()
get opals restart h5 format filename
bool inRestartRun()
true if we do a restart run
OpalData::OpenMode openMode_m
Mode for writing files.
virtual void operator()(Object *) const
The function to be executed.
void checkAndAddOutputFileName(const std::string &outfn)
checks the output file names of all items to avoid duplicates
BoundaryGeometry * getGlobalGeometry()
int getNumberOfMaxPhases()
void storeTitle(const std::string &)
Store the page title.
void reset()
reset object for consecutive runs
std::vector< std::string > arguments_m
Inform & endl(Inform &inf)
std::set< AttributeBase * >::iterator exprIterator
virtual const std::string getCategory() const =0
Return the object category as a string.
void create(Object *newObject)
Create new object.
static std::stack< OpalData * > stashedInstances
void setRestartRun(const bool &value=true)
set OPAL in restart mode
std::vector< MaxPhasesT >::iterator getLastMaxPhases()
std::vector< std::string > getAllNames() const
Get a list of all objects.
std::string::iterator iterator
bool hasRestartFile()
true if we do a restart from specified h5 file
virtual double getReal() const
Return value.
The base class for all OPAL exceptions.
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
void unregisterTable(Table *t)
Unregister table.
ObjectDir::iterator end()
Last object in alphabetic order of name.
Object * getParent() const
Return parent pointer.
void erase()
Delete all entries.
static void stashInstance()
void setRestartDumpFreq(const int &N)
set the dump frequency as found in restart file
virtual double getReal() const
Return real value.
ValueDefinition * referenceMomentum
bool match(const std::string &s) const
Match a string against the pattern.
void unregisterExpression(AttributeBase *)
Unregister expression.
std::map< std::string, std::string > getVariableData()
void apply(const ObjectFunction &)
Apply a function to all objects.
void printNames(std::ostream &stream, const std::string &pattern)
Print all objects.
OpenMode
Enum for writing to files.
static bool isInstantiated
void addEnergyData(double spos, double ekin)
const std::string & getOpalName() const
Return object name.
Abstract base class for attribute values of different types.
double getP0() const
Return value of global reference momentum.
OpenMode getOpenMode() const
void storeArguments(int argc, char *argv[])
The base class for all OPAL value definitions.
void setDataSink(DataSink *s)
std::set< AttributeBase * > exprDirectory
std::vector< MaxPhasesT > maxPhases_m
std::vector< MaxPhasesT >::iterator getFirstMaxPhases()
virtual bool isDependent(const std::string &name) const =0
Find out if table depends on the object identified by [b]name[/b].
PartBunchBase< double, 3 > * getPartBunch()
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
#define MAX_NUM_INSTANCES
std::string getInputBasename()
get input file name without extension
unsigned long long getMaxTrackSteps()
virtual std::string getString() const
Return value.
Object * find(const std::string &name)
Find entry.
void storeInputFn(const std::string &fn)
store opals input filename
void erase(const std::string &name)
Delete existing entry.
void setPartBunch(PartBunchBase< double, 3 > *p)
Abstract base class for functor objects whose argument is an Object.
PartBunchBase< double, 3 > * bunch_m
void setDirty(bool)
Set/reset the [b]modified[/b] flag.
std::map< double, double > energyEvolution_t
std::set< std::string > outFiles_m
int getRestartDumpFreq() const
get the dump frequency as found in restart file
void registerExpression(AttributeBase *)
Register expression.
void registerTable(Table *t)
Register table.
energyEvolution_t energyEvolution_m
std::pair< std::string, double > MaxPhasesT
energyEvolution_t::iterator getLastEnergyData()
ObjectDir::iterator begin()
First object in alphabetic order of name.
bool hasDataSinkAllocated_m
void incMaxTrackSteps(unsigned long long s)
void setPriorTrack(const bool &value=true)
true if in follow-up track
const std::map< std::string, unsigned int > & getProblemCharacteristicValues() const
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
static OpalData * instance
void insert(const std::string &name, Object *newObject)
Define new object.
std::list< Table * >::iterator tableIterator
bool hasPriorTrack()
true if in follow-up track
void setRestartFileName(std::string s)
store opals restart h5 format filename