Commit 10778cee authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov Committed by Dmitry Yu. Naumov
Browse files

[MPL] Add Property::value overload with vars.prev.

Some properties are implemented in incremental form and
require the previous time step value.
parent 9e4fedb5
......@@ -74,15 +74,21 @@ PropertyDataType Property::value() const
return value_;
}
/// The default implementation of this method only returns the property value
/// without altering it.
PropertyDataType Property::value(VariableArray const& /*variable_array*/,
VariableArray const& /*variable_array_prev*/,
ParameterLib::SpatialPosition const& /*pos*/,
double const /*t*/, double const /*dt*/) const
{
return value_;
}
PropertyDataType Property::value(VariableArray const& variable_array,
ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const
{
return value(variable_array, VariableArray{}, pos, t, dt);
}
/// The default implementation of this method only returns the
/// property value derivative without altering it.
PropertyDataType Property::dValue(VariableArray const& /*variable_array*/,
......
......@@ -54,8 +54,16 @@ public:
/// This virtual method simply returns the private value_ attribute without
/// changing it.
virtual PropertyDataType value() const;
/// This virtual method will compute the property value based on the primary
/// variables that are passed as arguments.
/// This virtual method will compute the property value based on the
/// variables that are passed as arguments and the variables from the
/// previous time step.
virtual PropertyDataType value(VariableArray const& variable_array,
VariableArray const& variable_array_prev,
ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const;
/// This virtual method will compute the property value based on the
/// variables that are passed as arguments with the default implementation
/// using empty variables array for the previous time step.
virtual PropertyDataType value(VariableArray const& variable_array,
ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const;
......@@ -116,6 +124,29 @@ public:
}
}
template <typename T>
T value(VariableArray const& variable_array,
VariableArray const& variable_array_prev,
ParameterLib::SpatialPosition const& pos, double const t,
double const dt) const
{
try
{
return std::get<T>(
value(variable_array, variable_array_prev, pos, t, dt));
}
catch (std::bad_variant_access const&)
{
OGS_FATAL(
"The value of {:s} is not of the requested type '{:s}' but a "
"{:s}.",
description(),
typeid(T).name(),
property_data_type_names_[value(variable_array,
variable_array_prev, pos, t, dt)
.index()]);
}
}
template <typename T>
T value(VariableArray const& variable_array,
ParameterLib::SpatialPosition const& pos, double const t,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment