OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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
31#include "PartBunch/PartBunch.h"
36#include "Physics/Units.h"
38#include "Structure/DataSink.h"
40#include "Utilities/Options.h"
44
45#include <algorithm>
46#include <iostream>
47#include <list>
48#include <set>
49
50#define MAX_NUM_INSTANCES 10
51
53 object->clear();
54}
55
56// Struct OpalDataImpl.
57// ------------------------------------------------------------------------
61
62 // The main object directory.
64
65 // The value of the global momentum.
67
68 // The flag telling that something has changed.
70
71 // Directory of tables, for recalculation when something changes.
72 std::list<Table*> tableDirectory;
73 typedef std::list<Table*>::iterator tableIterator;
74
75 // The set of expressions to be invalidated when something changes.
76 std::set<AttributeBase*> exprDirectory;
77 typedef std::set<AttributeBase*>::iterator exprIterator;
78
79 // The page title from the latest TITLE command.
80 std::string itsTitle_m;
81
83
84 // true if we restart a simulation
86
87 // Where to resume in a restart run
89
90 // Where to resume in a restart run
91 std::string restartFn_m;
92
93 // true if the name of a restartFile is specified
95
96 // dump frequency as found in restart file
98
99 // Input file name
100 std::string inputFn_m;
101
102 std::set<std::string> outFiles_m;
103
106
107 // last step of a run
109
111 // The particle bunch to be tracked.
113
115
117
118 // In units of seconds. This is half of tEmission
120
122
123 std::vector<MaxPhasesT> maxPhases_m;
125
126 // The cartesian mesh
128
129 // The field layout f
131
132 // The particle layout
134
135 // the accumulated (over all TRACKs) number of steps
136 unsigned long long maxTrackSteps_m;
137
142
143 std::map<std::string, unsigned int> problemSize_m;
144
145 std::vector<std::string> arguments_m;
146};
147
149 : mainDirectory(),
151 modified(false),
152 itsTitle_m(),
153 hasPriorRun_m(false),
154 isRestart_m(false),
155 restartStep_m(0),
156 hasRestartFile_m(false),
158 last_step_m(0),
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 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
186 mainDirectory.erase();
187 tableDirectory.clear();
188 exprDirectory.clear();
189}
190
191bool OpalData::isInstantiated = false;
193std::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)
213 return;
214 if (stashedInstances.size() + 1 > MAX_NUM_INSTANCES) {
215 throw OpalException("OpalData::stashInstance()", "too many OpalData instances stashed");
216 }
218 instance = nullptr;
219 isInstantiated = false;
220}
221
223 if (stashedInstances.size() == 0) {
224 throw OpalException("OpalData::popInstance()", "no OpalData instances stashed");
225 }
226 if (isInstantiated)
229 isInstantiated = true;
230 stashedInstances.pop();
231
232 return instance;
233}
234
235unsigned long long OpalData::getMaxTrackSteps() {
236 return p->maxTrackSteps_m;
237}
238
239void OpalData::setMaxTrackSteps(unsigned long long s) {
240 p->maxTrackSteps_m = s;
241}
242
243void 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
299void OpalData::setInPrepState(bool state) {
300 p->isInPrepState_m = state;
301}
302
304 return p->hasPriorRun_m;
305}
306
307void OpalData::setPriorTrack(const bool& value) {
308 p->hasPriorRun_m = value;
309}
310
312 return p->isRestart_m;
313}
314
315void 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
331void OpalData::setRestartFileName(std::string s) {
332 p->restartFn_m = s;
333 p->hasRestartFile_m = true;
334}
335
337 return p->hasRestartFile_m;
338}
339
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
356void 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
393void OpalData::setMaxPhase(std::string elName, double phi) {
394 p->maxPhases_m.push_back(MaxPhasesT(elName, phi));
395}
396
397std::vector<MaxPhasesT>::iterator OpalData::getFirstMaxPhases() {
398 return p->maxPhases_m.begin();
399}
400
401std::vector<MaxPhasesT>::iterator OpalData::getLastMaxPhases() {
402 return p->maxPhases_m.end();
403}
404
406 return p->maxPhases_m.size();
407}
408
409void OpalData::addEnergyData(double spos, double ekin) {
410 p->energyEvolution_m.insert(std::make_pair(spos, ekin));
411}
412
413energyEvolution_t::iterator OpalData::getFirstEnergyData() {
414 return p->energyEvolution_m.begin();
415}
416
417energyEvolution_t::iterator OpalData::getLastEnergyData() {
418 return p->energyEvolution_m.end();
419}
420
421// Mesh_t* OpalData::getMesh() {
422// return p->mesh_m;
423// }
424
425// FieldLayout_t* OpalData::getFieldLayout() {
426// return p->FL_m;
427// }
428
429// Layout_t* OpalData::getLayout() {
430// return p->PL_m;
431// }
432
433// void OpalData::setMesh(Mesh_t *mesh) {
434// p->mesh_m = mesh;
435// }
436
437// void OpalData::setFieldLayout(FieldLayout_t *fieldlayout) {
438// p->FL_m = fieldlayout;
439// }
440
441// void OpalData::setLayout(Layout_t *layout) {
442// p->PL_m = layout;
443// }
444
447 p->gPhaseShift_m = shift;
448}
449
452 return p->gPhaseShift_m;
453}
454
456 p->bg_m = bg;
457}
458
462
464 return p->bg_m != nullptr;
465}
466
468 for (ObjectDir::iterator i = p->mainDirectory.begin(); i != p->mainDirectory.end(); ++i) {
469 fun(&*i->second);
470 }
471}
472
473void OpalData::create(Object* newObject) {
474 // Test for existing node with same name.
475 const std::string name = newObject->getOpalName();
476 Object* oldObject = p->mainDirectory.find(name);
477
478 if (oldObject != nullptr) {
479 throw OpalException(
480 "OpalData::create()", "You cannot replace the object \"" + name + "\".");
481 } else {
482 p->mainDirectory.insert(name, newObject);
483 }
484}
485
486void OpalData::define(Object* newObject) {
487 // Test for existing node with same name.
488 const std::string name = newObject->getOpalName();
489 Object* oldObject = p->mainDirectory.find(name);
490
491 if (oldObject != nullptr && oldObject != newObject) {
492 // Attempt to replace an object.
493 if (oldObject->isBuiltin() || !oldObject->canReplaceBy(newObject)) {
494 throw OpalException(
495 "OpalData::define()", "You cannot replace the object \"" + name + "\".");
496 } else {
497 if (Options::info) {
498 *ippl::Info << "Replacing the object \"" << name << "\"." << endl;
499 }
500
501 // Erase all tables which depend on the new object.
502 OpalDataImpl::tableIterator i = p->tableDirectory.begin();
503 while (i != p->tableDirectory.end()) {
504 // We must increment i before calling erase(name),
505 // since erase(name) removes "this" from "tables".
506 Table* table = *i++;
507 const std::string& tableName = table->getOpalName();
508
509 if (table->isDependent(name)) {
510 if (Options::info) {
511 std::cerr << std::endl
512 << "Erasing dependent table \"" << tableName << "\"."
513 << std::endl;
514 }
515
516 // Remove table from directory.
517 // This erases the table from the main directory,
518 // and its destructor unregisters it from the table directory.
519 erase(tableName);
520 }
521 }
522
523 // Replace all references to this object.
524 for (ObjectDir::iterator i = p->mainDirectory.begin(); i != p->mainDirectory.end();
525 ++i) {
526 (*i).second->replace(oldObject, newObject);
527 }
528
529 // Remove old object.
530 erase(name);
531 }
532 }
533
534 // Force re-evaluation of expressions.
535 p->modified = true;
536 newObject->setDirty(true);
537 p->mainDirectory.insert(name, newObject);
538
539 // If this is a new definition of "P0", insert its definition.
540 if (name == "P0") {
541 if (ValueDefinition* p0 = dynamic_cast<ValueDefinition*>(newObject)) {
542 setP0(p0);
543 }
544 }
545}
546
547void OpalData::erase(const std::string& name) {
548 Object* oldObject = p->mainDirectory.find(name);
549
550 if (oldObject != nullptr) {
551 // Relink all children of "this" to "this->getParent()".
552 for (ObjectDir::iterator i = p->mainDirectory.begin(); i != p->mainDirectory.end(); ++i) {
553 Object* child = &*i->second;
554 if (child->getParent() == oldObject) {
555 child->setParent(oldObject->getParent());
556 }
557 }
558 // Remove the object.
559 p->mainDirectory.erase(name);
560 }
561}
562
563Object* OpalData::find(const std::string& name) {
564 return p->mainDirectory.find(name);
565}
566
567double OpalData::getP0() const {
568 return p->referenceMomentum->getReal() * Units::GeV2eV;
569}
570
572 p->modified = true;
573 if (obj)
574 obj->setDirty(true);
575}
576
577void OpalData::printAllNames(std::ostream& os) {
578 int column = 0;
579
580 os << std::endl << "All object names " << std::endl;
581
582 for (ObjectDir::const_iterator index = p->mainDirectory.begin();
583 index != p->mainDirectory.end(); ++index) {
584 const std::string name = (*index).first;
585
586 os << name << " = " << *(*index).second << std::endl;
587 /*
588 if (column < 80) {
589 column += name.length();
590
591 do {
592 os << ' ';
593 column++;
594 } while((column % 20) != 0);
595 } else {
596 os << std::endl;
597 column = 0;
598 }
599 */
600 }
601
602 if (column)
603 os << std::endl;
604 os << std::endl;
605}
606void OpalData::printNames(std::ostream& os, const std::string& pattern) {
607 int column = 0;
608 RegularExpression regex(pattern);
609 os << std::endl << "Object names matching the pattern \"" << pattern << "\":" << std::endl;
610
611 for (ObjectDir::const_iterator index = p->mainDirectory.begin();
612 index != p->mainDirectory.end(); ++index) {
613 const std::string name = (*index).first;
614
615 if (!name.empty() && regex.match(name)) {
616 os << name;
617
618 if (column < 80) {
619 column += name.length();
620
621 do {
622 os << ' ';
623 column++;
624 } while ((column % 20) != 0);
625 } else {
626 os << std::endl;
627 column = 0;
628 }
629 }
630 }
631
632 if (column)
633 os << std::endl;
634 os << std::endl;
635}
636
638 p->tableDirectory.push_back(table);
639}
640
642 for (OpalDataImpl::tableIterator i = p->tableDirectory.begin(); i != p->tableDirectory.end();) {
644 if (*j == table)
645 p->tableDirectory.erase(j);
646 }
647}
648
650 p->exprDirectory.insert(expr);
651}
652
654 p->exprDirectory.erase(expr);
655}
656
658 p->referenceMomentum = p0;
659}
660
661void OpalData::storeTitle(const std::string& title) {
662 p->itsTitle_m = title;
663}
664
665void OpalData::storeInputFn(const std::string& fn) {
666 p->inputFn_m = fn;
667}
668
669void OpalData::printTitle(std::ostream& os) {
670 os << p->itsTitle_m;
671}
672
673std::string OpalData::getTitle() {
674 return p->itsTitle_m;
675}
676
678 return "data";
679}
680
681std::string OpalData::getInputFn() {
682 return p->inputFn_m;
683}
684
686 std::string& fn = p->inputFn_m;
687 int const pdot = fn.rfind(".");
688 return fn.substr(0, pdot);
689}
690
691void OpalData::checkAndAddOutputFileName(const std::string& outfn) {
692 if (p->outFiles_m.count(outfn) == 0) {
693 p->outFiles_m.insert(outfn);
694 } else if (!hasBunchAllocated()) {
695 throw OpalException(
696 "OpalData::checkAndAddOutputFileName",
697 "Duplicate file name for output, '" + outfn + "', detected");
698 }
699}
700
702 Inform msg("OpalData ");
703 if (p->modified) {
704 // Force re-evaluation of expressions.
705 for (OpalDataImpl::exprIterator i = p->exprDirectory.begin(); i != p->exprDirectory.end();
706 ++i) {
707 (*i)->invalidate();
708 }
709
710 // Force refilling of dynamic tables.
711 for (OpalDataImpl::tableIterator i = p->tableDirectory.begin();
712 i != p->tableDirectory.end(); ++i) {
713 (*i)->invalidate();
714 }
715
716 // Update all definitions.
717 for (ObjectDir::iterator i = p->mainDirectory.begin(); i != p->mainDirectory.end(); ++i) {
718 (*i).second->update();
719 }
720
721 // Definitions are up-to-date.
722 p->modified = false;
723 }
724}
725
726std::map<std::string, std::string> OpalData::getVariableData() {
727 std::map<std::string, std::string> udata;
728 std::vector<std::string> uvars = this->getVariableNames();
729 for (auto& uvar : uvars) {
730 Object* tmpObject = OpalData::getInstance()->find(uvar);
731 if (dynamic_cast<RealVariable*>(tmpObject)) {
732 RealVariable* variable =
733 dynamic_cast<RealVariable*>(OpalData::getInstance()->find(uvar));
734 udata[uvar] = std::to_string(variable->getReal());
735 } else if (dynamic_cast<StringConstant*>(tmpObject)) {
736 StringConstant* variable =
737 dynamic_cast<StringConstant*>(OpalData::getInstance()->find(uvar));
738 udata[uvar] = variable->getString();
739 } else {
740 throw OpalException("OpalData::getVariableData()",
741 "Type of '" + uvar + "' not supported. "
742 "Only support for REAL and STRING.");
743 }
744 }
745 return udata;
746}
747
748std::vector<std::string> OpalData::getVariableNames() {
749 std::vector<std::string> result;
750
751 for (ObjectDir::const_iterator index = p->mainDirectory.begin();
752 index != p->mainDirectory.end(); ++index) {
753 std::string tmpName = (*index).first;
754 if (!tmpName.empty()) {
755 Object* tmpObject = OpalData::getInstance()->find(tmpName);
756 if (tmpObject) {
757 if (!tmpObject || tmpObject->isBuiltin())
758 continue;
759 if (tmpObject->getCategory() == "VARIABLE") {
760 result.push_back(tmpName);
761 }
762 }
763 }
764 }
765 return result;
766}
767
768void OpalData::addProblemCharacteristicValue(const std::string& name, unsigned int value) {
769 if (p->problemSize_m.find(name) != p->problemSize_m.end()) {
770 p->problemSize_m.insert(std::make_pair(name, value));
771 } else {
772 p->problemSize_m[name] = value;
773 }
774}
775
776const std::map<std::string, unsigned int>& OpalData::getProblemCharacteristicValues() const {
777 return p->problemSize_m;
778}
779
780void OpalData::storeArguments(int argc, char* argv[]) {
781 p->arguments_m.clear();
782 for (int i = 0; i < argc; ++i) {
783 p->arguments_m.push_back(argv[i]);
784 }
785}
786
787std::vector<std::string> OpalData::getArguments() {
788 return p->arguments_m;
789}
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::FieldLayout< Dim > FieldLayout_t
Definition PBunchDefs.h:27
ippl::UniformCartesian< double, 3 > Mesh_t
Definition PBunchDefs.h:19
#define MAX_NUM_INSTANCES
Definition OpalData.cpp:50
std::map< double, double > energyEvolution_t
Definition OpalData.h:42
std::pair< std::string, double > MaxPhasesT
Definition OpalData.h:41
typename ippl::ParticleSpatialLayout< T, Dim, Mesh_t< Dim > > PLayout_t
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:334
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Definition Object.cpp:48
Object * getParent() const
Return parent pointer.
Definition Object.cpp:313
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:308
void setDirty(bool)
Set/reset the [b]modified[/b] flag.
Definition Object.cpp:281
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:266
Abstract base class for functor objects whose argument is an Object.
std::string inputFn_m
Definition OpalData.cpp:100
int restart_dump_freq_m
Definition OpalData.cpp:97
energyEvolution_t energyEvolution_m
Definition OpalData.cpp:124
bool hasPriorRun_m
Definition OpalData.cpp:82
bool isInOPALCyclMode_m
Definition OpalData.cpp:138
std::list< Table * >::iterator tableIterator
Definition OpalData.cpp:73
Directory mainDirectory
Definition OpalData.cpp:63
bool hasRestartFile_m
Definition OpalData.cpp:94
bool isOptimizerFlag_m
Definition OpalData.cpp:140
PLayout_t< double, 3 > * PL_m
Definition OpalData.cpp:133
std::map< std::string, unsigned int > problemSize_m
Definition OpalData.cpp:143
int restartStep_m
Definition OpalData.cpp:88
std::set< std::string > outFiles_m
Definition OpalData.cpp:102
std::vector< std::string > arguments_m
Definition OpalData.cpp:145
BoundaryGeometry * bg_m
Definition OpalData.cpp:121
bool hasDataSinkAllocated_m
Definition OpalData.cpp:114
bool isRestart_m
Definition OpalData.cpp:85
OpalData::OpenMode openMode_m
Mode for writing files.
Definition OpalData.cpp:105
ValueDefinition * referenceMomentum
Definition OpalData.cpp:66
FieldLayout_t< 3 > * FL_m
Definition OpalData.cpp:130
std::list< Table * > tableDirectory
Definition OpalData.cpp:72
std::string restartFn_m
Definition OpalData.cpp:91
std::set< AttributeBase * > exprDirectory
Definition OpalData.cpp:76
PartBunch_t * bunch_m
Definition OpalData.cpp:112
std::set< AttributeBase * >::iterator exprIterator
Definition OpalData.cpp:77
bool isInPrepState_m
Definition OpalData.cpp:141
DataSink * dataSink_m
Definition OpalData.cpp:116
unsigned long long maxTrackSteps_m
Definition OpalData.cpp:136
bool isInOPALTMode_m
Definition OpalData.cpp:139
Mesh_t< 3 > * mesh_m
Definition OpalData.cpp:127
bool hasBunchAllocated_m
Definition OpalData.cpp:110
double gPhaseShift_m
Definition OpalData.cpp:119
std::vector< MaxPhasesT > maxPhases_m
Definition OpalData.cpp:123
std::string itsTitle_m
Definition OpalData.cpp:80
The global OPAL structure.
Definition OpalData.h:45
void addEnergyData(double spos, double ekin)
Definition OpalData.cpp:409
void printAllNames(std::ostream &stream)
Definition OpalData.cpp:577
DataSink * getDataSink()
Definition OpalData.cpp:389
void storeTitle(const std::string &)
Store the page title.
Definition OpalData.cpp:661
double getP0() const
Return value of global reference momentum.
Definition OpalData.cpp:567
int getLastStep() const
get the last step from a possible previous run
Definition OpalData.cpp:360
void registerExpression(AttributeBase *)
Register expression.
Definition OpalData.cpp:649
int getNumberOfMaxPhases()
Definition OpalData.cpp:405
PartBunch_t * getPartBunch()
Definition OpalData.cpp:376
unsigned long long getMaxTrackSteps()
Definition OpalData.cpp:235
void storeInputFn(const std::string &fn)
store opals input filename
Definition OpalData.cpp:665
void setPartBunch(PartBunch_t *p)
Definition OpalData.cpp:372
bool hasGlobalGeometry()
Definition OpalData.cpp:463
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:547
std::string getInputBasename()
get input file name without extension
Definition OpalData.cpp:685
void makeDirty(Object *object)
Invalidate expressions.
Definition OpalData.cpp:571
bool isInOPALTMode()
Definition OpalData.cpp:275
void setP0(ValueDefinition *p0)
Set the global momentum.
Definition OpalData.cpp:657
double getGlobalPhaseShift()
units: (sec)
Definition OpalData.cpp:450
bool isOptimizerRun()
Definition OpalData.cpp:279
std::map< std::string, std::string > getVariableData()
Definition OpalData.cpp:726
struct OpalDataImpl * p
Definition OpalData.h:271
void setOptimizerFlag()
Definition OpalData.cpp:291
bool isInPrepState()
Definition OpalData.cpp:295
std::string getTitle()
Get the title string.
Definition OpalData.cpp:673
void checkAndAddOutputFileName(const std::string &outfn)
checks the output file names of all items to avoid duplicates
Definition OpalData.cpp:691
std::vector< MaxPhasesT >::iterator getFirstMaxPhases()
Definition OpalData.cpp:397
void printNames(std::ostream &stream, const std::string &pattern)
Print all objects.
Definition OpalData.cpp:606
void setInOPALCyclMode()
Definition OpalData.cpp:283
void update()
Update all objects.
Definition OpalData.cpp:701
bool isInOPALCyclMode()
Definition OpalData.cpp:271
void apply(const ObjectFunction &)
Apply a function to all objects.
Definition OpalData.cpp:467
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:787
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:681
void bunchIsAllocated()
Definition OpalData.cpp:368
void unregisterExpression(AttributeBase *)
Unregister expression.
Definition OpalData.cpp:653
Object * find(const std::string &name)
Find entry.
Definition OpalData.cpp:563
bool hasPriorTrack()
true if in follow-up track
Definition OpalData.cpp:303
static std::stack< OpalData * > stashedInstances
Definition OpalData.h:262
int getRestartStep()
get the step where to restart
Definition OpalData.cpp:323
void create(Object *newObject)
Create new object.
Definition OpalData.cpp:473
static OpalData * instance
Definition OpalData.h:261
void printTitle(std::ostream &)
Print the page title.
Definition OpalData.cpp:669
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
OpenMode getOpenMode() const
Definition OpalData.cpp:352
bool hasDataSinkAllocated()
true if we already allocated a DataSink object
Definition OpalData.cpp:380
void setGlobalPhaseShift(double shift)
units: (sec)
Definition OpalData.cpp:445
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:641
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:780
void setInOPALTMode()
Definition OpalData.cpp:287
static bool isInstantiated
Definition OpalData.h:260
BoundaryGeometry * getGlobalGeometry()
Definition OpalData.cpp:459
void define(Object *newObject)
Define a new object.
Definition OpalData.cpp:486
energyEvolution_t::iterator getLastEnergyData()
Definition OpalData.cpp:417
OpenMode
Enum for writing to files.
Definition OpalData.h:58
void setRestartStep(int s)
store the location where to restart
Definition OpalData.cpp:319
void setGlobalGeometry(BoundaryGeometry *bg)
Definition OpalData.cpp:455
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:637
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
Definition OpalData.cpp:677
void addProblemCharacteristicValue(const std::string &name, unsigned int value)
Definition OpalData.cpp:768
void setOpenMode(OpenMode openMode)
Definition OpalData.cpp:348
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:776
std::vector< std::string > getVariableNames()
Definition OpalData.cpp:748
virtual void operator()(Object *) const
The function to be executed.
Definition OpalData.cpp:52
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.