From 5631db1f0b02fffabdafdc19f2ee7cf8a20d81fc Mon Sep 17 00:00:00 2001
From: hommel <johannes.hommel@iws.uni-stuttgart.de>
Date: Wed, 29 Nov 2017 13:47:34 +0100
Subject: [PATCH] [2pncmin][next] spatialParams now use the input file
 parameters

---
 .../implicit/dissolutionspatialparams.hh      |  43 ++--
 .../implicit/dissolutionspatialparams.hhnew   | 209 ++++++++++++++++++
 .../2pncmin/implicit/test_2pncmin.input       |   4 +-
 3 files changed, 240 insertions(+), 16 deletions(-)
 create mode 100644 test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hhnew

diff --git a/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh b/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh
index b73fd2ea05..66e032e1f0 100644
--- a/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh
+++ b/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh
@@ -97,20 +97,27 @@ public:
     DissolutionSpatialparams(const Problem& problem)
     : ParentType(problem)
     {
+        solubilityLimit_     = getParam<Scalar>("SpatialParams.SolubilityLimit", 0.26);
+        initialPorosity_     = getParam<Scalar>("SpatialParams.Porosity", 0.11);
+        initialPermeability_ = getParam<Scalar>("SpatialParams.Permeability", 2.23e-14);
+        irreducibleLiqSat_   = getParam<Scalar>("SpatialParams.IrreducibleLiqSat", 0.2);
+        irreducibleGasSat_   = getParam<Scalar>("SpatialParams.IrreducibleGasSat", 1e-3);
+        pEntry1_             = getParam<Scalar>("SpatialParams.Pentry1", 500);
+        bcLambda1_           = getParam<Scalar>("SpatialParams.BCLambda1", 2);
+
         // residual saturations
-        materialParams_.setSwr(0.2);
-        materialParams_.setSnr(1e-3);
+        materialParams_.setSwr(irreducibleLiqSat_);
+        materialParams_.setSnr(irreducibleGasSat_);
 
         // parameters of Brooks & Corey Law
-        materialParams_.setPe(500);
-        materialParams_.setLambda(2);
-    }
+        materialParams_.setPe(pEntry1_);
+        materialParams_.setLambda(bcLambda1_);
+
+        // set main diagonal entries of the permeability tensor to a value
+        // setting to one value means: isotropic, homogeneous
+        for (int i = 0; i < dim; i++)  //TODO make this nice and dependend on PermeabilityType!
+            initK_[i][i] = initialPermeability_;
 
