From c7b30242b6b425e4254d11aa8c4b63d8392f4153 Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Tue, 27 Nov 2012 21:36:07 +0000
Subject: [PATCH] implicit branch: unify spatial parameters of the 2p test.

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/branches/implicit@9689 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 test/implicit/2p/lensccproblem.hh       |   2 +-
 test/implicit/2p/lensccspatialparams.hh | 220 ------------------------
 test/implicit/2p/lensspatialparams.hh   |  25 ++-
 3 files changed, 22 insertions(+), 225 deletions(-)
 delete mode 100644 test/implicit/2p/lensccspatialparams.hh

diff --git a/test/implicit/2p/lensccproblem.hh b/test/implicit/2p/lensccproblem.hh
index f8dff793dd..fb2b8e78f3 100644
--- a/test/implicit/2p/lensccproblem.hh
+++ b/test/implicit/2p/lensccproblem.hh
@@ -46,7 +46,7 @@
 
 #include <dumux/material/fluidsystems/h2on2fluidsystem.hh>
 
-#include "lensccspatialparams.hh"
+#include "lensspatialparams.hh"
 
 namespace Dumux
 {
diff --git a/test/implicit/2p/lensccspatialparams.hh b/test/implicit/2p/lensccspatialparams.hh
deleted file mode 100644
index 73eed21cb2..0000000000
--- a/test/implicit/2p/lensccspatialparams.hh
+++ /dev/null
@@ -1,220 +0,0 @@
-// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-// vi: set et ts=4 sw=4 sts=4:
-/*****************************************************************************
- *   Copyright (C) 2010 by Markus Wolff                                      *
- *   Copyright (C) 2007-2008 by Klaus Mosthaf                                *
- *   Copyright (C) 2007-2008 by Bernd Flemisch                               *
- *   Copyright (C) 2008-2009 by Andreas Lauser                               *
- *   Institute for Modelling Hydraulic and Environmental Systems             *
- *   University of Stuttgart, Germany                                        *
- *   email: <givenname>.<name>@iws.uni-stuttgart.de                          *
- *                                                                           *
- *   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/>.   *
- *****************************************************************************/
-/*!
- * \file
- *
- * \brief The spatial parameters for the LensProblem which uses the
- *        twophase box model
- */
-#ifndef DUMUX_LENS_SPATIAL_PARAMS_HH
-#define DUMUX_LENS_SPATIAL_PARAMS_HH
-
-#include <dumux/material/spatialparams/boxspatialparams.hh>
-#include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchten.hh>
-#include <dumux/material/fluidmatrixinteractions/2p/linearmaterial.hh>
-#include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh>
-
-#include <dumux/implicit/2p/2pmodel.hh>
-
-namespace Dumux
-{
-
-//forward declaration
-template<class TypeTag>
-class LensSpatialParams;
-
-namespace Properties
-{
-// The spatial parameters TypeTag
-NEW_TYPE_TAG(LensSpatialParams);
-
-// Set the spatial parameters
-SET_TYPE_PROP(LensSpatialParams, SpatialParams, Dumux::LensSpatialParams<TypeTag>);
-
-// Set the material Law
-SET_PROP(LensSpatialParams, MaterialLaw)
-{
-private:
-    // define the material law which is parameterized by effective
-    // saturations
-    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
-    typedef RegularizedVanGenuchten<Scalar> EffectiveLaw;
-public:
-    // define the material law parameterized by absolute saturations
-    typedef EffToAbsLaw<EffectiveLaw> type;
-};
-}
-/*!
- * \ingroup TwoPCCModel
- * \ingroup CCTestProblems
- * \brief The spatial parameters for the LensProblem which uses the
- *        twophase box model
- */
-template<class TypeTag>
-class LensSpatialParams : public BoxSpatialParams<TypeTag>
-{
-    typedef BoxSpatialParams<TypeTag> ParentType;
-    typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
-    typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
-    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
-    typedef typename Grid::ctype CoordScalar;
-
-    enum {
-        dim=GridView::dimension,
-        dimWorld=GridView::dimensionworld
-    };
-
-    typedef Dune::FieldVector<CoordScalar,dimWorld> GlobalPosition;
-
-    typedef typename GridView::template Codim<0>::Entity Element;
-    typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry;
-
-public:
-    //get the material law from the property system
-    typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
-    typedef typename MaterialLaw::Params MaterialLawParams;
-
-    LensSpatialParams(const GridView& gridView)
-        : ParentType(gridView)
-    {
-        try
-        {
-            lensLowerLeft_[0]   = GET_RUNTIME_PARAM(TypeTag, Scalar, SpatialParams.LensLowerLeftX);
-            lensLowerLeft_[1]   = GET_RUNTIME_PARAM(TypeTag, Scalar, SpatialParams.LensLowerLeftY);
-            lensUpperRight_[0]  = GET_RUNTIME_PARAM(TypeTag, Scalar, SpatialParams.LensUpperRightX);
-            lensUpperRight_[1]  = GET_RUNTIME_PARAM(TypeTag, Scalar, SpatialParams.LensUpperRightY);
-        }
-        catch (Dumux::ParameterException &e) {
-            std::cerr << e << ". Abort!\n";
-            exit(1) ;
-        }
-        catch (...) {
-            std::cerr << "Unknown exception thrown!\n";
-            exit(1);
-        }
-
-        // residual saturations
-        lensMaterialParams_.setSwr(0.18);
-        lensMaterialParams_.setSnr(0.0);
-        outerMaterialParams_.setSwr(0.05);
-        outerMaterialParams_.setSnr(0.0);
-
-        // parameters for the Van Genuchten law
-        // alpha and n
-        lensMaterialParams_.setVgAlpha(0.00045);
-        lensMaterialParams_.setVgN(7.3);
-        outerMaterialParams_.setVgAlpha(0.0037);
-        outerMaterialParams_.setVgN(4.7);
-
-        // parameters for the linear law
-        // minimum and maximum pressures
- //        lensMaterialParams_.setEntryPC(0);
-//        outerMaterialParams_.setEntryPC(0);
-//        lensMaterialParams_.setMaxPC(0);
-//        outerMaterialParams_.setMaxPC(0);
-
-        lensK_ = 9.05e-12;
-        outerK_ = 4.6e-10;
-    }
-
-    /*!
-     * \brief Intrinsic permability
-     *
-     * \param element The current element
-     * \param fvElemGeom The current finite volume geometry of the element
-     * \param scvIdx The index of the sub-control volume.
-     * \return Intrinsic permeability
-     */
-    Scalar intrinsicPermeability(const Element &element,
-                                 const FVElementGeometry &fvElemGeom,
-                                 int scvIdx) const
-    {
-        if (scvIdx > 0)
-	    return intrinsicPermeability(*(fvElemGeom.neighbors[scvIdx]), fvElemGeom, 0);
-      
-        const GlobalPosition &globalPos = element.geometry().center();
-        if (isInLens_(globalPos))
-            return lensK_;
-        return outerK_;
-    }
-
-    /*!
-     * \brief Porosity
-     *
-     * \param element The current element
-     * \param fvElemGeom The current finite volume geometry of the element
-     * \param scvIdx The index of the sub-control volume.
-     * \return Porosity
-     */
-    Scalar porosity(const Element &element,
-                    const FVElementGeometry &fvElemGeom,
-                    int scvIdx) const
-    { return 0.4; }
-
-    /*!
-     * \brief Function for defining the parameters needed by constitutive relationships (kr-Sw, pc-Sw, etc.).
-     *
-     * \param element The current element
-     * \param fvElemGeom The current finite volume geometry of the element
-     * \param scvIdx The index of the sub-control volume.
-     * \return the material parameters object
-     */
-    const MaterialLawParams& materialLawParams(const Element &element,
-                                                const FVElementGeometry &fvElemGeom,
-                                                int scvIdx) const
-    {
-        if (scvIdx > 0)
-	    return materialLawParams(*(fvElemGeom.neighbors[scvIdx]), fvElemGeom, 0);
-      
-        const GlobalPosition &globalPos = element.geometry().center();
-
-        if (isInLens_(globalPos))
-            return lensMaterialParams_;
-        return outerMaterialParams_;
-    }
-
-
-private:
-    bool isInLens_(const GlobalPosition &pos) const
-    {
-        for (int i = 0; i < dim; ++i) {
-            if (pos[i] < lensLowerLeft_[i] || pos[i] > lensUpperRight_[i])
-                return false;
-        }
-        return true;
-    }
-
-    GlobalPosition lensLowerLeft_;
-    GlobalPosition lensUpperRight_;
-
-    Scalar lensK_;
-    Scalar outerK_;
-    MaterialLawParams lensMaterialParams_;
-    MaterialLawParams outerMaterialParams_;
-};
-
-} // end namespace
-#endif
-
diff --git a/test/implicit/2p/lensspatialparams.hh b/test/implicit/2p/lensspatialparams.hh
index 068695f2be..348ed83976 100644
--- a/test/implicit/2p/lensspatialparams.hh
+++ b/test/implicit/2p/lensspatialparams.hh
@@ -91,7 +91,8 @@ public:
     typedef typename MaterialLaw::Params MaterialLawParams;
 
     LensSpatialParams(const GridView& gridView)
-        : ParentType(gridView)
+    : ParentType(gridView), 
+      isBox_(GET_PROP_VALUE(TypeTag, ImplicitIsBox))
     {
         try
         {
@@ -145,7 +146,15 @@ public:
                                  const FVElementGeometry &fvElemGeom,
                                  int scvIdx) const
     {
-        const GlobalPosition &globalPos = fvElemGeom.subContVol[scvIdx].global;
+        if (!isBox_ && scvIdx > 0)
+            return intrinsicPermeability(*(fvElemGeom.neighbors[scvIdx]), fvElemGeom, 0);
+        
+        GlobalPosition globalPos;
+        if (isBox_)
+            globalPos = fvElemGeom.subContVol[scvIdx].global;
+        else 
+            globalPos = element.geometry().center();
+        
         if (isInLens_(globalPos))
             return lensK_;
         return outerK_;
@@ -176,8 +185,15 @@ public:
                                                 const FVElementGeometry &fvElemGeom,
                                                 int scvIdx) const
     {
-        const GlobalPosition &globalPos = fvElemGeom.subContVol[scvIdx].global;
-
+        if (!isBox_ && scvIdx > 0)
+            return materialLawParams(*(fvElemGeom.neighbors[scvIdx]), fvElemGeom, 0);
+        
+        GlobalPosition globalPos;
+        if (isBox_)
+            globalPos = fvElemGeom.subContVol[scvIdx].global;
+        else 
+            globalPos = element.geometry().center();
+        
         if (isInLens_(globalPos))
             return lensMaterialParams_;
         return outerMaterialParams_;
@@ -201,6 +217,7 @@ private:
     Scalar outerK_;
     MaterialLawParams lensMaterialParams_;
     MaterialLawParams outerMaterialParams_;
+    const bool isBox_;
 };
 
 } // end namespace
-- 
GitLab