FEDEM Solver
R8.0
Source code of the dynamics solver
|
Singleton class for external device functions (functions from file). More...
#include <FiDeviceFunctionFactory.H>
Public Member Functions | |
int | open (const std::string &fileName, FiDevFormat format=UNKNOWN_FILE, FiStatus status=IO_READ, int inputChannel=0, bool littleEndian=false) |
Opens the named file. More... | |
void | close (const std::string &fileName) |
Closes the named file. More... | |
void | close (int fileIndex) |
Closes the indexed file. More... | |
double | getValue (int fileIndex, double arg, int &stat, int channel=0, int zeroAd=0, double shift=0.0, double scale=1.0) const |
Evaluates the indexed function for the specified argument value. More... | |
bool | getValues (int fileIndex, double x0, double x1, std::vector< double > &x, std::vector< double > &y, int channel=0, int zeroAdjust=0, double shift=0.0, double scale=1.0) const |
Evaluate the indexed function for the specified argument range. More... | |
double | getStep (int fileIndex) const |
Returns (constant) argument increment of the indexed function. More... | |
double | getFrequency (int fileIndex) const |
Returns (constant) sampling frequency of the indexed function. More... | |
void | getAxisTitle (int fileIndex, int axis, char *axisText, size_t n) const |
Returns the axis title of the indexed function. More... | |
void | getAxisUnit (int fileIndex, int axis, char *unitText, size_t n) const |
Returns the axis unit of the indexed function. More... | |
bool | setValue (int fileIndex, double xVal, double yVal) |
Sets an argument/value pair for an indexed function. More... | |
void | setStep (int fileIndex, double step) const |
Sets the constant argument increment of the indexed function. More... | |
void | setFrequency (int fileIndex, double freq) const |
Sets the constant sampling frequency of the indexed function. More... | |
void | setAxisTitle (int fileIndex, int axis, const char *axisText) const |
Sets the axis title of the indexed function. More... | |
void | setAxisUnit (int fileIndex, int axis, const char *unitText) const |
Sets the axis unit of the indexed function. More... | |
int | channelIndex (int fileIndex, const std::string &channel) const |
Returns the index of a named channel of the indexed function. More... | |
bool | getChannelList (int fileIndex, std::vector< std::string > &ch) const |
Returns the list of channel labels for the indexed function. More... | |
void | dump () const |
Prints a summary of the currently open files to std::cout. More... | |
bool | initExtFuncFromFile (const std::string &fileName, const std::string &labels="") |
Opens a file to read external function values from. More... | |
bool | updateExtFuncFromFile (int nstep=1) |
Updates the external function values from file. More... | |
double | getExtFunc (int idx, int stat=0) const |
Evaluates an indexed external function. More... | |
void | storeExtFuncValues (double *data, unsigned int ndat, int iop, int &offs) |
Stores/extracts external function values from in-core array. More... | |
Static Public Member Functions | |
static bool | getChannelList (const std::string &fileName, std::vector< std::string > &channels) |
Returns the list of channel labels for the named function file. More... | |
static FiDevFormat | identify (const std::string &fileName, const std::string &path="", FiStatus status=IO_READ) |
Returns the file format of a named function file. More... | |
Static Public Member Functions inherited from FFaSingelton< FiDeviceFunctionFactory > | |
static FiDeviceFunctionFactory * | instance () |
Returns the actual instance of this class. More... | |
static void | removeInstance () |
Deletes the dynamically allocated instance. More... | |
static bool | allocated () |
Returns true, if the instance has been allocated. More... | |
Static Public Attributes | |
static int | myNumExtFun = 0 |
Number of external functions in current model. More... | |
Protected Member Functions | |
FiDeviceFunctionFactory () | |
Default constructor. More... | |
virtual | ~FiDeviceFunctionFactory () |
The destructor closes all opened files. More... | |
int | create (const std::string &fileName, int inputChannel, FiDevFormat format, FiStatus status, bool useLittleEndian) |
Opens the named file, not already opened. More... | |
FiDeviceFunctionBase * | getDevice (size_t fileIndex) const |
Returns the device object for the indexed function. More... | |
Protected Member Functions inherited from FFaSingelton< FiDeviceFunctionFactory > | |
FFaSingelton () | |
The constructor is protected to allow objects of sub-classes only. More... | |
FFaSingelton (const FFaSingelton &)=delete | |
Disable default copy constructor. More... | |
FFaSingelton & | operator= (const FFaSingelton &)=delete |
Disable default assignment operator. More... | |
Private Types | |
typedef std::map< std::string, size_t > | FileMap |
File name to device index mapping. More... | |
typedef std::pair< std::string, int > | FileChannel |
File name and column index pair. More... | |
typedef std::map< FileChannel, size_t > | FileChnMap |
File name and column to device index mapping. More... | |
Private Attributes | |
std::vector< FiDeviceFunctionBase * > | myDevices |
Device function container. More... | |
FileMap | myFileToIndexMap |
File name to device index mapping. More... | |
FileChnMap | myFileChannelMap |
File name/channel to device index mapping. More... | |
std::vector< double > | myExtValues |
Function values for external functions. More... | |
std::vector< int > | myExtIndex |
Associated file column indices. More... | |
FT_FILE | myExtFnFile |
External function value file handle. More... | |
Friends | |
class | FFaSingelton< FiDeviceFunctionFactory > |
Singleton class for external device functions (functions from file).
|
private |
File name and column index pair.
|
private |
File name and column to device index mapping.
|
private |
File name to device index mapping.
|
inlineprotected |
Default constructor.
|
protectedvirtual |
The destructor closes all opened files.
int FiDeviceFunctionFactory::channelIndex | ( | int | fileIndex, |
const std::string & | channel | ||
) | const |
Returns the index of a named channel of the indexed function.
void FiDeviceFunctionFactory::close | ( | const std::string & | fileName | ) |
Closes the named file.
void FiDeviceFunctionFactory::close | ( | int | fileIndex | ) |
Closes the indexed file.
|
protected |
Opens the named file, not already opened.
[in] | fileName | Full path of the file to open |
[in] | inputChannel | Column index for multi-channel files |
[in] | format | Format of the file to open |
[in] | status | File opening mode |
[in] | useLittleEndian | If true, use little endian output formatting |
void FiDeviceFunctionFactory::dump | ( | ) | const |
Prints a summary of the currently open files to std::cout.
void FiDeviceFunctionFactory::getAxisTitle | ( | int | fileIndex, |
int | axis, | ||
char * | axisText, | ||
size_t | n | ||
) | const |
Returns the axis title of the indexed function.
void FiDeviceFunctionFactory::getAxisUnit | ( | int | fileIndex, |
int | axis, | ||
char * | unitText, | ||
size_t | n | ||
) | const |
Returns the axis unit of the indexed function.
|
static |
Returns the list of channel labels for the named function file.
bool FiDeviceFunctionFactory::getChannelList | ( | int | fileIndex, |
std::vector< std::string > & | ch | ||
) | const |
Returns the list of channel labels for the indexed function.
|
protected |
Returns the device object for the indexed function.
|
inline |
Evaluates an indexed external function.
[in] | idx | External function index |
[in] | stat | Integration flag |
double FiDeviceFunctionFactory::getFrequency | ( | int | fileIndex | ) | const |
Returns (constant) sampling frequency of the indexed function.
double FiDeviceFunctionFactory::getStep | ( | int | fileIndex | ) | const |
Returns (constant) argument increment of the indexed function.
double FiDeviceFunctionFactory::getValue | ( | int | fileIndex, |
double | arg, | ||
int & | stat, | ||
int | channel = 0 , |
||
int | zeroAd = 0 , |
||
double | shift = 0.0 , |
||
double | scale = 1.0 |
||
) | const |
Evaluates the indexed function for the specified argument value.
[in] | fileIndex | 1-based index to the function to evaluate |
[in] | arg | Argument value |
[out] | stat | Error flag (negative on error) |
[in] | channel | Column index for multi-channel files |
[in] | zeroAd | If > 0, shift function value to zero for arg=0 |
[in] | shift | Additional shift of function value |
[in] | scale | Function value scaling factor (before shifting) |
bool FiDeviceFunctionFactory::getValues | ( | int | fileIndex, |
double | x0, | ||
double | x1, | ||
std::vector< double > & | x, | ||
std::vector< double > & | y, | ||
int | channel = 0 , |
||
int | zeroAdjust = 0 , |
||
double | shift = 0.0 , |
||
double | scale = 1.0 |
||
) | const |
Evaluate the indexed function for the specified argument range.
[in] | fileIndex | 1-based index to the function to evaluate |
[in] | x0 | Start value of argument range |
[in] | x1 | End value of argument range |
[out] | x | Argument values of all points in range [x0,x1] |
[out] | y | Function values of all points in range [x0,x1] |
[in] | channel | Column index for multi-channel files |
[in] | zeroAdjust | If > 0, shift function values to zero for x=0 |
[in] | shift | Additional shift of function values |
[in] | scale | Function value scaling factor (before shifting) |
|
static |
Returns the file format of a named function file.
bool FiDeviceFunctionFactory::initExtFuncFromFile | ( | const std::string & | fileName, |
const std::string & | labels = "" |
||
) |
Opens a file to read external function values from.
[in] | fileName | Full path of the file to open |
[in] | labels | Labels "<lab1,lab2,...>" identifying the columns to use |
int FiDeviceFunctionFactory::open | ( | const std::string & | fileName, |
FiDevFormat | format = UNKNOWN_FILE , |
||
FiStatus | status = IO_READ , |
||
int | inputChannel = 0 , |
||
bool | littleEndian = false |
||
) |
Opens the named file.
[in] | fileName | Full path of the file to open |
[in] | format | Format of the file to open |
[in] | status | File opening mode |
[in] | inputChannel | Column index for multi-channel files |
[in] | littleEndian | If true, use little endian output formatting |
void FiDeviceFunctionFactory::setAxisTitle | ( | int | fileIndex, |
int | axis, | ||
const char * | axisText | ||
) | const |
Sets the axis title of the indexed function.
void FiDeviceFunctionFactory::setAxisUnit | ( | int | fileIndex, |
int | axis, | ||
const char * | unitText | ||
) | const |
Sets the axis unit of the indexed function.
void FiDeviceFunctionFactory::setFrequency | ( | int | fileIndex, |
double | freq | ||
) | const |
Sets the constant sampling frequency of the indexed function.
void FiDeviceFunctionFactory::setStep | ( | int | fileIndex, |
double | step | ||
) | const |
Sets the constant argument increment of the indexed function.
bool FiDeviceFunctionFactory::setValue | ( | int | fileIndex, |
double | xVal, | ||
double | yVal | ||
) |
Sets an argument/value pair for an indexed function.
void FiDeviceFunctionFactory::storeExtFuncValues | ( | double * | data, |
unsigned int | ndat, | ||
int | iop, | ||
int & | offs | ||
) |
Stores/extracts external function values from in-core array.
data | Solution state array | |
[in] | ndat | Length of the solution state array |
[in] | iop | Option telling what to do: (0: return size, 1: store in data, 2: restore from data) |
offs | Running array offset, negative value indicates an error |
bool FiDeviceFunctionFactory::updateExtFuncFromFile | ( | int | nstep = 1 | ) |
Updates the external function values from file.
[in] | nstep | Number of steps to read |
|
friend |
|
private |
Device function container.
|
private |
External function value file handle.
|
private |
Associated file column indices.
|
private |
Function values for external functions.
|
private |
File name/channel to device index mapping.
|
private |
File name to device index mapping.
|
static |
Number of external functions in current model.