From 17ed97a473f2831c8e1293e0174b8dd919dc1741 Mon Sep 17 00:00:00 2001
From: Norbert Grunwald <Norbert.Grunwald@ufz.de>
Date: Tue, 10 Sep 2019 09:09:48 +0200
Subject: [PATCH] extract Exponential Propety create method

---
 MaterialLib/MPL/CreateProperty.cpp            | 29 +---------
 .../Properties/CreateExponentialProperty.cpp  | 54 +++++++++++++++++++
 .../Properties/CreateExponentialProperty.h    | 30 +++++++++++
 MaterialLib/MPL/Properties/CreateProperties.h |  1 +
 4 files changed, 86 insertions(+), 28 deletions(-)
 create mode 100644 MaterialLib/MPL/Properties/CreateExponentialProperty.cpp
 create mode 100644 MaterialLib/MPL/Properties/CreateExponentialProperty.h

diff --git a/MaterialLib/MPL/CreateProperty.cpp b/MaterialLib/MPL/CreateProperty.cpp
index ec6edcbdb25..955c9573188 100644
--- a/MaterialLib/MPL/CreateProperty.cpp
+++ b/MaterialLib/MPL/CreateProperty.cpp
@@ -48,34 +48,7 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty(
 
     if (property_type == "Exponential")
     {
-        auto const reference_value =
-            //! \ogs_file_param{properties__property__ExponentialProperty__reference_value}
-            config.getConfigParameter<double>("reference_value");
-
-        auto const& exponent_data_config =
-            //! \ogs_file_param{properties__property__ExponentialProperty__exponent}
-            config.getConfigSubtree("exponent");
-
-        auto const& variable_name =
-            //! \ogs_file_param{properties__property__ExponentialProperty__exponent__variable_name}
-            exponent_data_config.getConfigParameter<std::string>(
-                "variable_name");
-        auto const reference_condition =
-            //! \ogs_file_param{properties__property__ExponentialProperty__exponent__reference_condition}
-            exponent_data_config.getConfigParameter<double>(
-                "reference_condition");
-        auto const factor =
-            //! \ogs_file_param{properties__property__ExponentialProperty__exponent__factor}
-            exponent_data_config.getConfigParameter<double>("factor");
-
-        MaterialPropertyLib::Variable exp_data_type =
-            MaterialPropertyLib::convertStringToVariable(variable_name);
-
-        MaterialPropertyLib::ExponentData const exp_data{
-            exp_data_type, reference_condition, factor};
-
-        return std::make_unique<MaterialPropertyLib::ExponentialProperty>(
-            reference_value, exp_data);
+        return createExponentialProperty(config);
     }
 
     if (property_type == "Parameter")
diff --git a/MaterialLib/MPL/Properties/CreateExponentialProperty.cpp b/MaterialLib/MPL/Properties/CreateExponentialProperty.cpp
new file mode 100644
index 00000000000..262bf0b702b
--- /dev/null
+++ b/MaterialLib/MPL/Properties/CreateExponentialProperty.cpp
@@ -0,0 +1,54 @@
+/**
+ * \file
+ * \author Norbert Grunwald
+ * \date   Sep 10, 2019
+ *
+ * \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 "BaseLib/ConfigTree.h"
+#include "ExponentialProperty.h"
+
+namespace MaterialPropertyLib
+{
+std::unique_ptr<ExponentialProperty> createExponentialProperty(
+    BaseLib::ConfigTree const& config)
+{
+    config.checkConfigParameter("type", "Exponential");
+    DBUG("Create Exponential property");
+        auto const reference_value =
+            //! \ogs_file_param{properties__property__ExponentialProperty__reference_value}
+            config.getConfigParameter<double>("reference_value");
+
+        auto const& exponent_data_config =
+            //! \ogs_file_param{properties__property__ExponentialProperty__exponent}
+            config.getConfigSubtree("exponent");
+
+        auto const& variable_name =
+            //! \ogs_file_param{properties__property__ExponentialProperty__exponent__variable_name}
+            exponent_data_config.getConfigParameter<std::string>(
+                "variable_name");
+        auto const reference_condition =
+            //! \ogs_file_param{properties__property__ExponentialProperty__exponent__reference_condition}
+            exponent_data_config.getConfigParameter<double>(
+                "reference_condition");
+        auto const factor =
+            //! \ogs_file_param{properties__property__ExponentialProperty__exponent__factor}
+            exponent_data_config.getConfigParameter<double>("factor");
+
+        MaterialPropertyLib::Variable exp_data_type =
+            MaterialPropertyLib::convertStringToVariable(variable_name);
+
+        MaterialPropertyLib::ExponentData const exp_data{
+            exp_data_type, reference_condition, factor};
+
+        return std::make_unique<MaterialPropertyLib::ExponentialProperty>(
+            reference_value, exp_data);
+
+}
+}  // namespace MaterialPropertyLib
\ No newline at end of file
diff --git a/MaterialLib/MPL/Properties/CreateExponentialProperty.h b/MaterialLib/MPL/Properties/CreateExponentialProperty.h
new file mode 100644
index 00000000000..78ddf7f5dd2
--- /dev/null
+++ b/MaterialLib/MPL/Properties/CreateExponentialProperty.h
@@ -0,0 +1,30 @@
+/**
+ * \file
+ * \author Norbert Grunwald
+ * \date   Sep 10, 2019
+ *
+ * \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
+
+namespace BaseLib
+{
+class ConfigTree;
+}
+
+namespace MaterialPropertyLib
+{
+class ExponentialProperty;
+}
+
+namespace MaterialPropertyLib
+{
+std::unique_ptr<ExponentialProperty> createExponentialProperty(
+    BaseLib::ConfigTree const& config);
+}  // namespace MaterialPropertyLib
\ No newline at end of file
diff --git a/MaterialLib/MPL/Properties/CreateProperties.h b/MaterialLib/MPL/Properties/CreateProperties.h
index 400ceb1eaf7..51952c4bafd 100644
--- a/MaterialLib/MPL/Properties/CreateProperties.h
+++ b/MaterialLib/MPL/Properties/CreateProperties.h
@@ -13,5 +13,6 @@
 #pragma once
 
 #include "CreateConstant.h"
+#include "CreateExponentialProperty.h"
 #include "CreateIdealGasLaw.h"
 #include "CreateLinearProperty.h"
-- 
GitLab