From 0df6aa8fe793dddefb7051d96d9ec3779580317b Mon Sep 17 00:00:00 2001
From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de>
Date: Thu, 13 Oct 2016 09:30:25 +0200
Subject: [PATCH] [material] Introduce set functionality for setting the
 regularization thresholds

enables to:
* use different regularization methods for different soils
* change regularization threshold at runtime
---
 .../2p/regularizedbrookscoreyparams.hh        |  28 +++--
 .../2p/regularizedlinearmaterialparams.hh     |  40 +++++--
 .../2p/regularizedvangenuchtenparams.hh       | 107 ++++++++++++------
 3 files changed, 119 insertions(+), 56 deletions(-)

diff --git a/dumux/material/fluidmatrixinteractions/2p/regularizedbrookscoreyparams.hh b/dumux/material/fluidmatrixinteractions/2p/regularizedbrookscoreyparams.hh
index 050bc62f9a..54ea891c2e 100644
--- a/dumux/material/fluidmatrixinteractions/2p/regularizedbrookscoreyparams.hh
+++ b/dumux/material/fluidmatrixinteractions/2p/regularizedbrookscoreyparams.hh
@@ -46,32 +46,38 @@ public:
     RegularizedBrooksCoreyParams()
         : BrooksCoreyParams()
     {
+        setThresholdSw(0.01);
     }
 
     RegularizedBrooksCoreyParams(Scalar pe, Scalar lambda)
         : BrooksCoreyParams(pe, lambda)
     {
+        setThresholdSw(0.01);
     }
 
     /*!
-     * \brief Threshold saturation below which the capillary pressure
+     * \brief Set the threshold saturation below which the capillary pressure
      *        is regularized.
      *
-     * This is just 1%. If you need a different value, overload this
-     * class.
+     * Most problems are very sensitive to this value (e.g. making it smaller
+     * might result in negative pressures).
+     */
+    void setThresholdSw(Scalar thresholdSw)
+    {
+        thresholdSw_ = thresholdSw;
+    }
+
+    /*!
+     * \brief Threshold saturation below which the capillary pressure
+     *        is regularized.
      */
     Scalar thresholdSw() const
     {
-        // Most problems are very sensitive to this value
-        // (e.g. making it smaller might result in negative
-        // pressures)
-        //
-        // If you want to use a different regularization threshold,
-        // overload this class and supply the new class as second
-        // template parameter for the RegularizedVanGenuchten law!
-        return 1e-2;
+        return thresholdSw_;
     }
 
+private:
+    Scalar thresholdSw_;
 };
 } // namespace Dumux
 
diff --git a/dumux/material/fluidmatrixinteractions/2p/regularizedlinearmaterialparams.hh b/dumux/material/fluidmatrixinteractions/2p/regularizedlinearmaterialparams.hh
index d3b725972a..7d544aae99 100644
--- a/dumux/material/fluidmatrixinteractions/2p/regularizedlinearmaterialparams.hh
+++ b/dumux/material/fluidmatrixinteractions/2p/regularizedlinearmaterialparams.hh
@@ -43,28 +43,50 @@ public:
     typedef ScalarT Scalar;
 
     RegularizedLinearMaterialParams()
-    {}
+    {
+        setKrLowS(0.05);
+        setKrHighS(0.95);
+    }
+
+    /*!
+     * \brief Set the threshold saturation respective phase below
+     *        which the relative permeability gets regularized.
+     */
+    void setKrLowS(Scalar krLowS)
+    {
+        krLowS_ = krLowS;
+    }
 
     /*!
      * \brief Return the threshold saturation respective phase below
      *        which the relative permeability gets regularized.
-     *
-     * This is just 5%. If you need a different value, write your own
-     * parameter class.
      */
     Scalar krLowS() const
-    { return 0.05; }
+    {
+        return krLowS_;
+    }
+
+    /*!
+     * \brief Set the threshold saturation of the respective phase
+     *        above which the relative permeability gets regularized.
+     */
+    void setKrHighS(Scalar krHighS)
+    {
+        krHighS_ = krHighS;
+    }
 
     /*!
      * \brief Return the threshold saturation of the respective phase
      *        above which the relative permeability gets regularized.
-     *
-     * This is just 95%. If you need a different value, write your own
-     * parameter class.
      */
     Scalar krHighS() const
-    { return 0.95; }
+    {
+        return krHighS_;
+    }
 
