OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GenerateOpalSimulation Class Reference

Generates an OPAL input file from data and template file. More...

#include <GenerateOpalSimulation.h>

Public Member Functions

 GenerateOpalSimulation (std::string tmplFile, std::string varDictionary, std::map< std::string, std::string > userValues)
 
 ~GenerateOpalSimulation ()
 
void writeInputFile (std::string outputFile)
 

Private Member Functions

void fillDictionary ()
 
void scale (std::string name, std::string *value)
 Helper method to scale variable if necessary. More...
 

Private Attributes

std::string tmplFile_
 template filename More...
 
std::string varDictionary_
 data filename More...
 
std::map< std::string,
std::string > 
dictionary_
 holds parsed template data More...
 
std::map< std::string, double > scaleVars_
 holds all variables that need scaling More...
 

Detailed Description

Generates an OPAL input file from data and template file.

When running the optimizer with the OPAL forward solvers this utility class helps generating OPAL input files corresponding to the design variable values of the requested evaluation. Using the data file we start by generating the dictionary of known templates. When the input file is requested, all template variables in the template input file are replaced with values found in the dictionary.

TODO:

Definition at line 31 of file GenerateOpalSimulation.h.

Constructor & Destructor Documentation

GenerateOpalSimulation::GenerateOpalSimulation ( std::string  tmplFile,
std::string  varDictionary,
std::map< std::string, std::string >  userValues 
)
inline

Sets up the scaled variables and fills the dictionary with content of data file.

Parameters
[in]tmplFilefilename of template file
[in]varDictionaryfilename of data file
[in]userValuestemplate variables specified by the optimizer

Definition at line 43 of file GenerateOpalSimulation.h.

References dictionary_, fillDictionary(), scaleVars_, tmplFile_, and varDictionary_.

Here is the call graph for this function:

GenerateOpalSimulation::~GenerateOpalSimulation ( )
inline

Definition at line 57 of file GenerateOpalSimulation.h.

References dictionary_, and scaleVars_.

Member Function Documentation

void GenerateOpalSimulation::fillDictionary ( )
inlineprivate

Parses the data file and insert all values into the dictionary.

The data file needs to conform to the specification:

  • comments start with a hash symbol (end of line comments possible),
  • a data row starts with the name of the template variable and the value is separated by at least one whitespace.

In some cases the simple parser may fail, the characters scanned when splitting data rows are

' ',

Definition at line 127 of file GenerateOpalSimulation.h.

References dictionary_, endl(), scale(), and varDictionary_.

Referenced by GenerateOpalSimulation().

Here is the call graph for this function:

void GenerateOpalSimulation::scale ( std::string  name,
std::string *  value 
)
inlineprivate

Helper method to scale variable if necessary.

Definition at line 174 of file GenerateOpalSimulation.h.

References name, and scaleVars_.

Referenced by fillDictionary().

void GenerateOpalSimulation::writeInputFile ( std::string  outputFile)
inline

Replace all template variables in template file with corresponding values from the dictionary and write file to disk

Parameters
[in]outputFilewrite resulting input file to this file

Definition at line 68 of file GenerateOpalSimulation.h.

References dictionary_, endl(), Inform::precision(), and tmplFile_.

Here is the call graph for this function:

Member Data Documentation

std::map<std::string, std::string> GenerateOpalSimulation::dictionary_
private

holds parsed template data

Definition at line 110 of file GenerateOpalSimulation.h.

Referenced by fillDictionary(), GenerateOpalSimulation(), writeInputFile(), and ~GenerateOpalSimulation().

std::map<std::string, double> GenerateOpalSimulation::scaleVars_
private

holds all variables that need scaling

Definition at line 112 of file GenerateOpalSimulation.h.

Referenced by GenerateOpalSimulation(), scale(), and ~GenerateOpalSimulation().

std::string GenerateOpalSimulation::tmplFile_
private

template filename

Definition at line 106 of file GenerateOpalSimulation.h.

Referenced by GenerateOpalSimulation(), and writeInputFile().

std::string GenerateOpalSimulation::varDictionary_
private

data filename

Definition at line 108 of file GenerateOpalSimulation.h.

Referenced by fillDictionary(), and GenerateOpalSimulation().


The documentation for this class was generated from the following file: