From 12bf275e8290a2a85cbb4a58b3935c48bff603c8 Mon Sep 17 00:00:00 2001
From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de>
Date: Mon, 21 Nov 2016 11:25:55 +0100
Subject: [PATCH] [zeroeq] Update method set walls

* functions bBoxMaxIsWall() and bBoxMaxIsWall() in the problem are now used instead of a property
* wall array is now a std::vector
---
 CHANGELOG.md                                  |  3 ++
 dumux/freeflow/zeroeq/model.hh                | 35 +++++++++----------
 dumux/freeflow/zeroeq/problem.hh              | 16 +++++++++
 dumux/freeflow/zeroeq/properties.hh           |  2 --
 dumux/freeflow/zeroeq/propertydefaults.hh     |  6 ----
 dumux/freeflow/zeroeqnc/model.hh              | 10 +++---
 dumux/freeflow/zeroeqncni/model.hh            |  8 ++---
 .../zeroeq/zeroeqchanneltestproblem.hh        | 11 ++++--
 8 files changed, 51 insertions(+), 40 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d24cc1720..d9da880393 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,9 @@ Differences Between DuMuX 2.10 and DuMuX 2.11
 * IMPROVEMENTS and ENHANCEMENTS:
 
 * IMMEDIATE INTERFACE CHANGES not allowing/requiring a deprecation period:
+    - In the ZeroEq models, the properties BBoxMinIsWall and BBoxMaxIsWall have
+      been replaced by the functions bBoxMaxIsWall() and bBoxMaxIsWall() in the
+      problem file.
 
 * Deprecated PROPERTY and PARAMETER NAMES, to be removed after 2.11: BEWARE: The
   compiler will not print any warning if a deprecated property or parameter name
diff --git a/dumux/freeflow/zeroeq/model.hh b/dumux/freeflow/zeroeq/model.hh
index 25532d2fd5..53f1d2c356 100644
--- a/dumux/freeflow/zeroeq/model.hh
+++ b/dumux/freeflow/zeroeq/model.hh
@@ -75,9 +75,6 @@ class ZeroEqModel : public GET_PROP_TYPE(TypeTag, BaseStokesModel)
         dim = GridView::dimension,
         dimWorld = GridView::dimensionworld,
         intervals = GET_PROP_VALUE(TypeTag, NumberOfIntervals),
-        bboxMinIsWall = GET_PROP_VALUE(TypeTag, BBoxMinIsWall),
-        bboxMaxIsWall = GET_PROP_VALUE(TypeTag, BBoxMaxIsWall),
-        walls = (bboxMinIsWall ? 1 : 0) + (bboxMaxIsWall ? 1 : 0)
     };
 
     typedef Dune::ReferenceElements<Scalar, dim> ReferenceElements;
@@ -110,6 +107,9 @@ public:
                         << GET_PARAM_FROM_GROUP(TypeTag, int, ZeroEq, EddyViscosityModel)
                         << "." << std::endl;
         }
