Skip to content
Snippets Groups Projects
Commit aa436f77 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[ParL] Add time to possible function experssions.

parent c668bcaf
No related branches found
No related tags found
No related merge requests found
Mathematical expression of the function (currently x,y,z are supported variables). For non-scalar values, an expression should be given for each component.
Mathematical expression of the function (currently x,y,z, and t are supported variables). For non-scalar values, an expression should be given for each component.
......@@ -23,7 +23,7 @@ namespace ParameterLib
/// A parameter class evaluating functions defined by
/// user-provided mathematical expressions.
///
/// Currently, x, y, and z are supported as variables
/// Currently, x, y, z, and t are supported as variables
/// of the functions.
template <typename T>
struct FunctionParameter final : public Parameter<T>
......@@ -48,6 +48,7 @@ struct FunctionParameter final : public Parameter<T>
_symbol_table.create_variable("x");
_symbol_table.create_variable("y");
_symbol_table.create_variable("z");
_symbol_table.create_variable("t");
_vec_expression.resize(_vec_expression_str.size());
for (unsigned i = 0; i < _vec_expression_str.size(); i++)
......@@ -63,20 +64,21 @@ struct FunctionParameter final : public Parameter<T>
}
}
bool isTimeDependent() const override { return false; }
bool isTimeDependent() const override { return true; }
int getNumberOfComponents() const override
{
return _vec_expression.size();
}
std::vector<T> operator()(double const /*t*/,
std::vector<T> operator()(double const t,
SpatialPosition const& pos) const override
{
std::vector<T> cache(getNumberOfComponents());
auto& x = _symbol_table.get_variable("x")->ref();
auto& y = _symbol_table.get_variable("y")->ref();
auto& z = _symbol_table.get_variable("z")->ref();
auto& time = _symbol_table.get_variable("t")->ref();
if (!pos.getCoordinates())
{
OGS_FATAL(
......@@ -87,6 +89,7 @@ struct FunctionParameter final : public Parameter<T>
x = coords[0];
y = coords[1];
z = coords[2];
time = t;
for (unsigned i = 0; i < _vec_expression.size(); i++)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment