IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.

IG::Num::SimKosecFileManagerBase Class Reference

File manager for interfacing (for optimization purposes) the simulation code of Gregor Kosec. More...

Inheritance diagram for IG::Num::SimKosecFileManagerBase:
Collaboration diagram for IG::Num::SimKosecFileManagerBase:

List of all members.

Classes

class  InputFieldDefinition
 Contains data about a field that is recoginzed in the input file, such as field identification number, name, and description. This class is immutable except for Description, and it is thread safe in the scope of intended use. More...

Public Member Functions

string GetPath (string relativePath)
 Returns full path of the file or directory with the specified relative path within the data and messages exchange directory.
virtual void SaveInput ()
 Saves contents of the simulation input file. Usually the contents is generated by taking the contents of the template input file and making some modification in it in order to reflect the current values of optimization parameters.
void UpdateDefaultInputValues ()
 Updates the input field values for which default values are defined on the list DefaultInputValues.
string GetOptimizationParametersDefinedFromInput (int which)
 Returns value of the specified input (optimization) parameter obtained from the current contents of simulation input, according to the definition of direct mapping between this parameter and scalar input field value. If mapping is not defined for the component specified then null is returned. Returned value is obtained by GetInputFieldValue.
void GetOptimizationParametersDefinedFromInput (IVector param)
 Gets current values of input (optimization) parameters obtained from the current contents of simulation input, according to the definitions of direct mappings between input parameters and scalar input field values. Values are written to components of the provided vector. Vector is not resized, therefore it must be of correct dimension. Those components for which direct mapping between a specific input parameter and scalar input field in simulation input is not defined, are not obtained and stored in vector components (i.e., eventual previous values are preserved). Returned value is obtained by GetInputFieldValue.
virtual void UpdateOptimizationParametersDefined (IVector parameters)
 Updates simulation inputs according to the values of input (optimization) parameters for those parameters for which direct mapping to input fields are defined. Throws exception if the number of definitions is greater than 0 but also greater than dimension of the specified parameter vector (i.e. all definitions must be used, if any defined).
void UpdateInputDefined (IVector parameters)
 Updates simulation input with default values and with values of optimization parameters for which direct mappings to input fields are defined (the latter only when vector of parameters is specified, i.e. not null).
virtual InputFieldDefinition GetInputFieldDefinition (int fieldId)
 Returns an input field definition that corresponds to the specified field ID. Exception is thrown if the field with this ID is not yet contained in input field definitions.
virtual InputFieldDefinition GetInputFieldDefinition (string fieldName)
 Returns an input field definition that corresponds to the specified field name. Exception is thrown if definition with this name does not yet exist.
virtual InputFieldDefinition GetInputFieldDefinition (int fieldId, string fieldName)
 Returns an input field definition that corresponds to the specified field ID and field name. If a matching definition is already included then that definition is returned, if not then definition is created anew. Exception is thrown if neither of this can be done.
virtual InputFieldDefinition GetInputFieldDefinition (int fieldId, string fieldName, string fieldDescription)
 Returns an input field definition that corresponds to the specified field ID and field name. If a matching definition is already included then that definition is returned, if not then definition is created anew. Exception is thrown if neither of this can be done.
virtual void AddInputFieldDefinition (InputFieldDefinition def)
 Adds a new input field definition. Name of the definition must be unique (not already added).
virtual void AddInputFieldDefinitions (params InputFieldDefinition[] definitions)
 Adds a set of input field definitions by calling

See also:
AddInputFieldDefinition

.

void ClearInputFieldDefinition (int fieldId)
 Removes the specified input field definition from the stored collection of definitions.
void ClearinputfieldDefinition (string fieldName)
 Removes the specified input field definition from the stored collection of definitions.
void ClearInputFieldDefinition (int fieldId, string fieldName)
 Removes the specified input field definition from the stored collection of definitions.
void ClearinputFieldDefinitions ()
 Clears all input fielddefinitions.
virtual void RemoveInputFieldDefinitions ()
void SetInputFieldValue (string fieldName, string fieldValue)
 Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).
void SetInputFieldValue (int fieldId, string fieldValue)
 Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).
void SetInputFieldValue (int fieldId, string fieldName, string fieldValue)
 Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).
void SetInputFieldValue (InputFieldDefinition def, string fieldValue)
 Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).
void AddInputComment (string commentString)
 Adds comment to the input file.
string GetInputFieldValue (string fieldName)
 Returns value of the sepcified input field.
string GetInputFieldValue (int fieldId)
 Returns value of the sepcified input field.
