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