From 2bb40a7e7d4f55188526e786bf151e1742ad88c1 Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Wed, 23 Oct 2013 13:08:57 +0000
Subject: [PATCH] Fix decoupled 1p test.

Using a mutable permeability tensor in the spatial parameters resulted
in wrong averaged permeabilities. Store permeabilities in a vector
instead, just like in test_diffusion.


git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@11784 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 test/decoupled/1p/test_1pproblem.hh       |  2 +-
 test/decoupled/1p/test_1pspatialparams.hh | 37 +++++++++++++------
 test/references/test_1p-reference.vtu     | 44 +++++++++++------------
 3 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/test/decoupled/1p/test_1pproblem.hh b/test/decoupled/1p/test_1pproblem.hh
index b508ec7856..3fa223e286 100644
--- a/test/decoupled/1p/test_1pproblem.hh
+++ b/test/decoupled/1p/test_1pproblem.hh
@@ -142,7 +142,7 @@ public:
             exit(1);
         }
 
-        this->spatialParams().setDelta(delta_);
+        this->spatialParams().initialize(delta_);
     }
 
     /*!
diff --git a/test/decoupled/1p/test_1pspatialparams.hh b/test/decoupled/1p/test_1pspatialparams.hh
index e40f37400b..aa30c43948 100644
--- a/test/decoupled/1p/test_1pspatialparams.hh
+++ b/test/decoupled/1p/test_1pspatialparams.hh
@@ -39,26 +39,23 @@ class TestOnePSpatialParams: public FVSpatialParamsOneP<TypeTag>
     typedef FVSpatialParamsOneP<TypeTag> ParentType;
     typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
     typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
+    typedef typename GridView::IndexSet IndexSet;
     typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
     typedef typename Grid::ctype CoordScalar;
 
     enum
         {dim=Grid::dimension, dimWorld=Grid::dimensionworld};
     typedef typename Grid::Traits::template Codim<0>::Entity Element;
+    typedef typename GridView::template Codim<0>::Iterator ElementIterator;
 
     typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition;
     typedef Dune::FieldMatrix<Scalar,dim,dim> FieldMatrix;
 
 public:
 
-    const FieldMatrix& intrinsicPermeabilityAtPos (const GlobalPosition& globalPos) const
+    const FieldMatrix& intrinsicPermeability (const Element& element) const
     {
-        double rt = globalPos[0]*globalPos[0]+globalPos[1]*globalPos[1];
-        permeability_[0][0] = (delta_*globalPos[0]*globalPos[0] + globalPos[1]*globalPos[1])/rt;
-        permeability_[0][1] = permeability_[1][0] = -(1.0 - delta_)*globalPos[0]*globalPos[1]/rt;
-        permeability_[1][1] = (globalPos[0]*globalPos[0] + delta_*globalPos[1]*globalPos[1])/rt;
-
-        return permeability_;
+        return permeability_[indexSet_.index(element)];
     }
 
     double porosity(const Element& element) const
@@ -66,17 +63,37 @@ public:
         return 0.2;
     }
 
-    void setDelta(const double delta)
+    void initialize(const double delta)
     {
         delta_ = delta;
+        permeability_.resize(gridView_.size(0));
+
+        ElementIterator eIt = gridView_.template begin<0>();
+        ElementIterator eEndIt = gridView_.template end<0>();
+        for(;eIt != eEndIt; ++eIt)
+        {
+            setPermeability_(permeability_[indexSet_.index(*eIt)], eIt->geometry().center());
+        }
+
     }
 
     TestOnePSpatialParams(const GridView& gridView)
-    : ParentType(gridView), permeability_(0)
+    : ParentType(gridView), gridView_(gridView), indexSet_(gridView.indexSet())
     { }
 
 private:
-    mutable FieldMatrix permeability_;
+    void setPermeability_(FieldMatrix& perm, const GlobalPosition& globalPos) const
+    {
+        double rt = globalPos[0]*globalPos[0]+globalPos[1]*globalPos[1];
+        perm[0][0] = (delta_*globalPos[0]*globalPos[0] + globalPos[1]*globalPos[1])/rt;
+        perm[0][1] = -(1.0 - delta_)*globalPos[0]*globalPos[1]/rt;
+        perm[1][0] = perm[0][1];
+        perm[1][1] = (globalPos[0]*globalPos[0] + delta_*globalPos[1]*globalPos[1])/rt;
+    }
+
+    const GridView gridView_;
+    const IndexSet& indexSet_;
+    std::vector<FieldMatrix> permeability_;
     double delta_;
 };
 
diff --git a/test/references/test_1p-reference.vtu b/test/references/test_1p-reference.vtu
index 40e13bb534..6aaf036cdb 100644
--- a/test/references/test_1p-reference.vtu
+++ b/test/references/test_1p-reference.vtu
@@ -4,30 +4,30 @@
     <Piece NumberOfCells="64" NumberOfPoints="81">
       <CellData Scalars="pressure" Vectors="velocity">
         <DataArray type="Float32" Name="pressure" NumberOfComponents="1" format="ascii">
-          0.134323 0.183052 0.203147 0.19449 0.161069 0.109222 0.0462204 -0.0147278 0.183052 0.395195 0.512464 0.526295
-          0.45381 0.319656 0.147713 -0.0222035 0.203147 0.512464 0.702329 0.758698 0.686768 0.512331 0.269591 0.0171451
-          0.19449 0.526295 0.758698 0.86232 0.826021 0.661429 0.398211 0.0935879 0.161069 0.45381 0.686768 0.826021
-          0.844359 0.731349 0.496948 0.174174 0.109222 0.319656 0.512331 0.661429 0.731349 0.690355 0.521748 0.223249
-          0.0462204 0.147713 0.269591 0.398211 0.496948 0.521748 0.437118 0.21426 -0.0147278 -0.0222035 0.0171451 0.0935879
-          0.174174 0.223249 0.21426 0.122997
+          0.120132 0.180768 0.205897 0.198644 0.164572 0.111307 0.0464718 -0.0163382 0.180768 0.450061 0.568188 0.565928
+          0.478972 0.332977 0.150896 -0.0272024 0.205897 0.568188 0.787437 0.834874 0.740067 0.542487 0.279323 0.0104982
+          0.198644 0.565928 0.834874 0.948901 0.898261 0.708326 0.417814 0.0884083 0.164572 0.478972 0.740067 0.898261
+          0.91634 0.786284 0.525466 0.172503 0.111307 0.332977 0.542487 0.708326 0.786284 0.739549 0.552237 0.224624
+          0.0464718 0.150896 0.279323 0.417814 0.525466 0.552237 0.45916 0.216186 -0.0163382 -0.0272024 0.0104982 0.0884083
+          0.172503 0.224624 0.216186 0.121416
         </DataArray>
         <DataArray type="Float32" Name="velocity" NumberOfComponents="3" format="ascii">
-          -0.635385 -0.635385 0 -0.105666 -2.08192 0 -0.00674492 -2.75246 0 0.00416985 -2.82553 0
-          0.00553863 -2.42955 0 0.00504952 -1.70147 0 0.00399201 -0.771175 0 0.00103779 0.147072 0
-          -2.08192 -0.105666 0 -0.99857 -0.99857 0 -0.249458 -1.74836 0 0.0305497 -2.08621 0
-          0.0993801 -1.99544 0 0.1024 -1.55224 0 0.0832657 -0.866472 0 0.0280078 -0.121576 0
-          -2.75246 -0.00674492 0 -1.74836 -0.249458 0 -0.67148 -0.67148 0 -0.0154582 -1.0601 0
-          0.26249 -1.26451 0 0.332161 -1.21177 0 0.298072 -0.911135 0 0.144846 -0.426571 0
-          -2.82553 0.00416985 0 -2.08621 0.0305497 0 -1.0601 -0.0154582 0 -0.201927 -0.201927 0
-          0.321234 -0.471503 0 0.552789 -0.693519 0 0.57905 -0.754513 0 0.409333 -0.53998 0
-          -2.42955 0.00553863 0 -1.99544 0.0993801 0 -1.26451 0.26249 0 -0.471503 0.321234 0
-          0.180515 0.180515 0 0.602776 -0.100857 0 0.79572 -0.373355 0 0.789052 -0.409145 0
-          -1.70147 0.00504952 0 -1.55224 0.1024 0 -1.21177 0.332161 0 -0.693519 0.552789 0
-          -0.100857 0.602776 0 0.435841 0.435841 0 0.836432 0.130326 0 1.12462 -0.120997 0
-          -0.771175 0.00399201 0 -0.866472 0.0832657 0 -0.911135 0.298072 0 -0.754513 0.57905 0
-          -0.373355 0.79572 0 0.130326 0.836432 0 0.643578 0.643578 0 1.18237 0.232018 0
-          0.147072 0.00103779 0 -0.121576 0.0280078 0 -0.426571 0.144846 0 -0.53998 0.409333 0
-          -0.409145 0.789052 0 -0.120997 1.12462 0 0.232018 1.18237 0 0.701106 0.701106 0
+          -0.521741 -0.521741 0 -0.0464327 -1.99462 0 -0.00490418 -2.79179 0 0.00300124 -2.89065 0
+          0.00451401 -2.4851 0 0.00434727 -1.73469 0 0.00356306 -0.775297 0 0.000814598 0.172641 0
+          -1.99462 -0.0464327 0 -0.856854 -0.856854 0 -0.162138 -1.73031 0 0.044401 -2.13223 0
+          0.0909602 -2.04796 0 0.0916029 -1.58644 0 0.0750857 -0.872511 0 0.023239 -0.0977063 0
+          -2.79179 -0.00490418 0 -1.73031 -0.162138 0 -0.599039 -0.599039 0 0.0289948 -1.05906 0
+          0.263089 -1.29797 0 0.313184 -1.24308 0 0.277784 -0.921372 0 0.130538 -0.407895 0
+          -2.89065 0.00300124 0 -2.13223 0.044401 0 -1.05906 0.0289948 0 -0.172897 -0.172897 0
+          0.335892 -0.47472 0 0.5431 -0.711142 0 0.557918 -0.765683 0 0.390589 -0.528736 0
+          -2.4851 0.00451401 0 -2.04796 0.0909602 0 -1.29797 0.263089 0 -0.47472 0.335892 0
+          0.19167 0.19167 0 0.60642 -0.100994 0 0.786978 -0.378182 0 0.778697 -0.405019 0
+          -1.73469 0.00434727 0 -1.58644 0.0916029 0 -1.24308 0.313184 0 -0.711142 0.5431 0
+          -0.100994 0.60642 0 0.443215 0.443215 0 0.84069 0.133489 0 1.12905 -0.123418 0
+          -0.775297 0.00356306 0 -0.872511 0.0750857 0 -0.921372 0.277784 0 -0.765683 0.557918 0
+          -0.378182 0.786978 0 0.133489 0.84069 0 0.649857 0.649857 0 1.19212 0.222834 0
+          0.172641 0.000814598 0 -0.0977063 0.023239 0 -0.407895 0.130538 0 -0.528736 0.390589 0
+          -0.405019 0.778697 0 -0.123418 1.12905 0 0.222834 1.19212 0 0.688444 0.688444 0
         </DataArray>
       </CellData>
       <Points>
-- 
GitLab