From 0065e694d476869cb97a3b97fedd0eed0a9ae8d3 Mon Sep 17 00:00:00 2001
From: Simon Scholz <simon.scholz@iws.uni-stuttgart.de>
Date: Wed, 28 Aug 2019 16:48:57 +0200
Subject: [PATCH] deprecate FVGridGeometry property and use GridGeometry

---
 dumux/assembly/fvassembler.hh          | 42 +++++++++++++++-----------
 dumux/assembly/staggeredfvassembler.hh | 19 +++++++-----
 dumux/common/fvproblem.hh              |  5 +++
 dumux/common/properties.hh             |  4 +++
 dumux/multidomain/fvassembler.hh       | 19 +++++++++---
 dumux/multidomain/staggeredtraits.hh   |  3 +-
 dumux/multidomain/traits.hh            |  3 +-
 7 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/dumux/assembly/fvassembler.hh b/dumux/assembly/fvassembler.hh
index 421667059a..8453fe4823 100644
--- a/dumux/assembly/fvassembler.hh
+++ b/dumux/assembly/fvassembler.hh
@@ -56,7 +56,7 @@ class FVAssembler
     using TimeLoop = TimeLoopBase<GetPropType<TypeTag, Properties::Scalar>>;
     using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
 
-    static constexpr DiscretizationMethod discMethod = GetPropType<TypeTag, Properties::FVGridGeometry>::discMethod;
+    static constexpr DiscretizationMethod discMethod = GetPropType<TypeTag, Properties::GridGeometry>::discMethod;
     static constexpr bool isBox = discMethod == DiscretizationMethod::box;
 
     using ThisType = FVAssembler<TypeTag, diffMethod, isImplicit>;
@@ -66,7 +66,8 @@ class FVAssembler
 public:
     using Scalar = GetPropType<TypeTag, Properties::Scalar>;
     using JacobianMatrix = GetPropType<TypeTag, Properties::JacobianMatrix>;
-    using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
+    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
+    using FVGridGeometry [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] = GridGeometry;
     using Problem = GetPropType<TypeTag, Properties::Problem>;
     using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
 
@@ -78,10 +79,10 @@ public:
      *       it is however guaranteed that the state after assembly will be the same as before
      */
     FVAssembler(std::shared_ptr<const Problem> problem,
-                std::shared_ptr<const FVGridGeometry> fvGridGeometry,
+                std::shared_ptr<const GridGeometry> gridGeometry,
                 std::shared_ptr<GridVariables> gridVariables)
     : problem_(problem)
-    , fvGridGeometry_(fvGridGeometry)
+    , gridGeometry_(gridGeometry)
     , gridVariables_(gridVariables)
     , timeLoop_()
     , isStationaryProblem_(true)
@@ -111,12 +112,12 @@ public:
      *       it is however guaranteed that the state after assembly will be the same as before
      */
     FVAssembler(std::shared_ptr<const Problem> problem,
-                std::shared_ptr<const FVGridGeometry> fvGridGeometry,
+                std::shared_ptr<const GridGeometry> gridGeometry,
                 std::shared_ptr<GridVariables> gridVariables,
                 std::shared_ptr<const TimeLoop> timeLoop,
                 const SolutionVector& prevSol)
     : problem_(problem)
-    , fvGridGeometry_(fvGridGeometry)
+    , gridGeometry_(gridGeometry)
     , gridVariables_(gridVariables)
     , timeLoop_(timeLoop)
     , prevSol_(&prevSol)
@@ -140,7 +141,7 @@ public:
             localAssembler.assembleJacobianAndResidual(*jacobian_, *residual_, *gridVariables_, partialReassembler);
         });
 
