From 267f58bc3d5d3f4c174226d48c4d2f047f5573f7 Mon Sep 17 00:00:00 2001 From: Norbert Grunwald <Norbert.Grunwald@ufz.de> Date: Tue, 27 Aug 2019 06:01:41 +0200 Subject: [PATCH] pos and time passed to d2Value --- .../MPL/Properties/ExponentialProperty.cpp | 5 ++-- .../MPL/Properties/ExponentialProperty.h | 4 +++- MaterialLib/MPL/Properties/LinearProperty.cpp | 4 +++- MaterialLib/MPL/Properties/LinearProperty.h | 15 ++++++------ .../MPL/Properties/ParameterProperty.cpp | 4 +++- .../MPL/Properties/ParameterProperty.h | 9 +++---- MaterialLib/MPL/Property.cpp | 8 ++++--- MaterialLib/MPL/Property.h | 24 ++++++++++--------- .../TestMPLExponentialProperty.cpp | 7 +++--- Tests/MaterialLib/TestMPLLinearProperty.cpp | 5 ++-- 10 files changed, 47 insertions(+), 38 deletions(-) diff --git a/MaterialLib/MPL/Properties/ExponentialProperty.cpp b/MaterialLib/MPL/Properties/ExponentialProperty.cpp index c58847e5ef1..cbd1e2e1d0d 100644 --- a/MaterialLib/MPL/Properties/ExponentialProperty.cpp +++ b/MaterialLib/MPL/Properties/ExponentialProperty.cpp @@ -52,9 +52,8 @@ PropertyDataType ExponentialProperty::dValue( } PropertyDataType ExponentialProperty::d2Value( - VariableArray const& variable_array, - Variable const pv1, - Variable const pv2) const + VariableArray const& variable_array, Variable const pv1, Variable const pv2, + ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/) const { return _exponent_data.type == pv1 && _exponent_data.type == pv2 ? std::get<double>(_value) * diff --git a/MaterialLib/MPL/Properties/ExponentialProperty.h b/MaterialLib/MPL/Properties/ExponentialProperty.h index 6a43c100b9c..9c2c9a53432 100644 --- a/MaterialLib/MPL/Properties/ExponentialProperty.h +++ b/MaterialLib/MPL/Properties/ExponentialProperty.h @@ -51,7 +51,9 @@ public: /// property with respect to the given primary variables pv1 and pv2. PropertyDataType d2Value(VariableArray const& variable_array, Variable const pv1, - Variable const pv2) const override; + Variable const pv2, + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const override; private: ExponentData const _exponent_data; diff --git a/MaterialLib/MPL/Properties/LinearProperty.cpp b/MaterialLib/MPL/Properties/LinearProperty.cpp index a8cbbd3a3aa..b288a1a0932 100644 --- a/MaterialLib/MPL/Properties/LinearProperty.cpp +++ b/MaterialLib/MPL/Properties/LinearProperty.cpp @@ -48,7 +48,9 @@ PropertyDataType LinearProperty::dValue( PropertyDataType LinearProperty::d2Value( VariableArray const& /*variable_array*/, Variable const /*pv1*/, - Variable const /*pv2*/) const + Variable const /*pv2*/, + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const { return decltype(_value){}; } diff --git a/MaterialLib/MPL/Properties/LinearProperty.h b/MaterialLib/MPL/Properties/LinearProperty.h index 6c0a9ef3213..49674792a9b 100644 --- a/MaterialLib/MPL/Properties/LinearProperty.h +++ b/MaterialLib/MPL/Properties/LinearProperty.h @@ -15,12 +15,11 @@ namespace MaterialPropertyLib { - struct IndependentVariable { Variable type; - VariableType reference_condition; // scalar or vector - VariableType slope; // scalar or matrix + VariableType reference_condition; // scalar or vector + VariableType slope; // scalar or matrix }; /// The linear property class. This property calculates the linear relationship. @@ -45,14 +44,16 @@ public: /// the given primary variable. PropertyDataType dValue(VariableArray const& variable_array, Variable const primary_variable, - ParameterLib::SpatialPosition const& /*pos*/, - double const /*t*/) const override; - + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const override; + /// This method will compute the second derivative of a /// property with respect to the given primary variables pv1 and pv2. PropertyDataType d2Value(VariableArray const& variable_array, Variable const pv1, - Variable const pv2) const override; + Variable const pv2, + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const override; private: IndependentVariable const _independent_variable; diff --git a/MaterialLib/MPL/Properties/ParameterProperty.cpp b/MaterialLib/MPL/Properties/ParameterProperty.cpp index 18ead32d3a2..c60ced6c0e0 100644 --- a/MaterialLib/MPL/Properties/ParameterProperty.cpp +++ b/MaterialLib/MPL/Properties/ParameterProperty.cpp @@ -39,7 +39,9 @@ PropertyDataType ParameterProperty::dValue( PropertyDataType ParameterProperty::d2Value( VariableArray const& /*variable_array*/, Variable const /*pv1*/, - Variable const /*pv2*/) const + Variable const /*pv2*/, + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const { return double{}; } diff --git a/MaterialLib/MPL/Properties/ParameterProperty.h b/MaterialLib/MPL/Properties/ParameterProperty.h index ae42ead8232..8e00afddf7f 100644 --- a/MaterialLib/MPL/Properties/ParameterProperty.h +++ b/MaterialLib/MPL/Properties/ParameterProperty.h @@ -17,7 +17,6 @@ namespace MaterialPropertyLib { - /// The parameter property class. The property reads the value from a parameter. /// The current implementation accepts only the double datatype defined in /// PropertyDataType. @@ -37,13 +36,15 @@ public: /// the given primary variable. PropertyDataType dValue(VariableArray const& variable_array, Variable const primary_variable, - ParameterLib::SpatialPosition const& /*pos*/, - double const /*t*/) const override; + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const override; /// This method will compute the second derivative of a /// property with respect to the given primary variables pv1 and pv2. PropertyDataType d2Value(VariableArray const& variable_array, Variable const pv1, - Variable const pv2) const override; + Variable const pv2, + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const override; private: ParameterLib::Parameter<double> const& _parameter; diff --git a/MaterialLib/MPL/Property.cpp b/MaterialLib/MPL/Property.cpp index 9892ba51435..e6fcfaf4df2 100644 --- a/MaterialLib/MPL/Property.cpp +++ b/MaterialLib/MPL/Property.cpp @@ -36,8 +36,8 @@ PropertyDataType Property::value(VariableArray const& /*variable_array*/, /// property value derivative without altering it. PropertyDataType Property::dValue(VariableArray const& /*variable_array*/, Variable const /*variable*/, - ParameterLib::SpatialPosition const& /*pos*/, - double const /*t*/) const + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const { return _dvalue; } @@ -45,7 +45,9 @@ PropertyDataType Property::dValue(VariableArray const& /*variable_array*/, /// Default implementation: 2nd derivative of any constant property is zero. PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/, Variable const /*variable*/, - Variable const /*variable*/) const + Variable const /*variable*/, + ParameterLib::SpatialPosition const& /*pos*/, + double const /*t*/) const { return 0.0; } diff --git a/MaterialLib/MPL/Property.h b/MaterialLib/MPL/Property.h index 8368560ec64..6c102e369b9 100644 --- a/MaterialLib/MPL/Property.h +++ b/MaterialLib/MPL/Property.h @@ -39,8 +39,8 @@ enum PropertyDataTypeName nTensor }; -using PropertyDataType = std:: - variant<double, Pair, Vector, Tensor2d, SymmTensor, Tensor, std::string>; +using PropertyDataType = std::variant<double, Pair, Vector, Tensor2d, + SymmTensor, Tensor, std::string>; /// This class is the base class for any material property of any /// scale (i.e. components, phases, media, ...). The single value of @@ -66,13 +66,15 @@ public: /// with respect to the given variable pv. virtual PropertyDataType dValue(VariableArray const& variable_array, Variable const variable, - ParameterLib::SpatialPosition const& pos, - double const t) const; + ParameterLib::SpatialPosition const& pos, + double const t) const; /// This virtual method will compute the second derivative of a /// property with respect to the given variables pv1 and pv2. virtual PropertyDataType d2Value(VariableArray const& variable_array, Variable const variable1, - Variable const variable2) const; + Variable const variable2, + ParameterLib::SpatialPosition const& pos, + double const t) const; virtual void setScale( std::variant<Medium*, Phase*, Component*> /*scale_pointer*/){}; @@ -92,17 +94,17 @@ public: template <typename T> T dValue(VariableArray const& variable_array, Variable const variable, - ParameterLib::SpatialPosition const& pos, - double const t) const + ParameterLib::SpatialPosition const& pos, double const t) const { return std::get<T>(dValue(variable_array, variable, pos, t)); } template <typename T> - T d2Value(VariableArray const& variable_array, - Variable const& variable1, - Variable const& variable2) const + T d2Value(VariableArray const& variable_array, Variable const& variable1, + Variable const& variable2, + ParameterLib::SpatialPosition const& pos, double const t) const { - return std::get<T>(d2Value(variable_array, variable1, variable2)); + return std::get<T>( + d2Value(variable_array, variable1, variable2, pos, t)); } protected: diff --git a/Tests/MaterialLib/TestMPLExponentialProperty.cpp b/Tests/MaterialLib/TestMPLExponentialProperty.cpp index b32406083a7..341b505071e 100644 --- a/Tests/MaterialLib/TestMPLExponentialProperty.cpp +++ b/Tests/MaterialLib/TestMPLExponentialProperty.cpp @@ -49,10 +49,9 @@ TEST(MaterialPropertyLib, ExponentialProperty) reference_condition)), 1.e-16); ASSERT_NEAR( - std::get<double>( - exp_property.d2Value(variable_array, - MaterialPropertyLib::Variable::temperature, - MaterialPropertyLib::Variable::temperature)), + std::get<double>(exp_property.d2Value( + variable_array, MaterialPropertyLib::Variable::temperature, + MaterialPropertyLib::Variable::temperature, pos, time)), y_ref * std::pow(factor, 2) * std::exp(-factor * (std::get<double>(variable_array[static_cast<int>( diff --git a/Tests/MaterialLib/TestMPLLinearProperty.cpp b/Tests/MaterialLib/TestMPLLinearProperty.cpp index c9a2fc63bfa..b4d8ee9f773 100644 --- a/Tests/MaterialLib/TestMPLLinearProperty.cpp +++ b/Tests/MaterialLib/TestMPLLinearProperty.cpp @@ -41,9 +41,8 @@ TEST(MaterialPropertyLib, LinearProperty) pos, time)), y_ref * m, 1.e-16); ASSERT_EQ(std::get<double>(linear_property.d2Value( - variable_array, - MaterialPropertyLib::Variable::temperature, - MaterialPropertyLib::Variable::temperature)), + variable_array, MaterialPropertyLib::Variable::temperature, + MaterialPropertyLib::Variable::temperature, pos, time)), 0.0); } -- GitLab