Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
fields
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
"
13
#include "
fields/field_base.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
FieldBase
<spacedim, Value>
33
{
34
public
:
35
typedef
typename
FieldBase<spacedim, Value>::Point
Point
;
36
37
FieldFormula
(
unsigned
int
n_comp=0);
38
39
40
static
Input::Type::Record
input_type
;
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
virtual
bool
set_time(
double
time);
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,
60
std::vector<typename Value::return_type>
&value_list);
61
62
63
virtual
~
FieldFormula
();
64
65
private
:
66
// FieldValue_ wrapper for matrix of strings
67
typedef
FieldValue_<Value::NRows_, Value::NCols_, std::string>
StringValue
;
68
69
// StringValue::return_type == StringTensor, which behaves like arma::mat<string>
70
typename
StringValue::return_type
formula_matrix_
;
71
72
// FieldValue_ wrapper for unified reading of the input
73
StringValue
formula_matrix_helper_
;
74
75
// Matrix of parsers corresponding to the formula matrix returned by formula_matrix_helper_
76
std::vector< std::vector<FunctionParser>
>
parser_matrix_
;
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_ */
Generated on Thu May 29 2014 23:14:47 for Flow123d by
1.8.4