diff --git a/MaterialLib/MPL/Properties/ExponentialProperty.cpp b/MaterialLib/MPL/Properties/ExponentialProperty.cpp index c58847e5ef1054dc92b566989be040bb4804574f..cbd1e2e1d0d39f5bb2f8b7db880991bb6ca0d681 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 6a43c100b9cd988e4bbdfae61d34ca175e400feb..9c2c9a53432750030272fe682990c8d0c3f0a992 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 a8cbbd3a3aaa82213a764144f6bc43a8303fcad8..b288a1a0932b96fa47748c7ecb886e52bd8dd698 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 6c0a9ef3213013272b9a34976ecda22f5d265d6f..49674792a9bcd154cc0e523553ef59ab8c2a0ac1 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 18ead32d3a268c782c75970803624ae23a36bfd7..c60ced6c0e0273ac801b190fc3f88a9f3ab4b302 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 ae42ead82320e179498662074136060ba54dda5b..8e00afddf7f2dba779a7b3904f9e18b70a7d785e 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 9892ba5143512f9d1f89170d71f5a9da8fe7245b..e6fcfaf4df2a34eb32312284c0c5e925d58005d3 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 8368560ec6433e1c97d43cc1deea33c3e65b34c3..6c102e369b9766d474515c05e2d1b51bffe06ee7 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 b32406083a770f9bcd627b4b47019ecfbc6d8552..341b505071e538bfc35b4d05069cf8a6128271cf 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 c9a2fc63bfa3ffd215a45b1c78dc02fd099962b2..b4d8ee9f773887ba7cce65db635f2a4781db493a 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); }