+private:
+    Scalar krLowS_;
+    Scalar krHighS_;
 };
 } // namespace Dumux
 
diff --git a/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh b/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh
index 7fcc3a6523..6eab69b545 100644
--- a/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh
+++ b/dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh
@@ -46,71 +46,106 @@ public:
     typedef VanGenuchtenParams<Scalar> Parent;
 
     RegularizedVanGenuchtenParams()
-    {}
+    {
+        initialize();
+    }
 
-    RegularizedVanGenuchtenParams(Scalar vgAlpha,
-                                  Scalar vgN)
+    RegularizedVanGenuchtenParams(Scalar vgAlpha, Scalar vgN)
         : Parent(vgAlpha, vgN)
-    {}
+    {
+        initialize();
+    }
+
+    /*!
+     * \brief Sets some default regularization thresholds
+     */
+    void initialize()
+    {
+        setPcLowSw(0.01);
+        setPcHighSw(0.99);
+        setKrnLowSw(0.1);
+        setKrwHighSw(0.9);
+    }
 
     /*!
-     * \brief Threshold saturation below which the capillary pressure
-     *        is regularized.
+     * \brief Set the threshold saturation below which the capillary pressure is regularized.
      *
-     * This is just 1%. If you need a different value, overload this
-     * class.
+     * Most problems are very sensitive to this value (e.g. making it smaller might
+     * result in very high capillary pressures)
+     */
+    void setPcLowSw(Scalar pcLowSw)
+    {
+        pcLowSw_ = pcLowSw;
+    }
+
+    /*!
+     * \brief Threshold saturation below which the capillary pressure is regularized.
      */
     Scalar pcLowSw() const
     {
-        // Most problems are very sensitive to this value
-        // (e.g. making it smaller might result in negative
-        // pressures)
-        //
-        // If you want to use a different regularization threshold,
-        // overload this class and supply the new class as second
-        // template parameter for the RegularizedVanGenuchten law!
-        return 1e-2;
+        return pcLowSw_;
+    }
+
+    /*!
+     * \brief Set the threshold saturation above which the capillary pressure is regularized.
+     */
+    void setPcHighSw(Scalar pcHighSw)
+    {
+        pcHighSw_ = pcHighSw;
     }
 
     /*!
-     * \brief Threshold saturation above which the capillary pressure
-     *        is regularized.
+     * \brief Threshold saturation above which the capillary pressure is regularized.
      *
-     * This is just 99%. If you need a different value, overload this
-     * class.
+     * Most problems are very sensitive to this value (e.g. making it smaller might
+     * result in negative capillary pressures).
      */
     Scalar pcHighSw() const
     {
-        // Most problems are very sensitive to this value
-        // (e.g. making it smaller might result in negative
-        // pressures)
-        //
-        // If you want to use a different regularization threshold,
-        // overload this class and supply the new class as second
-        // template parameter for the RegularizedVanGenuchten law!
-        return 99e-2;
+        return pcHighSw_;
+    }
+
+    /*!
+     * \brief Set the threshold saturation below which the relative
+     *        permeability of the non-wetting phase gets regularized.
+     */
+    void setKrnLowSw(Scalar krnLowSw)
+    {
+        krnLowSw_ = krnLowSw;
     }
 
     /*!
      * \brief Threshold saturation below which the relative
      *        permeability of the non-wetting phase gets regularized.
-     *
-     * This is just 10%. If you need a different value, overload this
-     * class.
      */
     Scalar krnLowSw() const
-    { return 0.10; }
+    {
+        return krnLowSw_;
+    }
+
+    /*!
+     * \brief Set the threshold saturation above which the relative
+     *        permeability of the wetting phase gets regularized.
+     */
+    void setKrwHighSw(Scalar krwHighSw)
+    {
+        krwHighSw_ = krwHighSw;
+    }
 
     /*!
      * \brief Threshold saturation above which the relative
      *        permeability of the wetting phase gets regularized.
-     *
-     * This is just 90%. If you need a different value, overload this
-     * class.
      */
     Scalar krwHighSw() const
-    { return 0.90; }
+    {
+        return krwHighSw_;
+    }
 
+private:
+    Scalar pcLowSw_;
+    Scalar pcHighSw_;
+    Scalar krnLowSw_;
+    Scalar krwHighSw_;
 };
 } // namespace Dumux
 
-- 
GitLab