OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalData.cpp
Go to the documentation of this file.
1 //
2 // Class OpalData
3 // The global OPAL structure.
4 // The OPAL object holds all global data required for a OPAL execution.
5 // In particular it contains the main Directory, which allows retrieval
6 // of command objects by their name. For other data refer to the
7 // implementation file.
8 //
9 // Copyright (c) 200x - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
10 // All rights reserved
11 //
12 // This file is part of OPAL.
13 //
14 // OPAL is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21 //
23 
27 #include "AbstractObjects/Object.h"
29 #include "AbstractObjects/Table.h"
32 #include "Attributes/Attributes.h"
33 #include "OpalParser/OpalParser.h"
34 #include "Parser/FileStream.h"
35 #include "Parser/StringStream.h"
36 #include "Structure/DataSink.h"
39 #include "Utilities/Options.h"
43 
44 #include <iostream>
45 #include <list>
46 #include <set>
47 #include <algorithm>
48 
49 
50 #define MAX_NUM_INSTANCES 10
51 
52 
54  object->clear();
55 }
56 
57 
58 // Struct OpalDataImpl.
59 // ------------------------------------------------------------------------
60 struct OpalDataImpl {
61  OpalDataImpl();
62  ~OpalDataImpl();
63 
64  // The main object directory.
66 
67  // The value of the global momentum.
69 
70  // The flag telling that something has changed.
71  bool modified;
72 
73  // Directory of tables, for recalculation when something changes.
74  std::list<Table *> tableDirectory;
76 
77  // The set of expressions to be invalidated when something changes.
78  std::set <AttributeBase *> exprDirectory;
80 
81  // The page title from the latest TITLE command.
82  std::string itsTitle_m;
83 
85 
86  // true if we restart a simulation
88 
89  // Where to resume in a restart run
91 
92  // Where to resume in a restart run
93  std::string restartFn_m;
94 
95  // true if the name of a restartFile is specified
97 
98  // dump frequency as found in restart file
100 
101  // Input file name
102  std::string inputFn_m;
103 
104  std::set<std::string> outFiles_m;
105 
108 
109  // last step of a run
111 
113  // The particle bunch to be tracked.
115 
117 
119 
120  // In units of seconds. This is half of tEmission
122 
124 
125  std::vector<MaxPhasesT> maxPhases_m;
127 
128  // The cartesian mesh
130 
131  // The field layout f
133 
134  // The particle layout
136 
137  // the accumulated (over all TRACKs) number of steps
138  unsigned long long maxTrackSteps_m;
139 
144 
145  std::map<std::string, unsigned int> problemSize_m;
146 
147  std::vector<std::string> arguments_m;
148 };
149 
150 
152  mainDirectory(), referenceMomentum(0), modified(false), itsTitle_m(),
153  hasPriorRun_m(false),
154  isRestart_m(false),
155  restartStep_m(0),
156  hasRestartFile_m(false),
157  restart_dump_freq_m(1), last_step_m(0),
158  hasBunchAllocated_m(false),
159  hasDataSinkAllocated_m(false),
160  gPhaseShift_m(0.0),
161  maxTrackSteps_m(0),
162  isInOPALCyclMode_m(false),
163  isInOPALTMode_m(false),
164  isOptimizerFlag_m(false),
165  isInPrepState_m(false)
166 {
167  bunch_m = nullptr;
168  dataSink_m = nullptr;
169  bg_m = nullptr;
170  mesh_m = nullptr;
171  FL_m = nullptr;
172  PL_m = nullptr;
173 }
174 
176  // Make sure the main directory is cleared before the directories
177  // for tables and expressions are deleted.
178  delete mesh_m;// somehow this needs to be deleted first
179  delete FL_m;
180  //delete PL_m; //this gets deleted by FL_m
181 
182  delete bunch_m;
183  delete bg_m;
184  delete dataSink_m;
185 
187  tableDirectory.clear();
188  exprDirectory.clear();
189 }
190 
191 bool OpalData::isInstantiated = false;
192 OpalData *OpalData::instance = nullptr;
193 std::stack<OpalData*> OpalData::stashedInstances;
194 
196  if (!isInstantiated) {
197  instance = new OpalData();
198  isInstantiated = true;
199  return instance;
200  } else {
201  return instance;
202  }
203 }
204 
206  delete instance;
207  instance = nullptr;
208  isInstantiated = false;
209 }
210 
212  if (!isInstantiated) return;
213  if (stashedInstances.size() + 1 > MAX_NUM_INSTANCES) {
214  throw OpalException("OpalData::stashInstance()",
215  "too many OpalData instances stashed");
216  }
218  instance = nullptr;
219  isInstantiated = false;
220 }
221 
223  if (stashedInstances.size() == 0) {
224  throw OpalException("OpalData::popInstance()",
225  "no OpalData instances stashed");
226  }
228  instance = stashedInstances.top();
229  isInstantiated = true;
230  stashedInstances.pop();
231 
232  return instance;
233 }
234 
235 unsigned long long OpalData::getMaxTrackSteps() {
236  return p->maxTrackSteps_m;
237 }
238 
239 void OpalData::setMaxTrackSteps(unsigned long long s) {
240  p->maxTrackSteps_m = s;
241 }
242 
243 void OpalData::incMaxTrackSteps(unsigned long long s) {
244  p->maxTrackSteps_m += s;
245 }
246 
248  p = new OpalDataImpl();
249 }
250 
252  delete p;
253 }
254 
256  delete p;
257  p = new OpalDataImpl();
258  p->hasPriorRun_m = false;
259  p->isRestart_m = false;
260  p->hasRestartFile_m = false;
261  p->hasBunchAllocated_m = false;
262  p->hasDataSinkAllocated_m = false;
263  p->gPhaseShift_m = 0.0;
264  p->maxPhases_m.clear();
265  p->isInOPALCyclMode_m = false;
266  p->isInOPALTMode_m = false;
267  p->isInPrepState_m = false;
268  p->isOptimizerFlag_m = false;
269 }
270 
272  return p->isInOPALCyclMode_m;
273 }
274 
276  return p->isInOPALTMode_m;
277 }
278 
280  return p->isOptimizerFlag_m;
281 }
282 
284  p->isInOPALCyclMode_m = true;
285 }
286 
288  p->isInOPALTMode_m = true;
289 }
290 
292  p->isOptimizerFlag_m = true;
293 }
294 
296  return p->isInPrepState_m;
297 }
298 
299 void OpalData::setInPrepState(bool state) {
300  p->isInPrepState_m = state;
301 }
302 
304  return p->hasPriorRun_m;
305 }
306 
307 void OpalData::setPriorTrack(const bool &value) {
308  p->hasPriorRun_m = value;
309 }
310 
312  return p->isRestart_m;
313 }
314 
315 void OpalData::setRestartRun(const bool &value) {
316  p->isRestart_m = value;
317 }
318 
320  p->restartStep_m = s;
321 }
322 
324  return p->restartStep_m;
325 }
326 
328  return p->restartFn_m;
329 }
330 
331 void OpalData::setRestartFileName(std::string s) {
332  p->restartFn_m = s;
333  p->hasRestartFile_m = true;
334 }
335 
337  return p->hasRestartFile_m;
338 }
339 
340 void OpalData::setRestartDumpFreq(const int &N) {
341  p->restart_dump_freq_m = N;
342 }
343 
345  return p->restart_dump_freq_m;
346 }
347 
349  p->openMode_m = openMode;
350 }
351 
353  return p->openMode_m;
354 }
355 
356 void OpalData::setLastStep(const int &step) {
357  p->last_step_m = step;
358 }
359 
361  return p->last_step_m;
362 }
363 
365  return p->hasBunchAllocated_m;
366 }
367 
369  p->hasBunchAllocated_m = true;
370 }
371 
373  p->bunch_m = b;
374 }
375 
377  return p->bunch_m;
378 }
379 
381  return p->hasDataSinkAllocated_m;
382 }
383 
385  p->dataSink_m = s;
386  p->hasDataSinkAllocated_m = true;
387 }
388 
390  return p->dataSink_m;
391 }
392 
393 void OpalData::setMaxPhase(std::string elName, double phi) {
394  p->maxPhases_m.push_back(MaxPhasesT(elName, phi));
395 }
396 
398  return p->maxPhases_m.begin();
399 }
400 
402  return p->maxPhases_m.end();
403 }
404 
406  return p->maxPhases_m.size();
407 }
408 
409 void OpalData::addEnergyData(double spos, double ekin) {
410  p->energyEvolution_m.insert(std::make_pair(spos, ekin));
411 }
412 
414  return p->energyEvolution_m.begin();
415 }
416 
418  return p->energyEvolution_m.end();
419 }
420 
421 
422 // Mesh_t* OpalData::getMesh() {
423 // return p->mesh_m;
424 // }
425 
426 // FieldLayout_t* OpalData::getFieldLayout() {
427 // return p->FL_m;
428 // }
429 
430 // Layout_t* OpalData::getLayout() {
431 // return p->PL_m;
432 // }
433 
434 // void OpalData::setMesh(Mesh_t *mesh) {
435 // p->mesh_m = mesh;
436 // }
437 
438 // void OpalData::setFieldLayout(FieldLayout_t *fieldlayout) {
439 // p->FL_m = fieldlayout;
440 // }
441 
442 // void OpalData::setLayout(Layout_t *layout) {
443 // p->PL_m = layout;
444 // }
445 
446 void OpalData::setGlobalPhaseShift(double shift) {
448  p->gPhaseShift_m = shift;
449 }
450 
453  return p->gPhaseShift_m;
454 }
455 
457  p->bg_m = bg;
458 }
459 
461  return p->bg_m;
462 }
463 
465  return p->bg_m != nullptr;
466 }
467 
468 void OpalData::apply(const ObjectFunction &fun) {
470  i != p->mainDirectory.end(); ++i) {
471  fun(&*i->second);
472  }
473 }
474 
475 void OpalData::create(Object *newObject) {
476  // Test for existing node with same name.
477  const std::string name = newObject->getOpalName();
478  Object *oldObject = p->mainDirectory.find(name);
479 
480  if (oldObject != nullptr) {
481  throw OpalException("OpalData::create()",
482  "You cannot replace the object \"" + name + "\".");
483  } else {
484  p->mainDirectory.insert(name, newObject);
485  }
486 }
487 
488 void OpalData::define(Object *newObject) {
489  // Test for existing node with same name.
490  const std::string name = newObject->getOpalName();
491  Object *oldObject = p->mainDirectory.find(name);
492 
493  if (oldObject != nullptr && oldObject != newObject) {
494  // Attempt to replace an object.
495  if (oldObject->isBuiltin() || ! oldObject->canReplaceBy(newObject)) {
496  throw OpalException("OpalData::define()",
497  "You cannot replace the object \"" + name + "\".");
498  } else {
499  if (Options::info) {
500  INFOMSG("Replacing the object \"" << name << "\"." << endl);
501  }
502 
503  // Erase all tables which depend on the new object.
505  while(i != p->tableDirectory.end()) {
506  // We must increment i before calling erase(name),
507  // since erase(name) removes "this" from "tables".
508  Table *table = *i++;
509  const std::string &tableName = table->getOpalName();
510 
511  if (table->isDependent(name)) {
512  if (Options::info) {
513  std::cerr << std::endl << "Erasing dependent table \""
514  << tableName << "\"." << std::endl;
515  }
516 
517  // Remove table from directory.
518  // This erases the table from the main directory,
519  // and its destructor unregisters it from the table directory.
520  erase(tableName);
521  }
522  }
523 
524  // Replace all references to this object.
526  i != p->mainDirectory.end(); ++i) {
527  (*i).second->replace(oldObject, newObject);
528  }
529 
530  // Remove old object.
531  erase(name);
532  }
533  }
534 
535  // Force re-evaluation of expressions.
536  p->modified = true;
537  newObject->setDirty(true);
538  p->mainDirectory.insert(name, newObject);
539 
540  // If this is a new definition of "P0", insert its definition.
541  if (name == "P0") {
542  if (ValueDefinition *p0 = dynamic_cast<ValueDefinition *>(newObject)) {
543  setP0(p0);
544  }
545  }
546 }
547 
548 void OpalData::erase(const std::string &name) {
549  Object *oldObject = p->mainDirectory.find(name);
550 
551  if (oldObject != nullptr) {
552  // Relink all children of "this" to "this->getParent()".
554  i != p->mainDirectory.end(); ++i) {
555  Object *child = &*i->second;
556  if (child->getParent() == oldObject) {
557  child->setParent(oldObject->getParent());
558  }
559  }
560  // Remove the object.
562  }
563 }
564 
565 Object *OpalData::find(const std::string &name) {
566  return p->mainDirectory.find(name);
567 }
568 
569 double OpalData::getP0() const {
570  static const double energy_scale = 1.0e+9;
571  return p->referenceMomentum->getReal() * energy_scale;
572 }
573 
575  p->modified = true;
576  if (obj) obj->setDirty(true);
577 }
578 
579 void OpalData::printNames(std::ostream &os, const std::string &pattern) {
580  int column = 0;
581  RegularExpression regex(pattern);
582  os << std::endl << "Object names matching the pattern \""
583  << pattern << "\":" << std::endl;
584 
585  for (ObjectDir::const_iterator index = p->mainDirectory.begin();
586  index != p->mainDirectory.end(); ++index) {
587  const std::string name = (*index).first;
588 
589  if (! name.empty() && regex.match(name)) {
590  os << name;
591 
592  if (column < 80) {
593  column += name.length();
594 
595  do {
596  os << ' ';
597  column++;
598  } while((column % 20) != 0);
599  } else {
600  os << std::endl;
601  column = 0;
602  }
603  }
604  }
605 
606  if (column) os << std::endl;
607  os << std::endl;
608 }
609 
611  p->tableDirectory.push_back(table);
612 }
613 
615  for (OpalDataImpl::tableIterator i = p->tableDirectory.begin();
616  i != p->tableDirectory.end();) {
618  if (*j == table) p->tableDirectory.erase(j);
619  }
620 }
621 
623  p->exprDirectory.insert(expr);
624 }
625 
627  p->exprDirectory.erase(expr);
628 }
629 
631  p->referenceMomentum = p0;
632 }
633 
634 void OpalData::storeTitle(const std::string &title) {
635  p->itsTitle_m = title;
636 }
637 
638 void OpalData::storeInputFn(const std::string &fn) {
639  p->inputFn_m = fn;
640 }
641 
642 void OpalData::printTitle(std::ostream &os) {
643  os << p->itsTitle_m;
644 }
645 
646 std::string OpalData::getTitle() {
647  return p->itsTitle_m;
648 }
649 
651  return "data";
652 }
653 
654 std::string OpalData::getInputFn() {
655  return p->inputFn_m;
656 }
657 
659  std::string & fn = p->inputFn_m;
660  int const pdot = fn.rfind(".");
661  return fn.substr(0, pdot);
662 }
663 
664 void OpalData::checkAndAddOutputFileName(const std::string &outfn) {
665  if (p->outFiles_m.count(outfn) == 0) {
666  p->outFiles_m.insert(outfn);
667  } else if (!hasBunchAllocated()) {
668  throw OpalException(
669  "OpalData::checkAndAddOutputFileName",
670  "Duplicate file name for output, '" + outfn + "', detected");
671  }
672 }
673 
675  Inform msg("OpalData ");
676  if (p->modified) {
677  // Force re-evaluation of expressions.
678  for (OpalDataImpl::exprIterator i = p->exprDirectory.begin();
679  i != p->exprDirectory.end(); ++i) {
680  (*i)->invalidate();
681  }
682 
683  // Force refilling of dynamic tables.
684  for (OpalDataImpl::tableIterator i = p->tableDirectory.begin();
685  i != p->tableDirectory.end(); ++i) {
686  (*i)->invalidate();
687  }
688 
689  // Update all definitions.
691  i != p->mainDirectory.end(); ++i) {
692  (*i).second->update();
693  }
694 
695  // Definitions are up-to-date.
696  p->modified = false;
697  }
698 }
699 
700 std::map<std::string, std::string> OpalData::getVariableData() {
701  std::map<std::string, std::string> udata;
702  std::vector<std::string> uvars = this->getVariableNames();
703  for (auto& uvar : uvars) {
704  Object *tmpObject = OpalData::getInstance()->find(uvar);
705  if (dynamic_cast<RealVariable*>(tmpObject)) {
706  RealVariable* variable = dynamic_cast<RealVariable*>(OpalData::getInstance()->find(uvar));
707  udata[uvar] = std::to_string(variable->getReal());
708  } else if (dynamic_cast<StringConstant*>(tmpObject)) {
709  StringConstant* variable = dynamic_cast<StringConstant*>(OpalData::getInstance()->find(uvar));
710  udata[uvar] = variable->getString();
711  } else {
712  throw OpalException("OpalData::getVariableData()",
713  "Type of '" + uvar + "' not supported. "
714  "Only support for REAL and STRING.");
715  }
716  }
717  return udata;
718 }
719 
720 std::vector<std::string> OpalData::getVariableNames() {
721  std::vector<std::string> result;
722 
723  for (ObjectDir::const_iterator index = p->mainDirectory.begin();
724  index != p->mainDirectory.end(); ++index) {
725  std::string tmpName = (*index).first;
726  if (!tmpName.empty()) {
727  Object *tmpObject = OpalData::getInstance()->find(tmpName);
728  if (tmpObject) {
729  if (!tmpObject || tmpObject->isBuiltin())
730  continue;
731  if (tmpObject->getCategory() == "VARIABLE") {
732  result.push_back(tmpName);
733  }
734  }
735  }
736  }
737  return result;
738 }
739 
740 void OpalData::addProblemCharacteristicValue(const std::string &name, unsigned int value) {
741  if (p->problemSize_m.find(name) != p->problemSize_m.end()) {
742  p->problemSize_m.insert(std::make_pair(name, value));
743  } else {
744  p->problemSize_m[name] = value;
745  }
746 }
747 
748 const std::map<std::string, unsigned int> &OpalData::getProblemCharacteristicValues() const {
749  return p->problemSize_m;
750 }
751 
752 void OpalData::storeArguments(int argc, char *argv[]) {
753  p->arguments_m.clear();
754  for (int i = 0; i < argc; ++ i) {
755  p->arguments_m.push_back(argv[i]);
756  }
757 }
758 
759 std::vector<std::string> OpalData::getArguments() {
760  return p->arguments_m;
761 }
#define MAX_NUM_INSTANCES
Definition: OpalData.cpp:50
std::map< double, double > energyEvolution_t
Definition: OpalData.h:45
std::pair< std::string, double > MaxPhasesT
Definition: OpalData.h:41
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
#define INFOMSG(msg)
Definition: IpplInfo.h:348
const std::string name
std::string::iterator iterator
Definition: MSLang.h:16
bool info
Info flag.
Definition: Options.cpp:28
Abstract base class for attribute values of different types.
Definition: AttributeBase.h:32
A map of string versus pointer to Object.
Definition: Directory.h:38
void erase()
Delete all entries.
Definition: Directory.cpp:56
ObjectDir::iterator end()
Last object in alphabetic order of name.
Definition: Directory.cpp:46
ObjectDir::iterator begin()
First object in alphabetic order of name.
Definition: Directory.cpp:36
Object * find(const std::string &name) const
Find entry.
Definition: Directory.cpp:66
void insert(const std::string &name, Object *newObject)
Define new object.
Definition: Directory.cpp:77
The base class for all OPAL objects.
Definition: Object.h:48
void setParent(Object *)
Set parent object.
Definition: Object.cpp:307
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Definition: Object.cpp:48
Object * getParent() const
Return parent pointer.
Definition: Object.cpp:286
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:281
void setDirty(bool)
Set/reset the [b]modified[/b] flag.
Definition: Object.cpp:254
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.
Definition: Object.cpp:239
Abstract base class for functor objects whose argument is an Object.
std::string inputFn_m
Definition: OpalData.cpp:102
std::list< Table * > tableDirectory
Definition: OpalData.cpp:74
int restart_dump_freq_m
Definition: OpalData.cpp:99
PartBunchBase< double, 3 > * bunch_m
Definition: OpalData.cpp:114
energyEvolution_t energyEvolution_m
Definition: OpalData.cpp:126
bool hasPriorRun_m
Definition: OpalData.cpp:84
bool isInOPALCyclMode_m
Definition: OpalData.cpp:140
std::set< AttributeBase * > exprDirectory
Definition: OpalData.cpp:78
Mesh_t * mesh_m
Definition: OpalData.cpp:129
Directory mainDirectory
Definition: OpalData.cpp:65
bool hasRestartFile_m
Definition: OpalData.cpp:96
bool isOptimizerFlag_m
Definition: OpalData.cpp:142
std::map< std::string, unsigned int > problemSize_m
Definition: OpalData.cpp:145
int restartStep_m
Definition: OpalData.cpp:90
std::set< std::string > outFiles_m
Definition: OpalData.cpp:104
std::set< AttributeBase * >::iterator exprIterator
Definition: OpalData.cpp:79
std::vector< std::string > arguments_m
Definition: OpalData.cpp:147
BoundaryGeometry * bg_m
Definition: OpalData.cpp:123
bool hasDataSinkAllocated_m
Definition: OpalData.cpp:116
bool isRestart_m
Definition: OpalData.cpp:87
Layout_t * PL_m
Definition: OpalData.cpp:135
ValueDefinition * referenceMomentum
Definition: OpalData.cpp:68
FieldLayout_t * FL_m
Definition: OpalData.cpp:132
std::string restartFn_m
Definition: OpalData.cpp:93
OpalData::OPENMODE openMode_m
Mode for writing files.
Definition: OpalData.cpp:107
bool isInPrepState_m
Definition: OpalData.cpp:143
DataSink * dataSink_m
Definition: OpalData.cpp:118
unsigned long long maxTrackSteps_m
Definition: OpalData.cpp:138
bool isInOPALTMode_m
Definition: OpalData.cpp:141
bool hasBunchAllocated_m
Definition: OpalData.cpp:112
double gPhaseShift_m
Definition: OpalData.cpp:121
bool modified
Definition: OpalData.cpp:71
std::vector< MaxPhasesT > maxPhases_m
Definition: OpalData.cpp:125
std::list< Table * >::iterator tableIterator
Definition: OpalData.cpp:75
std::string itsTitle_m
Definition: OpalData.cpp:82
The global OPAL structure.
Definition: OpalData.h:49
void addEnergyData(double spos, double ekin)
Definition: OpalData.cpp:409
DataSink * getDataSink()
Definition: OpalData.cpp:389
void storeTitle(const std::string &)
Store the page title.
Definition: OpalData.cpp:634
double getP0() const
Return value of global reference momentum.
Definition: OpalData.cpp:569
int getLastStep() const
get the last step from a possible previous run
Definition: OpalData.cpp:360
void setOpenMode(OPENMODE openMode)
Definition: OpalData.cpp:348
void registerExpression(AttributeBase *)
Register expression.
Definition: OpalData.cpp:622
int getNumberOfMaxPhases()
Definition: OpalData.cpp:405
unsigned long long getMaxTrackSteps()
Definition: OpalData.cpp:235
void storeInputFn(const std::string &fn)
store opals input filename
Definition: OpalData.cpp:638
bool hasGlobalGeometry()
Definition: OpalData.cpp:464
void setRestartDumpFreq(const int &N)
set the dump frequency as found in restart file
Definition: OpalData.cpp:340
std::vector< MaxPhasesT >::iterator getLastMaxPhases()
Definition: OpalData.cpp:401
void erase(const std::string &name)
Delete existing entry.
Definition: OpalData.cpp:548
std::string getInputBasename()
get input file name without extension
Definition: OpalData.cpp:658
void makeDirty(Object *object)
Invalidate expressions.
Definition: OpalData.cpp:574
bool isInOPALTMode()
Definition: OpalData.cpp:275
OPENMODE getOpenMode() const
Definition: OpalData.cpp:352
void setP0(ValueDefinition *p0)
Set the global momentum.
Definition: OpalData.cpp:630
double getGlobalPhaseShift()
units: (sec)
Definition: OpalData.cpp:451
bool isOptimizerRun()
Definition: OpalData.cpp:279
std::map< std::string, std::string > getVariableData()
Definition: OpalData.cpp:700
struct OpalDataImpl * p
Definition: OpalData.h:281
void setOptimizerFlag()
Definition: OpalData.cpp:291
bool isInPrepState()
Definition: OpalData.cpp:295
std::string getTitle()
Get the title string.
Definition: OpalData.cpp:646
void checkAndAddOutputFileName(const std::string &outfn)
checks the output file names of all items to avoid duplicates
Definition: OpalData.cpp:664
void setPartBunch(PartBunchBase< double, 3 > *p)
Definition: OpalData.cpp:372
std::vector< MaxPhasesT >::iterator getFirstMaxPhases()
Definition: OpalData.cpp:397
void printNames(std::ostream &stream, const std::string &pattern)
Print all objects.
Definition: OpalData.cpp:579
void setInOPALCyclMode()
Definition: OpalData.cpp:283
void update()
Update all objects.
Definition: OpalData.cpp:674
bool isInOPALCyclMode()
Definition: OpalData.cpp:271
void apply(const ObjectFunction &)
Apply a function to all objects.
Definition: OpalData.cpp:468
bool hasRestartFile()
true if we do a restart from specified h5 file
Definition: OpalData.cpp:336
void setRestartRun(const bool &value=true)
set OPAL in restart mode
Definition: OpalData.cpp:315
void setMaxPhase(std::string elName, double phi)
Definition: OpalData.cpp:393
void setLastStep(const int &step)
set the last step in a run for possible follow-up run
Definition: OpalData.cpp:356
std::vector< std::string > getArguments()
Definition: OpalData.cpp:759
static void stashInstance()
Definition: OpalData.cpp:211
int getRestartDumpFreq() const
get the dump frequency as found in restart file
Definition: OpalData.cpp:344
std::string getRestartFileName()
get opals restart h5 format filename
Definition: OpalData.cpp:327
std::string getInputFn()
get opals input filename
Definition: OpalData.cpp:654
void bunchIsAllocated()
Definition: OpalData.cpp:368
void unregisterExpression(AttributeBase *)
Unregister expression.
Definition: OpalData.cpp:626
OPENMODE
Enum for writing to files.
Definition: OpalData.h:64
Object * find(const std::string &name)
Find entry.
Definition: OpalData.cpp:565
bool hasPriorTrack()
true if in follow-up track
Definition: OpalData.cpp:303
static std::stack< OpalData * > stashedInstances
Definition: OpalData.h:272
int getRestartStep()
get the step where to restart
Definition: OpalData.cpp:323
void create(Object *newObject)
Create new object.
Definition: OpalData.cpp:475
static OpalData * instance
Definition: OpalData.h:271
void printTitle(std::ostream &)
Print the page title.
Definition: OpalData.cpp:642
static void deleteInstance()
Definition: OpalData.cpp:205
void setRestartFileName(std::string s)
store opals restart h5 format filename
Definition: OpalData.cpp:331
void setInPrepState(bool state)
Definition: OpalData.cpp:299
void setPriorTrack(const bool &value=true)
true if in follow-up track
Definition: OpalData.cpp:307
void setDataSink(DataSink *s)
Definition: OpalData.cpp:384
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
Definition: OpalData.cpp:380
void setGlobalPhaseShift(double shift)
units: (sec)
Definition: OpalData.cpp:446
bool hasBunchAllocated()
true if we already allocated a ParticleBunch object
Definition: OpalData.cpp:364
energyEvolution_t::iterator getFirstEnergyData()
Definition: OpalData.cpp:413
void unregisterTable(Table *t)
Unregister table.
Definition: OpalData.cpp:614
void reset()
reset object for consecutive runs
Definition: OpalData.cpp:255
static OpalData * getInstance()
Definition: OpalData.cpp:195
void setMaxTrackSteps(unsigned long long s)
Definition: OpalData.cpp:239
void storeArguments(int argc, char *argv[])
Definition: OpalData.cpp:752
void setInOPALTMode()
Definition: OpalData.cpp:287
static bool isInstantiated
Definition: OpalData.h:270
BoundaryGeometry * getGlobalGeometry()
Definition: OpalData.cpp:460
void define(Object *newObject)
Define a new object.
Definition: OpalData.cpp:488
energyEvolution_t::iterator getLastEnergyData()
Definition: OpalData.cpp:417
void setRestartStep(int s)
store the location where to restart
Definition: OpalData.cpp:319
void setGlobalGeometry(BoundaryGeometry *bg)
Definition: OpalData.cpp:456
void incMaxTrackSteps(unsigned long long s)
Definition: OpalData.cpp:243
static OpalData * popInstance()
Definition: OpalData.cpp:222
void registerTable(Table *t)
Register table.
Definition: OpalData.cpp:610
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
Definition: OpalData.cpp:650
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
Definition: OpalData.cpp:740
bool inRestartRun()
true if we do a restart run
Definition: OpalData.cpp:311
const std::map< std::string, unsigned int > & getProblemCharacteristicValues() const
Definition: OpalData.cpp:748
PartBunchBase< double, 3 > * getPartBunch()
Definition: OpalData.cpp:376
std::vector< std::string > getVariableNames()
Definition: OpalData.cpp:720
virtual void operator()(Object *) const
The function to be executed.
Definition: OpalData.cpp:53
The base class for all OPAL tables.
Definition: Table.h:42
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.
Definition: OpalException.h:28
A regular expression.
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.
Definition: Inform.h:42