Public Types | Public Member Functions | Private Member Functions | Private Attributes
interpolationTable< Type > Class Template Reference

An interpolation/look-up table of scalar vs <Type> values. The reference scalar values must be monotonically increasing. More...

Inheritance diagram for interpolationTable< Type >:
Inheritance graph
[legend]
Collaboration diagram for interpolationTable< Type >:
Collaboration graph
[legend]

Public Types

enum  boundsHandling { ERROR, WARN, CLAMP, REPEAT }
 Enumeration for handling out-of-bound values. More...
 
- Public Types inherited from List< Tuple2< scalar, Type > >
typedef SubList< TsubList
 Declare type of subList. More...
 

Public Member Functions

 interpolationTable ()
 Construct null. More...
 
 interpolationTable (const List< Tuple2< scalar, Type > > &values, const boundsHandling bounds, const fileName &fName)
 Construct from components. More...
 
 interpolationTable (const fileName &fName)
 Construct given the name of the file containing the table of data. More...
 
 interpolationTable (const dictionary &dict)
 Construct by reading the fileName and boundsHandling from dictionary. More...
 
 interpolationTable (const interpolationTable &interpTable)
 Construct copy. More...
 
word boundsHandlingToWord (const boundsHandling &bound) const
 Return the out-of-bounds handling as a word. More...
 
boundsHandling wordToBoundsHandling (const word &bound) const
 Return the out-of-bounds handling as an enumeration. More...
 
boundsHandling outOfBounds (const boundsHandling &bound)
 Set the out-of-bounds handling from enum, return previous setting. More...
 
void check () const
 Check that list is monotonically increasing. More...
 
void write (Ostream &os) const
 Write. More...
 
Type rateOfChange (const scalar) const
 Return the rate of change at the interpolation location. More...
 
const Tuple2< scalar, Type > & operator[] (const label) const
 Return an element of constant Tuple2<scalar, Type> More...
 
Type operator() (const scalar) const
 Return an interpolated value. More...
 
- Public Member Functions inherited from List< Tuple2< scalar, Type > >
label size () const
 Return the number of elements in the UList. More...
 
 List ()
 Null constructor. More...
 
 List (const label)
 Construct with given size. More...
 
 List (const label, const T &)
 Construct with given size and value for all elements. More...
 
 List (const List< T > &)
 Copy constructor. More...
 
 List (const Xfer< List< T > > &)
 Construct by transferring the parameter contents. More...
 
 List (List< T > &, bool reUse)
 Construct as copy or re-use as specified. More...
 
 List (const UList< T > &, const labelUList &mapAddressing)
 Construct as subset. More...
 
 List (InputIterator first, InputIterator last)
 Construct given start and end iterators. More...
 
 List (const FixedList< T, Size > &)
 Construct as copy of FixedList<T, Size> More...
 
 List (const PtrList< T > &)
 Construct as copy of PtrList<T> More...
 
 List (const SLList< T > &)
 Construct as copy of SLList<T> More...
 
 List (const UIndirectList< T > &)
 Construct as copy of UIndirectList<T> More...
 
 List (const BiIndirectList< T > &)
 Construct as copy of BiIndirectList<T> More...
 
 List (Istream &)
 Construct from Istream. More...
 
 List (const label s)
 
 List (const label s, const T &a)
 
 List (const List< T > &a)
 
 List (const Xfer< List< T > > &lst)
 
 List (List< T > &a, bool reUse)
 
 List (const UList< T > &a, const labelUList &map)
 
 List (const PtrList< T > &lst)
 
 List (const SLList< T > &lst)
 
 List (const UIndirectList< T > &lst)
 
 List (const BiIndirectList< T > &lst)
 
 List ()
 
 List (Istream &is)
 
autoPtr< List< T > > clone () const
 Clone. More...
 
 ~List ()
 Destructor. More...
 
void resize (const label)
 Alias for setSize(const label) More...
 
void resize (const label, const T &)
 Alias for setSize(const label, const T&) More...
 
void setSize (const label)
 Reset size of List. More...
 
void setSize (const label, const T &)
 Reset size of List and value for new elements. More...
 
void clear ()
 Clear the list, i.e. set size to zero. More...
 
void append (const T &)
 Append an element at the end of the list. More...
 
void append (const UList< T > &)
 Append a List at the end of this list. More...
 
void append (const UIndirectList< T > &)
 Append a UIndirectList at the end of this list. More...
 
