From c9b4993730bc93cabdaf0e9eb18dc9dee5cac3c9 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Tue, 24 Apr 2018 08:25:55 +0200
Subject: [PATCH] [navierstokes] Add convenience function to calculate pseudo
 3D friction term

---
 doc/handbook/dumux-handbook.bib        | 28 +++++++++++++++-
 dumux/freeflow/navierstokes/problem.hh | 44 ++++++++++++++++++++++++--
 2 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/doc/handbook/dumux-handbook.bib b/doc/handbook/dumux-handbook.bib
index 2f050249d5..6264fca6b7 100644
--- a/doc/handbook/dumux-handbook.bib
+++ b/doc/handbook/dumux-handbook.bib
@@ -1068,7 +1068,7 @@ url = {http://www.sciencedirect.com/science/article/pii/S0169772204001160}
   volume = {198},
   pages = {71--78}
 }
-@misc{cooper2008, 
+@misc{cooper2008,
   title={{Release of the IAPWS formulation 2008 for the viscosity of ordinary water substance}},
   author={Cooper, J. R. and Dooley, R. B.},
   year={2008},
@@ -1676,3 +1676,29 @@ url={http://dx.doi.org/10.1007/s11242-015-0599-1}
   doi =       {10.1115/1.3240815},
   url =       {http://dx.doi.org/10.1115/1.3240815},
 }
+
+@Article{flekkoy1995a,
+  title={{Hydrodynamic dispersion at stagnation points: Simulations and experiments}},
+  author={{Flekk{\o}y, EG and Oxaal, U and Feder, J and J{\o}ssang, T}},
+  journal={Physical Review E},
+  volume={52},
+  number={5},
+  pages={4952},
+  year={1995},
+  publisher={APS},
+  doi = {10.1103/PhysRevE.52.4952},
+  url = {https://doi.org/10.1103/PhysRevE.52.4952}
+}
+
+@Article{venturoli2006a,
+  title={{Two-dimensional lattice-Boltzmann simulations of single phase flow in a pseudo two-dimensional micromodel}},
+  author={{Venturoli, Maddalena and Boek, Edo S}},
+  journal={Physica A: Statistical Mechanics and its Applications},
+  volume={362},
+  number={1},
+  pages={23--29},
+  year={2006},
+  publisher={Elsevier},
+  doi = {10.1016/j.physa.2005.09.006},
+  url = {https://doi.org/10.1016/j.physa.2005.09.006}
+ }
diff --git a/dumux/freeflow/navierstokes/problem.hh b/dumux/freeflow/navierstokes/problem.hh
index 376b5d843f..58d178085d 100644
--- a/dumux/freeflow/navierstokes/problem.hh
+++ b/dumux/freeflow/navierstokes/problem.hh
@@ -116,19 +116,57 @@ public:
      * If the <tt>Problem.EnableGravity</tt> parameter is true, this means
      * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$, else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$
      */
-    const GlobalPosition &gravity() const
+    const GlobalPosition& gravity() const
     { return gravity_; }
 
     //! Applys the initial face solution (velocities on the faces). Specialization for staggered grid discretization.
     template <class G = FVGridGeometry>
     typename std::enable_if<G::discMethod == DiscretizationMethod::staggered, void>::type
     applyInitialFaceSolution(SolutionVector& sol,
-                              const SubControlVolumeFace& scvf,
-                              const PrimaryVariables& initSol) const
+                             const SubControlVolumeFace& scvf,
+                             const PrimaryVariables& initSol) const
     {
         sol[FVGridGeometry::faceIdx()][scvf.dofIndex()][0] = initSol[Indices::velocity(scvf.directionIndex())];
     }
 
+
+    /*!
+     * \brief An additional drag term can be included as source term for the momentum balance
+     *        to mimic 3D flow behavior in 2D:
+     *  \f[
+     *        f_{drag} = -(8 \mu / h^2)v
+     *  \f]
+     *  Here, \f$h\f$ corresponds to the extruded height that is
+     *  bounded by the imaginary walls. See Flekkoy et al. (1995) \cite flekkoy1995a<BR>
+     *  A value of 8.0 is used as a default factor, corresponding
+     *  to the velocity profile at  the center plane
+     *  of the virtual height (maximum velocity). Setting this value to 12.0 corresponds
+     *  to an depth-averaged velocity (Venturoli and Boek, 2006) \cite venturoli2006a.
+     */
+    Scalar pseudo3DWallFriction(const Scalar velocity,
+                                const Scalar viscosity,
+                                const Scalar height,
+                                const Scalar factor = 8.0) const
+    {
+        static_assert(dim == 2, "Pseudo 3D wall friction may only be used in 2D");
+        return -factor * velocity * viscosity / (height*height);
+    }
+
+    //! Convenience function for staggered grid implementation.
+    template <class ElementVolumeVariables, class ElementFaceVariables, class G = FVGridGeometry>
+    typename std::enable_if<G::discMethod == DiscretizationMethod::staggered, Scalar>::type
+    pseudo3DWallFriction(const SubControlVolumeFace& scvf,
+                         const ElementVolumeVariables& elemVolVars,
+                         const ElementFaceVariables& elemFaceVars,
+                         const Scalar height,
+                         const Scalar factor = 8.0) const
+    {
+        const Scalar velocity = elemFaceVars[scvf].velocitySelf();
+        const Scalar viscosity = elemVolVars[scvf.insideScvIdx()].effectiveViscosity();
+        return pseudo3DWallFriction(velocity, viscosity, height, factor);
+    }
+
+
 private:
 
     //! Returns the implementation of the problem (i.e. static polymorphism)
-- 
GitLab