string GetInputFieldValue (int fieldId, string fieldName)
 Returns value of the sepcified input field.
string GetInputFieldValue (InputFieldDefinition def)
 Returns the value of the specified input field, which is obtained from the contents of teh input file.
abstract bool RepairInputParameters (IVector parameters)
 Repairs simulation parameters, if necessary, in such a way that values are consistent with simuation data (e.g. spacing of nodes).
virtual void ReadInputParameters (ref IVector inputParameters)
 Reads optimization input parameters form the file at a standard location.
virtual void WriteInputParameters (IVector inputParameters)
 Writes optimization input parameters to the standard location.
virtual void DeleteOutputFiles ()
 Deletes the output files. It is recommendable to delete simulation output before running simulation. In this way, one would know if the simulation program has been broken because the output file would not exist or would be corrupted (otherwise, one could simply read the output file genenerated in some previout run, without noticing that something is wrong).
virtual void ReadOutputValues (ref IVector outputValues)
 Reads optimization output values form the file at a standard location.
virtual void WriteOutputValues (IVector outputValues)
 Writes optimization ouptut values to the standard location.
void RunSimulator ()
 Runs the simulaor interfaced by the current object. This method only runs the simulator, it does not prepare any input.
void RunSimulator (string[] commandlineArguments)
 Runns the simulator with the specified command-line arguments. Warning: this method should be used for testing only because the command-line arguments that should be passed to the simulator are specified by the interrface rules and can not be specified arbitrarily. Otherwise, run the overloaded method with no arguments. This method only runs the simulator, it does not prepare any input.
void CalculateVectorResponse (IVector inputParameters, ref IVector outputValues)
 Calculates simulator's response for the specified input parameters.
void WriteToConsole ()
 Writes data about the current object to console. Normally, toString() will be used for that, but sometimed this method is used because it is more suitable for debugging.
override string ToString ()
 Returns string representation of the current object.

Protected Member Functions

 SimKosecFileManagerBase (string dataDirectory)
 Constructs a new file manager for interfacing simulator of Gregor Kosec.
abstract void Init ()
 Initializes internal variables. Called at the beginning of all constructors. To be overridden in derived classes!
virtual void InstallInputFields ()
 Installs data about input fields that can be queried and set in the input file.
abstract void InstallInputMappings ()
 Installs definitions of default values of input fields that are automatically set before running the simulation, and eventually definitios for mappings between (optimization) input parameters and input fields in input file. The latter are eventually used when for each input (optimization) parameter there exists a field that corresponds to that parameter. Many times this is not true because a single optimization parameters can affect a whole set of input fields.When running simulator by calling CalculateVectorResponse, input is prepared in the following order: First default parameters are set, then automatic mappings are performed (if any are defined) and finally the manual mappings are performed by calling UpdateInputParametersManual, thus manually defined parameter mapping overrides all others when defined.
virtual InputFieldDefinition GetDefinition (List< InputFieldDefinition > list, int id, string name)
 Finds and returns the specified input field definition on the specified list.
void AddDefaultInputValues (params InputFieldDefinition[] definitions)
 Adds a set of default input values to the list DefaultInputValues of default values. These values will be set when input file is prepared.
InputFieldDefinition GetDefaultInputValue (int id, string name)
 Finds and returns the specified deefault input value definition.

See also:
GetDefinition

void AddOptimizationParameterDefinitions (params InputFieldDefinition[] definitions)
 Adds a set of optimization parameter definitions to the list. Each definitios specifies which parameter in the simulation input file corresponds to a given optimization parameter. It is alloved that some definitions are null. The corresponding optimization parameters will not be mapped automatically to input fields by functions such as UpdateOptimizationParametersDefined, but tehir mapping must be provided specially in definitions of (usually overridden) functions such as UpdateInputParametersManual.
InputFieldDefinition GetOptimizationParameterDefinition (int id, string name)
 Finds and returns the specified optimization parameter definition.

See also:
GetDefinition

abstract void GetInputParametersManual (ref IVector inputParameters)
 Gets the current values of input parameters form the input file. This method must be overridden in derived concrete classes.
abstract void UpdateInputParametersManual (IVector inputParameters)
 Prepares current values of input parameters in the simulation input that will be written to the simulation input file. This method must be overridden in derived concrete classes. Only mappings form input parameters to simulation input that are manually defined must be performed by this function, since automatic mappings are already included in functions such as WriteInputParameters.

Protected Attributes

bool _redirectOutput = false
string _redirectedOutputPath = null
string _directory = null
string _csvSeparator = SimKosecConst.CsvSeparatorDefault
IBoundingBox _inputParameterBounds