-    /*!
-     * \brief Called by the Problem to initialize the spatial params.
-     */
-    void init()
-    {
         //! Intitialize the parameter laws
         poroLaw_.init(*this);
         permLaw_.init(*this);
@@ -145,7 +152,7 @@ public:
      *  \param scv The sub-control volume
      */
     Scalar initialPorosity(const Element& element, const SubControlVolume &scv) const
-    { return 0.11; }
+    { return initialPorosity_; }
 
     /*!
      *  \brief Define the initial permeability \f$[m^2]\f$ distribution
@@ -153,8 +160,8 @@ public:
      *  \param element The finite element
      *  \param scv The sub-control volume
      */
-    Scalar initialPermeability(const Element& element, const SubControlVolume &scv) const
-    { return 2.23e-14; }
+    PermeabilityType initialPermeability(const Element& element, const SubControlVolume &scv) const
+    { return initK_; }
 
     /*!
      *  \brief Define the minimum porosity \f$[-]\f$ after clogging caused by mineralization
@@ -172,7 +179,7 @@ public:
     { return 1.0 - porosityAtPos(scv.center()); }
 
     Scalar solubilityLimit() const
-    { return 0.26; }
+    { return solubilityLimit_; }
 
     Scalar theta(const SubControlVolume &scv) const
     { return 10.0; }
@@ -186,6 +193,14 @@ private:
 
     PorosityLaw poroLaw_;
     PermeabilityLaw permLaw_;
+    Scalar solubilityLimit_;
+    Scalar initialPorosity_;
+    Scalar initialPermeability_;
+    PermeabilityType initK_= 0.0;
+    Scalar irreducibleLiqSat_;
+    Scalar irreducibleGasSat_;
+    Scalar pEntry1_;
+    Scalar bcLambda1_;
 };
 
 } // end namespace Dumux
diff --git a/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hhnew b/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hhnew
new file mode 100644
index 0000000000..654a94dfef
--- /dev/null
+++ b/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hhnew
@@ -0,0 +1,209 @@
+// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// vi: set et ts=4 sw=4 sts=4:
+/*****************************************************************************
+ *   See the file COPYING for full copying permissions.                      *
+ *                                                                           *
+ *   This program is free software: you can redistribute it and/or modify    *
+ *   it under the terms of the GNU General Public License as published by    *
+ *   the Free Software Foundation, either version 2 of the License, or       *
+ *   (at your option) any later version.                                     *
+ *                                                                           *
+ *   This program is distributed in the hope that it will be useful,         *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
+ *   GNU General Public License for more details.                            *
+ *                                                                           *
+ *   You should have received a copy of the GNU General Public License       *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
+ *****************************************************************************/
+#ifndef DUMUX_INJECTION_SPATIAL_PARAMETERS_HH
+#define DUMUX_INJECTION_SPATIAL_PARAMETERS_HH
+
+#include <dumux/porousmediumflow/2pncmin/implicit/indices.hh>
+#include <dumux/material/spatialparams/implicit.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/linearmaterial.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscorey.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh>
+#include <dumux/material/fluidmatrixinteractions/porosityprecipitation.hh>
+#include <dumux/material/fluidmatrixinteractions/permeabilitykozenycarman.hh>
+
+namespace Dumux
+{
+//forward declaration
+template<class TypeTag>
+class DissolutionSpatialparams;
+
+namespace Properties
+{
+// The spatial parameters TypeTag
+NEW_TYPE_TAG(DissolutionSpatialparams);
+
+// Set the spatial parameters
+SET_TYPE_PROP(DissolutionSpatialparams, SpatialParams, DissolutionSpatialparams<TypeTag>);
+
+// Set the material Law
+SET_PROP(DissolutionSpatialparams, MaterialLaw)
+{
+private:
+    // define the material law which is parameterized by effective saturations
+    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
+public:
+    // define the material law parameterized by absolute saturations
+    using type = EffToAbsLaw<RegularizedBrooksCorey<Scalar>>;
+};
+
+} // end namespace Properties
+
+/**
+ * \brief Definition of the spatial parameters for the brine-co2 problem
+ *
+ */
+template<class TypeTag>
+class DissolutionSpatialparams : public ImplicitSpatialParams<TypeTag>
+{
+    using ThisType = DissolutionSpatialparams<TypeTag>;
+    using ParentType = ImplicitSpatialParams<TypeTag>;
+    using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
+    using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
+    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
+    using MaterialLawParams = typename GET_PROP_TYPE(TypeTag, MaterialLawParams);
+    using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
+    using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector);
+    using CoordScalar = typename GridView::ctype;
+    enum {
+        dim=GridView::dimension,
+        dimWorld=GridView::dimensionworld,
+    };
+
+    using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
+    enum {
+        wPhaseIdx = FluidSystem::wPhaseIdx,
+        nPhaseIdx = FluidSystem::nPhaseIdx,
+    };
+
+    using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
+    using Tensor = Dune::FieldMatrix<CoordScalar, dimWorld, dimWorld>;
+    using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
+    using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
+    using Element = typename GridView::template Codim<0>::Entity;
+
+    using PorosityLaw = PorosityPrecipitation<TypeTag>;
+    using PermeabilityLaw = PermeabilityKozenyCarman<TypeTag>;
+
+public:
+    // type used for the permeability (i.e. tensor or scalar)
+    using PermeabilityType = Tensor;
+
+    DissolutionSpatialparams(const Problem& problem)
+    : ParentType(problem)
+    {
+        solubilityLimit_     = getParam<Scalar>("SpatialParams.SolubilityLimit", 0.26);
+        initialPorosity_     = getParam<Scalar>("SpatialParams.Porosity", 0.11);
+        initialPermeability_ = getParam<Scalar>("SpatialParams.Permeability", 2.23e-14);
+        irreducibleLiqSat_   = getParam<Scalar>("SpatialParams.IrreducibleLiqSat", 0.2);
+        irreducibleGasSat_   = getParam<Scalar>("SpatialParams.IrreducibleGasSat", 1e-3);
+        pEntry1_             = getParam<Scalar>("SpatialParams.Pentry1", 500);
+        bcLambda1_           = getParam<Scalar>("SpatialParams.BCLambda1", 2);
+
+
+        // residual saturations
+        materialParams_.setSwr(irreducibleLiqSat_);
+        materialParams_.setSnr(irreducibleGasSat_);
+
+        // parameters of Brooks & Corey Law
+        materialParams_.setPe(pEntry1_);
+        materialParams_.setLambda(bcLambda1_);
+    }
+
+    /*!
+     * \brief Called by the Problem to initialize the spatial params.
+     */
+    void init()
+    {
+        //! Intitialize the parameter laws
+        poroLaw_.init(*this);
+        permLaw_.init(*this);
+    }
+
+    /*! Intrinsic permeability tensor K \f$[m^2]\f$ depending
+     *  on the position in the domain
+     *
+     *  \param element The finite volume element
+     *  \param scv The sub-control volume
+     *
+     *  Solution dependent permeability function
+     */
+    PermeabilityType permeability(const Element& element,
+                        const SubControlVolume& scv,
+                        const ElementSolutionVector& elemSol) const
+    { return permLaw_.evaluatePermeability(element, scv, elemSol); }
+
+    /*!
+     *  \brief Define the minimum porosity \f$[-]\f$ distribution
+     *
+     *  \param element The finite element
+     *  \param scv The sub-control volume
+     */
+    Scalar minPorosity(const Element& element, const SubControlVolume &scv) const
+    { return 1e-5; }
+
+    /*!
+     *  \brief Define the initial porosity \f$[-]\f$ distribution
+     *
+     *  \param element The finite element
+     *  \param scv The sub-control volume
+     */
+    Scalar initialPorosity(const Element& element, const SubControlVolume &scv) const
+    { return initialPorosity_; }
+
+    /*!
+     *  \brief Define the initial permeability \f$[m^2]\f$ distribution
+     *
+     *  \param element The finite element
+     *  \param scv The sub-control volume
+     */
+    Scalar initialPermeability(const Element& element, const SubControlVolume &scv) const
+    { return initialPermeability_; }
+
+    /*!
+     *  \brief Define the minimum porosity \f$[-]\f$ after clogging caused by mineralization
+     *
+     *  \param element The finite element
+     *  \param scv The sub-control volume
+     */
+    Scalar porosity(const Element& element,
+                    const SubControlVolume& scv,
+                    const ElementSolutionVector& elemSol) const
+    { return poroLaw_.evaluatePorosity(element, scv, elemSol); }
+
+
+    Scalar solidity(const SubControlVolume &scv) const
+    { return 1.0 - porosityAtPos(scv.center()); }
+
+    Scalar solubilityLimit() const
+    { return solubilityLimit_; }
+
+    Scalar theta(const SubControlVolume &scv) const
+    { return 10.0; }
+
+    // return the brooks-corey context depending on the position
+    const MaterialLawParams& materialLawParamsAtPos(const GlobalPosition& globalPos) const
+    { return materialParams_; }
+
+private:
+    MaterialLawParams materialParams_;
+
+    PorosityLaw poroLaw_;
+    PermeabilityLaw permLaw_;
+    Scalar solubilityLimit_;
+    Scalar initialPorosity_;
+    Scalar initialPermeability_;
+    Scalar irreducibleLiqSat_;
+    Scalar irreducibleGasSat_;
+    Scalar pEntry1_;
+    Scalar bcLambda1_;
+};
+
+} // end namespace Dumux
+
+#endif
diff --git a/test/porousmediumflow/2pncmin/implicit/test_2pncmin.input b/test/porousmediumflow/2pncmin/implicit/test_2pncmin.input
index 0fb4f4cf3b..8583eb5cc4 100644
--- a/test/porousmediumflow/2pncmin/implicit/test_2pncmin.input
+++ b/test/porousmediumflow/2pncmin/implicit/test_2pncmin.input
@@ -37,12 +37,12 @@ InitPrecipitatedSalt1    = 0.0     # [-]  initial precipitated salt
 InitPrecipitatedSalt2    = 0.05    # [-]  initial precipitated salt in the blocked part
 
 [SpatialParams]
-SolubilityLimit     = 0.295        # [-]  solubility limit of salt in brine
+SolubilityLimit     = 0.26 #0.295        # [-]  solubility limit of salt in brine
 Porosity            = 0.11         # [-]  initial porosity
 Permeability        = 2.23e-14
 IrreducibleLiqSat   = 0.2          # [-]  irreducible liquid saturation
 IrreducibleGasSat   = 0.001        # [-]  irreducible gas saturation
-Pentry1             = 0.0          # [Pa]
+Pentry1             = 500 #0.0          # [Pa]
 BCLambda1           = 2            # [-]
 
 [Vtk]
-- 
GitLab