Class xlifepp::Function#

class Function#

Collaboration diagram for xlifepp::Function:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "5" [label="std::map< string_t, number_t >" tooltip="std::map< string_t, number_t >"] "9" [label="std::map< string_t, std::pair< ValueType, StrucType > >" tooltip="std::map< string_t, std::pair< ValueType, StrucType > >"] "6" [label="std::map< K, T >" tooltip="std::map< K, T >"] "4" [label="std::vector< T >" tooltip="std::vector< T >"] "8" [label="std::vector< real_t >" tooltip="std::vector< real_t >"] "3" [label="std::vector< xlifepp::Parameter * >" tooltip="std::vector< xlifepp::Parameter * >"] "1" [label="xlifepp::Function" tooltip="xlifepp::Function" fillcolor="#BFBFBF"] "2" [label="xlifepp::Parameters" tooltip="xlifepp::Parameters"] "7" [label="xlifepp::Point" tooltip="xlifepp::Point"] "5" -> "6" [dir=forward tooltip="template-instance"] "9" -> "6" [dir=forward tooltip="template-instance"] "8" -> "4" [dir=forward tooltip="template-instance"] "3" -> "4" [dir=forward tooltip="template-instance"] "1" -> "2" [dir=forward tooltip="usage"] "1" -> "1" [dir=forward tooltip="usage"] "1" -> "7" [dir=forward tooltip="usage"] "1" -> "9" [dir=forward tooltip="usage"] "2" -> "3" [dir=forward tooltip="usage"] "2" -> "5" [dir=forward tooltip="usage"] "7" -> "8" [dir=forward tooltip="public-inheritance"] }

The class Function encapsulates in object function a user’s functions.

It is used by internal computing functions

this class is able to deal with any user function of type

r function(const Point&, Parameters&) (function tpe)
r function(const Point&, const Point&, Parameters&) (kernel type)
and their vector forms
Vector<r> function(const Vector<Point>&, Parameters&)
Vector<r> function(const Vector<Point>&, const Vector<Point>&, Parameters&)
with r of type: real_t, complex_t, Vector<real_t>, Vector<complex_t>, Matrix<real_t> or Matrix<complex_t>

This class mainly proposes:

  • two constructors (unamed and named)

  • a fast call to compute function values when function is well identified (see member functions fun_xxx)

  • a general safe call to compute function values (see operator ()); require only output argument compatibility if output argument is not compatible, an error occurs with a message

  • some utilities to return type of function and type of arguments (use rtti functions)

Note: A Parameters is attached to a Function using a pointer. This Parameters is passed to the function by reference therefore, it may be shared by few functions and when it is modified it is for any function sharing it. In a way, this parameters is global

Public Functions

Function()#

default constructor

Function(const Function&, bool fullcopy = false)#

copy constructor with full copy option

Function(funSR_t &f, const char *na, Parameters &pa = defaultParameters)#

constructor with function name (const char*) along the function prototypes

Function(funSR_t &f, const string_t &na, Parameters &pa = defaultParameters)#

constructor with function name (string) along the function prototypes

Function(funSR_t &f, dimen_t d, const char *na, Parameters &pa = defaultParameters)#

constructor with function name (const char*) along the function prototypes

Function(funSR_t &f, dimen_t d, const string_t &na, Parameters &pa = defaultParameters)#

constructor with function name (string) along the function prototypes

Function(funSR_t &f, dimen_t d, Parameters &pa = defaultParameters)#

constructor along the function prototypes

Function(funSR_t &f, Parameters &pa = defaultParameters)#

constructor along the function prototypes

template<typename T>
Function(Tabular<T> &tab, dimen_t dp, const string_t &na = "", FunctType ft = _function)#

tabular stuff

constructor from a Tabular

template<typename T>
Function(Tabular<T> &tab, dimen_t dp, Function &fpx, const string_t &na = "", FunctType ft = _function)#

constructor from a Tabular

~Function()#

destructor

inline void addParam(Parameter &pa)#

add a parameter to the current list of parameters