Properties

object Lock [get]
 This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
object InternalLock [get]
 Used internally for locking access to internal fields.
bool RedirectOutput [get, set]
 Gets or sets the plag indicating whether standard output will be redirected or not.
string RedirectedOutputPath [get, set]
 Gets or sets path to the file where standard output will be redirected. Setting to null causes that output will not be redirected.
string RedirectedOutputFileName [get, set]
 Gets or sets name of the file where output is redirected. Setting to null or empty string means that output will not be redirected.Setting to non-empty string means that output will be redirected to the file named as set by this property, and residing in data directory (property DataDirectory).Getter just returns the current state of matters (null if output is not redirected, file name otherwise).
int OutputLevel [get, set]
 Level of information that is output to the console by some methods.
virtual int NumInputParameters [get, set]
 Number of input optimization parameters for the simulator.
virtual int NumOutputValues [get, set]
 Number of optimization output values produced by the simulator.
string DataDirectory [get, set]
 Directory for data and messages exchange through files.
string CsvSeparator [get, set]
 Separator used to separate values in CSV files.
virtual string TemplateInputPath [get, set]
 File path of the template analysis input file. This file is transcribed, with appropriate modification according to the optimization parameters, to the actual simulation input file. Setter takes only pure file name, without path information. If set to null then file path is set to null and will be recalculated when getter is called.
virtual string InputPath [get, set]
 File path of the analysis input file. This file contains all the input data for the direct analysis. If set to null then file path is set to null and will be recalculated when getter is called.
virtual string ExecutableFilename [get, set]
 File name of the executable that performs the direct analysis.
virtual string ExecutablePath [get, set]
 File path of the analysis exeutable. If set to null then file path is set to null and will be recalculated when getter is called.
virtual string OutputBaseDirpath [get, set]
 Path of the base directory where output files are located. Setter takes only pure directory name, without path information. If set to null then directory path is set to null and will be recalculated when getter is called.
virtual string OutputDirpath [get, set]
 Path of the directory where output files are located. Setter takes only pure directory name, without path information. If set to null then directory path is set to null and will be recalculated when getter is called.
string OptOutputCsvPath [get, set]
 File path of the analysis output file in CSV format. This file contains the pre-agreed set of output values obtained by post-processing of simulator results. If set to null then file path is set to null and will be recalculated when getter is called.
virtual string InputFileContents [get, set]
 The current input file contents. By default this is obtained form the template input file. If the property is set to null at some point then it will be set to contents of the template input file at the first get access.
virtual string[][] InputFileLines [get, set]
 The current input represented as an array of text lines.
List< InputFieldDefinitionDefaultInputValues [get]
 List containing default values for input parameters, which will be set before the simulation input file is prepared, which makes possible to play with the definition of the template direct problem.
List< InputFieldDefinitionOptimizationParameterDefinitions [get]
 List of definitions of direct mappings od input (optimization) parameters to input fields. Contains, for each input parameter, the definition of the input field that is represented by this parameter. This list can contain null references, which are usually for parameters that can not be directly mapped to scalar input fields defined in the simulation input file.
SortedDictionary< string,
InputFieldDefinition
InputFieldDefinitions [get]
 Gets the sorted dictionary that contains input field definitions. This should be used only exceptionally; use the higher level method for dealing with input field definitions.
virtual IBoundingBox InputParameterBounds [get, set]
 Bounds on input parameters.
string[] OneCommandArgument [get]
 Used to run the simulatior in the default case where there is only one command-line argument.

Private Attributes

object _mainLock = new object()
object _internalLock = new object()
int _outputLevel = Util.OutputLevel
int _numInputParameters
int _numOutputValues
string _templateInputFilename = SimKosecConst.TemplateInputFileNameDefault
string _templateInputPath
string _inputFilename = SimKosecConst.InputFileNameDefault
string _inputPath
string _executableFilename = SimKosecConst.ExecutableFilenameDefault
string _executablePath
string _outputBaseDirname = SimKosecConst.OutputDirectortyBaseDefault
string _outputBaseDirpath
string _outputDirname
string _outputDirpath
string _optOutputCsvFilename = SimKosecConst.OptimizationOutputFileName
string _optOutputCsvPath
string xxxfjafjkasjflajfla = ""
string _inputFileContents
string[][] _inputFileLines
List< InputFieldDefinition_optimizationParameters = new List<InputFieldDefinition>()
List< InputFieldDefinition_defaultInputValues = new List<InputFieldDefinition>()
SortedDictionary< string,
InputFieldDefinition
_inputFields = new SortedDictionary<string, InputFieldDefinition>()
string[] _oneCommandArgument = new string[1]

