From 4c29620bdfb8c39d1fca238cc8119bc95b87f33f Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Thu, 5 Mar 2020 19:02:24 +0100
Subject: [PATCH] [staggered][faceVars] Pass faceSolution instead of global
 solutionVector to update

* check if type is correct (Scalar)
---
 dumux/discretization/staggered/freeflow/facevariables.hh | 8 ++++++--
 dumux/discretization/staggered/gridfacevariables.hh      | 9 +++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dumux/discretization/staggered/freeflow/facevariables.hh b/dumux/discretization/staggered/freeflow/facevariables.hh
index 89cdfa2e6f..6eebd6e3c2 100644
--- a/dumux/discretization/staggered/freeflow/facevariables.hh
+++ b/dumux/discretization/staggered/freeflow/facevariables.hh
@@ -26,6 +26,7 @@
 
 #include <array>
 #include <vector>
+#include <type_traits>
 
 namespace Dumux {
 
@@ -88,14 +89,17 @@ public:
     * \param fvGeometry The finite-volume geometry
     * \param scvf The sub-control volume face of interest
     */
-    template<class SolVector, class Problem, class Element,
+    template<class FaceSolution, class Problem, class Element,
              class FVElementGeometry, class SubControlVolumeFace>
-    void update(const SolVector& faceSol,
+    void update(const FaceSolution& faceSol,
                 const Problem& problem,
                 const Element& element,
                 const FVElementGeometry& fvGeometry,
                 const SubControlVolumeFace& scvf)
     {
+        static_assert(std::decay_t<decltype(faceSol[0])>::dimension == 1,
+                      "\n\n\nVelocity primary variable must be a scalar value. \n\n Make sure to use\n\n ffSol = partial(sol, ffFaceIdx, ffCellCenterIdx);\n\n");
+
         inAxisVelocities_.self = faceSol[scvf.dofIndex()];
         inAxisVelocities_.opposite = faceSol[scvf.dofIndexOpposingFace()];
 
diff --git a/dumux/discretization/staggered/gridfacevariables.hh b/dumux/discretization/staggered/gridfacevariables.hh
index f6c5eb6315..ccc8859b48 100644
--- a/dumux/discretization/staggered/gridfacevariables.hh
+++ b/dumux/discretization/staggered/gridfacevariables.hh
@@ -27,6 +27,7 @@
 //! make the local view function available whenever we use this class
 #include <dumux/discretization/localview.hh>
 #include <dumux/discretization/staggered/elementfacevariables.hh>
+#include <dumux/discretization/staggered/facesolution.hh>
 
 namespace Dumux {
 
@@ -82,18 +83,18 @@ public:
 
     //! Update all face variables
     template<class GridGeometry, class SolutionVector>
-    void update(const GridGeometry& gridGeometry, const SolutionVector& faceSol)
+    void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
     {
-
         faceVariables_.resize(gridGeometry.numScvf());
 
-        for(auto&& element : elements(gridGeometry.gridView()))
+        for (auto&& element : elements(gridGeometry.gridView()))
         {
             auto fvGeometry = localView(gridGeometry);
             fvGeometry.bindElement(element);
 
-            for(auto&& scvf : scvfs(fvGeometry))
+            for (auto&& scvf : scvfs(fvGeometry))
             {
+                const auto faceSol = StaggeredFaceSolution(scvf, sol, gridGeometry);
                 faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf);
             }
         }
-- 
GitLab