CEPS  24.01
Cardiac ElectroPhysiology Simulator
FunctionDictionary Class Reference

Detailed Description

FunctionDictionary that holds functions which can be used to define source terms, boundary conditions or physical coefficients.

Entries are added from a character string. See the Syntax to add boundary conditions and source terms. page for usage. Some entries can be added directly from an object, though (constants, functions...)

Definition at line 45 of file FunctionDictionary.hpp.

#include <FunctionDictionary.hpp>

Inheritance diagram for FunctionDictionary:
[legend]

Public Types

template<class _Result >
using Entry = SAFunc< _Result > *
 Typedef for any kind of entry. We do not put SAFunc<_Result>* as the operators return a ceps::Function .... More...
 
using ScalarEntry = Entry< CepsMathScalar >
 Typedef for scalar functions. More...
 
using VectorEntry = Entry< CepsMathVertex >
 Typedef for vector functions. More...
 
using TensorEntry = Entry< CepsMathTensor >
 Typedef for tensor functions. More...
 
template<class _Result >
using Map = CepsMap< CepsString, Entry< _Result > >
 Typedef for map of functions, any kind. More...
 
using ScalarMap = Map< CepsMathScalar >
 Typedef for the map of scalar functions. More...
 
using VectorMap = Map< CepsMathVertex >
 Typedef for the map of vector functions. More...
 
using TensorMap = Map< CepsMathTensor >
 Typedef for the map of tensor functions. More...
 

Public Member Functions

 FunctionDictionary ()
 Constructor, adds some function by default. More...
 
 ~FunctionDictionary ()
 Destructor. More...
 
void add (const CepsString &label, const CepsString &params, Geometry *geom=nullptr)
 Add an object from parameters. More...
 
void addConstant (const CepsString &label, const CepsString &params)
 Add a constant function through parameter string. More...
 
template<class _Constant >
void addConstant (const CepsString &label, _Constant value)
 Add a constant function directly from the value. More...
 
void addCstPiecewise (const CepsString &label, const CepsString &params)
 Add a piecewise function, constant on each region. More...
 
void addFctPiecewise (const CepsString &label, const CepsString &params)
 Add a piecewise function, function on eacg. More...
 
void addFromFile (const CepsString &label, const CepsString &params, Geometry *geom, CepsBool neverMind=false)
 Add a function read from data file, requires geometry. If the extension is compatible with CoeffReader (vtk, etc) it creates a space varying function. Otherwise, consider the file as a column formatted text file and return an interpolator. (The functor in the interpolator can be set later on for correct selection from CepsStandardArgs) The last bool cancels the add if data with arrayname provided in params is not found in file (spatial only) More...
 
void addFunction (const CepsString &label, const CepsString &params)
 Add a function deduced from tags only, works only with scalar return type. More...
 
void addOperator (const CepsString &label, const CepsString &params)
 Add an operation between already registered functions and/or real constants. More...
 
template<class _Obj1 , class _Obj2 >
void addOperator (const CepsString &label, _Obj1 *a, const CepsChar &op, _Obj2 *b)
 Add an operation between already registered functions and/or real constants, directly from the objects. More...
 
void addAlias (const CepsString &label, const CepsString &params)
 Adds a shortcut to an already existing function. More...
 
void addEntry (const CepsString &label, ScalarEntry func)
 Ads an entry to the map of scalar functions. More...
 
void addEntry (const CepsString &label, VectorEntry func)
 Ads an entry to the map of vector functions. More...
 
void addEntry (const CepsString &label, TensorEntry func)
 Ads an entry to the map of tensor functions. More...
 
CepsBool hasScalar (const CepsString &label) const
 Tells if function "label" is registered. More...
 
CepsBool hasVector (const CepsString &label) const
 Tells if function "label" is registered. More...
 
CepsBool hasTensor (const CepsString &label) const
 Tells if function "label" is registered. More...
 
const ScalarMapgetScalars () const
 Get all scalar entries, const version. More...
 
const VectorMapgetVectors () const
 Get all vector entries, const version. More...
 
const TensorMapgetTensors () const
 Get all tensor entries, const version. More...
 
const ScalarEntry getScalar (const CepsString &label) const
 Get a single scalar entry, const version. More...
 
const VectorEntry getVector (const CepsString &label) const
 Get a single vector entry, const version. More...
 
const TensorEntry getTensor (const CepsString &label) const
 Get a single tensor entry, const version. More...
 
const ScalarEntry getScalar (const CepsString &label, const ScalarEntry def) const
 Get a single scalar entry, with default value, const version. More...
 
const VectorEntry getVector (const CepsString &label, const VectorEntry def) const
 Get a single vector entry, with default value, const version. More...
 
const TensorEntry getTensor (const CepsString &label, const TensorEntry def) const
 Get a single tensor entry, with default value, const version. More...
 
