FEDEM Solver
R8.0
Source code of the dynamics solver
|
Class representing external device functions based on ASCII files. More...
#include <FiASCFile.H>
Public Member Functions | |
FiASCFile (const char *fname=NULL, int nchan=1) | |
Default constructor. More... | |
virtual | ~FiASCFile () |
Empty destructor. More... | |
virtual size_t | getValueCount () const |
Returns the number of (x,y) pairs of the function. More... | |
virtual double | getValue (double x, int channel, bool zeroAdjust, double vertShift, double scaleFac) |
Evaluates the function for a given x value. More... | |
virtual bool | getValues (double x0, double x1, Doubles &x, Doubles &y, int channel, bool zeroAdj, double shift, double scale) |
Evaluates the function at all points within specified interval. More... | |
virtual void | getRawData (Doubles &x, Doubles &y, double minX, double maxX, int channel) |
Extracts all function data point values within specified interval. More... | |
virtual void | getData (Doubles &x, Doubles &y, const std::string &channel, double minX, double maxX) |
Extracts all function data point values within specified interval. More... | |
virtual void | setValue (double x, double y) |
Assigns a function value for a single-channel function. More... | |
virtual bool | setData (const Doubles &x, const Doubles &y) |
Adds a channel to current file by interpolation. More... | |
virtual void | setDescription (const std::string &desc) |
Assigns a name to the (last) channel in file. More... | |
virtual void | setEmptyChannel (const std::string &desc) |
Adds an empty channel to the file. More... | |
virtual void | setPrecision (int type) |
Defines the output precision. More... | |
virtual bool | getChannelList (Strings &list) |
Extracts the list of channel names (file column labels). More... | |
virtual int | isChannelPresentInFile (const std::string &channel) |
Returns the column index of the named channel. More... | |
virtual bool | isChannelPresentInFile (int channel) |
Returns true if channel is a valid column index. More... | |
Public Member Functions inherited from FiDeviceFunctionBase | |
virtual | ~FiDeviceFunctionBase () |
bool | open (const char *devicename, FileStatus status=Read_Only) |
bool | open (FileStatus status=Read_Only) |
bool | close (bool noHeader=false) |
const std::string & | getDevicename () const |
void | setExtrapolationPolicy (InterpolationPolicy policy=Constant) |
void | setInterpolationPolicy (InterpolationPolicy policy=Linear) |
virtual void | getValueRange (double &mn, double &mx) const |
virtual double | getXAxisOrigin () const |
virtual bool | getChannelList (std::vector< std::string > &) |
virtual void | setTimeSpan (double) |
double | integrate (double x, int order=1, int channel=0, double vertShift=0.0, double scaleFac=1.0) |
int | getRefCount () const |
int | ref () |
int | unref () |
double | getStep () const |
double | getFrequency () const |
void | setStep (double aStep) |
void | setFrequency (double aFreqency) |
void | setParent (const std::string &modelfile) |
bool | isReadOnly () const |
FileStatus | getFileStatus () const |
void | getAxisUnit (int axis, char *unitText, size_t n) const |
void | getAxisTitle (int axis, char *titleText, size_t n) const |
void | setAxisUnit (int axis, const char *unitText) |
void | setAxisTitle (int axis, const char *titleText) |
Static Public Member Functions | |
static int | getNoChannels (const char *fname) |
Counts the number of channels (number of columns minus one). More... | |
static bool | isMultiChannel (FT_FILE fd, const char *fname=NULL, bool rewind=false) |
Checks if the specified file consists of two or more columns. More... | |
static int | readHeader (FT_FILE fd, Strings &header) |
Reads the header section of a specified file. More... | |
static bool | readNext (FT_FILE fd, const std::vector< int > &columns, Doubles &values) |
Reads the next line of data from specified file. More... | |
Static Public Attributes | |
static size_t | bufferSize = 0 |
Buffer size for ASCII output in KBytes. More... | |
Protected Member Functions | |
virtual bool | concludingDeviceWrite (bool noHeader) |
Writes all function data to file. More... | |
virtual bool | initialDeviceRead () |
Reads the file and loads the first channel into core. More... | |
virtual bool | preliminaryDeviceWrite () |
Dummy method doing nothing. More... | |
Protected Member Functions inherited from FiDeviceFunctionBase | |
FiDeviceFunctionBase (const char *devicename=NULL) | |
FiDeviceFunctionBase (const FiDeviceFunctionBase &)=delete | |
FiDeviceFunctionBase & | operator= (const FiDeviceFunctionBase &)=delete |
double | interpolate (double x, double x0, double f0, double x1, double f1) const |
double | extrapolate (double x, double x0, double f0, double x1, double f1) const |
bool | writeString (const char *str) |
bool | writeString (const char *lab, const std::string &val) |
Private Types | |
typedef std::vector< double > | Doubles |
Convenience type definition. More... | |
typedef std::vector< std::string > | Strings |
Convenience type definition. More... | |
typedef std::map< double, Doubles > | ValuesMap |
Mapping from x-value (time) to channel values. More... | |
typedef ValuesMap::iterator | ValuesIter |
Convenience type definition. More... | |
Private Member Functions | |
int | readChannel (int channel) |
Reads the specified channel into core. More... | |
Static Private Member Functions | |
static char * | readLine (FT_FILE fd, bool commentsOnly=false) |
Reads one line of data from specified file. More... | |
static int | countColumns (FT_FILE fd) |
Returns the number of columns in the file fd. More... | |
Private Attributes | |
Strings | chn |
Channel names (columns labels) More... | |
ValuesMap | myValues |
Curve data, either for all or one channel. More... | |
ValuesIter | vit0 |
Start iterator of last evaluation interval. More... | |
ValuesIter | vit1 |
End iterator of last evaluation interval. More... | |
int | myChannel |
Channel (column index) that currently resides in core. More... | |
int | myNumChannels |
Number of columns minus 1 (column 1 is the X-values) More... | |
int | outputFormat |
0: 4-digits, 1: 8 digits, 2: 16-digits More... | |
bool | isCSVt |
If true, this file has microsec as first column. More... | |
Additional Inherited Members | |
Public Types inherited from FiDeviceFunctionBase | |
enum | Axis { X =0 , Y =1 } |
enum | Endianness { LittleEndian , BigEndian } |
enum | FileFormat { ascii , binary } |
enum | FileStatus { Not_Loaded =-1 , Not_Open =0 , Read_Only =1 , Write_Only =2 } |
enum | InterpolationPolicy { Constant , Linear , Previous_Value , Next_Value } |
Protected Attributes inherited from FiDeviceFunctionBase | |
FT_FILE | myFile |
std::string | myParent |
std::string | myDatasetDevice |
Endianness | myOutputEndian |
Endianness | myInputEndian |
double | myStep |
std::map< int, axisInfo > | myAxisInfo |
Static Protected Attributes inherited from FiDeviceFunctionBase | |
static Endianness | myMachineEndian |
Class representing external device functions based on ASCII files.
This class is used to represent a polyline (or piece-wise linear) function defined through a sequence of (x,y) points, where the x- and y-values are stored as two columns of a multi-column ASCII file (the file itself may contain two or more columns of data). The first column of the file is always the x-values, which need to be monotonically increasing, i.e., xi-1 ≤ xi ≤ xi+1 for all i.
|
private |
Convenience type definition.
|
private |
Convenience type definition.
|
private |
Convenience type definition.
|
private |
Mapping from x-value (time) to channel values.
FiASCFile::FiASCFile | ( | const char * | fname = NULL , |
int | nchan = 1 |
||
) |
Default constructor.
[in] | fname | Name of file containing the function data. |
[in] | nchan | Number of channels in file (used when writing the file) |
|
inlinevirtual |
Empty destructor.
|
protectedvirtual |
Writes all function data to file.
Implements FiDeviceFunctionBase.
|
staticprivate |
Returns the number of columns in the file fd.
|
virtual |
Extracts the list of channel names (file column labels).
|
virtual |
Extracts all function data point values within specified interval.
[out] | x | X-values (argument values) of all points within the interval |
[out] | y | Y-values (function values) of all points within the interval |
[in] | channel | Channel name identifying the function values to use |
[in] | minX | Lower bound of function argument interval |
[in] | maxX | Upper bound of function argument interval |
Reimplemented from FiDeviceFunctionBase.
|
static |
Counts the number of channels (number of columns minus one).
|
virtual |
Extracts all function data point values within specified interval.
[out] | x | X-values (argument values) of all points within the interval |
[out] | y | Y-values (function values) of all points within the interval |
[in] | minX | Lower bound of function argument interval |
[in] | maxX | Upper bound of function argument interval |
[in] | channel | Column index identifying the function values to use |
Implements FiDeviceFunctionBase.
|
virtual |
Evaluates the function for a given x value.
[in] | x | The function argument to evaluate for |
[in] | channel | Column index identifying the function values to use |
[in] | zeroAdjust | If true, the function values are shifted such that it evaluates to zero (or vertShift) at its first point value |
[in] | vertShift | Additional function-value shift |
[in] | scaleFac | Function-value scaling factor |
Implements FiDeviceFunctionBase.
|
inlinevirtual |
Returns the number of (x,y) pairs of the function.
Implements FiDeviceFunctionBase.
|
virtual |
Evaluates the function at all points within specified interval.
[in] | x0 | Lower bound of function argument interval |
[in] | x1 | Upper bound of function argument interval |
[out] | x | X-values (argument values) of all points within the interval |
[out] | y | Y-values (function values) of all points within the interval |
[in] | channel | Column index identifying the function values to use |
[in] | zeroAdj | If true, the function values are shifted such that it evaluates to zero (or shift) at its first point value |
[in] | shift | Additional function-value shift |
[in] | scale | Function-value scaling factor |
This method is equivalent to the getRawData() method if invoked with zeroAdj = false, shift = 0.0 and scale = 1.0, however, the former method will be more efficient in that case.
Implements FiDeviceFunctionBase.
|
protectedvirtual |
Reads the file and loads the first channel into core.
Implements FiDeviceFunctionBase.
|
virtual |
Returns the column index of the named channel.
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Returns true if channel is a valid column index.
Reimplemented from FiDeviceFunctionBase.
|
static |
Checks if the specified file consists of two or more columns.
|
inlineprotectedvirtual |
Dummy method doing nothing.
Implements FiDeviceFunctionBase.
|
private |
Reads the specified channel into core.
Reads the header section of a specified file.
[in] | fd | File descriptor to read from |
[out] | header | Array of channel names (column labels) of the file |
|
staticprivate |
Reads one line of data from specified file.
[in] | fd | File descriptor to read from |
[in] | commentsOnly | If true, only read comment lines |
|
static |
Reads the next line of data from specified file.
[in] | fd | File descriptor to read from |
[in] | columns | Column indices of the channels to read |
[out] | values | Array of channel values |
Adds a channel to current file by interpolation.
Implements FiDeviceFunctionBase.
|
virtual |
Assigns a name to the (last) channel in file.
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Adds an empty channel to the file.
Reimplemented from FiDeviceFunctionBase.
|
inlinevirtual |
Defines the output precision.
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Assigns a function value for a single-channel function.
Implements FiDeviceFunctionBase.
|
static |
Buffer size for ASCII output in KBytes.
|
private |
Channel names (columns labels)
|
private |
If true, this file has microsec as first column.
|
private |
Channel (column index) that currently resides in core.
|
private |
Number of columns minus 1 (column 1 is the X-values)
|
private |
Curve data, either for all or one channel.
|
private |
0: 4-digits, 1: 8 digits, 2: 16-digits
|
private |
Start iterator of last evaluation interval.
|
private |
End iterator of last evaluation interval.