Detailed Description

File manager for interfacing (for optimization purposes) the simulation code of Gregor Kosec.

$A Igor Aug11;


Constructor & Destructor Documentation

IG::Num::SimKosecFileManagerBase::SimKosecFileManagerBase ( string  dataDirectory) [inline, protected]

Constructs a new file manager for interfacing simulator of Gregor Kosec.

Parameters:
dataDirectoryData directory for simulation code. This directory usually contains the simulator as well as the input files, and output is written to the specified locations within the directory.

Member Function Documentation

abstract void IG::Num::SimKosecFileManagerBase::Init ( ) [protected, pure virtual]

Initializes internal variables. Called at the beginning of all constructors. To be overridden in derived classes!

Implemented in IG::Num::SimKosecFileManagerConvBase, and IG::Num::SimKosecFileManagerConv2.

virtual void IG::Num::SimKosecFileManagerBase::InstallInputFields ( ) [inline, protected, virtual]

Installs data about input fields that can be queried and set in the input file.

Reimplemented in IG::Num::SimKosecFileManagerConvBase.

abstract void IG::Num::SimKosecFileManagerBase::InstallInputMappings ( ) [protected, pure virtual]

Installs definitions of default values of input fields that are automatically set before running the simulation, and eventually definitios for mappings between (optimization) input parameters and input fields in input file. The latter are eventually used when for each input (optimization) parameter there exists a field that corresponds to that parameter. Many times this is not true because a single optimization parameters can affect a whole set of input fields.When running simulator by calling CalculateVectorResponse, input is prepared in the following order: First default parameters are set, then automatic mappings are performed (if any are defined) and finally the manual mappings are performed by calling UpdateInputParametersManual, thus manually defined parameter mapping overrides all others when defined.

Implemented in IG::Num::SimKosecFileManagerConvBase.

string IG::Num::SimKosecFileManagerBase::GetPath ( string  relativePath) [inline]

Returns full path of the file or directory with the specified relative path within the data and messages exchange directory.

Parameters:
relativePathRelative path (with respect to data and messages exchange directory)
virtual void IG::Num::SimKosecFileManagerBase::SaveInput ( ) [inline, virtual]

Saves contents of the simulation input file. Usually the contents is generated by taking the contents of the template input file and making some modification in it in order to reflect the current values of optimization parameters.

virtual InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetDefinition ( List< InputFieldDefinition list,
int  id,
string  name 
) [inline, protected, virtual]

Finds and returns the specified input field definition on the specified list.

Parameters:
listList that is searched for the specified definition.
idID of the definiton. If less or equal to 0 then definition is searched only by field name.
nameField name that it searched for. If id is greater than 0 then the definition that is found must have matching names and IDs, otherwise exception is thrown.
Returns:
The definition form the list that matched the specified field ID and/or field name, or null if such a definitio is not found on the list.
void IG::Num::SimKosecFileManagerBase::AddDefaultInputValues ( params InputFieldDefinition[]  definitions) [inline, protected]

Adds a set of default input values to the list DefaultInputValues of default values. These values will be set when input file is prepared.

Parameters:
definitions
InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetDefaultInputValue ( int  id,
string  name 
) [inline, protected]

Finds and returns the specified deefault input value definition.

See also:
GetDefinition

Parameters:
listList that is searched for the specified definition.
idID of the definiton. If less or equal to 0 then definition is searched only by field name.
nameField name that it searched for. If id is greater than 0 then the definition that is found must have matching names and IDs, otherwise exception is thrown.
Returns:
The definition form the list that matched the specified field ID and/or field name, or null if such a definitio is not found on the list.
void IG::Num::SimKosecFileManagerBase::UpdateDefaultInputValues ( ) [inline]

Updates the input field values for which default values are defined on the list DefaultInputValues.

void IG::Num::SimKosecFileManagerBase::AddOptimizationParameterDefinitions ( params InputFieldDefinition[]  definitions) [inline, protected]

Adds a set of optimization parameter definitions to the list. Each definitios specifies which parameter in the simulation input file corresponds to a given optimization parameter. It is alloved that some definitions are null. The corresponding optimization parameters will not be mapped automatically to input fields by functions such as UpdateOptimizationParametersDefined, but tehir mapping must be provided specially in definitions of (usually overridden) functions such as UpdateInputParametersManual.

