From ff640c8d6f8d0f187d193ea4be3bf1af9ff41021 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Thu, 25 Feb 2016 17:32:53 +0100
Subject: [PATCH] [test] Update the fv element geometry test

---
 dumux/implicit/tpfa/properties.hh       | 52 ++++++++++++++
 dumux/implicit/tpfa/propertydefaults.hh | 93 +++++++++++++++++++++++++
 test/implicit/test_fvelementgeometry.cc | 61 +++++++---------
 3 files changed, 172 insertions(+), 34 deletions(-)
 create mode 100644 dumux/implicit/tpfa/properties.hh
 create mode 100644 dumux/implicit/tpfa/propertydefaults.hh

diff --git a/dumux/implicit/tpfa/properties.hh b/dumux/implicit/tpfa/properties.hh
new file mode 100644
index 0000000000..3c0803c107
--- /dev/null
+++ b/dumux/implicit/tpfa/properties.hh
@@ -0,0 +1,52 @@
+// -*- 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_CC_TPFA_PROPERTIES_HH
+#define DUMUX_CC_TPFA_PROPERTIES_HH
+
+#include <dumux/implicit/properties.hh>
+
+/*!
+ * \ingroup Properties
+ * \ingroup ImplicitProperties
+ * \ingroup CCTpfaModel
+ * \file
+ * \brief Specify the shape functions, operator assemblers, etc
+ *        used for the CCTpfaModel.
+ */
+namespace Dumux
+{
+
+namespace Properties
+{
+// \{
+
+//////////////////////////////////////////////////////////////////
+// Type tags
+//////////////////////////////////////////////////////////////////
+
+//! The type tag for models based on the cell-centered two-point flux approximation scheme
+NEW_TYPE_TAG(CCTpfaModel, INHERITS_FROM(ImplicitBase));
+}
+}
+
+// \}
+
+#include <dumux/implicit/tpfa/propertydefaults.hh>
+
+#endif
diff --git a/dumux/implicit/tpfa/propertydefaults.hh b/dumux/implicit/tpfa/propertydefaults.hh
new file mode 100644
index 0000000000..9aefd14d48
--- /dev/null
+++ b/dumux/implicit/tpfa/propertydefaults.hh
@@ -0,0 +1,93 @@
+// -*- 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/>.   *
+ *****************************************************************************/
+/*!
+ * \ingroup Properties
+ * \ingroup CCTpfaProperties
+ * \ingroup CCTpfaModel
+ * \file
+ *
+ * \brief Default properties for cell centered models
+ */
+#ifndef DUMUX_CCTPFA_PROPERTY_DEFAULTS_HH
+#define DUMUX_CCTPFA_PROPERTY_DEFAULTS_HH
+
+#include <dumux/implicit/propertydefaults.hh>
+#include <dumux/implicit/cellcentered/assembler.hh>
+#include <dumux/implicit/fvelementgeometry.hh>
+#include <dumux/implicit/tpfa/fvelementgeometryvector.hh>
+#include <dumux/implicit/cellcentered/elementboundarytypes.hh>
+#include <dumux/implicit/cellcentered/localresidual.hh>
+#include <dumux/implicit/cellcentered/properties.hh>
+
+namespace Dumux {
+
+// forward declarations
+template<class TypeTag> class CCLocalResidual;
+template<class TypeTag> class CCElementBoundaryTypes;
+template<class TypeTag> class FVElementGeometry;
+
+namespace Properties {
+//! Set the default for the FVElementGeometry vector
+SET_TYPE_PROP(CCTpfaModel, FVElementGeometryVector, TpfaFVElementGeometryVector<TypeTag>);
+
+//! Set the default for the ElementBoundaryTypes
+SET_TYPE_PROP(CCTpfaModel, ElementBoundaryTypes, Dumux::CCElementBoundaryTypes<TypeTag>);
+
+//! Mapper for the degrees of freedoms.
+SET_TYPE_PROP(CCTpfaModel, DofMapper, typename GET_PROP_TYPE(TypeTag, ElementMapper));
+
+//! Set the BaseLocalResidual to CCTpfaLocalResidual
+SET_TYPE_PROP(CCTpfaModel, BaseLocalResidual, Dumux::CCLocalResidual<TypeTag>);
+
+//! An array of secondary variable containers
+SET_TYPE_PROP(CCTpfaModel, ElementVolumeVariables, Dumux::CCElementVolumeVariables<TypeTag>);
+
+//! Assembler for the global jacobian matrix
+SET_TYPE_PROP(CCTpfaModel, JacobianAssembler, Dumux::CCAssembler<TypeTag>);
+
+//! indicate that this is no box discretization
+SET_BOOL_PROP(CCTpfaModel, ImplicitIsBox, false);
+
+//! The sub control volume
+SET_PROP(CCTpfaModel, SubControlVolume)
+{
+private:
+    using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
+    using ScvGeometry = typename Grid::template Codim<0>::Geometry;
+    using IndexType = typename Grid::LeafGridView::IndexSet::IndexType;
+public:
+    typedef Dumux::SubControlVolume<ScvGeometry, IndexType, /*isBox=*/false> type;
+};
+
+SET_PROP(CCTpfaModel, SubControlVolumeFace)
+{
+private:
+    using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
+    using ScvfGeometry = typename Grid::template Codim<1>::Geometry;
+    using IndexType = typename Grid::LeafGridView::IndexSet::IndexType;
+public:
+    typedef Dumux::SubControlVolumeFace<ScvfGeometry, IndexType> type;
+
+};
+
+} // namespace Properties
+
+} // namespace Dumux
+
+#endif
diff --git a/test/implicit/test_fvelementgeometry.cc b/test/implicit/test_fvelementgeometry.cc
index 54c1ca1964..76778d9835 100644
--- a/test/implicit/test_fvelementgeometry.cc
+++ b/test/implicit/test_fvelementgeometry.cc
@@ -29,8 +29,9 @@
 #include <dune/common/test/iteratortest.hh>
 #include <dune/grid/utility/structuredgridfactory.hh>
 #include <dune/grid/yaspgrid.hh>