void associateVector(UnitaryVector uv, number_t d = 3)#

associate to the function a unitary vector

template<class T>
inline void checkFunctionType(T&, FunctType) const#

to check the type of output and input arguments

to check the type of the function when computing its value using the operator ().

This function uses Run Time Information (RTTI), so it must be used sparingly for this reason, when it is invoked, the checkType_ value is reset to false

inline void checkTypeOff() const#

deactivate the checking of integrity

inline void checkTypeOn() const#

activate the checking of integrity

inline bool &conjugate()#

<return the conjugate state (true/false) flag

inline bool conjugate() const#

return the conjugate state (true/false) flag

inline void conjugate(bool v) const#

set the conjugate stateflag

void createTabular(real_t x0, real_t dx, number_t nx, const string_t &nax = "x")#

tabulating f(x)

void createTabular(real_t x0, real_t dx, number_t nx, real_t y0, real_t dy, number_t ny, const string_t &nax = "x", const string_t &nay = "y")#

tabulating f(x,y)

void createTabular(real_t x0, real_t dx, number_t nx, real_t y0, real_t dy, number_t ny, real_t z0, real_t dz, number_t nz, const string_t &nax = "x", const string_t &nay = "y", const string_t &naz = "z")#

tabulating f(x,y,z)

template<typename T>
void createTabularT(const T &t, real_t x0, real_t dx, number_t nx, const string_t &nax = "x")#

tabulating f(x) - template

template<typename T>
void createTabularT(const T &t, real_t x0, real_t dx, number_t nx, real_t y0, real_t dy, number_t ny, const string_t &nax = "x", const string_t &nay = "y")#

tabulating f(x,y)) - template

template<typename T>
void createTabularT(const T &t, real_t x0, real_t dx, number_t nx, real_t y0, real_t dy, number_t ny, real_t z0, real_t dz, number_t nz, const string_t &nax = "x", const string_t &nay = "y", const string_t &naz = "z")#

tabulating f(x,y,z) - template

inline dimPair dims() const#

return the dimensions of object returned by function

void fullCopy(const Function&)#

full copy of a Function

inline const void *fun_p() const#

return fun void pointer

inline real_t funSR(const Point &x) const#

compute the value(s) of the function using correct type function (no check performed)

template<typename T>
inline T &funTable(const Point &x, T &res) const#

compute function using table_

inline const Vector<real_t> &get_n() const#

get pointer to normal in theThreadData

inline const Vector<real_t> *get_np() const#

get pointer to normal in theThreadData

inline const Function *grad_p() const#

return grad Function pointer

void init(void*, const string_t&, const string_t&, FunctType, ArgType, Parameters&, dimen_t d = 3)#

to initialize members, used by the constructors

void isNotAFunction() const#

true if not a function

void isNotAKernel() const#

true if not a kernel

inline bool isVoidFunction() const#

true if fun pointer is 0

template<typename T>
inline T &kerTable(const Point &x, const Point &y, T &res) const#

compute kernel using table_

inline string_t name() const#

return the function name

inline bool normalRequired() const#

true if normal required

Value operator()(const Point &x) const#

evaluate function at a point, returning a Value

Value operator()(const Point &x, const Point &y) const#

evaluate kernel function at a couple of points, returning a Value

template<typename T>
inline T &operator()(const Point &x, const Point &y, T &res) const#

compute the value of the function at a given couple of points

compute in a safe way the value of the kernel function at a given couple of points.

the function is either a function of a couple of points or a function of a couple of vectors of points

template<typename T>
inline T &operator()(const Point &x, T &res) const#

compute the value of the function at a given point

compute in a safe way the value of the function at a given point.

the function is either a function of a single point or a function of a vector of points n, nx or ny are additional normal vectors

template<typename T>
inline Vector<T> &operator()(const Vector<Point> &x, const Vector<Point> &y, Vector<T> &res) const#

compute the values of the function at a given couple of vector of points

compute in a safe way the value of the kernel function at a couple of vectors of points.

the function is either a function of a couple of points or a function of a couple of vectors of points