Parameters:
definitionsDefinitions to be added. If any of them is null then an ArgumentException is thrown.
InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetOptimizationParameterDefinition ( int  id,
string  name 
) [inline, protected]

Finds and returns the specified optimization parameter definition.

See also:
GetDefinition

Parameters:
listList that is searched for the specified definition.
idID of the definiton. If less or equal to 0 then definition is searched only by field name.
nameField name that it searched for. If id is greater than 0 then the definition that is found must have matching names and IDs, otherwise exception is thrown.
Returns:
The definition form the list that matched the specified field ID and/or field name, or null if such a definitio is not found on the list.
string IG::Num::SimKosecFileManagerBase::GetOptimizationParametersDefinedFromInput ( int  which) [inline]

Returns value of the specified input (optimization) parameter obtained from the current contents of simulation input, according to the definition of direct mapping between this parameter and scalar input field value. If mapping is not defined for the component specified then null is returned. Returned value is obtained by GetInputFieldValue.

Parameters:
whichSpecifies which optimization parameter is returned.
Returns:
Value of the specified input (optimization) parameter if direct mapping between that parameter and a scalar simulation input field is defined, or null if such mapping is not defined.
void IG::Num::SimKosecFileManagerBase::GetOptimizationParametersDefinedFromInput ( IVector  param) [inline]

Gets current values of input (optimization) parameters obtained from the current contents of simulation input, according to the definitions of direct mappings between input parameters and scalar input field values. Values are written to components of the provided vector. Vector is not resized, therefore it must be of correct dimension. Those components for which direct mapping between a specific input parameter and scalar input field in simulation input is not defined, are not obtained and stored in vector components (i.e., eventual previous values are preserved). Returned value is obtained by GetInputFieldValue.

Parameters:
paramVector of parameters that are provided.
virtual void IG::Num::SimKosecFileManagerBase::UpdateOptimizationParametersDefined ( IVector  parameters) [inline, virtual]

Updates simulation inputs according to the values of input (optimization) parameters for those parameters for which direct mapping to input fields are defined. Throws exception if the number of definitions is greater than 0 but also greater than dimension of the specified parameter vector (i.e. all definitions must be used, if any defined).

Parameters:
parametersVector of values of input (optimization) parameters to be mapped to simulation input.
Exceptions:
ArgumentExceptionIf number of definitions of parameters installed is greater than 0 but the specified vector of parameters is null or of dimension smaller than the number of definitions.
void IG::Num::SimKosecFileManagerBase::UpdateInputDefined ( IVector  parameters) [inline]

Updates simulation input with default values and with values of optimization parameters for which direct mappings to input fields are defined (the latter only when vector of parameters is specified, i.e. not null).

Parameters:
parametersVector of input (optimization) parameters.
virtual InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetInputFieldDefinition ( int  fieldId) [inline, virtual]

Returns an input field definition that corresponds to the specified field ID. Exception is thrown if the field with this ID is not yet contained in input field definitions.

Parameters:
fieldIdInput field ID. Should be greater than 0.
virtual InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetInputFieldDefinition ( string  fieldName) [inline, virtual]

Returns an input field definition that corresponds to the specified field name. Exception is thrown if definition with this name does not yet exist.

Parameters:
fieldNameInput field name.
virtual InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetInputFieldDefinition ( int  fieldId,
string  fieldName 
) [inline, virtual]

Returns an input field definition that corresponds to the specified field ID and field name. If a matching definition is already included then that definition is returned, if not then definition is created anew. Exception is thrown if neither of this can be done.

Parameters:
fieldIdInput field ID. Less or equal to 0 means undefined.
fieldNameInput field name.
virtual InputFieldDefinition IG::Num::SimKosecFileManagerBase::GetInputFieldDefinition ( int  fieldId,
string  fieldName,
string  fieldDescription 
) [inline, virtual]

Returns an input field definition that corresponds to the specified field ID and field name. If a matching definition is already included then that definition is returned, if not then definition is created anew. Exception is thrown if neither of this can be done.

Parameters:
fieldIdInput field ID. Less or equal to 0 means undefined.
fieldNameInput field name.
fieldDescriptionInput field description.
virtual void IG::Num::SimKosecFileManagerBase::AddInputFieldDefinition ( InputFieldDefinition  def) [inline, virtual]

Adds a new input field definition. Name of the definition must be unique (not already added).

Parameters:
defInput field definition to be added.
virtual void IG::Num::SimKosecFileManagerBase::AddInputFieldDefinitions ( params InputFieldDefinition[]  definitions) [inline, virtual]

