From cbfaf37c5fe60b60220686b1598910f9287da1f1 Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Fri, 5 Jun 2020 17:20:46 +0200
Subject: [PATCH] [MPL] added createPermeabilityMohrCoulombFailureIndexModel

---
 MaterialLib/MPL/CreateProperty.cpp            |  9 +-
 ...rmeabilityMohrCoulombFailureIndexModel.cpp | 83 +++++++++++++++++++
 ...PermeabilityMohrCoulombFailureIndexModel.h | 40 +++++++++
 MaterialLib/MPL/Properties/CreateProperties.h |  1 +
 4 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.cpp
 create mode 100644 MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.h

diff --git a/MaterialLib/MPL/CreateProperty.cpp b/MaterialLib/MPL/CreateProperty.cpp
index c91ee91a2c8..bea2a9af967 100644
--- a/MaterialLib/MPL/CreateProperty.cpp
+++ b/MaterialLib/MPL/CreateProperty.cpp
@@ -27,7 +27,7 @@
 namespace
 {
 std::unique_ptr<MaterialPropertyLib::Property> createProperty(
-    int const /*geometry_dimension*/,
+    int const geometry_dimension,
     BaseLib::ConfigTree const& config,
     std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
     ParameterLib::CoordinateSystem const* const local_coordinate_system,
@@ -73,6 +73,13 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty(
         return createIdealGasLaw(config);
     }
 
+    if (boost::iequals(property_type,
+                       "PermeabilityMohrCoulombFailureIndexModel"))
+    {
+        return createPermeabilityMohrCoulombFailureIndexModel(
+            geometry_dimension, config, parameters, local_coordinate_system);
+    }
+
     if (boost::iequals(property_type, "PermeabilityOrthotropicPowerLaw"))
     {
         return createPermeabilityOrthotropicPowerLaw(config,
diff --git a/MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.cpp b/MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.cpp
new file mode 100644
index 00000000000..1b2037ed5de
--- /dev/null
+++ b/MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.cpp
@@ -0,0 +1,83 @@
+/**
+ * \file
+ * \copyright
+ * Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ * Created on June 5, 2020, 9:07 AM
+ */
+
+#include "CreatePermeabilityMohrCoulombFailureIndexModel.h"
+
+#include <string>
+
+#include "BaseLib/ConfigTree.h"
+#include "Parameter.h"
+#include "ParameterLib/CoordinateSystem.h"
+#include "ParameterLib/Parameter.h"
+#include "ParameterLib/Utils.h"
+#include "PermeabilityMohrCoulombFailureIndexModel.h"
+
+namespace MaterialPropertyLib
+{
+std::unique_ptr<Property> createPermeabilityMohrCoulombFailureIndexModel(
+    int const geometry_dimension,
+    BaseLib::ConfigTree const& config,
+    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
+    ParameterLib::CoordinateSystem const* const local_coordinate_system)
+{
+    if ((geometry_dimension != 2) && (geometry_dimension != 3))
+    {
+        OGS_FATAL(
+            "The PermeabilityMohrCoulombFailureIndexModel is implemented only "
+            "for 2D or 3D problems");
+    }
+
+    //! \ogs_file_param{properties__property__type}
+    config.checkConfigParameter("type",
+                                "PermeabilityMohrCoulombFailureIndexModel");
+
+    // Second access for storage.
+    //! \ogs_file_param{properties__property__name}
+    auto property_name = config.peekConfigParameter<std::string>("name");
+
+    DBUG("Create PermeabilityMohrCoulombFailureIndexModel property {:s}.",
+         property_name);
+
+    std::string const& parameter_name =
+        //! \ogs_file_param{properties__property__PermeabilityMohrCoulombFailureIndexModel__initial_permeability}
+        config.getConfigParameter<std::string>(
+            "initial_permeability");
+    auto const& parameter_k0 = ParameterLib::findParameter<double>(
+        parameter_name, parameters, 0, nullptr);
+
+    auto const kr =
+        //! \ogs_file_param{properties__property__PermeabilityMohrCoulombFailureIndexModel__reference_permeability}
+        config.getConfigParameter<double>("reference_permeability");
+    auto const b =
+        //! \ogs_file_param{properties__property__PermeabilityMohrCoulombFailureIndexModel__fitting_factor}
+        config.getConfigParameter<double>("fitting_factor");
+    auto const c =
+        //! \ogs_file_param{properties__property__PermeabilityMohrCoulombFailureIndexModel__cohesion}
+        config.getConfigParameter<double>("cohesion");
+    auto const phi =
+        //! \ogs_file_param{properties__property__PermeabilityMohrCoulombFailureIndexModel__friction_angle}
+        config.getConfigParameter<double>("friction_angle");
+    auto const max_k =
+        //! \ogs_file_param{properties__property__PermeabilityMohrCoulombFailureIndexModel__maximum_permeability}
+        config.getConfigParameter<double>("maximum_permeability");
+
+    if (geometry_dimension == 2)
+    {
+        return std::make_unique<PermeabilityMohrCoulombFailureIndexModel<2>>(
+            std::move(property_name), parameter_k0, kr, b, c, phi, max_k,
+            local_coordinate_system);
+    }
+
+    return std::make_unique<PermeabilityMohrCoulombFailureIndexModel<3>>(
+        std::move(property_name), parameter_k0, kr, b, c, phi, max_k,
+        local_coordinate_system);
+}
+}  // namespace MaterialPropertyLib
diff --git a/MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.h b/MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.h
new file mode 100644
index 00000000000..9350b0a9ae9
--- /dev/null
+++ b/MaterialLib/MPL/Properties/CreatePermeabilityMohrCoulombFailureIndexModel.h
@@ -0,0 +1,40 @@
+/**
+ * \file
+ * \copyright
+ * Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ * Created on June 5, 2020, 9:07 AM
+ */
+
+#pragma once
+
+#include <memory>
+#include <vector>
+
+namespace BaseLib
+{
+class ConfigTree;
+}
+
+namespace ParameterLib
+{
+struct CoordinateSystem;
+struct ParameterBase;
+}  // namespace ParameterLib
+
+namespace MaterialPropertyLib
+{
+class Property;
+}
+
+namespace MaterialPropertyLib
+{
+std::unique_ptr<Property> createPermeabilityMohrCoulombFailureIndexModel(
+    int const geometry_dimension,
+    BaseLib::ConfigTree const& config,
+    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
+    ParameterLib::CoordinateSystem const* const local_coordinate_system);
+}  // namespace MaterialPropertyLib
diff --git a/MaterialLib/MPL/Properties/CreateProperties.h b/MaterialLib/MPL/Properties/CreateProperties.h
index d57b0c292ea..bc85705aaba 100644
--- a/MaterialLib/MPL/Properties/CreateProperties.h
+++ b/MaterialLib/MPL/Properties/CreateProperties.h
@@ -26,6 +26,7 @@
 #include "CreateIdealGasLaw.h"
 #include "CreateLinear.h"
 #include "CreateParameter.h"
+#include "CreatePermeabilityMohrCoulombFailureIndexModel.h"
 #include "CreatePermeabilityOrthotropicPowerLaw.h"
 #include "CreatePorosityFromMassBalance.h"
 #include "CreateSaturationDependentSwelling.h"
-- 
GitLab