18 #ifndef FIELD_FORMULA_IMPL_HH_ 19 #define FIELD_FORMULA_IMPL_HH_ 25 #include <boost/foreach.hpp> 34 template <
int spacedim, class Value>
41 "String, array of strings, or matrix of strings with formulas for individual " 42 "entries of scalar, vector, or tensor value respectively.\n" 43 "For vector values, you can use just one string to enter homogeneous vector.\n" 44 "For square (($N\\times N$))-matrix values, you can use:\n\n" 45 " - array of strings of size (($N$)) to enter diagonal matrix\n" 46 " - array of strings of size (($\\frac12N(N+1)$)) to enter symmetric matrix (upper triangle, row by row)\n" 47 " - just one string to enter (spatially variable) multiple of the unit matrix.\n" 48 "Formula can contain variables ```x,y,z,t``` and usual operators and functions." )
54 template <
int spacedim,
class Value>
56 Input::register_class< FieldFormula<spacedim, Value>,
unsigned int >(
"FieldFormula") +
61 template <
int spacedim,
class Value>
64 formula_matrix_(this->value_.n_rows(), this->value_.n_cols())
67 for(
unsigned int row=0; row < this->
value_.n_rows(); row++) {
74 template <
int spacedim,
class Value>
82 template <
int spacedim,
class Value>
86 bool any_parser_changed =
false;
89 std::string vars = string(
"x,y,z").substr(0, 2*spacedim-1);
91 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
92 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
96 FunctionParser tmp_parser;
97 #pragma GCC diagnostic push 98 #pragma GCC diagnostic ignored "-Wunused-variable" 100 int err=tmp_parser.ParseAndDeduceVariables(
formula_matrix_.
at(row,col), var_list);
101 OLD_ASSERT( err != FunctionParser::FP_NO_ERROR,
"ParseAndDeduceVariables error: %s\n", tmp_parser.ErrorMsg() );
103 #pragma GCC diagnostic pop 105 bool time_dependent =
false;
106 BOOST_FOREACH(std::string &var_name, var_list ) {
107 if (var_name == std::string(
"t") ) time_dependent=
true;
108 else if (var_name ==
"x" || var_name ==
"y" || var_name ==
"z")
continue;
110 xprintf(
Warn,
"Unknown variable '%s' in the FieldFormula[%d][%d] == '%s'\n at the input address:\n %s \n",
114 if (time_dependent) {
125 if (
parser_matrix_[row][col].GetParseErrorType() != FunctionParser::FP_NO_ERROR ) {
126 xprintf(
UsrErr,
"ParserError: %s\n in the FieldFormula[%d][%d] == '%s'\n at the input address:\n %s \n",
133 any_parser_changed =
true;
140 return any_parser_changed;
147 template <
int spacedim,
class Value>
150 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
151 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
161 template <
int spacedim,
class Value>
166 for(
unsigned int i=0; i< point_list.size(); i++) {
167 Value envelope(value_list[i]);
169 "value_list[%d] has wrong number of rows: %d; should match number of components: %d\n",
170 i, envelope.n_rows(),this->
value_.n_rows());
172 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
173 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
174 envelope(row,col) =
parser_matrix_[row][col].Eval(point_list[i].memptr());
180 template <
int spacedim,
class Value>
TimeStep time_
Actual time level; initial value is -infinity.
Value::return_type r_value_
Space< spacedim >::Point Point
std::string & at(unsigned int row)
Value value_
Last value, prevents passing large values (vectors) by value.
#define OLD_ASSERT_EQUAL(a, b)
Representation of one time step..
#define FLOW123D_FORCE_LINK_IN_CHILD(x)