+#include <dune/grid/common/mcmgmapper.hh>
 
-#include <dumux/common/basicproperties.hh>
+#include <dumux/implicit/tpfa/properties.hh>
 #include <dumux/implicit/tpfa/fvelementgeometryvector.hh>
 #include <dumux/implicit/fvelementgeometry.hh>
 #include <dumux/implicit/subcontrolvolume.hh>
@@ -38,45 +39,30 @@
 
 namespace Dumux
 {
-namespace Properties
-{
-NEW_PROP_TAG(SubControlVolume);
-NEW_PROP_TAG(SubControlVolumeFace);
-NEW_PROP_TAG(FVElementGeometry);
-NEW_PROP_TAG(FVElementGeometryVector);
-
-NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(NumericModel));
-
-SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>);
 
-SET_TYPE_PROP(TestFVGeometry, GridView, typename GET_PROP_TYPE(TypeTag, Grid)::LeafGridView);
-
-SET_PROP(TestFVGeometry, SubControlVolume)
+template<class TypeTag>
+class MockProblem
 {
-private:
-    using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
-    using ScvGeometry = typename Grid::template Codim<0>::Geometry;
-    using IndexType = typename Grid::LeafGridView::IndexSet::IndexType;
+    using ElementMapper = typename GET_PROP_TYPE(TypeTag, DofMapper);
+    using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
 public:
-    typedef Dumux::SubControlVolume<ScvGeometry, IndexType> type;
-};
+    MockProblem(const GridView& gridView) : mapper_(gridView) {}
 
-SET_PROP(TestFVGeometry, SubControlVolumeFace)
-{
+    const ElementMapper& elementMapper() const
+    { return mapper_; }
 private:
-    using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
-    using ScvfGeometry = typename Grid::template Codim<1>::Geometry;
-    using IndexType = typename Grid::LeafGridView::IndexSet::IndexType;
-public:
-    typedef Dumux::SubControlVolumeFace<ScvfGeometry, IndexType> type;
-
+    ElementMapper mapper_;
 };
 
-SET_TYPE_PROP(TestFVGeometry, FVElementGeometry, FVElementGeometry<TypeTag>);
+namespace Properties
+{
+NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(CCTpfaModel));
 
-SET_TYPE_PROP(TestFVGeometry, FVElementGeometryVector, TpfaFVElementGeometryVector<TypeTag>);
+SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>);
 
+SET_TYPE_PROP(TestFVGeometry, Problem, Dumux::MockProblem<TypeTag>);
 }
+
 }
 
 template<class T>
@@ -107,6 +93,8 @@ int main (int argc, char *argv[]) try
     using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
     using FVElementGeometryVector = typename GET_PROP_TYPE(TypeTag, FVElementGeometryVector);
 
+    using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
+
     // make a grid
     GlobalPosition lower(0.0);
     GlobalPosition upper(1.0);
@@ -114,14 +102,17 @@ int main (int argc, char *argv[]) try
     std::shared_ptr<Grid> grid = Dune::StructuredGridFactory<Grid>::createCubeGrid(lower, upper, els);
     auto leafGridView = grid->leafGridView();
 
+    Problem problem(leafGridView);
+
     FVElementGeometryVector fvGeometries(leafGridView);
-    fvGeometries.update();
+    fvGeometries.update(problem);
 
     // iterate over elements. For every element get fv geometry and loop over scvs and scvfaces
     for (const auto& element : elements(leafGridView))
     {
-        std::cout << std::endl << "Checking fvGeometry of element " << leafGridView.indexSet().index(element) << std::endl;
-        auto fvGeometry = fvGeometries.fvGeometry(element);
+        auto eIdx = problem.elementMapper().index(element);
+        std::cout << std::endl << "Checking fvGeometry of element " << eIdx << std::endl;
+        auto fvGeometry = fvGeometries.fvGeometry(eIdx);
 
         auto range = fvGeometry.scvs();
         NoopFunctor<SubControlVolume> op;
@@ -140,7 +131,9 @@ int main (int argc, char *argv[]) try
 
         for (auto&& scvf : fvGeometry.scvfs())
         {
-            std::cout << "-- scvf center at: " << scvf.center() << std::endl;
+            std::cout << "-- scvf center at: " << scvf.center();
+            if (scvf.boundary()) std::cout << " (on boundary).";
+            std::cout << std::endl;
         }
     }
 }
-- 
GitLab