From 72b380a03a35874ce005603ca8ad0d3ec6a7efed Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Thu, 15 Aug 2019 11:05:01 +0200
Subject: [PATCH] [MPL] Impl. of ParameterProperty.

---
 .../MPL/Properties/ParameterProperty.cpp      | 45 +++++++++++++++++
 .../MPL/Properties/ParameterProperty.h        | 49 +++++++++++++++++++
 MaterialLib/MPL/Properties/Properties.h       |  1 +
 3 files changed, 95 insertions(+)
 create mode 100644 MaterialLib/MPL/Properties/ParameterProperty.cpp
 create mode 100644 MaterialLib/MPL/Properties/ParameterProperty.h

diff --git a/MaterialLib/MPL/Properties/ParameterProperty.cpp b/MaterialLib/MPL/Properties/ParameterProperty.cpp
new file mode 100644
index 00000000000..5406b62396c
--- /dev/null
+++ b/MaterialLib/MPL/Properties/ParameterProperty.cpp
@@ -0,0 +1,45 @@
+/**
+ * \file
+ *
+ * \copyright
+ * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#include "MaterialLib/MPL/Properties/ParameterProperty.h"
+
+namespace MaterialPropertyLib
+{
+ParameterProperty::ParameterProperty(
+    ParameterLib::Parameter<double> const& parameter)
+    : _parameter(parameter)
+{
+}
+
+PropertyDataType ParameterProperty::value(
+    VariableArray const& /*variable_array*/,
+    ParameterLib::SpatialPosition const& pos,
+    double const t) const
+{
+    return _parameter(t, pos)[0];
+}
+
+PropertyDataType ParameterProperty::dValue(
+    VariableArray const& /*variable_array*/,
+    Variable const /*primary_variable*/) const
+{
+    return double{};
+}
+
+PropertyDataType ParameterProperty::d2Value(
+    VariableArray const& /*variable_array*/,
+    Variable const /*pv1*/,
+    Variable const /*pv2*/) const
+{
+    return double{};
+}
+
+}  // namespace MaterialPropertyLib
diff --git a/MaterialLib/MPL/Properties/ParameterProperty.h b/MaterialLib/MPL/Properties/ParameterProperty.h
new file mode 100644
index 00000000000..923e8d52683
--- /dev/null
+++ b/MaterialLib/MPL/Properties/ParameterProperty.h
@@ -0,0 +1,49 @@
+/**
+ * \file
+ *
+ * \copyright
+ * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+#pragma once
+
+#include "MaterialLib/MPL/Property.h"
+#include "MaterialLib/MPL/VariableType.h"
+
+#include "ParameterLib/Parameter.h"
+
+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.
+class ParameterProperty final : public Property
+{
+public:
+    /// This constructor accepts a Parameter.
+    ParameterProperty(ParameterLib::Parameter<double> const& parameter);
+
+    /// This method computes the value of a property depending linearly on
+    /// the value of the given primary variable.
+    PropertyDataType value(VariableArray const& variable_array,
+                           ParameterLib::SpatialPosition const& pos,
+                           double const t) const override;
+
+    /// This method will compute the derivative of a property with respect to
+    /// the given primary variable.
+    PropertyDataType dValue(VariableArray const& variable_array,
+                            Variable const primary_variable) 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;
+
+private:
+    ParameterLib::Parameter<double> const& _parameter;
+};
+}  // namespace MaterialPropertyLib
diff --git a/MaterialLib/MPL/Properties/Properties.h b/MaterialLib/MPL/Properties/Properties.h
index 0d4ca2876b3..0928c348415 100644
--- a/MaterialLib/MPL/Properties/Properties.h
+++ b/MaterialLib/MPL/Properties/Properties.h
@@ -15,3 +15,4 @@
 #include "Constant.h"
 #include "LinearProperty.h"
 #include "ExponentialProperty.h"
+#include "ParameterProperty.h"
-- 
GitLab