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

Base class for external device functions. More...

#include <FiDeviceFunctionBase.H>

Inheritance diagram for FiDeviceFunctionBase:
Inheritance graph
[legend]

Classes

struct  AxisInfo
 Convenience struct holding curve axis information. More...
 

Public Types

enum  Endianness { LittleEndian , BigEndian }
 Enumerator for endianness values. More...
 
enum  FileFormat { ascii , binary }
 Enumerator for the file formats. More...
 
enum  FileStatus { Not_Loaded =-1 , Not_Open =0 , Read_Only =1 , Write_Only =2 }
 Enumerator for file opening statuses. More...
 
enum  InterpolationPolicy { Constant , Linear , Previous_Value , Next_Value }
 Enumerator for interpolation and extrapolation policies. More...
 

Public Member Functions

virtual ~FiDeviceFunctionBase ()
 The destructor closes the device function file. More...
 
bool open (const char *devicename, FileStatus status=Read_Only)
 Opens the specified device function file for reading or writing. More...
 
bool open (FileStatus status=Read_Only)
 Opens the file myDatasetDevice for reading or writing. More...
 
bool close (bool noHeader=false)
 Closes the device function file. More...
 
const std::string & getDevicename () const
 Returns the myDatasetDevice of this device function. More...
 
void setExtrapolationPolicy (InterpolationPolicy policy=Constant)
 Defines the extrapolation policy to be used. More...
 
void setInterpolationPolicy (InterpolationPolicy policy=Linear)
 Defines the interpolation policy to be used. More...
 
virtual size_t getValueCount () const =0
 Returns the number of (x,y) pairs for this device. More...
 
virtual void getValueRange (double &mn, double &mx) const
 Calculates the function value range for this device. More...
 
virtual double getXAxisOrigin () const
 Returns the function argument origin for this device. More...
 
virtual bool getChannelList (Strings &)
 Gets the list channel names for a multi-channel device. More...
 
virtual bool isChannelPresentInFile (int)
 Checks if an indexed channel is present in the device. More...
 
virtual int isChannelPresentInFile (const std::string &)
 Checks if a nameed channel is present in the device. More...
 
virtual void setTimeSpan (double)
 Sets the maximum time span for the device function. More...
 
virtual void setPrecision (int)
 Sets the precision to be used when writing the device to file. More...
 
virtual double getValue (double x, int channel=0, bool zeroAdjust=false, double vertShift=0.0, double scaleFac=1.0)=0
 Evaluates the function for a given x value. More...
 
virtual bool getValues (double x0, double x1, Doubles &x, Doubles &y, int channel, bool zeroAdjust=false, double shift=0.0, double scale=1.0)=0
 Evaluates the function at all points within specified interval. More...
 
virtual void getRawData (Doubles &x, Doubles &y, double minX, double maxX, int channel=0)=0
 Extracts all function data point values within specified interval. More...
 
virtual void getData (Doubles &x, Doubles &y, const std::string &, double minX=0.0, double maxX=-1.0)
 Extracts all function data point values within specified interval. More...
 
virtual void setValue (double x, double y)=0
 Assigns a function value for a single-channel function. More...
 
virtual bool setData (const Doubles &x, const Doubles &y)=0
 Adds a complete set of x,y-pair values for a new channel. More...
 
double integrate (double x, int order=1, int channel=0, double vertShift=0.0, double scaleFac=1.0)
 Computes the integral of this device over the interval [0,x]. More...
 
int getRefCount () const
 Returns the current reference count for this device. More...
 
int ref ()
 Increments the reference count fir this device. More...
 
int unref ()
 Decrements the reference count for this device. More...
 
double getStep () const
 returns the constant sampling time increment. More...
 
double getFrequency () const
 returns the constant sampling frequency. More...
 
void setStep (double aStep)
 Sets the sampling increment for devices with constant sampling. More...
 
void setFrequency (double aFreqency)
 Sets the sampling frequency for devices with constant sampling. More...
 