Adds a set of input field definitions by calling

See also:
AddInputFieldDefinition

.

Parameters:
definitionsDefinitions to be added (can be null).
void IG::Num::SimKosecFileManagerBase::ClearInputFieldDefinition ( int  fieldId) [inline]

Removes the specified input field definition from the stored collection of definitions.

Parameters:
fieldIdField ID of the definiiton to be removed. Must be greater than 0.
void IG::Num::SimKosecFileManagerBase::ClearinputfieldDefinition ( string  fieldName) [inline]

Removes the specified input field definition from the stored collection of definitions.

Parameters:
fieldNameField name of the definition to be removed.
void IG::Num::SimKosecFileManagerBase::ClearInputFieldDefinition ( int  fieldId,
string  fieldName 
) [inline]

Removes the specified input field definition from the stored collection of definitions.

Parameters:
fieldIdField ID. This is used to find the input field definition if field name is not specified.
fieldNameField name. If not specified the field ID is used to find the definition to be removed, otherwise field ID is just used to check if the field name is consistent with ID.
void IG::Num::SimKosecFileManagerBase::ClearinputFieldDefinitions ( ) [inline]

Clears all input fielddefinitions.

virtual void IG::Num::SimKosecFileManagerBase::RemoveInputFieldDefinitions ( ) [inline, virtual]
void IG::Num::SimKosecFileManagerBase::SetInputFieldValue ( string  fieldName,
string  fieldValue 
) [inline]

Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).

Parameters:
fieldNameName of the field to be set.
fieldValueValue to be assigned to the specified field.
void IG::Num::SimKosecFileManagerBase::SetInputFieldValue ( int  fieldId,
string  fieldValue 
) [inline]

Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).

Parameters:
fieldIdId of the field to be set.
fieldValueValue to be assigned to the specified field.
void IG::Num::SimKosecFileManagerBase::SetInputFieldValue ( int  fieldId,
string  fieldName,
string  fieldValue 
) [inline]

Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).

Parameters:
fieldIdId of the field to be set.
fieldNameName of the field to be set.
fieldValueValue to be assigned to the specified field.
void IG::Num::SimKosecFileManagerBase::SetInputFieldValue ( InputFieldDefinition  def,
string  fieldValue 
) [inline]

Sets the sepcified input field to the specified value. This is done by appending a corresponding text to the contents of the input file (at this stage, the file is not modified yet).

Parameters:
defDefinition of the input field to be set.
fieldValueValue to be assigned to the field.
void IG::Num::SimKosecFileManagerBase::AddInputComment ( string  commentString) [inline]

Adds comment to the input file.

Parameters:
commentStringComment text.
string IG::Num::SimKosecFileManagerBase::GetInputFieldValue ( string  fieldName) [inline]

Returns value of the sepcified input field.

Parameters:
fieldNameName of the field to be set.
string IG::Num::SimKosecFileManagerBase::GetInputFieldValue ( int  fieldId) [inline]

Returns value of the sepcified input field.

Parameters:
fieldIdId of the field to be set.
string IG::Num::SimKosecFileManagerBase::GetInputFieldValue ( int  fieldId,
string  fieldName 
) [inline]

Returns value of the sepcified input field.

Parameters:
fieldIdId of the field to be set.
fieldNameName of the field to be set.
string IG::Num::SimKosecFileManagerBase::GetInputFieldValue ( InputFieldDefinition  def) [inline]

Returns the value of the specified input field, which is obtained from the contents of teh input file.

Parameters:
defDefinition data for the input field whose value is to be returned.

Current contents of the input file are stored in the internal structure (lines of text split in such a way that ID, field name and value can be readily obtained). When input field values are added, this data is modified such that changes are immediately taken into account. Algorithm for this is rather naive (complete input is invalidated upon each change), therefore it is recommended to first querry all the necessary parameters and then change anything, or to perform all the changes first and then query input field values.

abstract void IG::Num::SimKosecFileManagerBase::GetInputParametersManual ( ref IVector  inputParameters) [protected, pure virtual]

Gets the current values of input parameters form the input file. This method must be overridden in derived concrete classes.

Parameters:
inputParametersVector object where current values of input parameters are stored.

Implemented in IG::Num::SimKosecFileManagerConv2, and IG::Num::SimKosecFileManagerConv3.

abstract bool IG::Num::SimKosecFileManagerBase::RepairInputParameters ( IVector  parameters) [pure virtual]

Repairs simulation parameters, if necessary, in such a way that values are consistent with simuation data (e.g. spacing of nodes).