void deleteScalar (const CepsString &label)
 Delete a single scalar entry. Be careful if the functor was created outside dictionary. More...
 
void deleteVector (const CepsString &label)
 Delete a single vector entry. Be careful if the functor was created outside dictionary. More...
 
void deleteTensor (const CepsString &label)
 Delete a single tensor entry. Be careful if the functor was created outside dictionary. More...
 
- Public Member Functions inherited from CepsObject
 CepsObject ()=default
 default constructor More...
 
 CepsObject (const CepsObject &)=default
 Copy constructor. More...
 
virtual ~CepsObject ()=default
 Destructor. More...
 
CepsObjectoperator= (const CepsObject &)=default
 Assignment operator. More...
 
CepsObjecttoBaseObject ()
 Returns a pointer to CepsObject class. More...
 
const CepsObjecttoBaseObject () const
 Returns a pointer to CepsObject class, const version. More...
 
ProfilergetProfiler () const
 Access to profiler. More...
 

Protected Attributes

ScalarMap m_scalars
 All scalar entries. More...
 
VectorMap m_vectors
 All vector entries. More...
 
TensorMap m_tensors
 All tensor entries. More...
 
CepsSet< CepsStringm_doNotDelete
 Functions that must not be deleted (created by alias) More...
 
CepsString m_address = " See https://carmen.gitlabpages.inria.fr/ceps/syntax.html for details on syntax"
 A string that is displayed in error messages. More...
 

Private Member Functions

ScalarEntry parseFunction (const CepsString &params)
 Returns a pointer to a function deduced from the string parameters. More...
 
ScalarEntry parseTimeFunction (const CepsVector< CepsString > &params)
 Returns a pointer to a function deduced from the string parameters. More...
 
ScalarEntry parseSpatialFunction (const CepsVector< CepsString > &params)
 Returns a pointer to a function deduced from the string parameters. More...
 
void checkParam (const CepsVector< CepsString > &words, const CepsVector< CepsString > &keys, const CepsVector< CepsUInt > &nToRead={}) const
 Aborts if a function parameter is missing or not a number. More...
 
template<class _Result >
void addInternal (const CepsString &label, Entry< _Result > func, Map< _Result > &map, const CepsString &name)
 Internal adding method. More...
 
template<CepsUInt n, typename Reals >
void addInterpolationTable (const CepsString &label, std::ifstream &ifs, const CepsString &fileName, CepsBool time)
 Internal method to add intepolation tables of scalar, vector and tensors. More...
 

Static Private Member Functions

template<class _Result >
static CepsBool hasInternal (const CepsString &key, const Map< _Result > &map)
 Internal inspecting method. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from CepsObject
static Profiler m_profiler
 The same profiler for each big object. More...
 

Member Typedef Documentation

◆ Entry

template<class _Result >
using FunctionDictionary::Entry = SAFunc<_Result>*

Typedef for any kind of entry. We do not put SAFunc<_Result>* as the operators return a ceps::Function ....

Definition at line 53 of file FunctionDictionary.hpp.

◆ Map

template<class _Result >
using FunctionDictionary::Map = CepsMap<CepsString, Entry<_Result> >

Typedef for map of functions, any kind.

Definition at line 63 of file FunctionDictionary.hpp.

◆ ScalarEntry

Typedef for scalar functions.

Definition at line 55 of file FunctionDictionary.hpp.

◆ ScalarMap

Typedef for the map of scalar functions.

Definition at line 65 of file FunctionDictionary.hpp.

◆ TensorEntry

Typedef for tensor functions.

Definition at line 59 of file FunctionDictionary.hpp.

◆ TensorMap

Typedef for the map of tensor functions.

Definition at line 69 of file FunctionDictionary.hpp.

◆ VectorEntry

Typedef for vector functions.

Definition at line 57 of file FunctionDictionary.hpp.

◆ VectorMap

Typedef for the map of vector functions.

Definition at line 67 of file FunctionDictionary.hpp.

Constructor & Destructor Documentation

◆ FunctionDictionary()

FunctionDictionary::FunctionDictionary ( )

Constructor, adds some function by default.

Definition at line 33 of file FunctionDictionary.cpp.

◆ ~FunctionDictionary()

FunctionDictionary::~FunctionDictionary ( )

Destructor.

Definition at line 38 of file FunctionDictionary.cpp.

Member Function Documentation

◆ add()

void FunctionDictionary::add ( const CepsString label,
const CepsString params,
Geometry geom = nullptr 
)

Add an object from parameters.

Parameters
labelthe key of the object
paramsthe params of the object
geoma geometry, needed for data loaded from file, nullptr otherwise

Definition at line 52 of file FunctionDictionary.cpp.

◆ addAlias()

