Flow123d  master-f44eb46
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
FieldFormula< spacedim, Value > Class Template Reference

#include <field_formula.hh>

Inheritance diagram for FieldFormula< spacedim, Value >:
Inheritance graph
[legend]
Collaboration diagram for FieldFormula< spacedim, Value >:
Collaboration graph
[legend]

Public Types

typedef FieldAlgorithmBase< spacedim, Value >::Point Point
 
typedef FieldAlgorithmBase< spacedim, ValueFactoryBaseType
 
- Public Types inherited from FieldAlgorithmBase< spacedim, Value >
typedef Space< spacedim >::Point Point
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_Field, std::string)
 
 DECLARE_INPUT_EXCEPTION (ExcNotDoubleField,<< "Can not use integer valued field "<< EI_Field::qval<< " in the formula: \n")
 
 TYPEDEF_ERR_INFO (EI_BParserMsg, std::string)
 
 TYPEDEF_ERR_INFO (EI_Formula, std::string)
 
 DECLARE_INPUT_EXCEPTION (ExcParserError,<< "Parsing in "<< EI_BParserMsg::val<< " in the formula: "<< EI_Formula::qval<< "\n")
 
 TYPEDEF_ERR_INFO (EI_FParserMsg, std::string)
 
 TYPEDEF_ERR_INFO (EI_Row, unsigned int)
 
 TYPEDEF_ERR_INFO (EI_Col, unsigned int)
 
 DECLARE_INPUT_EXCEPTION (ExcFParserError,<< "ParserError: "<< EI_FParserMsg::val<< "\n in the FieldFormula["<< EI_Row::val<< "]["<< EI_Row::val<< "] == "<< EI_Formula::qval<< " \n")
 
 FieldFormula (unsigned int n_comp=0)
 