virtual void setDescription (const std::string &)
 Assigns a name to the (last) channel in the device. More...
 
virtual void setEmptyChannel (const std::string &)
 Flags an empty channel for multi-channel devices. More...
 
void setParent (const std::string &modelfile)
 Sets the model file name associated with this device. More...
 
bool isReadOnly () const
 Returns whether this is a read-only device or not. More...
 
FileStatus getFileStatus () const
 Returns the myFileStatus of this device function. More...
 
void getAxisUnit (int axis, char *unitText, size_t n) const
 Gets the axis unit. More...
 
void getAxisTitle (int axis, char *titleText, size_t n) const
 Gets the axis title. More...
 
void setAxisUnit (int axis, const char *unitText)
 Sets the axis unit. More...
 
void setAxisTitle (int axis, const char *titleText)
 Sets the axis title. More...
 

Protected Types

using Doubles = std::vector< double >
 Convenience type alias. More...
 
using Strings = std::vector< std::string >
 Convenience type alias. More...
 

Protected Member Functions

 FiDeviceFunctionBase (const char *devicename=NULL)
 The default constructor initialize the data members. More...
 
 FiDeviceFunctionBase (const FiDeviceFunctionBase &)=delete
 Deleted copy constructor. More...
 
FiDeviceFunctionBase & operator= (const FiDeviceFunctionBase &)=delete
 Deleted assignment operator. More...
 
double interpolate (double x, double x0, double f0, double x1, double f1) const
 Calculates the function value at x by interpolation. More...
 
double extrapolate (double x, double x0, double f0, double x1, double f1) const
 Calculates the function value at x by extrapolation. More...
 
bool writeString (const char *str)
 Convenience method for a writing text header. More...
 
bool writeString (const char *lab, const std::string &val)
 Convenience method for writing text headers. More...
 
virtual bool initialDeviceRead ()=0
 Reads the file content, or at least its meta data. More...
 
virtual bool preliminaryDeviceWrite ()=0
 Writes the meta data for this device function to file. More...
 
virtual bool concludingDeviceWrite (bool noHeader=false)=0
 Writes the content of this device function to file. More...
 

Protected Attributes

FT_FILE myFile
 File handle of this device function. More...
 
std::string myParent
 Name of FEDEM model that owns this function. More...
 
std::string myDatasetDevice
 Name of file associated with myFile. More...
 
Endianness myOutputEndian
 Endianness assumed for binary output. More...
 
Endianness myInputEndian
 Endianness assumed for binary input. More...
 
double myStep
 Time series information. More...
 
std::array< AxisInfo, 2 > myAxisInfo
 

Static Protected Attributes

static Endianness myMachineEndian
 Endianness for the running computer. More...
 

Private Attributes

FileStatus myFileStatus
 Current file status after opening, etc. More...
 
std::array< InterpolationPolicy, 2 > myInterpolationPolicy
 Options for interpolation and extrapolation of curve data. More...
 
Doubles Xval
 Function argument values, used for integration. More...
 
Doubles Yval
 The function values associated with Xval. More...
 
int myRefCount
 Used for reference counting. More...
 

Detailed Description

Base class for external device functions.

Member Typedef Documentation

◆ Doubles

using FiDeviceFunctionBase::Doubles = std::vector<double>
protected

Convenience type alias.

◆ Strings

using FiDeviceFunctionBase::Strings = std::vector<std::string>
protected

Convenience type alias.

Member Enumeration Documentation

◆ Endianness

Enumerator for endianness values.

Enumerator
LittleEndian 
BigEndian 

◆ FileFormat

Enumerator for the file formats.

Enumerator
ascii 
binary 

◆ FileStatus

Enumerator for file opening statuses.

Enumerator
Not_Loaded 
Not_Open 
Read_Only 
Write_Only 

◆ InterpolationPolicy

Enumerator for interpolation and extrapolation policies.