void transfer (List< T > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (DynamicList< T, SizeInc, SizeMult, SizeDiv > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (SortableList< T > &)
 Transfer the contents of the argument List into this list. More...
 
void transfer (List< T > &a)
 
void transfer (SortableList< T > &a)
 
Xfer< List< T > > xfer ()
 Transfer contents to the Xfer container. More...
 
TnewElmt (const label)
 Return subscript-checked element of UList. More...
 
void operator= (const UList< T > &)
 Assignment from UList operator. Takes linear time. More...
 
void operator= (const List< T > &)
 Assignment operator. Takes linear time. More...
 
void operator= (const SLList< T > &)
 Assignment from SLList operator. Takes linear time. More...
 
void operator= (const UIndirectList< T > &)
 Assignment from UIndirectList operator. Takes linear time. More...
 
void operator= (const BiIndirectList< T > &)
 Assignment from BiIndirectList operator. Takes linear time. More...
 
void operator= (const T &)
 Assignment of all entries to the given value. More...
 

Private Member Functions

void readTable ()
 Read the table of data from file. More...
 

Private Attributes

boundsHandling boundsHandling_
 Enumeration for handling out-of-bound values. More...
 
fileName fileName_
 File name. More...
 
autoPtr< tableReader< Type > > reader_
 The actual reader. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from List< Tuple2< scalar, Type > >
static const List< T > & null ()
 Return a null List. More...
 
- Protected Member Functions inherited from List< Tuple2< scalar, Type > >
void size (const label)
 Override size to be inconsistent with allocated storage. More...
 

Detailed Description

template<class Type>
class Foam::interpolationTable< Type >

An interpolation/look-up table of scalar vs <Type> values. The reference scalar values must be monotonically increasing.

The handling of out-of-bounds values depends on the current setting of outOfBounds.

If REPEAT is chosen for the out-of-bounds handling, the final time value is treated as being equivalent to time=0 for the following periods.

The construct from dictionary reads a filename from a dictionary and has an optional readerType. Default is to read OpenFOAM format. The only other format is csv (comma separated values):

Read csv format: readerType csv; fileName "$FOAM_CASE/constant/p0vsTime.csv"; hasHeaderLine true; // skip first line timeColumn 0; // time is in column 0 valueColumns (1); // value starts in column 1

Note
  • Accessing an empty list results in an error.
  • Accessing a list with a single element always returns the same value.
Source files

Definition at line 77 of file interpolationTable.H.

Member Enumeration Documentation

◆ boundsHandling

Enumeration for handling out-of-bound values.

Enumerator
ERROR 

Exit with a FatalError

WARN 

Issue warning and clamp value (default)

CLAMP 

Clamp value to the start/end value

REPEAT 

Treat as a repeating list

Definition at line 86 of file interpolationTable.H.

Constructor & Destructor Documentation

◆ interpolationTable() [1/5]

Construct null.

Definition at line 59 of file interpolationTable.C.

◆ interpolationTable() [2/5]

interpolationTable ( const List< Tuple2< scalar, Type > > &  values,
const boundsHandling  bounds,
const fileName fName 
)

Construct from components.

Definition at line 70 of file interpolationTable.C.

◆ interpolationTable() [3/5]

interpolationTable ( const fileName fName)

Construct given the name of the file containing the table of data.

Definition at line 84 of file interpolationTable.C.

◆ interpolationTable() [4/5]

interpolationTable ( const dictionary dict)

Construct by reading the fileName and boundsHandling from dictionary.

and read the table from that file. This is a specialised constructor used by patchFields

Definition at line 96 of file interpolationTable.C.

◆ interpolationTable() [5/5]

interpolationTable ( const interpolationTable< Type > &  interpTable)

Construct copy.

Definition at line 109 of file interpolationTable.C.

Member Function Documentation

◆ readTable()

void readTable
private

Read the table of data from file.

Definition at line 33 of file interpolationTable.C.

◆ boundsHandlingToWord()

Foam::word boundsHandlingToWord ( const boundsHandling bound) const

Return the out-of-bounds handling as a word.

Definition at line 125 of file interpolationTable.C.

◆ wordToBoundsHandling()

Foam::interpolationTable< Type >::boundsHandling wordToBoundsHandling ( const word bound) const

Return the out-of-bounds handling as an enumeration.

Definition at line 162 of file interpolationTable.C.

◆ outOfBounds()

Foam::interpolationTable< Type >::boundsHandling outOfBounds ( const boundsHandling bound)

Set the out-of-bounds handling from enum, return previous setting.

Definition at line 195 of file interpolationTable.C.

◆ check()

void check

Check that list is monotonically increasing.

Exit with a FatalError if there is a problem

Definition at line 206 of file interpolationTable.C.

◆ write()

void write ( Ostream os) const

Write.

Definition at line 230 of file interpolationTable.C.

◆ rateOfChange()

Type rateOfChange ( const scalar  value) const

Return the rate of change at the interpolation location.

for the give value

Definition at line 244 of file interpolationTable.C.

◆ operator[]()

const Foam::Tuple2< Foam::scalar, Type > & operator[] ( const label  i) const

Return an element of constant Tuple2<scalar, Type>

Definition at line 391 of file interpolationTable.C.

◆ operator()()

Type operator() ( const scalar  value) const

Return an interpolated value.

Definition at line 474 of file interpolationTable.C.

Field Documentation

◆ boundsHandling_

boundsHandling boundsHandling_
private

Enumeration for handling out-of-bound values.

Definition at line 100 of file interpolationTable.H.

◆ fileName_

fileName fileName_
private

File name.

Definition at line 103 of file interpolationTable.H.

◆ reader_

autoPtr<tableReader<Type> > reader_
private

The actual reader.

Definition at line 106 of file interpolationTable.H.


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