virtual void init_from_input (const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
 
bool set_time (const TimeStep &time) override
 
void set_mesh (const Mesh *mesh) override
 
void cache_update (FieldValueCache< typename Value::element_type > &data_cache, ElementCacheMap &cache_map, unsigned int region_patch_idx) override
 
std::vector< const FieldCommon * > set_dependency (FieldSet &field_set) override
 
void cache_reinit (const ElementCacheMap &cache_map) override
 
virtual ~FieldFormula ()
 
- Public Member Functions inherited from FieldAlgorithmBase< spacedim, Value >
 TYPEDEF_ERR_INFO (EI_Field, std::string)
 
 DECLARE_EXCEPTION (ExcInputInitUnsupported,<< "The field "<< EI_Field::qval<< " do not support initialization from input.\n")
 
 FieldAlgorithmBase (unsigned int n_comp=0)
 
void set_component_idx (unsigned int idx)
 
unsigned int n_comp () const
 
FieldResult field_result () const
 
virtual double next_change_time ()
 
virtual void set_native_dh (std::shared_ptr< DOFHandlerMultiDim >)
 
bool is_constant_in_space () const
 
virtual std::vector< const FieldCommon * > set_dependency (FMT_UNUSED FieldSet &field_set)
 
virtual ~FieldAlgorithmBase ()
 

Static Public Member Functions

static const Input::Type::Recordget_input_type ()
 Implementation. More...
 
- Static Public Member Functions inherited from FieldAlgorithmBase< spacedim, Value >
static std::string template_name ()
 
static Input::Type::Abstractget_input_type ()
 
static const Input::Type::Instanceget_input_type_instance (Input::Type::Selection value_selection=Input::Type::Selection())
 
static const Input::Type::Recordget_field_algo_common_keys ()
 
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory (const Input::AbstractRecord &rec, const struct FieldAlgoBaseInitData &init_data)
 

Private Member Functions

arma::vec eval_depth_var (const Point &p)
 

Private Attributes

std::string formula_
 
bparser::Parser b_parser_
 
Input::Record in_rec_
 Accessor to Input::Record. More...
 
std::shared_ptr< SurfaceDepthsurface_depth_
 Surface depth object calculate distance from surface. More...
 
bool has_depth_var_
 Flag indicates if depth variable 'd' is used in formula - obsolete parameter of FParser. More...
 
bool has_time_
 Flag indicates if time variable 't' is used in formula - parameter of BParser. More...
 
uint sum_shape_sizes_
 Helper variable for construct of arena, holds sum of sizes (over shape) of all dependent fields. More...
 
bparser::ArenaAlloc * arena_alloc_
 Arena object providing data arrays. More...
 
double * X_
 Coordinates vector. More...
 
double * x_
 Coordinates x, part of previous array. More...
 
double * y_
 Coordinates y, part of previous array. More...
 
double * z_
 Coordinates z, part of previous array. More...
 
double * d_
 Surface depth variable, used optionally if 'd' variable is set. More...
 
double * res_
 Result vector of BParser. More...
 
uintsubsets_
 Subsets indices in range 0 ... n-1. More...
 
std::vector< const FieldCommon * > required_fields_
 
std::unordered_map< const FieldCommon *, double * > eval_field_data_
 

Static Private Attributes

static const int registrar
 Registrar of class to factory. More...
 

Additional Inherited Members

- Static Public Attributes inherited from FieldAlgorithmBase< spacedim, Value >
static const unsigned int spacedim_ =spacedim
 
static constexpr bool is_enum_valued = std::is_same<typename Value::element_type, FieldEnum>::value
 
- Protected Member Functions inherited from FieldAlgorithmBase< spacedim, Value >
void init_unit_conversion_coefficient (const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
 Init value of unit_conversion_coefficient_ from input. More...
 
- Protected Attributes inherited from FieldAlgorithmBase< spacedim, Value >
TimeStep time_
 Actual time level; initial value is -infinity. More...
 
Value value_
 Last value, prevents passing large values (vectors) by value. More...
 
Value::return_type r_value_
 
FieldResult field_result_
 Indicator of particular values (zero, one) constant over space. More...
 
unsigned int component_idx_
 Specify if the field is part of a MultiField and which component it is. More...
 
double unit_conversion_coefficient_
 Coeficient of conversion of user-defined unit. More...
 
bool is_constant_in_space_
 Flag detects that field is only dependent on time. More...
 

Detailed Description

template<int spacedim, class Value>
class FieldFormula< spacedim, Value >

Class representing fields given by runtime parsed formulas.

Using libraries: https://github.com/flow123d/bparser/

Allows parsing:

Definition at line 61 of file field_formula.hh.

Member Typedef Documentation

◆ FactoryBaseType

template<int spacedim, class Value >
typedef FieldAlgorithmBase<spacedim, Value> FieldFormula< spacedim, Value >::FactoryBaseType

Definition at line 65 of file field_formula.hh.

◆ Point

template<int spacedim, class Value >
typedef FieldAlgorithmBase<spacedim, Value>::Point FieldFormula< spacedim, Value >::Point

Definition at line 64 of file field_formula.hh.

Constructor & Destructor Documentation

◆ FieldFormula()

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::FieldFormula ( unsigned int  n_comp = 0)

Definition at line 74 of file field_formula.cc.

◆ ~FieldFormula()

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::~FieldFormula
virtual

Definition at line 280 of file field_formula.cc.

Member Function Documentation

◆ cache_reinit()

template<int spacedim, class Value >
void FieldFormula< spacedim, Value >::cache_reinit ( const ElementCacheMap cache_map)
overridevirtual

Overload FieldAlgorithmBase::cache_reinit

Reinit arena data member.

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 223 of file field_formula.cc.

◆ cache_update()

template<int spacedim, class Value >
void FieldFormula< spacedim, Value >::cache_update ( FieldValueCache< typename Value::element_type > &  data_cache,
ElementCacheMap cache_map,
unsigned int  region_patch_idx 
)
overridevirtual

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 115 of file field_formula.cc.

◆ DECLARE_INPUT_EXCEPTION() [1/3]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::DECLARE_INPUT_EXCEPTION ( ExcFParserError  )

◆ DECLARE_INPUT_EXCEPTION() [2/3]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::DECLARE_INPUT_EXCEPTION ( ExcNotDoubleField  ,
<< "Can not use integer valued field "<< EI_Field::qval<< " in the formula: \n"   
)

◆ DECLARE_INPUT_EXCEPTION() [3/3]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::DECLARE_INPUT_EXCEPTION ( ExcParserError  ,
<< "Parsing in "<< EI_BParserMsg::val<< " in the formula: "<< EI_Formula::qval<< "\n"   
)

◆ eval_depth_var()

template<int spacedim, class Value >
arma::vec FieldFormula< spacedim, Value >::eval_depth_var ( const Point p)
inlineprivate

Evaluate depth variable if it is contained in formula.

Return arma vec of point coordinates extended by depth value (or zero if depth is not contained.

Definition at line 160 of file field_formula.cc.

◆ get_input_type()

template<int spacedim, class Value >
const Input::Type::Record & FieldFormula< spacedim, Value >::get_input_type
static

Implementation.

Definition at line 38 of file field_formula.cc.

◆ init_from_input()

template<int spacedim, class Value >
void FieldFormula< spacedim, Value >::init_from_input ( const Input::Record rec,
const struct FieldAlgoBaseInitData init_data 
)
virtual

Function can provide way to initialize itself from the input data.

TODO: make protected, should be called through function factory

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 85 of file field_formula.cc.

◆ set_dependency()

template<int spacedim, class Value >
std::vector< const FieldCommon * > FieldFormula< spacedim, Value >::set_dependency ( FieldSet field_set)
override

Set reference of FieldSet.

Definition at line 180 of file field_formula.cc.

◆ set_mesh()

template<int spacedim, class Value >
void FieldFormula< spacedim, Value >::set_mesh ( const Mesh mesh)
overridevirtual

Create SurfaceDepth object if surface region is set.

See also description of the FieldBase<...>::set_mesh.

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 105 of file field_formula.cc.

◆ set_time()

template<int spacedim, class Value >
bool FieldFormula< spacedim, Value >::set_time ( const TimeStep time)
overridevirtual

For time dependent formulas returns always true. For time independent formulas returns true only for the first time.

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 95 of file field_formula.cc.

◆ TYPEDEF_ERR_INFO() [1/6]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_BParserMsg  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [2/6]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_Col  ,
unsigned int   
)

◆ TYPEDEF_ERR_INFO() [3/6]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_Field  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [4/6]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_Formula  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [5/6]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_FParserMsg  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [6/6]

template<int spacedim, class Value >
FieldFormula< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_Row  ,
unsigned int   
)

Member Data Documentation

◆ arena_alloc_

template<int spacedim, class Value >
bparser::ArenaAlloc* FieldFormula< spacedim, Value >::arena_alloc_
private

Arena object providing data arrays.

Definition at line 150 of file field_formula.hh.

◆ b_parser_

template<int spacedim, class Value >
bparser::Parser FieldFormula< spacedim, Value >::b_parser_
private

Definition at line 132 of file field_formula.hh.

◆ d_

template<int spacedim, class Value >
double* FieldFormula< spacedim, Value >::d_
private

Surface depth variable, used optionally if 'd' variable is set.

Definition at line 157 of file field_formula.hh.

◆ eval_field_data_

template<int spacedim, class Value >
std::unordered_map<const FieldCommon *, double *> FieldFormula< spacedim, Value >::eval_field_data_
private

Data of fields evaluated in expressions.

Temporary data member, we need to copy data from FieldValueCaches to arrays allocated in arena.

Definition at line 167 of file field_formula.hh.

◆ formula_

template<int spacedim, class Value >
std::string FieldFormula< spacedim, Value >::formula_
private

Definition at line 129 of file field_formula.hh.

◆ has_depth_var_

template<int spacedim, class Value >
bool FieldFormula< spacedim, Value >::has_depth_var_
private

Flag indicates if depth variable 'd' is used in formula - obsolete parameter of FParser.

Definition at line 141 of file field_formula.hh.

◆ has_time_

template<int spacedim, class Value >
bool FieldFormula< spacedim, Value >::has_time_
private

Flag indicates if time variable 't' is used in formula - parameter of BParser.

Definition at line 144 of file field_formula.hh.

◆ in_rec_

template<int spacedim, class Value >
Input::Record FieldFormula< spacedim, Value >::in_rec_
private

Accessor to Input::Record.

Definition at line 135 of file field_formula.hh.

◆ registrar

template<int spacedim, class Value >
const int FieldFormula< spacedim, Value >::registrar
staticprivate
Initial value:
=
Input::register_class< FieldFormula<spacedim, Value>, unsigned int >("FieldFormula") +

Registrar of class to factory.

Definition at line 170 of file field_formula.hh.

◆ required_fields_

template<int spacedim, class Value >
std::vector<const FieldCommon * > FieldFormula< spacedim, Value >::required_fields_
private

Definition at line 160 of file field_formula.hh.

◆ res_

template<int spacedim, class Value >
double* FieldFormula< spacedim, Value >::res_
private

Result vector of BParser.

Definition at line 158 of file field_formula.hh.

◆ subsets_

template<int spacedim, class Value >
uint* FieldFormula< spacedim, Value >::subsets_
private

Subsets indices in range 0 ... n-1.

Definition at line 159 of file field_formula.hh.

◆ sum_shape_sizes_

template<int spacedim, class Value >
uint FieldFormula< spacedim, Value >::sum_shape_sizes_
private

Helper variable for construct of arena, holds sum of sizes (over shape) of all dependent fields.

Definition at line 147 of file field_formula.hh.

◆ surface_depth_

template<int spacedim, class Value >
std::shared_ptr<SurfaceDepth> FieldFormula< spacedim, Value >::surface_depth_
private

Surface depth object calculate distance from surface.

Definition at line 138 of file field_formula.hh.

◆ X_

template<int spacedim, class Value >
double* FieldFormula< spacedim, Value >::X_
private

Coordinates vector.

Definition at line 153 of file field_formula.hh.

◆ x_

template<int spacedim, class Value >
double* FieldFormula< spacedim, Value >::x_
private

Coordinates x, part of previous array.

Definition at line 154 of file field_formula.hh.

◆ y_

template<int spacedim, class Value >
double* FieldFormula< spacedim, Value >::y_
private

Coordinates y, part of previous array.

Definition at line 155 of file field_formula.hh.

◆ z_

template<int spacedim, class Value >
double* FieldFormula< spacedim, Value >::z_
private

Coordinates z, part of previous array.

Definition at line 156 of file field_formula.hh.


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