Enumerator
Constant 
Linear 
Previous_Value 
Next_Value 

Constructor & Destructor Documentation

◆ FiDeviceFunctionBase() [1/2]

FiDeviceFunctionBase::FiDeviceFunctionBase ( const char *  devicename = NULL)
explicitprotected

The default constructor initialize the data members.

◆ FiDeviceFunctionBase() [2/2]

FiDeviceFunctionBase::FiDeviceFunctionBase ( const FiDeviceFunctionBase &  )
protecteddelete

Deleted copy constructor.

◆ ~FiDeviceFunctionBase()

virtual FiDeviceFunctionBase::~FiDeviceFunctionBase ( )
inlinevirtual

The destructor closes the device function file.

Member Function Documentation

◆ close()

bool FiDeviceFunctionBase::close ( bool  noHeader = false)

Closes the device function file.

If the file is Write_Only, the content is flushed to disk first.

◆ concludingDeviceWrite()

virtual bool FiDeviceFunctionBase::concludingDeviceWrite ( bool  noHeader = false)
protectedpure virtual

Writes the content of this device function to file.

Implemented in FiRPC3File, FiDACFile, FiCurveASCFile, and FiASCFile.

◆ extrapolate()

double FiDeviceFunctionBase::extrapolate ( double  x,
double  x0,
double  f0,
double  x1,
double  f1 
) const
protected

Calculates the function value at x by extrapolation.

◆ getAxisTitle()

void FiDeviceFunctionBase::getAxisTitle ( int  axis,
char *  titleText,
size_t  n 
) const

Gets the axis title.

◆ getAxisUnit()

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

Gets the axis unit.

◆ getChannelList()

virtual bool FiDeviceFunctionBase::getChannelList ( Strings &  )
inlinevirtual

Gets the list channel names for a multi-channel device.

Reimplemented in FiRPC3File, and FiASCFile.

◆ getData()

virtual void FiDeviceFunctionBase::getData ( Doubles &  x,
Doubles &  y,
const std::string &  ,
double  minX = 0.0,
double  maxX = -1.0 
)
inlinevirtual

Extracts all function data point values within specified interval.

Reimplemented in FiRPC3File, and FiASCFile.

◆ getDevicename()

const std::string& FiDeviceFunctionBase::getDevicename ( ) const
inline

Returns the myDatasetDevice of this device function.

◆ getFileStatus()

FileStatus FiDeviceFunctionBase::getFileStatus ( ) const
inline

Returns the myFileStatus of this device function.

◆ getFrequency()

double FiDeviceFunctionBase::getFrequency ( ) const
inline

returns the constant sampling frequency.

◆ getRawData()

virtual void FiDeviceFunctionBase::getRawData ( Doubles &  x,
Doubles &  y,
double  minX,
double  maxX,
int  channel = 0 
)
pure virtual

Extracts all function data point values within specified interval.

Implemented in FiCurveASCFile, FiDACFile, FiRPC3File, and FiASCFile.

◆ getRefCount()

int FiDeviceFunctionBase::getRefCount ( ) const
inline

Returns the current reference count for this device.

◆ getStep()

double FiDeviceFunctionBase::getStep ( ) const
inline

returns the constant sampling time increment.

◆ getValue()

virtual double FiDeviceFunctionBase::getValue ( double  x,
int  channel = 0,
bool  zeroAdjust = false,
double  vertShift = 0.0,
double  scaleFac = 1.0 
)
pure virtual

Evaluates the function for a given x value.

Implemented in FiCurveASCFile, FiDACFile, FiRPC3File, and FiASCFile.

◆ getValueCount()

virtual size_t FiDeviceFunctionBase::getValueCount ( ) const
pure virtual

Returns the number of (x,y) pairs for this device.

Implemented in FiRPC3File, FiDACFile, FiCurveASCFile, and FiASCFile.

◆ getValueRange()

