Commit 206e22fd authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov
Browse files

[MPL] Add variable array prev to dValue().

With default overload using empty VariableArray for the
previous timestep's values.
parent b87ea9d8
......@@ -89,9 +89,8 @@ PropertyDataType Property::value(VariableArray const& variable_array,
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*/,
VariableArray const& /*variable_array_prev*/,
Variable const /*variable*/,
ParameterLib::SpatialPosition const& /*pos*/,
double const /*t*/, double const /*dt*/) const
......@@ -99,6 +98,16 @@ PropertyDataType Property::dValue(VariableArray const& /*variable_array*/,
return dvalue_;
}
/// The default implementation of this method only returns the
/// property value derivative without altering it.
PropertyDataType Property::dValue(VariableArray const& variable_array,
Variable const variable,
ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const
{
return dValue(variable_array, VariableArray{}, variable, pos, t, dt);
}
/// Default implementation: 2nd derivative of any constant property is zero.
PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/,
Variable const /*variable*/,
......
......@@ -67,8 +67,17 @@ public:
virtual PropertyDataType value(VariableArray const& variable_array,
ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const;
/// This virtual method will compute the derivative of a property
/// with respect to the given variable pv.
/// This virtual method will compute the property derivative value based on
/// the variables that are passed as arguments and the variables from the
/// previous time step.
virtual PropertyDataType dValue(VariableArray const& variable_array,
VariableArray const& variable_array_prev,
Variable const variable,
ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const;
/// This virtual method will compute the property derivative 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 dValue(VariableArray const& variable_array,
Variable const variable,
ParameterLib::SpatialPosition const& pos,
......@@ -168,6 +177,28 @@ public:
}
}
template <typename T>
T dValue(VariableArray const& variable_array,
VariableArray const& variable_array_prev, Variable const variable,
ParameterLib::SpatialPosition const& pos, double const t,
double const dt) const
{
try
{
return std::get<T>(dValue(variable_array, variable_array_prev,
variable, pos, t, dt));
}
catch (std::bad_variant_access const&)
{
OGS_FATAL(
"The first derivative value of {:s} is not of the requested "
"type '{:s}' but a {:s}.",
description(),
typeid(T).name(),
property_data_type_names_
[dValue(variable_array, variable, pos, t, dt).index()]);
}
}
template <typename T>
T dValue(VariableArray const& variable_array, Variable const variable,
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