From 0a97d2fb232e2a08d152ffa92ee1f20a2c7f6e2f Mon Sep 17 00:00:00 2001
From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de>
Date: Thu, 17 Dec 2015 11:28:57 +0100
Subject: [PATCH] [problem] Move isCornerPoint() to more upstream position,
 because it may be used in other circumstances, too.

---
 dumux/implicit/common/implicitproblem.hh      | 15 +++++++++
 .../2cnistokes2p2cni/2p2cnisubproblem.hh      | 28 ++++++-----------
 .../2cnistokes2p2cni/stokes2cnisubproblem.hh  | 31 ++++++-------------
 .../2cnizeroeq2p2cni/2p2cnisubproblem.hh      | 28 ++++++-----------
 .../2cnizeroeq2p2cni/zeroeq2cnisubproblem.hh  | 21 +------------
 .../2cstokes2p2c/2p2csubproblem.hh            | 28 ++++++-----------
 .../2cstokes2p2c/stokes2csubproblem.hh        | 31 ++++++-------------
 .../2czeroeq2p2c/2p2csubproblem.hh            | 28 ++++++-----------
 .../2czeroeq2p2c/zeroeq2csubproblem.hh        | 21 +------------
 9 files changed, 71 insertions(+), 160 deletions(-)

diff --git a/dumux/implicit/common/implicitproblem.hh b/dumux/implicit/common/implicitproblem.hh
index 2d0769972b..6e74bc2cd1 100644
--- a/dumux/implicit/common/implicitproblem.hh
+++ b/dumux/implicit/common/implicitproblem.hh
@@ -680,6 +680,21 @@ public:
     const GlobalPosition &bBoxMax() const
     { return bBoxMax_; }
 
+    /*!
+     * \brief Determines if globalPos is a corner of the grid, this is needed for
+     *        the multidomain models.
+     *
+     * \param globalPos The global position
+     * \param eps The epsilon for comparing the locations
+     */
+    bool isCornerPoint(const GlobalPosition &globalPos, Scalar eps = 1e-8)
+    {
+      return ((globalPos[0] < asImp_().bBoxMin()[0] + eps && globalPos[1] < asImp_().bBoxMin()[1] + eps)
+              || (globalPos[0] < asImp_().bBoxMin()[0] + eps && globalPos[1] > asImp_().bBoxMax()[1] - eps)
+              || (globalPos[0] > asImp_().bBoxMax()[0] - eps && globalPos[1] < asImp_().bBoxMin()[1] + eps)
+              || (globalPos[0] > asImp_().bBoxMax()[0] - eps && globalPos[1] > asImp_().bBoxMax()[1] - eps));
+    }
+
     /*!
      * \brief Returns the mapper for vertices to indices for constant grids.
      */
diff --git a/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh b/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh
index df114ef356..e9dad48372 100644
--- a/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh
+++ b/test/multidomain/2cnistokes2p2cni/2p2cnisubproblem.hh
@@ -205,6 +205,15 @@ public:
         outfile.close();
     }
 
+    // functions have to be overwritten, otherwise they remain uninitialized
+    //! \copydoc Dumux::ImplicitProblem::bBoxMin()
+    const GlobalPosition &bBoxMin() const
+    { return bBoxMin_; }
+
+    //! \copydoc Dumux::ImplicitProblem::bBoxMax()
+    const GlobalPosition &bBoxMax() const
+    { return bBoxMax_; }
+
     /*!
      * \name Problem parameters
      */
@@ -408,19 +417,6 @@ public:
         }
     }
 
-    /*!
-     * \brief Determines if globalPos is a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        return ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)));
-    }
-
     // \}
 
 private:
@@ -451,12 +447,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     static constexpr Scalar eps_ = 1e-8;
     GlobalPosition bBoxMin_;
     GlobalPosition bBoxMax_;
diff --git a/test/multidomain/2cnistokes2p2cni/stokes2cnisubproblem.hh b/test/multidomain/2cnistokes2p2cni/stokes2cnisubproblem.hh
index 228e370cd5..7a73268f75 100644
--- a/test/multidomain/2cnistokes2p2cni/stokes2cnisubproblem.hh
+++ b/test/multidomain/2cnistokes2p2cni/stokes2cnisubproblem.hh
@@ -173,6 +173,15 @@ public:
         initializationTime_ = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, InitTime);
     }
 
+    // functions have to be overwritten, otherwise they remain uninitialized
+    //! \copydoc Dumux::ImplicitProblem::bBoxMin()
+    const GlobalPosition &bBoxMin() const
+    { return bBoxMin_; }
+
+    //! \copydoc Dumux::ImplicitProblem::bBoxMax()
+    const GlobalPosition &bBoxMax() const
+    { return bBoxMax_; }
+
     /*!
      * \name Problem parameters
      */