virtual void FiDeviceFunctionBase::getValueRange ( double &  mn,
double &  mx 
) const
inlinevirtual

Calculates the function value range for this device.

Reimplemented in FiRPC3File, and FiDACFile.

◆ getValues()

virtual bool FiDeviceFunctionBase::getValues ( double  x0,
double  x1,
Doubles &  x,
Doubles &  y,
int  channel,
bool  zeroAdjust = false,
double  shift = 0.0,
double  scale = 1.0 
)
pure virtual

Evaluates the function at all points within specified interval.

Implemented in FiCurveASCFile, FiRPC3File, FiDACFile, and FiASCFile.

◆ getXAxisOrigin()

virtual double FiDeviceFunctionBase::getXAxisOrigin ( ) const
inlinevirtual

Returns the function argument origin for this device.

Reimplemented in FiDACFile.

◆ initialDeviceRead()

virtual bool FiDeviceFunctionBase::initialDeviceRead ( )
protectedpure virtual

Reads the file content, or at least its meta data.

Implemented in FiRPC3File, FiDACFile, FiCurveASCFile, and FiASCFile.

◆ integrate()

double FiDeviceFunctionBase::integrate ( double  x,
int  order = 1,
int  channel = 0,
double  vertShift = 0.0,
double  scaleFac = 1.0 
)

Computes the integral of this device over the interval [0,x].

◆ interpolate()

double FiDeviceFunctionBase::interpolate ( double  x,
double  x0,
double  f0,
double  x1,
double  f1 
) const
protected

Calculates the function value at x by interpolation.

◆ isChannelPresentInFile() [1/2]

virtual int FiDeviceFunctionBase::isChannelPresentInFile ( const std::string &  )
inlinevirtual

Checks if a nameed channel is present in the device.

Reimplemented in FiRPC3File, and FiASCFile.

◆ isChannelPresentInFile() [2/2]

virtual bool FiDeviceFunctionBase::isChannelPresentInFile ( int  )
inlinevirtual

Checks if an indexed channel is present in the device.

Reimplemented in FiRPC3File, and FiASCFile.

◆ isReadOnly()

bool FiDeviceFunctionBase::isReadOnly ( ) const
inline

Returns whether this is a read-only device or not.

◆ open() [1/2]

bool FiDeviceFunctionBase::open ( const char *  devicename,
FileStatus  status = Read_Only 
)

Opens the specified device function file for reading or writing.

◆ open() [2/2]

bool FiDeviceFunctionBase::open ( FileStatus  status = Read_Only)
inline

Opens the file myDatasetDevice for reading or writing.

◆ operator=()

FiDeviceFunctionBase& FiDeviceFunctionBase::operator= ( const FiDeviceFunctionBase &  )
protecteddelete

Deleted assignment operator.

◆ preliminaryDeviceWrite()

virtual bool FiDeviceFunctionBase::preliminaryDeviceWrite ( )
protectedpure virtual

Writes the meta data for this device function to file.

Implemented in FiRPC3File, FiDACFile, FiCurveASCFile, and FiASCFile.

◆ ref()

int FiDeviceFunctionBase::ref ( )
inline

Increments the reference count fir this device.

◆ setAxisTitle()

void FiDeviceFunctionBase::setAxisTitle ( int  axis,
const char *  titleText 
)

Sets the axis title.

◆ setAxisUnit()

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

Sets the axis unit.

◆ setData()

virtual bool FiDeviceFunctionBase::setData ( const Doubles &  x,
const Doubles &  y 
)
pure virtual

Adds a complete set of x,y-pair values for a new channel.

Implemented in FiRPC3File, FiDACFile, FiCurveASCFile, and FiASCFile.

◆ setDescription()

virtual void FiDeviceFunctionBase::setDescription ( const std::string &  )
inlinevirtual

Assigns a name to the (last) channel in the device.

Reimplemented in FiRPC3File, and FiASCFile.

◆ setEmptyChannel()