-        enforcePeriodicConstraints_(*jacobian_, *residual_, *fvGridGeometry_);
+        enforcePeriodicConstraints_(*jacobian_, *residual_, *gridGeometry_);
     }
 
     /*!
@@ -189,9 +190,9 @@ public:
         // for box communicate the residual with the neighboring processes
         if (isBox && gridView().comm().size() > 1)
         {
-            using VertexMapper = typename FVGridGeometry::VertexMapper;
+            using VertexMapper = typename GridGeometry::VertexMapper;
             VertexHandleSum<typename SolutionVector::block_type, SolutionVector, VertexMapper>
-            sumResidualHandle(residual, fvGridGeometry_->vertexMapper());
+            sumResidualHandle(residual, gridGeometry_->vertexMapper());
             gridView().communicate(sumResidualHandle,
                                    Dune::InteriorBorder_InteriorBorder_Interface,
                                    Dune::ForwardCommunication);
@@ -251,7 +252,7 @@ public:
         jacobian_->setSize(numDofs, numDofs);
 
         // create occupation pattern of the jacobian
-        const auto occupationPattern = getJacobianPattern<isImplicit>(fvGridGeometry());
+        const auto occupationPattern = getJacobianPattern<isImplicit>(gridGeometry());
 
         // export pattern to jacobian
         occupationPattern.exportIdx(*jacobian_);
@@ -263,19 +264,24 @@ public:
 
     //! Returns the number of degrees of freedom
     std::size_t numDofs() const
-    { return fvGridGeometry_->numDofs(); }
+    { return gridGeometry_->numDofs(); }
 
     //! The problem
     const Problem& problem() const
     { return *problem_; }
 
     //! The global finite volume geometry
-    const FVGridGeometry& fvGridGeometry() const
-    { return *fvGridGeometry_; }
+    [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]]
+    const GridGeometry& fvGridGeometry() const
+    { return gridGeometry(); }
+
+    //! The global finite volume geometry
+    const GridGeometry& gridGeometry() const
+    { return *gridGeometry_; }
 
     //! The gridview
     const GridView& gridView() const
-    { return fvGridGeometry().gridView(); }
+    { return gridGeometry().gridView(); }
 
     //! The global grid variables
     GridVariables& gridVariables()
@@ -416,9 +422,9 @@ private:
     }
 
     template<class GG> std::enable_if_t<GG::discMethod == DiscretizationMethod::box, void>
-    enforcePeriodicConstraints_(JacobianMatrix& jac, SolutionVector& res, const GG& fvGridGeometry)
+    enforcePeriodicConstraints_(JacobianMatrix& jac, SolutionVector& res, const GG& gridGeometry)
     {
-        for (const auto& m : fvGridGeometry.periodicVertexMap())
+        for (const auto& m : gridGeometry.periodicVertexMap())
         {
             if (m.first < m.second)
             {
@@ -436,13 +442,13 @@ private:
     }
 
     template<class GG> std::enable_if_t<GG::discMethod != DiscretizationMethod::box, void>
-    enforcePeriodicConstraints_(JacobianMatrix& jac, SolutionVector& res, const GG& fvGridGeometry) {}
+    enforcePeriodicConstraints_(JacobianMatrix& jac, SolutionVector& res, const GG& gridGeometry) {}
 
     //! pointer to the problem to be solved
     std::shared_ptr<const Problem> problem_;
 
     //! the finite volume geometry of the grid
-    std::shared_ptr<const FVGridGeometry> fvGridGeometry_;
+    std::shared_ptr<const GridGeometry> gridGeometry_;
 
     //! the variables container for the grid
     std::shared_ptr<GridVariables> gridVariables_;
diff --git a/dumux/assembly/staggeredfvassembler.hh b/dumux/assembly/staggeredfvassembler.hh
index 82a005b10f..59d1b18858 100644
--- a/dumux/assembly/staggeredfvassembler.hh
+++ b/dumux/assembly/staggeredfvassembler.hh
@@ -65,16 +65,17 @@ class StaggeredFVAssembler: public MultiDomainFVAssembler<StaggeredMultiDomainTr
     using TimeLoop = TimeLoopBase<GetPropType<TypeTag, Properties::Scalar>>;
 
 public:
-    using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
+    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
+    using FVGridGeometry [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] = GridGeometry;
     using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
     using CouplingManager = typename ParentType::CouplingManager;
 
     //! The constructor for stationary problems
     StaggeredFVAssembler(std::shared_ptr<const Problem> problem,
-                         std::shared_ptr<const FVGridGeometry> fvGridGeometry,
+                         std::shared_ptr<const GridGeometry> gridGeometry,
                          std::shared_ptr<GridVariables> gridVariables)
     : ParentType(std::make_tuple(problem, problem),
-                 std::make_tuple(fvGridGeometry->cellCenterFVGridGeometryPtr(), fvGridGeometry->faceFVGridGeometryPtr()),
+                 std::make_tuple(gridGeometry->cellCenterFVGridGeometryPtr(), gridGeometry->faceFVGridGeometryPtr()),
                  std::make_tuple(gridVariables->cellCenterGridVariablesPtr(), gridVariables->faceGridVariablesPtr()),
                  std::make_shared<CouplingManager>())
     {
@@ -85,11 +86,11 @@ public:
     //! The constructor for instationary problems
     [[deprecated("Please use the constructor additionally taking the previous solution. Will be removed after 3.2 release!")]]
     StaggeredFVAssembler(std::shared_ptr<const Problem> problem,
-                         std::shared_ptr<const FVGridGeometry> fvGridGeometry,
+                         std::shared_ptr<const GridGeometry> gridGeometry,
                          std::shared_ptr<GridVariables> gridVariables,
                          std::shared_ptr<const TimeLoop> timeLoop)
     : ParentType(std::make_tuple(problem, problem),
-                 std::make_tuple(fvGridGeometry->cellCenterFVGridGeometryPtr(), fvGridGeometry->faceFVGridGeometryPtr()),
+                 std::make_tuple(gridGeometry->cellCenterFVGridGeometryPtr(), gridGeometry->faceFVGridGeometryPtr()),
                  std::make_tuple(gridVariables->cellCenterGridVariablesPtr(), gridVariables->faceGridVariablesPtr()),
                  std::make_shared<CouplingManager>(),
                  timeLoop)
@@ -123,8 +124,12 @@ public:
     { return ParentType::gridVariables(Dune::index_constant<0>()); }
 
     //! The global finite volume geometry
-    const FVGridGeometry& fvGridGeometry() const
-    { return ParentType::fvGridGeometry(Dune::index_constant<0>()).actualfvGridGeometry(); }
+    [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]]
+    const GridGeometry& fvGridGeometry() const
+    { return gridGeometry(); }
+
+    const GridGeometry& gridGeometry() const
+    { return ParentType::gridGeometry(Dune::index_constant<0>()).actualfvGridGeometry(); }
 
 };
 
diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh
index 80b5065ff7..21c87a31f8 100644
--- a/dumux/common/fvproblem.hh
+++ b/dumux/common/fvproblem.hh
@@ -580,7 +580,12 @@ public:
     // \}
 
     //! The finite volume grid geometry
+    [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]]
     const FVGridGeometry& fvGridGeometry() const
+    { return gridGeometry(); }
+
+    //! The finite volume grid geometry
+    const FVGridGeometry& gridGeometry() const
     { return *fvGridGeometry_; }
 
     //! The parameter group in which to retrieve runtime parameters
diff --git a/dumux/common/properties.hh b/dumux/common/properties.hh
index 7b6e54457c..72478c8bf0 100644
--- a/dumux/common/properties.hh
+++ b/dumux/common/properties.hh
@@ -111,8 +111,12 @@ struct BalanceEqOpts { using type = UndefinedProperty; };          //!< A class
 template<class TypeTag, class MyTypeTag>
 struct ElementBoundaryTypes { using type = UndefinedProperty; };                //!< Stores the boundary types on an element
 
+// TODO: Remove deprecated property FVGridGeometry after 3.1
 template<class TypeTag, class MyTypeTag>
 struct FVGridGeometry { using type = UndefinedProperty; };                      //!< The type of the global finite volume geometry
+template<class TypeTag, class MyTypeTag>
+struct GridGeometry { using type = GetPropType<TypeTag, Properties::FVGridGeometry>;  };       //!< The type of the global finite volume geometry
+
 template<class TypeTag, class MyTypeTag>
 struct EnableFVGridGeometryCache { using type = UndefinedProperty; };           //!< specifies if geometric data is saved (faster, but more memory consuming)
 
diff --git a/dumux/multidomain/fvassembler.hh b/dumux/multidomain/fvassembler.hh
index 1ef43029a5..40fadeb18f 100644
--- a/dumux/multidomain/fvassembler.hh
+++ b/dumux/multidomain/fvassembler.hh
@@ -73,7 +73,10 @@ public:
     using GridVariables = typename MDTraits::template SubDomain<id>::GridVariables;
 
     template<std::size_t id>
-    using FVGridGeometry = typename MDTraits::template SubDomain<id>::FVGridGeometry;
+    using GridGeometry = typename MDTraits::template SubDomain<id>::GridGeometry;
+
+    template<std::size_t id>
+    using FVGridGeometry [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] = GridGeometry<id>;
 
     template<std::size_t id>
     using Problem = typename MDTraits::template SubDomain<id>::Problem;
@@ -357,13 +360,19 @@ public:
 
     //! the finite volume grid geometry of domain i
     template<std::size_t i>
+    [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]]
     const auto& fvGridGeometry(Dune::index_constant<i> domainId) const
+    { return gridGeometry(domainId); }
+
+    //! the finite volume grid geometry of domain i
+    template<std::size_t i>
+    const auto& gridGeometry(Dune::index_constant<i> domainId) const
     { return *std::get<domainId>(fvGridGeometryTuple_); }
 
     //! the grid view of domain i
     template<std::size_t i>
     const auto& gridView(Dune::index_constant<i> domainId) const
-    { return fvGridGeometry(domainId).gridView(); }
+    { return gridGeometry(domainId).gridView(); }
 
     //! the grid variables of domain i
     template<std::size_t i>
@@ -500,7 +509,7 @@ private:
     Dune::MatrixIndexSet getJacobianPattern_(Dune::index_constant<i> domainI,
                                              Dune::index_constant<j> domainJ) const
     {
-        const auto& gg = fvGridGeometry(domainI);
+        const auto& gg = gridGeometry(domainI);
         auto pattern = getJacobianPattern<isImplicit()>(gg);
         couplingManager_->extendJacobianPattern(domainI, pattern);
         return pattern;
@@ -512,8 +521,8 @@ private:
                                              Dune::index_constant<j> domainJ) const
     {
         return getCouplingJacobianPattern<isImplicit()>(*couplingManager_,
-                                                        domainI, fvGridGeometry(domainI),
-                                                        domainJ, fvGridGeometry(domainJ));
+                                                        domainI, gridGeometry(domainI),
+                                                        domainJ, gridGeometry(domainJ));
     }
 
     //! pointer to the problem to be solved
diff --git a/dumux/multidomain/staggeredtraits.hh b/dumux/multidomain/staggeredtraits.hh
index 96bbc26a17..a3c88fc9c1 100644
--- a/dumux/multidomain/staggeredtraits.hh
+++ b/dumux/multidomain/staggeredtraits.hh
@@ -194,7 +194,8 @@ public:
         using Index = Dune::index_constant<id>;
         using TypeTag = SubDomainTypeTag<id>;
         using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
-        using FVGridGeometry = typename Detail::Staggered::SubDomainFVGridGeometryImpl<SubDomainTypeTag, id>::type;
+        using GridGeometry = typename Detail::Staggered::SubDomainFVGridGeometryImpl<SubDomainTypeTag, id>::type;
+        using FVGridGeometry [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] = GridGeometry;
         using GridVariables = typename Detail::Staggered::SubDomainGridVariablesImpl<SubDomainTypeTag, id>::type;
         using SolutionVector = typename Detail::Staggered::SubDomainSolutionVectorImpl<SubDomainTypeTag, id>::type;
         using PrimaryVariables = typename Detail::Staggered::SubDomainPrimaryVariablesImpl<SubDomainTypeTag, id>::type;
diff --git a/dumux/multidomain/traits.hh b/dumux/multidomain/traits.hh
index bd282f9632..fd300dc0b1 100644
--- a/dumux/multidomain/traits.hh
+++ b/dumux/multidomain/traits.hh
@@ -181,7 +181,8 @@ public:
         using Index = Dune::index_constant<id>;
         using TypeTag = SubDomainTypeTag<id>;
         using Grid = GetPropType<SubDomainTypeTag<id>, Properties::Grid>;
-        using FVGridGeometry = GetPropType<SubDomainTypeTag<id>, Properties::FVGridGeometry>;
+        using GridGeometry = GetPropType<SubDomainTypeTag<id>, Properties::GridGeometry>;
+        using FVGridGeometry [[deprecated("Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] = GridGeometry;
         using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
         using GridVariables =GetPropType<SubDomainTypeTag<id>, Properties::GridVariables>;
         using IOFields = GetPropType<SubDomainTypeTag<id>, Properties::IOFields>;
-- 
GitLab