24 #include <boost/foreach.hpp> 33 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,d``` and usual operators and functions." )
52 "The vector used to project evaluation point onto the surface.")
54 "The name of region set considered as the surface. You have to set surface region if you " 55 "want to use formula variable ```d```.")
62 template <
int spacedim,
class Value>
64 Input::register_class< FieldFormula<spacedim, Value>,
unsigned int >(
"FieldFormula") +
69 template <
int spacedim,
class Value>
72 formula_matrix_(this->value_.n_rows(), this->value_.n_cols()),
77 for(
unsigned int row=0; row < this->
value_.n_rows(); row++) {
84 template <
int spacedim,
class Value>
94 template <
int spacedim,
class Value>
98 bool any_parser_changed =
false;
104 std::string vars = string(
"x,y,z").substr(0, 2*spacedim-1);
107 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
108 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
112 FunctionParser tmp_parser;
113 tmp_parser.AddConstant(
"Pi", 3.14159265358979323846);
114 tmp_parser.AddConstant(
"E", 2.71828182845904523536);
117 #pragma GCC diagnostic push 118 #pragma GCC diagnostic ignored "-Wunused-variable" 120 int err=tmp_parser.ParseAndDeduceVariables(
formula_matrix_.
at(row,col), var_list);
121 ASSERT(err != FunctionParser::FP_NO_ERROR)(tmp_parser.ErrorMsg()).error(
"ParseAndDeduceVariables error\n");
123 #pragma GCC diagnostic pop 125 BOOST_FOREACH(std::string &var_name, var_list ) {
126 if (var_name == std::string(
"t") ) time_dependent[row*this->
value_.n_rows()+col]=
true;
127 else if (var_name == std::string(
"d") ) {
132 WarningOut().fmt(
"Unset surface region. Variable '{}' in the FieldFormula[{}][{}] == '{}' will be set to zero\n at the input address:\n {} \n",
135 else if (var_name ==
"x" || var_name ==
"y" || var_name ==
"z") {
140 WarningOut().fmt(
"Unknown variable '{}' in the FieldFormula[{}][{}] == '{}'\n at the input address:\n {} \n",
145 parser_matrix_[row][col].AddConstant(
"Pi", 3.14159265358979323846);
146 parser_matrix_[row][col].AddConstant(
"E", 2.71828182845904523536);
147 if (time_dependent[row*this->
value_.n_rows()+col]) {
153 vars += string(
",d");
156 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
157 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
165 if (
parser_matrix_[row][col].GetParseErrorType() != FunctionParser::FP_NO_ERROR ) {
166 xprintf(
UsrErr,
"ParserError: %s\n in the FieldFormula[%d][%d] == '%s'\n at the input address:\n %s \n",
169 value_input_address.c_str());
173 any_parser_changed =
true;
181 return any_parser_changed;
185 template <
int spacedim,
class Value>
188 std::string surface_region;
190 surface_depth_ = std::make_shared<SurfaceDepth>(mesh, surface_region,
in_rec_.
val<std::string>(
"surface_direction"));
198 template <
int spacedim,
class Value>
203 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
204 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
214 template <
int spacedim,
class Value>
220 for(
unsigned int i=0; i< point_list.
size(); i++) {
221 Value envelope(value_list[i]);
223 .error(
"value_list['i'] has wrong number of rows\n");
226 for(
unsigned int row=0; row < this->
value_.n_rows(); row++)
227 for(
unsigned int col=0; col < this->
value_.n_cols(); col++) {
234 template <
int spacedim,
class Value>
240 p_depth.subvec(0,spacedim-1) = p;
243 }
catch (SurfaceDepth::ExcTooLargeSnapDistance &e) {
244 e << SurfaceDepth::EI_FieldTime(this->
time_.
end());
255 template <
int spacedim,
class Value>
TimeStep time_
Actual time level; initial value is -infinity.
void init_unit_conversion_coefficient(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Init value of unit_conversion_coefficient_ from input.
unsigned int size() const
#define INSTANCE_ALL(field)
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
ArmaVec< Type, nr > vec(uint mat_index) const
Value::return_type r_value_
double unit_conversion_coefficient_
Coeficient of conversion of user-defined unit.
Space< spacedim >::Point Point
std::string & at(unsigned int row)
bool is_constant_in_space_
Flag detects that field is only dependent on time.
Value value_
Last value, prevents passing large values (vectors) by value.
#define WarningOut()
Macro defining 'warning' record of log.
Representation of one time step..
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)