@@ -370,22 +379,6 @@ public:
     }
     // \}
 
-    /*!
-     * \brief Determines if globalPos is a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        if ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)))
-            return true;
-        else
-            return false;
-    }
-
     //! \brief Returns the reference velocity.
     const Scalar refVelocity() const
     { return refVelocity_ + variation_(sinusVAmplitude_, sinusVPeriod_); }
@@ -458,12 +451,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     const Scalar height_() const
     { return bBoxMax_[1] - bBoxMin_[1]; }
 
diff --git a/test/multidomain/2cnizeroeq2p2cni/2p2cnisubproblem.hh b/test/multidomain/2cnizeroeq2p2cni/2p2cnisubproblem.hh
index 9d7f8ebbba..5f413336dc 100644
--- a/test/multidomain/2cnizeroeq2p2cni/2p2cnisubproblem.hh
+++ b/test/multidomain/2cnizeroeq2p2cni/2p2cnisubproblem.hh
@@ -194,6 +194,15 @@ public:
         outfile.close();
     }
 
+    // functions have to be overwritten, otherwise they remain uninitialized
+    //! \copydoc Dumux::ImplicitProblem::bBoxMin()
+    const GlobalPosition &bBoxMin() const
+    { return bBoxMin_; }
+
+    //! \copydoc Dumux::ImplicitProblem::bBoxMax()
+    const GlobalPosition &bBoxMax() const
+    { return bBoxMax_; }
+
     /*!
      * \name Problem parameters
      */
@@ -334,19 +343,6 @@ public:
         }
     }
 
-    /*!
-     * \brief Determine if we are on a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        return ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)));
-    }
-
     // \}
 
 private:
@@ -375,12 +371,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     static constexpr Scalar eps_ = 1e-8;
     GlobalPosition bBoxMin_;
     GlobalPosition bBoxMax_;
diff --git a/test/multidomain/2cnizeroeq2p2cni/zeroeq2cnisubproblem.hh b/test/multidomain/2cnizeroeq2p2cni/zeroeq2cnisubproblem.hh
index b2e3d1b1be..e76f41abd0 100644
--- a/test/multidomain/2cnizeroeq2p2cni/zeroeq2cnisubproblem.hh
+++ b/test/multidomain/2cnizeroeq2p2cni/zeroeq2cnisubproblem.hh
@@ -170,7 +170,7 @@ public:
         refTemperature_ = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, FreeFlow, RefTemperature);
     }
 
-    // functions have to be overwritten, otherwise they remain uninitialised
+    // functions have to be overwritten, otherwise they remain uninitialized
     //! \copydoc Dumux::ImplicitProblem::bBoxMin()
     const GlobalPosition &bBoxMin() const
     { return bBoxMin_; }
@@ -278,19 +278,6 @@ public:
 
     // \}
 
-    /*!
-     * \brief Determine if we are on a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        return ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)));
-    }
-
     //! \brief Returns the velocity at the inflow.
     const Scalar refVelocity() const
     {
@@ -356,12 +343,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     static constexpr Scalar eps_ = 1e-8;
     GlobalPosition bBoxMin_;
     GlobalPosition bBoxMax_;
diff --git a/test/multidomain/2cstokes2p2c/2p2csubproblem.hh b/test/multidomain/2cstokes2p2c/2p2csubproblem.hh
index e8ba6ea621..253cfa3535 100644
--- a/test/multidomain/2cstokes2p2c/2p2csubproblem.hh
+++ b/test/multidomain/2cstokes2p2c/2p2csubproblem.hh
@@ -176,6 +176,15 @@ public:
         outfile.close();
     }
 
+    // functions have to be overwritten, otherwise they remain uninitialized
+    //! \copydoc ImplicitProblem::bBoxMin()
+    const GlobalPosition &bBoxMin() const
+    { return bBoxMin_; }
+
+    //! \copydoc ImplicitProblem::bBoxMax()
+    const GlobalPosition &bBoxMax() const
+    { return bBoxMax_; }
+
     /*!
      * \name Problem parameters
      */
@@ -369,19 +378,6 @@ public:
         }
     }
 