void FunctionDictionary::addAlias ( const CepsString label,
const CepsString params 
)

Adds a shortcut to an already existing function.

Definition at line 345 of file FunctionDictionary.cpp.

◆ addConstant() [1/2]

template<class _Constant >
void FunctionDictionary::addConstant ( const CepsString label,
_Constant  value 
)

Add a constant function directly from the value.

Definition at line 289 of file FunctionDictionary.hpp.

◆ addConstant() [2/2]

void FunctionDictionary::addConstant ( const CepsString label,
const CepsString params 
)

Add a constant function through parameter string.

Definition at line 83 of file FunctionDictionary.cpp.

◆ addCstPiecewise()

void FunctionDictionary::addCstPiecewise ( const CepsString label,
const CepsString params 
)

Add a piecewise function, constant on each region.

Definition at line 104 of file FunctionDictionary.cpp.

◆ addEntry() [1/3]

void FunctionDictionary::addEntry ( const CepsString label,
ScalarEntry  func 
)

Ads an entry to the map of scalar functions.

Definition at line 366 of file FunctionDictionary.cpp.

◆ addEntry() [2/3]

void FunctionDictionary::addEntry ( const CepsString label,
TensorEntry  func 
)

Ads an entry to the map of tensor functions.

Definition at line 378 of file FunctionDictionary.cpp.

◆ addEntry() [3/3]

void FunctionDictionary::addEntry ( const CepsString label,
VectorEntry  func 
)

Ads an entry to the map of vector functions.

Definition at line 372 of file FunctionDictionary.cpp.

◆ addFctPiecewise()

void FunctionDictionary::addFctPiecewise ( const CepsString label,
const CepsString params 
)

Add a piecewise function, function on eacg.

Definition at line 152 of file FunctionDictionary.cpp.

◆ addFromFile()

void FunctionDictionary::addFromFile ( const CepsString label,
const CepsString params,
Geometry geom,
CepsBool  neverMind = false 
)

Add a function read from data file, requires geometry. If the extension is compatible with CoeffReader (vtk, etc) it creates a space varying function. Otherwise, consider the file as a column formatted text file and return an interpolator. (The functor in the interpolator can be set later on for correct selection from CepsStandardArgs) The last bool cancels the add if data with arrayname provided in params is not found in file (spatial only)

Definition at line 193 of file FunctionDictionary.cpp.

◆ addFunction()

void FunctionDictionary::addFunction ( const CepsString label,
const CepsString params 
)

Add a function deduced from tags only, works only with scalar return type.

Definition at line 285 of file FunctionDictionary.cpp.

◆ addInternal()

template<class _Result >
void FunctionDictionary::addInternal ( const CepsString label,
Entry< _Result >  func,
Map< _Result > &  map,
const CepsString name 
)
private

Internal adding method.

Definition at line 312 of file FunctionDictionary.hpp.

◆ addInterpolationTable()

template<CepsUInt n, typename Reals >
void FunctionDictionary::addInterpolationTable ( const CepsString label,
std::ifstream &  ifs,
const CepsString fileName,
CepsBool  time 
)
private

Internal method to add intepolation tables of scalar, vector and tensors.

Definition at line 341 of file FunctionDictionary.hpp.

◆ addOperator() [1/2]

template<class _Obj1 , class _Obj2 >
void FunctionDictionary::addOperator ( const CepsString label,
_Obj1 *  a,
const CepsChar op,
_Obj2 *  b 
)

Add an operation between already registered functions and/or real constants, directly from the objects.

Definition at line 296 of file FunctionDictionary.hpp.

◆ addOperator() [2/2]

void FunctionDictionary::addOperator ( const CepsString label,
const CepsString params 
)

Add an operation between already registered functions and/or real constants.

Definition at line 291 of file FunctionDictionary.cpp.

◆ checkParam()

void FunctionDictionary::checkParam ( const CepsVector< CepsString > &  words,
const CepsVector< CepsString > &  keys,
const CepsVector< CepsUInt > &  nToRead = {} 
) const
private

Aborts if a function parameter is missing or not a number.

Definition at line 612 of file FunctionDictionary.cpp.

◆ deleteScalar()

void FunctionDictionary::deleteScalar ( const CepsString label)

Delete a single scalar entry. Be careful if the functor was created outside dictionary.

Definition at line 488 of file FunctionDictionary.cpp.

◆ deleteTensor()

void FunctionDictionary::deleteTensor ( const CepsString label)

Delete a single tensor entry. Be careful if the functor was created outside dictionary.

Definition at line 504 of file FunctionDictionary.cpp.

◆ deleteVector()

void FunctionDictionary::deleteVector ( const CepsString label)

Delete a single vector entry. Be careful if the functor was created outside dictionary.

Definition at line 496 of file FunctionDictionary.cpp.

