diff --git a/Documentation/ProjectFile/prj/parameters/parameter/Function/t_expression.md b/Documentation/ProjectFile/prj/parameters/parameter/Function/t_expression.md index fee5201f0277819181e7b981cd40fb692704997e..f9eaacbf26b6efa4cedc4acaa0d3cc050bd96ea7 100644 --- a/Documentation/ProjectFile/prj/parameters/parameter/Function/t_expression.md +++ b/Documentation/ProjectFile/prj/parameters/parameter/Function/t_expression.md @@ -1 +1 @@ -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. diff --git a/ParameterLib/FunctionParameter.h b/ParameterLib/FunctionParameter.h index fbacd6cf6e8533f1ddc4edba09b030f636a428a2..812fdeac365dfe348e6f4079bf2c813b9547ac73 100644 --- a/ParameterLib/FunctionParameter.h +++ b/ParameterLib/FunctionParameter.h @@ -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++) {