+
+        wall.resize((this->problem_().bBoxMinIsWall() ? 1 : 0)
+                    + (this->problem_().bBoxMaxIsWall() ? 1 : 0));
     }
 
     /*!
@@ -364,7 +364,7 @@ public:
         bool headerWritten[intervals];         //!< Header of scv-data file was already written.
         WallProperties() {}                    //!< Constructor for wall properties.
     };
-    WallProperties wall[walls];
+    std::vector<WallProperties> wall;
 
     /*!
      * \brief Initializes the wall structure with values.
@@ -375,20 +375,20 @@ public:
      */
     void resetWallProperties()
     {
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < wall.size(); ++wallIdx)
         {
             for (int posIdx = 0; posIdx < intervals; ++posIdx)
             {
-                if (walls == 1)
+                if (wall.size() == 1)
                 {
-                    if (bboxMinIsWall)
+                    if (this->problem_().bBoxMinIsWall())
                     {
                         wall[wallIdx].wallPos[posIdx] = this->problem_().bBoxMin()[wallNormal_];
                         wall[wallIdx].boundaryLayerThickness[posIdx] = this->problem_().bBoxMax()[wallNormal_] - this->problem_().bBoxMin()[wallNormal_] + eps_;
                         wall[wallIdx].isBBoxMinWall = true;
                         wall[wallIdx].sandGrainRoughness[posIdx] = GET_PARAM_FROM_GROUP(TypeTag, Scalar, ZeroEq, BBoxMinSandGrainRoughness);
                     }
-                    if (bboxMaxIsWall)
+                    if (this->problem_().bBoxMaxIsWall())
                     {
                         wall[wallIdx].wallPos[posIdx] = this->problem_().bBoxMax()[wallNormal_];
                         wall[wallIdx].boundaryLayerThickness[posIdx] = this->problem_().bBoxMin()[wallNormal_] - this->problem_().bBoxMax()[wallNormal_] - eps_;
@@ -396,7 +396,7 @@ public:
                         wall[wallIdx].sandGrainRoughness[posIdx] = GET_PARAM_FROM_GROUP(TypeTag, Scalar, ZeroEq, BBoxMaxSandGrainRoughness);
                     }
                 }
-                if (walls == 2 && wallIdx == 0)
+                if (wall.size() == 2 && wallIdx == 0)
                 {
                     wall[0].wallPos[posIdx] = this->problem_().bBoxMin()[wallNormal_];
                     wall[1].wallPos[posIdx] = this->problem_().bBoxMax()[wallNormal_];
@@ -431,7 +431,7 @@ public:
      */
     void resetWallFluidProperties()
     {
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < wall.size(); ++wallIdx)
             for (int posIdx = 0; posIdx < intervals; ++posIdx)
             {
                 wall[wallIdx].wallDensity[posIdx] = 0.0;
@@ -453,7 +453,7 @@ public:
         asImp_().updateCrossLength();
         asImp_().resetWallFluidProperties();
         asImp_().updateWallFluidProperties();
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < wall.size(); ++wallIdx)
         {
             for (int posIdx = 0; posIdx < intervals; ++posIdx)
                 if (wall[wallIdx].viscousSublayerThicknessCalculated[posIdx] > wall[wallIdx].boundaryLayerThicknessCalculated[posIdx])
@@ -484,10 +484,10 @@ public:
      */
     int getWallIdx(const GlobalPosition &globalPos, const int posIdx) const
     {
-        if (walls == 0)
+        if (wall.size() == 0)
             DUNE_THROW(Dune::NotImplemented, "Eddy viscosity models are not implemented for use without walls.");
 
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < wall.size(); ++wallIdx)
             if ((wall[wallIdx].isBBoxMinWall && globalPos[wallNormal_] < wall[wallIdx].wallPos[posIdx] + wall[wallIdx].boundaryLayerThickness[posIdx])
                  || (!wall[wallIdx].isBBoxMinWall && globalPos[wallNormal_] > wall[wallIdx].wallPos[posIdx] + wall[wallIdx].boundaryLayerThickness[posIdx]))
             {
@@ -576,7 +576,7 @@ public:
      */
     bool useViscosityInner(const GlobalPosition &globalPos, const int posIdx) const
     {
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < wall.size(); ++wallIdx)
             if ((wall[wallIdx].isBBoxMinWall && globalPos[wallNormal_] < wall[wallIdx].wallPos[posIdx] + wall[wallIdx].crossLength[posIdx])
                 || (!wall[wallIdx].isBBoxMinWall && globalPos[wallNormal_] > wall[wallIdx].wallPos[posIdx] + wall[wallIdx].crossLength[posIdx]))
                 return true;
@@ -635,12 +635,12 @@ public:
             {
                 wall[wallIdx].maxVelocity[posIdx][dimIdx] = fluxVars.velocity()[dimIdx];
 //                 // if the values in the middle should be set on both wall
-//                 for (int wIdx = 0; wIdx < walls; ++wIdx)
+//                 for (int wIdx = 0; wIdx < wall.size(); ++wIdx)
 //                     if (std::abs(distanceToWallReal(globalPos, wallIdx, posIdx)) < std::abs(wall[wIdx].boundaryLayerThickness[posIdx] + 1e-5))
 //                         wall[wIdx].maxVelocity[posIdx][dimIdx] = fluxVars.velocity()[dimIdx];
                 // set it as maxVelocityAbs
                 if (std::abs(wall[wallIdx].maxVelocityAbs[posIdx][dimIdx]) < std::abs(fluxVars.velocity()[dimIdx]))
-                    for (int wIdx = 0; wIdx < walls; ++wIdx)
+                    for (int wIdx = 0; wIdx < wall.size(); ++wIdx)
                         wall[wIdx].maxVelocityAbs[posIdx][dimIdx] = fluxVars.velocity()[dimIdx];
                 wall[wallIdx].fluxValuesCount[posIdx]++;
             }
@@ -654,7 +654,7 @@ public:
             wall[wallIdx].fMax[posIdx] = fluxVars.fz();
             wall[wallIdx].yMax[posIdx] = distanceToWallRough(globalPos, wallIdx, posIdx);
 //            // if the values in the middle should be set on both wall
-//            for (int wIdx = 0; wIdx < walls; ++wIdx)
+//            for (int wIdx = 0; wIdx < wall.size(); ++wIdx)
 //                if (std::abs(distanceToWall(globalPos, wIdx, posIdx)) < std::abs(wall[wIdx].boundaryLayerThickness[posIdx] + 1e-4))
 //                    {
 //                        wall[wIdx].fMax[posIdx] = fluxVars.fz();
@@ -988,7 +988,6 @@ public:
         }
     }
 
-
 protected:
     //! Current implementation.
     Implementation &asImp_()
diff --git a/dumux/freeflow/zeroeq/problem.hh b/dumux/freeflow/zeroeq/problem.hh
index 07488b0977..0603e60f44 100644
--- a/dumux/freeflow/zeroeq/problem.hh
+++ b/dumux/freeflow/zeroeq/problem.hh
@@ -75,6 +75,22 @@ public:
     {
         this->model().updateWallProperties();
     }
+
+    /*!
+     * \brief The left/lower boundary in ZeroEqWallNormal direction is a wall
+     */
+    bool bBoxMinIsWall()
+    {
+        return true;
+    }
+
+    /*!
+     * \brief The right/upper boundary in ZeroEqWallNormal direction is a wall
+     */
+    bool bBoxMaxIsWall()
+    {
+        return true;
+    }
 };
 
 }
diff --git a/dumux/freeflow/zeroeq/properties.hh b/dumux/freeflow/zeroeq/properties.hh
index e46ddd8508..006ebec52c 100644
--- a/dumux/freeflow/zeroeq/properties.hh
+++ b/dumux/freeflow/zeroeq/properties.hh
@@ -50,8 +50,6 @@ NEW_TYPE_TAG(BoxZeroEq, INHERITS_FROM(BoxStokes));
 //////////////////////////////////////////////////////////////////
 
 NEW_PROP_TAG(KarmanConstant); //!< The Karman constant
-NEW_PROP_TAG(BBoxMinIsWall); //!< Sets BBoxMin as a wall
-NEW_PROP_TAG(BBoxMaxIsWall); //!< Sets BBoxMax as a wall
 NEW_PROP_TAG(ZeroEqFlowNormal); //!< Indicates the main flow direction
 NEW_PROP_TAG(ZeroEqWallNormal); //!< Indicates the wall normal direction
 NEW_PROP_TAG(ZeroEqBBoxMinSandGrainRoughness); //!< Sets a sand grain roughness at BBoxMin
diff --git a/dumux/freeflow/zeroeq/propertydefaults.hh b/dumux/freeflow/zeroeq/propertydefaults.hh
index 46bcb756ba..4e488f6746 100644
--- a/dumux/freeflow/zeroeq/propertydefaults.hh
+++ b/dumux/freeflow/zeroeq/propertydefaults.hh
@@ -58,12 +58,6 @@ SET_BOOL_PROP(BoxZeroEq, EnableNavierStokes, true);
 //! Set the Karman constant \f$[-]\f$
 SET_SCALAR_PROP(BoxZeroEq, KarmanConstant, 0.41);
 
-//! Set BBoxMin of wall normal direction as a wall
-SET_BOOL_PROP(BoxZeroEq, BBoxMinIsWall, true);
-
-//! Set BBoxMax of wall normal direction as a wall
-SET_BOOL_PROP(BoxZeroEq, BBoxMaxIsWall, true);
-
 //! Set main flow direction
 SET_INT_PROP(BoxZeroEq, ZeroEqFlowNormal, 0);
 
diff --git a/dumux/freeflow/zeroeqnc/model.hh b/dumux/freeflow/zeroeqnc/model.hh
index 93571947cd..38d24e68cc 100644
--- a/dumux/freeflow/zeroeqnc/model.hh
+++ b/dumux/freeflow/zeroeqnc/model.hh
@@ -85,9 +85,7 @@ class ZeroEqncModel : public ZeroEqModel<TypeTag>
     enum {
         dim = GridView::dimension,
         dimWorld = GridView::dimensionworld,
-        intervals = GET_PROP_VALUE(TypeTag, NumberOfIntervals),
-        walls = (GET_PROP_VALUE(TypeTag, BBoxMinIsWall) ? 1 : 0)
-                + (GET_PROP_VALUE(TypeTag, BBoxMaxIsWall) ? 1 : 0)
+        intervals = GET_PROP_VALUE(TypeTag, NumberOfIntervals)
     };
     enum { transportCompIdx = Indices::transportCompIdx,
            numComponents = Indices::numComponents };
@@ -311,7 +309,7 @@ public:
     {
         ParentType::resetWallProperties();
 
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < this->wall.size(); ++wallIdx)
             for (int posIdx = 0; posIdx < intervals; ++posIdx)
             {
                 this->wall[wallIdx].maxMassFraction[posIdx] = 0.0;
@@ -328,11 +326,11 @@ public:
         int wallIdx = this->getWallIdx(globalPos, posIdx);
         // mass fraction
         if (this->wall[wallIdx].maxMassFraction[posIdx] < fluxVars.massFraction(transportCompIdx))
-            for (int wIdx = 0; wIdx < walls; ++wIdx)
+            for (int wIdx = 0; wIdx < this->wall.size(); ++wIdx)
                 this->wall[wIdx].maxMassFraction[posIdx] = fluxVars.massFraction(transportCompIdx);
         // mole fraction
         if (this->wall[wallIdx].maxMoleFraction[posIdx] < fluxVars.moleFraction(transportCompIdx))
-            for (int wIdx = 0; wIdx < walls; ++wIdx)
+            for (int wIdx = 0; wIdx < this->wall.size(); ++wIdx)
                 this->wall[wIdx].maxMoleFraction[posIdx] = fluxVars.moleFraction(transportCompIdx);
     }
 
diff --git a/dumux/freeflow/zeroeqncni/model.hh b/dumux/freeflow/zeroeqncni/model.hh
index 9bd2fbd8b6..20b1afc4f7 100644
--- a/dumux/freeflow/zeroeqncni/model.hh
+++ b/dumux/freeflow/zeroeqncni/model.hh
@@ -96,9 +96,7 @@ class ZeroEqncniModel : public ZeroEqncModel<TypeTag>
     enum {
         dim = GridView::dimension,
         dimWorld = GridView::dimensionworld,
-        intervals = GET_PROP_VALUE(TypeTag, NumberOfIntervals),
-        walls = (GET_PROP_VALUE(TypeTag, BBoxMinIsWall) ? 1 : 0)
-                + (GET_PROP_VALUE(TypeTag, BBoxMaxIsWall) ? 1 : 0)
+        intervals = GET_PROP_VALUE(TypeTag, NumberOfIntervals)
     };
     enum { transportCompIdx = Indices::transportCompIdx,
            numComponents = Indices::numComponents };
@@ -331,7 +329,7 @@ public:
     {
         ParentType::resetWallProperties();
 
-        for (int wallIdx = 0; wallIdx < walls; ++wallIdx)
+        for (int wallIdx = 0; wallIdx < this->wall.size(); ++wallIdx)
             for (int posIdx = 0; posIdx < intervals; ++posIdx)
             {
                 this->wall[wallIdx].maxTemperature[posIdx] = 0.0;
@@ -346,7 +344,7 @@ public:
         int posIdx = this->getPosIdx(globalPos);
         int wallIdx = this->getWallIdx(globalPos, posIdx);
         if (this->wall[wallIdx].maxTemperature[posIdx] < fluxVars.temperature())
-            for (int wIdx = 0; wIdx < walls; ++wIdx)
+            for (int wIdx = 0; wIdx < this->wall.size(); ++wIdx)
                 this->wall[wIdx].maxTemperature[posIdx] = fluxVars.temperature();
     }
 
diff --git a/test/freeflow/zeroeq/zeroeqchanneltestproblem.hh b/test/freeflow/zeroeq/zeroeqchanneltestproblem.hh
index bc794d5a1a..d6c568b4f3 100644
--- a/test/freeflow/zeroeq/zeroeqchanneltestproblem.hh
+++ b/test/freeflow/zeroeq/zeroeqchanneltestproblem.hh
@@ -53,9 +53,6 @@ SET_TYPE_PROP(ZeroEqChannelTestProblem, Fluid,
 // Disable gravity
 SET_BOOL_PROP(ZeroEqChannelTestProblem, ProblemEnableGravity, false);
 
-// Set only bottom as wall
-SET_BOOL_PROP(ZeroEqChannelTestProblem, BBoxMaxIsWall, false);
-
 #if HAVE_UMFPACK
 // Use UMFPack as linear solver
 SET_TYPE_PROP(ZeroEqChannelTestProblem, LinearSolver, UMFPackBackend<TypeTag>);
@@ -147,6 +144,14 @@ public:
         return 273.15 + 10; // -> 10 °C
     }
 
+    /*!
+     * \brief The right/upper boundary in ZeroEqWallNormal direction is a wall
+     */
+    bool bBoxMaxIsWall()
+    {
+        return false;
+    }
+
     // \}
 
     /*!
-- 
GitLab