FEDEM Solver  R8.0
Source code of the dynamics solver
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Attributes | Friends | List of all members
FiDeviceFunctionFactory Class Reference

Singleton class for external device functions (functions from file). More...

#include <FiDeviceFunctionFactory.H>

Inheritance diagram for FiDeviceFunctionFactory:
Inheritance graph
[legend]
Collaboration diagram for FiDeviceFunctionFactory:
Collaboration graph
[legend]

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 FiDeviceFunctionFactoryinstance ()
 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...
 
FiDeviceFunctionBasegetDevice (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...
 
FFaSingeltonoperator= (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 >
 

Detailed Description

Singleton class for external device functions (functions from file).

Member Typedef Documentation

◆ FileChannel

typedef std::pair<std::string,int> FiDeviceFunctionFactory::FileChannel
private

File name and column index pair.

◆ FileChnMap

typedef std::map<FileChannel,size_t> FiDeviceFunctionFactory::FileChnMap
private

File name and column to device index mapping.

◆ FileMap

typedef std::map<std::string,size_t> FiDeviceFunctionFactory::FileMap
private

File name to device index mapping.

Constructor & Destructor Documentation

◆ FiDeviceFunctionFactory()

FiDeviceFunctionFactory::FiDeviceFunctionFactory ( )
inlineprotected

Default constructor.

◆ ~FiDeviceFunctionFactory()

FiDeviceFunctionFactory::~FiDeviceFunctionFactory ( )
protectedvirtual

The destructor closes all opened files.

Member Function Documentation

◆ channelIndex()

int FiDeviceFunctionFactory::channelIndex ( int  fileIndex,
const std::string &  channel 
) const

Returns the index of a named channel of the indexed function.

◆ close() [1/2]

void FiDeviceFunctionFactory::close ( const std::string &  fileName)

Closes the named file.

◆ close() [2/2]

void FiDeviceFunctionFactory::close ( int  fileIndex)

Closes the indexed file.

◆ create()

int FiDeviceFunctionFactory::create ( const std::string &  fileName,
int  inputChannel,
FiDevFormat  format,
FiStatus  status,
bool  useLittleEndian 
)
protected

Opens the named file, not already opened.

Parameters
[in]fileNameFull path of the file to open
[in]inputChannelColumn index for multi-channel files
[in]formatFormat of the file to open
[in]statusFile opening mode
[in]useLittleEndianIf true, use little endian output formatting
Returns
1-based index to the opened file

◆ dump()

void FiDeviceFunctionFactory::dump ( ) const

Prints a summary of the currently open files to std::cout.

◆ getAxisTitle()

void FiDeviceFunctionFactory::getAxisTitle ( int  fileIndex,
int  axis,
char *  axisText,
size_t  n 
) const

Returns the axis title of the indexed function.

◆ getAxisUnit()

void FiDeviceFunctionFactory::getAxisUnit ( int  fileIndex,
int  axis,
char *  unitText,
size_t  n 
) const

Returns the axis unit of the indexed function.

◆ getChannelList() [1/2]

bool FiDeviceFunctionFactory::getChannelList ( const std::string &  fileName,
std::vector< std::string > &  channels 
)
static

Returns the list of channel labels for the named function file.

◆ getChannelList() [2/2]

bool FiDeviceFunctionFactory::getChannelList ( int  fileIndex,
std::vector< std::string > &  ch 
) const

Returns the list of channel labels for the indexed function.

◆ getDevice()

FiDeviceFunctionBase * FiDeviceFunctionFactory::getDevice ( size_t  fileIndex) const
protected

Returns the device object for the indexed function.

◆ getExtFunc()

double FiDeviceFunctionFactory::getExtFunc ( int  idx,
int  stat = 0 
) const
inline

Evaluates an indexed external function.

Parameters
[in]idxExternal function index
[in]statIntegration flag
Returns
The function value

◆ getFrequency()

double FiDeviceFunctionFactory::getFrequency ( int  fileIndex) const

Returns (constant) sampling frequency of the indexed function.

◆ getStep()

double FiDeviceFunctionFactory::getStep ( int  fileIndex) const

Returns (constant) argument increment of the indexed function.

◆ getValue()

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.

Parameters
[in]fileIndex1-based index to the function to evaluate
[in]argArgument value
[out]statError flag (negative on error)
[in]channelColumn index for multi-channel files
[in]zeroAdIf > 0, shift function value to zero for arg=0
[in]shiftAdditional shift of function value
[in]scaleFunction value scaling factor (before shifting)
Returns
The function value

◆ getValues()

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.

Parameters
[in]fileIndex1-based index to the function to evaluate
[in]x0Start value of argument range
[in]x1End value of argument range
[out]xArgument values of all points in range [x0,x1]
[out]yFunction values of all points in range [x0,x1]
[in]channelColumn index for multi-channel files
[in]zeroAdjustIf > 0, shift function values to zero for x=0
[in]shiftAdditional shift of function values
[in]scaleFunction value scaling factor (before shifting)

◆ identify()

FiDevFormat FiDeviceFunctionFactory::identify ( const std::string &  fileName,
const std::string &  path = "",
FiStatus  status = IO_READ 
)
static

Returns the file format of a named function file.

◆ initExtFuncFromFile()

bool FiDeviceFunctionFactory::initExtFuncFromFile ( const std::string &  fileName,
const std::string &  labels = "" 
)

Opens a file to read external function values from.

Parameters
[in]fileNameFull path of the file to open
[in]labelsLabels "<lab1,lab2,...>" identifying the columns to use

◆ open()

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.

Parameters
[in]fileNameFull path of the file to open
[in]formatFormat of the file to open
[in]statusFile opening mode
[in]inputChannelColumn index for multi-channel files
[in]littleEndianIf true, use little endian output formatting
Returns
1-based index to the opened file

◆ setAxisTitle()

void FiDeviceFunctionFactory::setAxisTitle ( int  fileIndex,
int  axis,
const char *  axisText 
) const

Sets the axis title of the indexed function.

◆ setAxisUnit()

void FiDeviceFunctionFactory::setAxisUnit ( int  fileIndex,
int  axis,
const char *  unitText 
) const

Sets the axis unit of the indexed function.

◆ setFrequency()

void FiDeviceFunctionFactory::setFrequency ( int  fileIndex,
double  freq 
) const

Sets the constant sampling frequency of the indexed function.

◆ setStep()

void FiDeviceFunctionFactory::setStep ( int  fileIndex,
double  step 
) const

Sets the constant argument increment of the indexed function.

◆ setValue()

bool FiDeviceFunctionFactory::setValue ( int  fileIndex,
double  xVal,
double  yVal 
)

Sets an argument/value pair for an indexed function.

◆ storeExtFuncValues()

void FiDeviceFunctionFactory::storeExtFuncValues ( double *  data,
unsigned int  ndat,
int  iop,
int &  offs 
)

Stores/extracts external function values from in-core array.

Parameters
dataSolution state array
[in]ndatLength of the solution state array
[in]iopOption telling what to do: (0: return size, 1: store in data, 2: restore from data)
offsRunning array offset, negative value indicates an error

◆ updateExtFuncFromFile()

bool FiDeviceFunctionFactory::updateExtFuncFromFile ( int  nstep = 1)

Updates the external function values from file.

Parameters
[in]nstepNumber of steps to read

Friends And Related Function Documentation

◆ FFaSingelton< FiDeviceFunctionFactory >

friend class FFaSingelton< FiDeviceFunctionFactory >
friend

Member Data Documentation

◆ myDevices

std::vector<FiDeviceFunctionBase*> FiDeviceFunctionFactory::myDevices
private

Device function container.

◆ myExtFnFile

FT_FILE FiDeviceFunctionFactory::myExtFnFile
private

External function value file handle.

◆ myExtIndex

std::vector<int> FiDeviceFunctionFactory::myExtIndex
private

Associated file column indices.

◆ myExtValues

std::vector<double> FiDeviceFunctionFactory::myExtValues
private

Function values for external functions.

◆ myFileChannelMap

FileChnMap FiDeviceFunctionFactory::myFileChannelMap
private

File name/channel to device index mapping.

◆ myFileToIndexMap

FileMap FiDeviceFunctionFactory::myFileToIndexMap
private

File name to device index mapping.

◆ myNumExtFun

int FiDeviceFunctionFactory::myNumExtFun = 0
static

Number of external functions in current model.


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