virtual void FiDeviceFunctionBase::setEmptyChannel ( const std::string &  )
inlinevirtual

Flags an empty channel for multi-channel devices.

Reimplemented in FiASCFile.

◆ setExtrapolationPolicy()

void FiDeviceFunctionBase::setExtrapolationPolicy ( InterpolationPolicy  policy = Constant)
inline

Defines the extrapolation policy to be used.

◆ setFrequency()

void FiDeviceFunctionBase::setFrequency ( double  aFreqency)
inline

Sets the sampling frequency for devices with constant sampling.

◆ setInterpolationPolicy()

void FiDeviceFunctionBase::setInterpolationPolicy ( InterpolationPolicy  policy = Linear)
inline

Defines the interpolation policy to be used.

◆ setParent()

void FiDeviceFunctionBase::setParent ( const std::string &  modelfile)
inline

Sets the model file name associated with this device.

◆ setPrecision()

virtual void FiDeviceFunctionBase::setPrecision ( int  )
inlinevirtual

Sets the precision to be used when writing the device to file.

Reimplemented in FiRPC3File, FiCurveASCFile, and FiASCFile.

◆ setStep()

void FiDeviceFunctionBase::setStep ( double  aStep)
inline

Sets the sampling increment for devices with constant sampling.

◆ setTimeSpan()

virtual void FiDeviceFunctionBase::setTimeSpan ( double  )
inlinevirtual

Sets the maximum time span for the device function.

Reimplemented in FiRPC3File.

◆ setValue()

virtual void FiDeviceFunctionBase::setValue ( double  x,
double  y 
)
pure virtual

Assigns a function value for a single-channel function.

Implemented in FiRPC3File, FiDACFile, FiCurveASCFile, and FiASCFile.

◆ unref()

int FiDeviceFunctionBase::unref ( )

Decrements the reference count for this device.

If the reference count reaches zero the device is deleted.

◆ writeString() [1/2]

bool FiDeviceFunctionBase::writeString ( const char *  lab,
const std::string &  val 
)
protected

Convenience method for writing text headers.

◆ writeString() [2/2]

bool FiDeviceFunctionBase::writeString ( const char *  str)
protected

Convenience method for a writing text header.

Member Data Documentation

◆ myAxisInfo

std::array<AxisInfo,2> FiDeviceFunctionBase::myAxisInfo
protected

◆ myDatasetDevice

std::string FiDeviceFunctionBase::myDatasetDevice
protected

Name of file associated with myFile.

◆ myFile

FT_FILE FiDeviceFunctionBase::myFile
protected

File handle of this device function.

◆ myFileStatus

FileStatus FiDeviceFunctionBase::myFileStatus
private

Current file status after opening, etc.

◆ myInputEndian

Endianness FiDeviceFunctionBase::myInputEndian
protected

Endianness assumed for binary input.

◆ myInterpolationPolicy

std::array<InterpolationPolicy,2> FiDeviceFunctionBase::myInterpolationPolicy
private

Options for interpolation and extrapolation of curve data.

◆ myMachineEndian

FiDeviceFunctionBase::Endianness FiDeviceFunctionBase::myMachineEndian
staticprotected
Initial value:
=
@ BigEndian
Definition: FiDeviceFunctionBase.H:45

Endianness for the running computer.

◆ myOutputEndian

Endianness FiDeviceFunctionBase::myOutputEndian
protected

Endianness assumed for binary output.

◆ myParent

std::string FiDeviceFunctionBase::myParent
protected

Name of FEDEM model that owns this function.

◆ myRefCount

int FiDeviceFunctionBase::myRefCount
private

Used for reference counting.

◆ myStep

double FiDeviceFunctionBase::myStep
protected

Time series information.

◆ Xval

Doubles FiDeviceFunctionBase::Xval
private

Function argument values, used for integration.

◆ Yval

Doubles FiDeviceFunctionBase::Yval
private

The function values associated with Xval.


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