|
OPAL (Object Oriented Parallel Accelerator Library)
2024.1
OPAL
|
Concrete implementation of an Opal simulation wrapper. More...
#include <OpalSimulation.h>


Public Member Functions | |
| OpalSimulation (Expressions::Named_t objectives, Expressions::Named_t constraints, Param_t params, std::string name, MPI_Comm comm, CmdArguments_t args, std::map< std::string, std::string > uvars) | |
| virtual | ~OpalSimulation () |
| void | run () |
| std::map< std::string, std::vector< double > > | getData (const std::vector< std::string > &statVariables) |
| void | collectResults () |
| Parse SDDS stat file and build up requested variable dictionary. More... | |
| void | cleanUp () |
| void | cleanUp (const std::vector< std::string > &keep) |
| remove temporary files except to the ones in 'keep' More... | |
| reqVarContainer_t | getResults () |
| returns container containing all requested variables with results More... | |
| void | setFilename (int id) |
| set job id (SAMPLE command) More... | |
Public Member Functions inherited from Simulation | |
| Simulation (CmdArguments_t args) | |
| ~Simulation () | |
| CmdArguments_t | getArgs () |
Private Member Functions | |
| void | invalidBunch () |
| mark a solution as invalid More... | |
| bool | hasResultsAvailable () |
| check if we already have simulated the current set of design vars More... | |
| void | createSymlink_m (const std::string &path) |
| create symbolic links More... | |
| void | copyH5_m () |
| copy H5 file More... | |
| void | setupSimulation () |
| create directories, input files, fieldmaps... More... | |
| void | setupFSStructure () |
| create directories, input files, symlinks... More... | |
| void | getVariableDictionary (variableDictionary_t &dictionary, const std::string &filename, const Expressions::Expr_t *const expression) |
| get variables for expression evaluation from SDDS file. Can throw SDDSParserException More... | |
| void | redirectOutToFile () |
| redirect stdout and stderr to file More... | |
| void | restoreOut () |
| restore stdout and stderr to default More... | |
Private Attributes | |
| std::string | simulationName_ |
| identification of the simulation (corresponding to output filename) More... | |
| std::string | simulationDirName_ |
| full path of simulation directory (where simulation will be run) More... | |
| std::string | simTmpDir_ |
| temporary directory for simulation data (environment var SIMTMPDIR) More... | |
| std::string | pwd_ |
| holds current directory (for restoring) More... | |
| std::streambuf * | strm_buffer_ |
| stream buffer to redirect output More... | |
| std::streambuf * | strm_err_ |
| stream buffer to redirect stderr More... | |
| std::map< std::string, std::string > | userVariables_ |
| variable dictionary holding requested optimizer values More... | |
| reqVarContainer_t | requestedVars_ |
| holds solutions returned to the optimizer More... | |
| Expressions::Named_t | objectives_ |
| Expressions::Named_t | constraints_ |
| std::set< std::string > | dvarNames_ |
| MPI_Comm | comm_ |
| std::unique_ptr < GenerateOpalSimulation > | gs_ |
| object to generate simulation input files More... | |
| int | id_m |
| job id (SAMPLE command) More... | |
Concrete implementation of an Opal simulation wrapper.
In order to work properly the user must ensure that the environment variables
are specified correctly.
Definition at line 30 of file OpalSimulation.h.
| OpalSimulation::OpalSimulation | ( | Expressions::Named_t | objectives, |
| Expressions::Named_t | constraints, | ||
| Param_t | params, | ||
| std::string | name, | ||
| MPI_Comm | comm, | ||
| CmdArguments_t | args, | ||
| std::map< std::string, std::string > | uvars | ||
| ) |
Setup OPAL run.
| [in] | objectives | of the optimization problem |
| [in] | constraints | of the optimization problem |
| [in] | params | |
| [in] | name | of the simulation |
| [in] | comm | MPI communicator used for running the simulation |
| [in] | args | command line arguments passed to the framework |
| [in] | uvars | defined in the input file (e.g. REAL a = 1.0) |
Definition at line 37 of file OpalSimulation.cpp.
References dvarNames_, endl(), Hypervolume::fs, NativeHashGenerator::generate(), gs_, name, simTmpDir_, simulationDirName_, simulationName_, and userVariables_.

|
virtual |
Definition at line 134 of file OpalSimulation.cpp.
References requestedVars_, and userVariables_.
| void OpalSimulation::cleanUp | ( | ) |
remove temporary simulation files (if Boost filesystem library is not available, this call do nothing).
Definition at line 622 of file OpalSimulation.cpp.
References comm_, endl(), Hypervolume::fs, and simulationDirName_.
Referenced by collectResults().

| void OpalSimulation::cleanUp | ( | const std::vector< std::string > & | keep | ) |
remove temporary files except to the ones in 'keep'
Definition at line 638 of file OpalSimulation.cpp.
References comm_, endl(), Expressions::find(), Hypervolume::fs, it, test::result, simulationDirName_, and Util::toUpper().

|
virtual |
Parse SDDS stat file and build up requested variable dictionary.
Implements Simulation.
Definition at line 464 of file OpalSimulation.cpp.
References cleanUp(), constraints_, Physics::e, endl(), EVALUATE, Expression::evaluate(), exception, Expression::getRegFuncs(), getVariableDictionary(), invalidBunch(), objectives_, pwd_, requestedVars_, test::result, simulationDirName_, simulationName_, Expression::toString(), SDDSParserException::what(), OptPilotException::what(), SDDSParserException::where(), and OptPilotException::where().

