Flow123d  jenkins-Flow123d-linux-release-multijob-282
field_formula.hh
Go to the documentation of this file.
1 /*
2  * field_formula.hh
3  *
4  * Created on: Jan 2, 2013
5  * Author: jb
6  */
7 
8 #ifndef FIELD_FORMULA_HH_
9 #define FIELD_FORMULA_HH_
10 
11 
12 #include "system/system.hh"
14 #include "mesh/point.hh"
15 
16 #include <string>
17 using namespace std;
18 
19 class FunctionParser;
20 
21 /**
22  * Class representing fields given by runtime parsed formulas.
23  *
24  * Using library:
25  * http://warp.povusers.org/FunctionParser/
26  *
27  * TODO:
28  * correct support for discrete functions (use integer parser), actually we just convert double to int
29  *
30  */
31 template <int spacedim, class Value>
32 class FieldFormula : public FieldAlgorithmBase<spacedim, Value>
33 {
34 public:
36 
37  FieldFormula(unsigned int n_comp=0);
38 
39 
41 
42  static Input::Type::Record get_input_type(Input::Type::AbstractRecord &a_type, const typename Value::ElementInputType *eit);
43 
44  virtual void init_from_input(const Input::Record &rec);
45 
46  /**
47  * For time dependent formulas returns always true. For time independent formulas returns true only for the first time.
48  */
49  bool set_time(const TimeStep &time) override;
50 
51  /**
52  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
53  */
54  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
55 
56  /**
57  * Returns std::vector of scalar values in several points at once.
58  */
59  virtual void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
61 
62 
63  virtual ~FieldFormula();
64 
65 private:
66  // FieldValue_ wrapper for matrix of strings
68 
69  // StringValue::return_type == StringTensor, which behaves like arma::mat<string>
71 
72  // FieldValue_ wrapper for unified reading of the input
74 
75  // Matrix of parsers corresponding to the formula matrix returned by formula_matrix_helper_
77 
78  // Full address of the FiledFormula 'value' key.
79  // Necessary in the case of an error during parsing.
80  std::string value_input_address_;
81 
82 };
83 
84 
85 
86 #endif /* FIELD_FORMULA_HH_ */
std::string value_input_address_
internal::ReturnType< NRows, NCols, ET >::return_type return_type
FieldAlgorithmBase< spacedim, Value >::Point Point
StringValue::return_type formula_matrix_
FieldValue_< Value::NRows_, Value::NCols_, std::string > StringValue
static Input::Type::Record input_type
Implementation.
Accessor to the data with type Type::Record.
Definition: accessors.hh:327
Class for declaration of polymorphic Record.
Definition: type_record.hh:487
Space< spacedim >::Point Point
StringValue formula_matrix_helper_
std::vector< std::vector< FunctionParser > > parser_matrix_
Record type proxy class.
Definition: type_record.hh:169
Representation of one time step.