From 7291c461c4871d9d33c5f2bcf8cfbbee2a68023f Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 19 Dec 2022 14:32:06 +0100
Subject: [PATCH] [ff][onep] Enable auxiliary flux to add stabilization term in
 the problem

---
 .../navierstokes/mass/1p/localresidual.hh     | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/dumux/freeflow/navierstokes/mass/1p/localresidual.hh b/dumux/freeflow/navierstokes/mass/1p/localresidual.hh
index e436db6455..07ab8bff34 100644
--- a/dumux/freeflow/navierstokes/mass/1p/localresidual.hh
+++ b/dumux/freeflow/navierstokes/mass/1p/localresidual.hh
@@ -24,11 +24,23 @@
 #ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
 #define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
 
+#include <type_traits>
+
 #include <dumux/common/numeqvector.hh>
 #include <dumux/common/properties.hh>
 
 namespace Dumux {
 
+/*!
+ * \ingroup NavierStokesModel
+ * \brief Traits class to be specialized for problems to add auxiliary fluxes
+ * \note This can be used, for example, to implement flux stabilization terms
+ */
+template<class Problem>
+struct ImplementsAuxiliaryFluxNavierStokesMassOneP
+: public std::false_type
+{};
+
 /*!
  * \ingroup NavierStokesModel
  * \brief Element-wise calculation of the Navier-Stokes residual for single-phase flow.
@@ -79,7 +91,7 @@ public:
     }
 
     /*!
-     * \brief Evaluatex the mass flux over a face of a sub control volume.
+     * \brief Evaluate the mass flux over a face of a sub control volume.
      *
      * \param problem The problem
      * \param element The element
@@ -97,7 +109,14 @@ public:
     {
         FluxVariables fluxVars;
         fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
-        return fluxVars.flux(0);
+        auto flux = fluxVars.flux(0);
+
+        // the auxiliary flux is enabled if the trait is specialized for the problem
+        // this can be used, for example, to implement flux stabilization terms
+        if constexpr (ImplementsAuxiliaryFluxNavierStokesMassOneP<Problem>::value)
+            flux += problem.auxiliaryFlux(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
+
+        return flux;
     }
 };
 
-- 
GitLab