|
private |
copy H5 file
Definition at line 172 of file OpalSimulation.cpp.
References endl(), Hypervolume::fs, Simulation::getArgs(), simulationDirName_, and simulationName_.
Referenced by setupFSStructure().

|
private |
create symbolic links
Definition at line 154 of file OpalSimulation.cpp.
References Physics::e, endl(), Hypervolume::fs, and simulationDirName_.
Referenced by setupFSStructure().

| std::map< std::string, std::vector< double > > OpalSimulation::getData | ( | const std::vector< std::string > & | statVariables | ) |
Definition at line 439 of file OpalSimulation.cpp.
References Physics::e, endl(), SDDS::SDDSParser::getBoostVariantValue(), SDDS::SDDSParser::getColumnData(), SDDS::SDDSParser::getColumnType(), SDDS::SDDSParser::run(), simulationDirName_, simulationName_, type, SDDSParserException::what(), and SDDSParserException::where().

|
inlinevirtual |
returns container containing all requested variables with results
Implements Simulation.
Definition at line 70 of file OpalSimulation.h.
References requestedVars_.
|
private |
get variables for expression evaluation from SDDS file. Can throw SDDSParserException
Definition at line 578 of file OpalSimulation.cpp.
References Expression::getReqVars(), it, and userVariables_.
Referenced by collectResults().

|
private |
check if we already have simulated the current set of design vars
Definition at line 139 of file OpalSimulation.cpp.
References endl(), simulationDirName_, and simulationName_.
Referenced by run().

|
private |
mark a solution as invalid
Definition at line 611 of file OpalSimulation.cpp.
References EVALUATE, objectives_, and requestedVars_.
Referenced by collectResults().
|
private |
redirect stdout and stderr to file
Definition at line 298 of file OpalSimulation.cpp.
References strm_buffer_, and strm_err_.
|
private |
restore stdout and stderr to default
Definition at line 319 of file OpalSimulation.cpp.
References strm_buffer_, and strm_err_.
|
virtual |
Calls Opal through Opal-lib wrapper and returns when simulation has either failed or finished.
Implements Simulation.
Definition at line 325 of file OpalSimulation.cpp.
References arg(), comm_, endl(), exception, Hypervolume::fs, Simulation::getArgs(), hasResultsAvailable(), Options::info, Options::infoLevel, min(), pwd_, run_opal(), Options::seed, setupSimulation(), simulationDirName_, simulationName_, Options::warn, Options::warnLevel, ClassicException::what(), and ClassicException::where().

|
inline |
|
private |
create directories, input files, symlinks...
Definition at line 240 of file OpalSimulation.cpp.
References comm_, copyH5_m(), createSymlink_m(), Physics::e, endl(), Hypervolume::fs, gs_, simulationDirName_, and simulationName_.
Referenced by setupSimulation().

|
private |
create directories, input files, fieldmaps...
Definition at line 197 of file OpalSimulation.cpp.
References comm_, Hypervolume::fs, Simulation::getArgs(), OpalData::getInstance(), id_m, OpalData::setOptimizerFlag(), setupFSStructure(), simTmpDir_, simulationDirName_, and simulationName_.
Referenced by run().

|
private |
Definition at line 102 of file OpalSimulation.h.
Referenced by cleanUp(), run(), setupFSStructure(), and setupSimulation().
|
private |
Definition at line 99 of file OpalSimulation.h.
Referenced by collectResults().
|
private |
Definition at line 100 of file OpalSimulation.h.
Referenced by OpalSimulation().
|
private |
object to generate simulation input files
Definition at line 105 of file OpalSimulation.h.
Referenced by OpalSimulation(), and setupFSStructure().
|
private |
job id (SAMPLE command)
Definition at line 108 of file OpalSimulation.h.
Referenced by setFilename(), and setupSimulation().
|
private |
Definition at line 98 of file OpalSimulation.h.
Referenced by collectResults(), and invalidBunch().
|
private |
holds current directory (for restoring)
Definition at line 85 of file OpalSimulation.h.
Referenced by collectResults(), and run().
|
private |
holds solutions returned to the optimizer
Definition at line 96 of file OpalSimulation.h.
Referenced by collectResults(), getResults(), invalidBunch(), and ~OpalSimulation().
|
private |
temporary directory for simulation data (environment var SIMTMPDIR)
Definition at line 82 of file OpalSimulation.h.
Referenced by OpalSimulation(), and setupSimulation().
|
private |
full path of simulation directory (where simulation will be run)
Definition at line 80 of file OpalSimulation.h.
Referenced by cleanUp(), collectResults(), copyH5_m(), createSymlink_m(), getData(), hasResultsAvailable(), OpalSimulation(), run(), setupFSStructure(), and setupSimulation().
|
private |
identification of the simulation (corresponding to output filename)
Definition at line 78 of file OpalSimulation.h.
Referenced by collectResults(), copyH5_m(), getData(), hasResultsAvailable(), OpalSimulation(), run(), setupFSStructure(), and setupSimulation().
|
private |
stream buffer to redirect output
Definition at line 88 of file OpalSimulation.h.
Referenced by redirectOutToFile(), and restoreOut().
|
private |
stream buffer to redirect stderr
Definition at line 90 of file OpalSimulation.h.
Referenced by redirectOutToFile(), and restoreOut().
|
private |
variable dictionary holding requested optimizer values
Definition at line 93 of file OpalSimulation.h.
Referenced by getVariableDictionary(), OpalSimulation(), and ~OpalSimulation().
1.8.5