Parameters:
parametersVector of parameters to be repaired. Repaired values are stored in the same vector.
Returns:
true if parameters were corrected, false otherwise.

Implemented in IG::Num::SimKosecFileManagerConv2, and IG::Num::SimKosecFileManagerConv3.

abstract void IG::Num::SimKosecFileManagerBase::UpdateInputParametersManual ( IVector  inputParameters) [protected, pure virtual]

Prepares current values of input parameters in the simulation input that will be written to the simulation input file. This method must be overridden in derived concrete classes. Only mappings form input parameters to simulation input that are manually defined must be performed by this function, since automatic mappings are already included in functions such as WriteInputParameters.

Parameters:
inputParametersVector of input (optimization) parameter values to be set.

Implemented in IG::Num::SimKosecFileManagerConv2, and IG::Num::SimKosecFileManagerConv3.

virtual void IG::Num::SimKosecFileManagerBase::ReadInputParameters ( ref IVector  inputParameters) [inline, virtual]

Reads optimization input parameters form the file at a standard location.

Parameters:
inputParametersReference to an object where input parameters are stored. If number of inpput parameters is defined then the provided vector is resized if necessary. Otherwise, the vector provided must be of correct dimension.
virtual void IG::Num::SimKosecFileManagerBase::WriteInputParameters ( IVector  inputParameters) [inline, virtual]

Writes optimization input parameters to the standard location.

Parameters:
outputValuesParameters to be written.
virtual void IG::Num::SimKosecFileManagerBase::DeleteOutputFiles ( ) [inline, virtual]

Deletes the output files. It is recommendable to delete simulation output before running simulation. In this way, one would know if the simulation program has been broken because the output file would not exist or would be corrupted (otherwise, one could simply read the output file genenerated in some previout run, without noticing that something is wrong).

virtual void IG::Num::SimKosecFileManagerBase::ReadOutputValues ( ref IVector  outputValues) [inline, virtual]

Reads optimization output values form the file at a standard location.

Parameters:
outputValuesReference to an object where output parameters will be stored.
virtual void IG::Num::SimKosecFileManagerBase::WriteOutputValues ( IVector  outputValues) [inline, virtual]

Writes optimization ouptut values to the standard location.

Parameters:
outputValuesValues to be written.
void IG::Num::SimKosecFileManagerBase::RunSimulator ( ) [inline]

Runs the simulaor interfaced by the current object. This method only runs the simulator, it does not prepare any input.

void IG::Num::SimKosecFileManagerBase::RunSimulator ( string[]  commandlineArguments) [inline]

Runns the simulator with the specified command-line arguments. Warning: this method should be used for testing only because the command-line arguments that should be passed to the simulator are specified by the interrface rules and can not be specified arbitrarily. Otherwise, run the overloaded method with no arguments. This method only runs the simulator, it does not prepare any input.

Parameters:
commandlineArgumentsCommand-line arguments that are passed to the simulator program.
void IG::Num::SimKosecFileManagerBase::CalculateVectorResponse ( IVector  inputParameters,
ref IVector  outputValues 
) [inline]

Calculates simulator's response for the specified input parameters.

Parameters:
inputParametersInput parameters for which response is calculated.
outputValuesVector object where the calculated response is stored after calculation.

Implements IG::Num::IResponseEvaluatorVectorSimple.

void IG::Num::SimKosecFileManagerBase::WriteToConsole ( ) [inline]

Writes data about the current object to console. Normally, toString() will be used for that, but sometimed this method is used because it is more suitable for debugging.

override string IG::Num::SimKosecFileManagerBase::ToString ( ) [inline]

Returns string representation of the current object.


Member Data Documentation

object IG::Num::SimKosecFileManagerBase::_mainLock = new object() [private]
object IG::Num::SimKosecFileManagerBase::_internalLock = new object() [private]
int IG::Num::SimKosecFileManagerBase::_outputLevel = Util.OutputLevel [private]
SortedDictionary<string, InputFieldDefinition> IG::Num::SimKosecFileManagerBase::_inputFields = new SortedDictionary<string, InputFieldDefinition>() [private]
string [] IG::Num::SimKosecFileManagerBase::_oneCommandArgument = new string[1] [private]

Property Documentation

object IG::Num::SimKosecFileManagerBase::Lock [get]

This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.

Implements IG::Lib::ILockable.

object IG::Num::SimKosecFileManagerBase::InternalLock [get, protected]

Used internally for locking access to internal fields.

bool IG::Num::SimKosecFileManagerBase::RedirectOutput [get, set]

