Cantera  3.1.0b1
Loading...
Searching...
No Matches
Tabulated1 Class Reference

Implements a tabulated function. More...

#include <Func1.h>

Inheritance diagram for Tabulated1:
[legend]

Detailed Description

Implements a tabulated function.

The functor class is based on tabulated arrays tvals and fvals, where tvals contain independent variables and fvals are corresponding function values. Depending on configuration, the function is either interpolated linearly between the tabulated points (type "tabulated-linear" ; default), or yields the last tabulated value until a new tabulated time value is reached (type "tabulated-previous" ).

Definition at line 355 of file Func1.h.

Public Member Functions

 Tabulated1 (size_t n, const double *tvals, const double *fvals, const string &method="linear")
 Constructor.
 
 Tabulated1 (const vector< double > &params)
 Constructor uses \( 2 n \) parameters in the following order: \( [t_0, t_1, \dots, t_{n-1}, f_0, f_1, \dots, f_{n-1}] \).
 
void setMethod (const string &method)
 Set the interpolation method.
 
bool isIdentical (shared_ptr< Func1 > other) const override
 Routine to determine if two functions are the same.
 
string write (const string &arg) const override
 Write LaTeX string describing function.
 
string type () const override
 Returns a string describing the type of the function.
 
double eval (double t) const override
 Evaluate the function.
 
shared_ptr< Func1derivative () const override
 Creates a derivative to the current function.
 
- Public Member Functions inherited from Func1
 Func1 (shared_ptr< Func1 > f1, shared_ptr< Func1 > f2)
 
 Func1 (shared_ptr< Func1 > f1, double A)
 
Func1operator= (const Func1 &right)=delete
 
virtual string type () const
 Returns a string describing the type of the function.
 
string typeName () const
 Returns a string with the class name of the functor.
 
double operator() (double t) const
 Calls method eval to evaluate the function.
 
virtual double eval (double t) const
 Evaluate the function.
 
virtual shared_ptr< Func1derivative () const
 Creates a derivative to the current function.
 
virtual bool isIdentical (shared_ptr< Func1 > other) const
 Routine to determine if two functions are the same.
 
virtual bool isIdentical (Func1 &other) const
 Routine to determine if two functions are the same.
 
virtual double isProportional (TimesConstant1 &other)
 
virtual double isProportional (Func1 &other)
 
virtual string write (const string &arg) const
 Write LaTeX string describing function.
 
double c () const
 Accessor function for the stored constant m_c.
 
shared_ptr< Func1func1_shared () const
 Accessor function for m_f1.
 
shared_ptr< Func1func2_shared () const
 Accessor function for m_f2.
 
virtual int order () const
 Return the order of the function, if it makes sense.
 

Private Attributes

vector< double > m_tvec
 Vector of time values.
 
vector< double > m_fvec
 Vector of function values.
 
bool m_isLinear
 Boolean indicating interpolation method.
 

Additional Inherited Members

- Protected Attributes inherited from Func1
double m_c = 0.0
 
shared_ptr< Func1m_f1
 
shared_ptr< Func1m_f2
 

Constructor & Destructor Documentation

◆ Tabulated1() [1/2]

Tabulated1 ( size_t  n,
const double *  tvals,
const double *  fvals,
const string &  method = "linear" 
)

Constructor.

Parameters
nSize of tabulated value arrays
tvalsPointer to time value array
fvalsPointer to function value array
methodInterpolation method ('linear' or 'previous')

Definition at line 321 of file Func1.cpp.

◆ Tabulated1() [2/2]

Tabulated1 ( const vector< double > &  params)

Constructor uses \( 2 n \) parameters in the following order: \( [t_0, t_1, \dots, t_{n-1}, f_0, f_1, \dots, f_{n-1}] \).

Definition at line 337 of file Func1.cpp.

Member Function Documentation

◆ setMethod()

void setMethod ( const string &  method)

Set the interpolation method.

Parameters
methodEvaluation method. If "linear" (default), a linear interpolation between tabulated values is used; if "previous", the last tabulated value is held until a new tabulated time value is reached.
Since
New in Cantera 3.0

Definition at line 360 of file Func1.cpp.

◆ isIdentical()

bool isIdentical ( shared_ptr< Func1 other) const
inlineoverridevirtual

Routine to determine if two functions are the same.

Two functions are the same if they are the same function. For example, either ID and stored constant are the same, or the m_f1 and m_f2 are identical if they are non-null. Functors of the base class Func1 are by default not identical, as they are used by callback functions that cannot be differentiated. In instances where exact comparisons are not implemented, false is returned to prevent false positives that could lead to incorrect simplifications of compound functors.

Reimplemented from Func1.

Definition at line 379 of file Func1.h.

◆ write()

string write ( const string &  arg) const
overridevirtual

Write LaTeX string describing function.

Reimplemented from Func1.

Definition at line 443 of file Func1.cpp.

◆ type()

string type ( ) const
inlineoverridevirtual

Returns a string describing the type of the function.

Since
New in Cantera 3.0.

Reimplemented from Func1.

Definition at line 385 of file Func1.h.

◆ eval()

double eval ( double  t) const
overridevirtual

Evaluate the function.

Reimplemented from Func1.

Definition at line 372 of file Func1.cpp.

◆ derivative()

shared_ptr< Func1 > derivative ( ) const
overridevirtual

Creates a derivative to the current function.

Returns
shared pointer to new derivative function.
Since
Starting in Cantera 3.1, the return type is a shared_ptr.

Reimplemented from Func1.

Definition at line 395 of file Func1.cpp.

Member Data Documentation

◆ m_tvec

vector<double> m_tvec
private

Vector of time values.

Definition at line 395 of file Func1.h.

◆ m_fvec

vector<double> m_fvec
private

Vector of function values.

Definition at line 396 of file Func1.h.

◆ m_isLinear

bool m_isLinear
private

Boolean indicating interpolation method.

Definition at line 397 of file Func1.h.


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