◆ getScalar() [1/2]

const FunctionDictionary::ScalarEntry FunctionDictionary::getScalar ( const CepsString label) const

Get a single scalar entry, const version.

Definition at line 427 of file FunctionDictionary.cpp.

◆ getScalar() [2/2]

const FunctionDictionary::ScalarEntry FunctionDictionary::getScalar ( const CepsString label,
const ScalarEntry  def 
) const

Get a single scalar entry, with default value, const version.

Definition at line 457 of file FunctionDictionary.cpp.

◆ getScalars()

const FunctionDictionary::ScalarMap & FunctionDictionary::getScalars ( ) const

Get all scalar entries, const version.

Definition at line 409 of file FunctionDictionary.cpp.

◆ getTensor() [1/2]

const FunctionDictionary::TensorEntry FunctionDictionary::getTensor ( const CepsString label) const

Get a single tensor entry, const version.

Definition at line 447 of file FunctionDictionary.cpp.

◆ getTensor() [2/2]

const FunctionDictionary::TensorEntry FunctionDictionary::getTensor ( const CepsString label,
const TensorEntry  def 
) const

Get a single tensor entry, with default value, const version.

Definition at line 475 of file FunctionDictionary.cpp.

◆ getTensors()

const FunctionDictionary::TensorMap & FunctionDictionary::getTensors ( ) const

Get all tensor entries, const version.

Definition at line 421 of file FunctionDictionary.cpp.

◆ getVector() [1/2]

const FunctionDictionary::VectorEntry FunctionDictionary::getVector ( const CepsString label) const

Get a single vector entry, const version.

Definition at line 437 of file FunctionDictionary.cpp.

◆ getVector() [2/2]

const FunctionDictionary::VectorEntry FunctionDictionary::getVector ( const CepsString label,
const VectorEntry  def 
) const

Get a single vector entry, with default value, const version.

Definition at line 466 of file FunctionDictionary.cpp.

◆ getVectors()

const FunctionDictionary::VectorMap & FunctionDictionary::getVectors ( ) const

Get all vector entries, const version.

Definition at line 415 of file FunctionDictionary.cpp.

◆ hasInternal()

template<class _Result >
CepsBool FunctionDictionary::hasInternal ( const CepsString key,
const Map< _Result > &  map 
)
staticprivate

Internal inspecting method.

Definition at line 334 of file FunctionDictionary.hpp.

◆ hasScalar()

CepsBool FunctionDictionary::hasScalar ( const CepsString label) const

Tells if function "label" is registered.

Definition at line 387 of file FunctionDictionary.cpp.

◆ hasTensor()

CepsBool FunctionDictionary::hasTensor ( const CepsString label) const

Tells if function "label" is registered.

Definition at line 399 of file FunctionDictionary.cpp.

◆ hasVector()

CepsBool FunctionDictionary::hasVector ( const CepsString label) const

Tells if function "label" is registered.

Definition at line 393 of file FunctionDictionary.cpp.

◆ parseFunction()

FunctionDictionary::ScalarEntry FunctionDictionary::parseFunction ( const CepsString params)
private

Returns a pointer to a function deduced from the string parameters.

The function can be a product of time and space functions

Definition at line 517 of file FunctionDictionary.cpp.

◆ parseSpatialFunction()

FunctionDictionary::ScalarEntry FunctionDictionary::parseSpatialFunction ( const CepsVector< CepsString > &  params)
private

Returns a pointer to a function deduced from the string parameters.

Definition at line 591 of file FunctionDictionary.cpp.

◆ parseTimeFunction()

FunctionDictionary::ScalarEntry FunctionDictionary::parseTimeFunction ( const CepsVector< CepsString > &  params)
private

Returns a pointer to a function deduced from the string parameters.

Definition at line 572 of file FunctionDictionary.cpp.

Field Documentation

◆ m_address

CepsString FunctionDictionary::m_address = " See https://carmen.gitlabpages.inria.fr/ceps/syntax.html for details on syntax"
protected

A string that is displayed in error messages.

Definition at line 281 of file FunctionDictionary.hpp.

◆ m_doNotDelete

CepsSet<CepsString> FunctionDictionary::m_doNotDelete
protected

Functions that must not be deleted (created by alias)

Definition at line 278 of file FunctionDictionary.hpp.

◆ m_scalars

ScalarMap FunctionDictionary::m_scalars
protected

All scalar entries.

Definition at line 274 of file FunctionDictionary.hpp.

◆ m_tensors

TensorMap FunctionDictionary::m_tensors
protected

All tensor entries.

Definition at line 276 of file FunctionDictionary.hpp.

◆ m_vectors

VectorMap FunctionDictionary::m_vectors
protected

All vector entries.

Definition at line 275 of file FunctionDictionary.hpp.


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