Gets or sets the plag indicating whether standard output will be redirected or not.

If this flag is set to true but path to the file (property RedirectedOutputPath) where output is redirected is not specified yet then this path will be generated form path to input file (just the ".out" extension is added).

string IG::Num::SimKosecFileManagerBase::RedirectedOutputPath [get, set]

Gets or sets path to the file where standard output will be redirected. Setting to null causes that output will not be redirected.

string IG::Num::SimKosecFileManagerBase::RedirectedOutputFileName [get, set]

Gets or sets name of the file where output is redirected. Setting to null or empty string means that output will not be redirected.Setting to non-empty string means that output will be redirected to the file named as set by this property, and residing in data directory (property DataDirectory).Getter just returns the current state of matters (null if output is not redirected, file name otherwise).

int IG::Num::SimKosecFileManagerBase::OutputLevel [get, set]

Level of information that is output to the console by some methods.

virtual int IG::Num::SimKosecFileManagerBase::NumInputParameters [get, set]

Number of input optimization parameters for the simulator.

Reimplemented in IG::Num::SimKosecFileManagerConv3.

virtual int IG::Num::SimKosecFileManagerBase::NumOutputValues [get, set]

Number of optimization output values produced by the simulator.

string IG::Num::SimKosecFileManagerBase::DataDirectory [get, set]

Directory for data and messages exchange through files.

string IG::Num::SimKosecFileManagerBase::CsvSeparator [get, set]

Separator used to separate values in CSV files.

virtual string IG::Num::SimKosecFileManagerBase::TemplateInputPath [get, set]

File path of the template analysis input file. This file is transcribed, with appropriate modification according to the optimization parameters, to the actual simulation input file. Setter takes only pure file name, without path information. If set to null then file path is set to null and will be recalculated when getter is called.

virtual string IG::Num::SimKosecFileManagerBase::InputPath [get, set]

File path of the analysis input file. This file contains all the input data for the direct analysis. If set to null then file path is set to null and will be recalculated when getter is called.

virtual string IG::Num::SimKosecFileManagerBase::ExecutableFilename [get, set]

File name of the executable that performs the direct analysis.

virtual string IG::Num::SimKosecFileManagerBase::ExecutablePath [get, set]

File path of the analysis exeutable. If set to null then file path is set to null and will be recalculated when getter is called.

virtual string IG::Num::SimKosecFileManagerBase::OutputBaseDirpath [get, set]

Path of the base directory where output files are located. Setter takes only pure directory name, without path information. If set to null then directory path is set to null and will be recalculated when getter is called.

virtual string IG::Num::SimKosecFileManagerBase::OutputDirpath [get, set]

Path of the directory where output files are located. Setter takes only pure directory name, without path information. If set to null then directory path is set to null and will be recalculated when getter is called.

string IG::Num::SimKosecFileManagerBase::OptOutputCsvPath [get, set]

File path of the analysis output file in CSV format. This file contains the pre-agreed set of output values obtained by post-processing of simulator results. If set to null then file path is set to null and will be recalculated when getter is called.

virtual string IG::Num::SimKosecFileManagerBase::InputFileContents [get, set]

The current input file contents. By default this is obtained form the template input file. If the property is set to null at some point then it will be set to contents of the template input file at the first get access.

virtual string [][] IG::Num::SimKosecFileManagerBase::InputFileLines [get, set]

The current input represented as an array of text lines.

List<InputFieldDefinition> IG::Num::SimKosecFileManagerBase::DefaultInputValues [get, protected]

List containing default values for input parameters, which will be set before the simulation input file is prepared, which makes possible to play with the definition of the template direct problem.

List<InputFieldDefinition> IG::Num::SimKosecFileManagerBase::OptimizationParameterDefinitions [get, protected]

List of definitions of direct mappings od input (optimization) parameters to input fields. Contains, for each input parameter, the definition of the input field that is represented by this parameter. This list can contain null references, which are usually for parameters that can not be directly mapped to scalar input fields defined in the simulation input file.

SortedDictionary<string, InputFieldDefinition> IG::Num::SimKosecFileManagerBase::InputFieldDefinitions [get, protected]

Gets the sorted dictionary that contains input field definitions. This should be used only exceptionally; use the higher level method for dealing with input field definitions.

virtual IBoundingBox IG::Num::SimKosecFileManagerBase::InputParameterBounds [get, set]

Bounds on input parameters.

string [] IG::Num::SimKosecFileManagerBase::OneCommandArgument [get, protected]

Used to run the simulatior in the default case where there is only one command-line argument.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties Events