-    /*!
-     * \brief Determines if globalPos is a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        return ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)));
-    }
-
     // \}
 private:
     /*!
@@ -408,12 +404,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     static constexpr Scalar eps_ = 1e-8;
     GlobalPosition bBoxMin_;
     GlobalPosition bBoxMax_;
diff --git a/test/multidomain/2cstokes2p2c/stokes2csubproblem.hh b/test/multidomain/2cstokes2p2c/stokes2csubproblem.hh
index 37f045bc0b..69f83590c4 100644
--- a/test/multidomain/2cstokes2p2c/stokes2csubproblem.hh
+++ b/test/multidomain/2cstokes2p2c/stokes2csubproblem.hh
@@ -168,6 +168,15 @@ public:
         initializationTime_ = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, InitTime);
     }
 
+    // functions have to be overwritten, otherwise they remain uninitialized
+    //! \copydoc ImplicitProblem::bBoxMin()
+    const GlobalPosition &bBoxMin() const
+    { return bBoxMin_; }
+
+    //! \copydoc ImplicitProblem::bBoxMax()
+    const GlobalPosition &bBoxMax() const
+    { return bBoxMax_; }
+
     /*!
      * \name Problem parameters
      */
@@ -344,22 +353,6 @@ public:
     }
     // \}
 
-    /*!
-     * \brief Determines if globalPos is a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        if ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos)) ||
-            (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)))
-            return true;
-        else
-            return false;
-    }
-
     //! \brief Returns the reference velocity.
     const Scalar refVelocity() const
     { return refVelocity_ + variation_(sinusVAmplitude_, sinusVPeriod_); }
@@ -431,12 +424,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     // the height of the free-flow domain
     const Scalar height_() const
     { return bBoxMax_[1] - bBoxMin_[1]; }
diff --git a/test/multidomain/2czeroeq2p2c/2p2csubproblem.hh b/test/multidomain/2czeroeq2p2c/2p2csubproblem.hh
index 904dcfecd0..073ebd4ee6 100644
--- a/test/multidomain/2czeroeq2p2c/2p2csubproblem.hh
+++ b/test/multidomain/2czeroeq2p2c/2p2csubproblem.hh
@@ -174,6 +174,15 @@ public:
         outfile.close();
     }
 
+    // functions have to be overwritten, otherwise they remain uninitialized
+    //! \copydoc ImplicitProblem::bBoxMin()
+    const GlobalPosition &bBoxMin() const
+    { return bBoxMin_; }
+
+    //! \copydoc ImplicitProblem::bBoxMax()
+    const GlobalPosition &bBoxMax() const
+    { return bBoxMax_; }
+
     /*!
      * \name Problem parameters
      */
@@ -328,19 +337,6 @@ public:
         }
     }
 
-    /*!
-     * \brief Determines if globalPos is a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        return ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)));
-    }
-
 private:
     // Internal method for the initial condition (reused for the dirichlet conditions!)
     void initial_(PrimaryVariables &values,
@@ -363,12 +359,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     static constexpr Scalar eps_ = 1e-8;
     GlobalPosition bBoxMin_;
     GlobalPosition bBoxMax_;
diff --git a/test/multidomain/2czeroeq2p2c/zeroeq2csubproblem.hh b/test/multidomain/2czeroeq2p2c/zeroeq2csubproblem.hh
index 9beed5ef22..85c93f996e 100644
--- a/test/multidomain/2czeroeq2p2c/zeroeq2csubproblem.hh
+++ b/test/multidomain/2czeroeq2p2c/zeroeq2csubproblem.hh
@@ -170,7 +170,7 @@ public:
         refTemperature_ = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, FreeFlow, RefTemperature);
     }
 
-    // functions have to be overwritten, otherwise they remain uninitialised
+    // functions have to be overwritten, otherwise they remain uninitialized
     //! \copydoc ImplicitProblem::bBoxMin()
     const GlobalPosition &bBoxMin() const
     { return bBoxMin_; }
@@ -295,19 +295,6 @@ public:
 
     // \}
 
-    /*!
-     * \brief Determines if globalPos is a corner of the grid
-     *
-     * \param globalPos The global position
-     */
-    bool isCornerPoint(const GlobalPosition &globalPos)
-    {
-        return ((onLeftBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onLeftBoundary_(globalPos) && onUpperBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onLowerBoundary_(globalPos))
-                || (onRightBoundary_(globalPos) && onUpperBoundary_(globalPos)));
-    }
-
     //! \brief Returns the velocity at the inflow.
     const Scalar refVelocity() const
     {
@@ -386,12 +373,6 @@ private:
     bool onUpperBoundary_(const GlobalPosition &globalPos) const
     { return globalPos[1] > bBoxMax_[1] - eps_; }
 
-    bool onBoundary_(const GlobalPosition &globalPos) const
-    {
-        return (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos)
-                || onLowerBoundary_(globalPos) || onUpperBoundary_(globalPos));
-    }
-
     static constexpr Scalar eps_ = 1e-8;
     GlobalPosition bBoxMin_;
     GlobalPosition bBoxMax_;
-- 
GitLab