OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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;
76 typedef std::list<Table *>::iterator tableIterator;
77
78 // The set of expressions to be invalidated when something changes.
79 std::set <AttributeBase *> exprDirectory;
80 typedef std::set<AttributeBase *>::iterator exprIterator;
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
154 hasPriorRun_m(false),
155 isRestart_m(false),
156 restartStep_m(0),
157 hasRestartFile_m(false),
159 hasBunchAllocated_m(false),
161 gPhaseShift_m(0.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
187 mainDirectory.erase();
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
342 p->restart_dump_freq_m = N;
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
382 return p->hasDataSinkAllocated_m;
383}
384
386 p->dataSink_m = s;
387 p->hasDataSinkAllocated_m = true;
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
398std::vector<MaxPhasesT>::iterator OpalData::getFirstMaxPhases() {
399 return p->maxPhases_m.begin();
400}
401
402std::vector<MaxPhasesT>::iterator OpalData::getLastMaxPhases() {
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
414energyEvolution_t::iterator OpalData::getFirstEnergyData() {
415 return p->energyEvolution_m.begin();
416}
417
418energyEvolution_t::iterator OpalData::getLastEnergyData() {
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
464
466 return p->bg_m != nullptr;
467}
468
470 for (ObjectDir::iterator i = p->mainDirectory.begin();
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 if (oldObject->isBuiltin()) {
496 throw OpalException("OpalData::define()",
497 "The keyword \""
498 + name +
499 "\" is protected and can't be used to name an object.");
500 } else if (! oldObject->canReplaceBy(newObject)) {
501 throw OpalException("OpalData::define()",
502 "You cannot replace the already defined object \""
503 + name +
504 "\".");
505 }
506 if (Options::info) {
507 INFOMSG("Replacing the object \"" << name << "\"." << endl);
508 }
509
510 // Erase all tables which depend on the new object.
511 OpalDataImpl::tableIterator i = p->tableDirectory.begin();
512 while(i != p->tableDirectory.end()) {
513 // We must increment i before calling erase(name),
514 // since erase(name) removes "this" from "tables".
515 Table *table = *i++;
516 const std::string &tableName = table->getOpalName();
517
518 if (table->isDependent(name)) {
519 if (Options::info) {
520 std::cerr << std::endl << "Erasing dependent table \""
521 << tableName << "\"." << std::endl;
522 }
523
524 // Remove table from directory.
525 // This erases the table from the main directory,
526 // and its destructor unregisters it from the table directory.
527 erase(tableName);
528 }
529 }
530
531 // Replace all references to this object.
532 for (ObjectDir::iterator i = p->mainDirectory.begin();
533 i != p->mainDirectory.end(); ++i) {
534 (*i).second->replace(oldObject, newObject);
535 }
536
537 // Remove old object.
538 erase(name);
539 }
540
541 // Force re-evaluation of expressions.
542 p->modified = true;
543 newObject->setDirty(true);
544 p->mainDirectory.insert(name, newObject);
545
546 // If this is a new definition of "P0", insert its definition.
547 if (name == "P0") {
548 if (ValueDefinition *p0 = dynamic_cast<ValueDefinition *>(newObject)) {
549 setP0(p0);
550 }
551 }
552}
553
554void OpalData::erase(const std::string &name) {
555 Object *oldObject = p->mainDirectory.find(name);
556
557 if (oldObject != nullptr) {
558 // Relink all children of "this" to "this->getParent()".
559 for (ObjectDir::iterator i = p->mainDirectory.begin();
560 i != p->mainDirectory.end(); ++i) {
561 Object *child = &*i->second;
562 if (child->getParent() == oldObject) {
563 child->setParent(oldObject->getParent());
564 }
565 }
566 // Remove the object.
567 p->mainDirectory.erase(name);
568 }
569}
570
571Object *OpalData::find(const std::string &name) {
572 return p->mainDirectory.find(name);
573}
574
575double OpalData::getP0() const {
576 return p->referenceMomentum->getReal() * Units::GeV2eV;
577}
578
580 p->modified = true;
581 if (obj) obj->setDirty(true);
582}
583
584void OpalData::printNames(std::ostream &os, const std::string &pattern) {
585 int column = 0;
586 RegularExpression regex(pattern);
587 os << std::endl << "Object names matching the pattern \""
588 << pattern << "\":" << std::endl;
589
590 for (ObjectDir::const_iterator index = p->mainDirectory.begin();
591 index != p->mainDirectory.end(); ++index) {
592 const std::string name = (*index).first;
593
594 if (! name.empty() && regex.match(name)) {
595 os << name;
596
597 if (column < 80) {
598 column += name.length();
599
600 do {
601 os << ' ';
602 column++;
603 } while((column % 20) != 0);
604 } else {
605 os << std::endl;
606 column = 0;
607 }
608 }
609 }
610
611 if (column) os << std::endl;
612 os << std::endl;
613}
614
615std::vector<std::string> OpalData::getAllNames() const {
616 std::vector<std::string> name_list;
617 for (ObjectDir::const_iterator index = p->mainDirectory.begin();
618 index != p->mainDirectory.end(); ++index) {
619 const std::string name = (*index).first;
620 name_list.push_back(name);
621 }
622 return name_list;
623}
624
625
627 p->tableDirectory.push_back(table);
628}
629
631 for (OpalDataImpl::tableIterator i = p->tableDirectory.begin();
632 i != p->tableDirectory.end();) {
634 if (*j == table) p->tableDirectory.erase(j);
635 }
636}
637
639 p->exprDirectory.insert(expr);
640}
641
643 p->exprDirectory.erase(expr);
644}
645
647 p->referenceMomentum = p0;
648}
649
650void OpalData::storeTitle(const std::string &title) {
651 p->itsTitle_m = title;
652}
653
654void OpalData::storeInputFn(const std::string &fn) {
655 p->inputFn_m = fn;
656}
657
658void OpalData::printTitle(std::ostream &os) {
659 os << p->itsTitle_m;
660}
661
662std::string OpalData::getTitle() {
663 return p->itsTitle_m;
664}
665
667 return "data";
668}
669
670std::string OpalData::getInputFn() {
671 return p->inputFn_m;
672}
673
675 std::string & fn = p->inputFn_m;
676 int const pdot = fn.rfind(".");
677 return fn.substr(0, pdot);
678}
679
680void OpalData::checkAndAddOutputFileName(const std::string &outfn) {
681 if (p->outFiles_m.count(outfn) == 0) {
682 p->outFiles_m.insert(outfn);
683 } else if (!hasBunchAllocated()) {
684 throw OpalException(
685 "OpalData::checkAndAddOutputFileName",
686 "Duplicate file name for output, '" + outfn + "', detected");
687 }
688}
689
691 Inform msg("OpalData ");
692 if (p->modified) {
693 // Force re-evaluation of expressions.
694 for (OpalDataImpl::exprIterator i = p->exprDirectory.begin();
695 i != p->exprDirectory.end(); ++i) {
696 (*i)->invalidate();
697 }
698
699 // Force refilling of dynamic tables.
700 for (OpalDataImpl::tableIterator i = p->tableDirectory.begin();
701 i != p->tableDirectory.end(); ++i) {
702 (*i)->invalidate();
703 }
704
705 // Update all definitions.
706 for (ObjectDir::iterator i = p->mainDirectory.begin();
707 i != p->mainDirectory.end(); ++i) {
708 (*i).second->update();
709 }
710
711 // Definitions are up-to-date.
712 p->modified = false;
713 }
714}
715
716std::map<std::string, std::string> OpalData::getVariableData() {
717 std::map<std::string, std::string> udata;
718 std::vector<std::string> uvars = this->getVariableNames();
719 for (auto& uvar : uvars) {
720 Object *tmpObject = OpalData::getInstance()->find(uvar);
721 if (dynamic_cast<RealVariable*>(tmpObject)) {
722 RealVariable* variable = dynamic_cast<RealVariable*>(OpalData::getInstance()->find(uvar));
723 udata[uvar] = std::to_string(variable->getReal());
724 } else if (dynamic_cast<StringConstant*>(tmpObject)) {
725 StringConstant* variable = dynamic_cast<StringConstant*>(OpalData::getInstance()->find(uvar));
726 udata[uvar] = variable->getString();
727 } else {
728 throw OpalException("OpalData::getVariableData()",
729 "Type of '" + uvar + "' not supported. "
730 "Only support for REAL and STRING.");
731 }
732 }
733 return udata;
734}
735
736std::vector<std::string> OpalData::getVariableNames() {
737 std::vector<std::string> result;
738
739 for (ObjectDir::const_iterator index = p->mainDirectory.begin();
740 index != p->mainDirectory.end(); ++index) {
741 std::string tmpName = (*index).first;
742 if (!tmpName.empty()) {
743 Object *tmpObject = OpalData::getInstance()->find(tmpName);
744 if (tmpObject) {
745 if (!tmpObject || tmpObject->isBuiltin())
746 continue;
747 if (tmpObject->getCategory() == "VARIABLE") {
748 result.push_back(tmpName);
749 }
750 }
751 }
752 }
753 return result;
754}
755
756void OpalData::addProblemCharacteristicValue(const std::string &name, unsigned int value) {
757 if (p->problemSize_m.find(name) != p->problemSize_m.end()) {
758 p->problemSize_m.insert(std::make_pair(name, value));
759 } else {
760 p->problemSize_m[name] = value;
761 }
762}
763
764const std::map<std::string, unsigned int> &OpalData::getProblemCharacteristicValues() const {
765 return p->problemSize_m;
766}
767
768void OpalData::storeArguments(int argc, char *argv[]) {
769 p->arguments_m.clear();
770 for (int i = 0; i < argc; ++ i) {
771 p->arguments_m.push_back(argv[i]);
772 }
773}
774
775std::vector<std::string> OpalData::getArguments() {
776 return p->arguments_m;
777}
UniformCartesian< 3, double > Mesh_t
Definition PBunchDefs.h:22
ParticleSpatialLayout< double, 3, Mesh_t > Layout_t
Definition PBunchDefs.h:24
CenteredFieldLayout< 3, Mesh_t, Center_t > FieldLayout_t
Definition PBunchDefs.h:28
#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:44
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
bool info
Info flag.
Definition Options.cpp:28
Abstract base class for attribute values of different types.
A map of string versus pointer to Object.
Definition Directory.h:38
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
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:650
double getP0() const
Return value of global reference momentum.
Definition OpalData.cpp:575
int getLastStep() const
get the last step from a possible previous run
Definition OpalData.cpp:361
void registerExpression(AttributeBase *)
Register expression.
Definition OpalData.cpp:638
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:654
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:554
std::string getInputBasename()
get input file name without extension
Definition OpalData.cpp:674
void makeDirty(Object *object)
Invalidate expressions.
Definition OpalData.cpp:579
bool isInOPALTMode()
Definition OpalData.cpp:276
void setP0(ValueDefinition *p0)
Set the global momentum.
Definition OpalData.cpp:646
double getGlobalPhaseShift()
units: (sec)
Definition OpalData.cpp:452
bool isOptimizerRun()
Definition OpalData.cpp:280
std::map< std::string, std::string > getVariableData()
Definition OpalData.cpp:716
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:662
void checkAndAddOutputFileName(const std::string &outfn)
checks the output file names of all items to avoid duplicates
Definition OpalData.cpp:680
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:584
void setInOPALCyclMode()
Definition OpalData.cpp:284
void update()
Update all objects.
Definition OpalData.cpp:690
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:775
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:670
void bunchIsAllocated()
Definition OpalData.cpp:369
void unregisterExpression(AttributeBase *)
Unregister expression.
Definition OpalData.cpp:642
Object * find(const std::string &name)
Find entry.
Definition OpalData.cpp:571
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:658
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:615
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:630
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:768
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:626
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
Definition OpalData.cpp:666
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
Definition OpalData.cpp:756
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:764
PartBunchBase< double, 3 > * getPartBunch()
Definition OpalData.cpp:377
std::vector< std::string > getVariableNames()
Definition OpalData.cpp:736
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.
The base class for all OPAL exceptions.
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.