template<typename T>
inline Vector<T> &operator()(const Vector<Point> &x, Vector<T> &res) const#

compute the values of the function at a given vector of points

compute in a safe way the values of the function at a vector of points.

the function is either a function of a point or a function of a vector of points

Parameter &parameter(const char *s) const#

access parameter by name (char *)

Parameter &parameter(const size_t) const#

accses parameter by rank >=1

associate a unitary vector to the function - DEPRECATED -

Parameter &parameter(const string_t&) const#

access parameter by name (string)

inline Parameters &params()#

return the parameters list

inline Parameters &params() const#

return the parameters list

inline Parameters *&params_p()#

return the parameters list pointer

inline const Parameters *params_p() const#

return the parameters list pointer

void printInfo(std::ostream &out) const#

print utility

inline void set_n(const Vector<real_t> &n) const#

set pointer to normal in theThreadData

inline void set_np(const Vector<real_t> *np = nullptr) const#

set pointer to normal in theThreadData

template<typename K>
void setParam(const K &v, const string_t &name) const#

set parameter name to v

inline void setX(const Point &P) const#

management of kernel argument

inline StrucType structReturned() const#

return the structure of return argument (saclar_t, vector_t or matrix_t)

inline StrucType strucType() const#

return the structure of return argument (saclar_t, vector_t or matrix_t)

inline bool tangentRequired() const#

true if tangent required

const TermVector *termVector() const#

return TermVector pointer when interpolated function (0 if not)

Point termVectorPoint() const#

return a dof coordinate from TermVector if interpolated function

inline bool &transpose()#

return the transpose state (true/false) flag

inline bool transpose() const#

return the transpose state (true/false) flag

inline void transpose(bool v) const#

set the transpose stateflag

inline ArgType typeArg() const#

return the input argument type (_pointArg or vectorOfPointArg)

inline FunctType typeFunction() const#

return the function type (function or kernel)

inline ValueType typeReturned() const#

return the type of return argument (real_t or complex_t)

inline ValueType valueType() const#

return the type of return argument (real_t or complex_t)

Public Members

ArgType argType_#

type of the function argument (_pointArg or _vectorOfPointArg)

mutable bool checkType_ = false#

to activate the checking of arguments (see operator ())

mutable bool conjugate_ = false#

temporary flag for conjugate operation in OperatorOnUnknown construction (see operator lib)

dimen_t dimPoint_#

dimension of point (default=3)

dimPair dims_#

dimension of returned values (does not take into account vectorOfPointArg)

FunctType functionType_#

type of the function (_function or _kernel}

string_t name_#

name of function and comments

bool requireDof = false#

true if user declares that its function requires dof

bool requireDom = false#

true if user declares that its function requires domain

bool requireElt = false#

true if user declares that its function requires element

bool requireNx = false#

true if user declares that its function requires normal or x-normal vector

bool requireNy = false#

true if user declares that its function (kernel) requires y-normal vector

bool requireTx = false#

true if user declares that its function requires normal or x-tangent vector

bool requireTy = false#

true if user declares that its function (kernel) requires y-tangent vector

StrucType returnedStruct_#

structure of returned value (one among _scalar, _vector, _matrix)

ValueType returnedType_#

type of returned value (one among _real, _complex)

mutable bool transpose_ = false#

temporary flag for transpose operation in OperatorOnUnknown construction (see operator lib)

mutable Point xory#

point x or y as parameter of the kernel (unused for ordinary function)

mutable bool xpar = false#

true means that point x is consider as a parameter (unused for ordinary function)

Public Static Functions

static void initReturnTypes()#

initialisation of the map

Public Static Attributes

static std::map<string_t, std::pair<ValueType, StrucType>> returnArgs#

rtti names of return arguments

list of RTI names of return args of function

static std::map<string_t, std::pair<ValueType, StrucType>> returnTypes#

rtti names of pointer function

list of RTI names of return types of function

Friends

friend std::ostream &operator<<(std::ostream&, const Function&)#

print operator