From fafb7953c6ab5d461784a331583526c5a9626292 Mon Sep 17 00:00:00 2001
From: Sina Ackermann <sina.ackermann@iws.uni-stuttgart.de>
Date: Thu, 9 Mar 2017 15:49:47 +0100
Subject: [PATCH] [staggeredGrid][nonisothermal] Simplify flux calculations

* improvements in fluxvariables, localresidual
* further modifications necessary: properties, propertydefaults, indices
* no test problem yet
---
 dumux/freeflow/staggeredni/CMakeLists.txt     |  1 -
 dumux/freeflow/staggeredni/fluxvariables.hh   | 47 ++-----------------
 dumux/freeflow/staggeredni/indices.hh         |  3 +-
 dumux/freeflow/staggeredni/localresidual.hh   | 26 ++--------
 dumux/freeflow/staggeredni/properties.hh      |  2 +-
 .../freeflow/staggeredni/propertydefaults.hh  |  9 +++-
 6 files changed, 20 insertions(+), 68 deletions(-)

diff --git a/dumux/freeflow/staggeredni/CMakeLists.txt b/dumux/freeflow/staggeredni/CMakeLists.txt
index cd81e3cdc4..a032dedb63 100644
--- a/dumux/freeflow/staggeredni/CMakeLists.txt
+++ b/dumux/freeflow/staggeredni/CMakeLists.txt
@@ -6,5 +6,4 @@ localresidual.hh
 model.hh
 properties.hh
 propertydefaults.hh
-volumevariables.hh
 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/porousmediumflow/1p/implicit)
\ No newline at end of file
diff --git a/dumux/freeflow/staggeredni/fluxvariables.hh b/dumux/freeflow/staggeredni/fluxvariables.hh
index d0acbf7f6f..a594070a28 100644
--- a/dumux/freeflow/staggeredni/fluxvariables.hh
+++ b/dumux/freeflow/staggeredni/fluxvariables.hh
@@ -33,7 +33,7 @@ namespace Dumux
 namespace Properties
 {
 // forward declaration
-NEW_PROP_TAG(EnableComponentTransport);
+//NEW_PROP_TAG(EnableComponentTransport);
 NEW_PROP_TAG(EnableEnergyBalance);
 NEW_PROP_TAG(EnableInertiaTerms);
 }
@@ -65,23 +65,13 @@ class FreeFlowFluxVariablesImpl<TypeTag, false, true> : public FreeFlowFluxVaria
     using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
     using GlobalFaceVars = typename GET_PROP_TYPE(TypeTag, GlobalFaceVars);
     using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
-    using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); // TODO ?
     using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
     using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
-    using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);
-    using IndexType = typename GridView::IndexSet::IndexType;
-    using Stencil = std::vector<IndexType>;
-
-//    using MolecularDiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType);
 
+    using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType);
     static constexpr bool navierStokes = GET_PROP_VALUE(TypeTag, EnableInertiaTerms);
-//    static constexpr auto numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
-
     static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles);
 
-//    //! The index of the component balance equation that gets replaced with the total mass balance
-//    static const int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx);
-
     using ParentType = FreeFlowFluxVariablesImpl<TypeTag, false, false>;
 
     enum {
@@ -89,15 +79,8 @@ class FreeFlowFluxVariablesImpl<TypeTag, false, true> : public FreeFlowFluxVaria
         dim = GridView::dimension,
         dimWorld = GridView::dimensionworld,
 
-        pressureIdx = Indices::pressureIdx,
-        velocityIdx = Indices::velocityIdx,
-        temperatureIdx = Indices::temperatureIdx, // TODO necessary?
-
-        massBalanceIdx = Indices::massBalanceIdx,
         momentumBalanceIdx = Indices::momentumBalanceIdx,
         energyBalanceIdx = Indices::energyBalanceIdx,
-        conti0EqIdx = Indices::conti0EqIdx,
-        phaseIdx = Indices::phaseIdx
     };
 
 public:
@@ -112,7 +95,8 @@ public:
         CellCenterPrimaryVariables flux(0.0);
 
         flux += advectiveFluxForCellCenter_(problem, fvGeometry, elemVolVars, globalFaceVars, scvf);
-        flux += diffusiveFluxForCellCenter_(problem, fvGeometry, elemVolVars, scvf);
+        flux += HeatConductionType::diffusiveFluxForCellCenter_(problem, fvGeometry, elemVolVars, scvf);
+        flux *= scvf.area() * sign(scvf.outerNormalScalar());
         return flux;
     }
 
@@ -135,7 +119,7 @@ private:
         if(scvf.boundary())
         {
             const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
-                if(bcTypes.isOutflow(momentumBalanceIdx))
+                if(bcTypes.isOutflow(momentumBalanceIdx)) // TODO ??
                     isOutflow = true;
         }
 
@@ -153,32 +137,11 @@ private:
         const Scalar upstreamEnthalpy = upstreamVolVars.enthalpy();
         const Scalar downstreamEnthalpy = downstreamVolVars.enthalpy();
 
-//        flux[massBalanceIdx] = TODO??
         flux[energyBalanceIdx] = (upWindWeight * upstreamDensity * upstreamEnthalpy
                                  + (1.0 - upWindWeight) * downstreamDensity * downstreamEnthalpy)
                                  * velocity;
-
-        flux *= scvf.area() * sign(scvf.outerNormalScalar());
-        return flux;
-    }
-
-    CellCenterPrimaryVariables diffusiveFluxForCellCenter_(const FluxVariables& fluxVars)
-    {
-        CellCenterPrimaryVariables flux(0.0);
-
-        // compute diffusive flux --> no diffusive flux (only 1 component)
-
-        // compute conductive flux
-        computeConductiveFlux_(flux, fluxVars);
-
         return flux;
     }
-
-    void computeConductiveFlux_(CellCenterPrimaryVariables& flux, FluxVariables& fluxVars)
-    {
-        flux[energyBalanceIdx] -= fluxVars.temperatureGrad() * fluxVars.face().normal
-                   * (fluxVars.thermalConductivity() + fluxVars.thermalEddyConductivity());
-    }
 };
 
 } // end namespace
diff --git a/dumux/freeflow/staggeredni/indices.hh b/dumux/freeflow/staggeredni/indices.hh
index 2f9c73dd76..d134b7279a 100644
--- a/dumux/freeflow/staggeredni/indices.hh
+++ b/dumux/freeflow/staggeredni/indices.hh
@@ -43,7 +43,8 @@ private:
 
 public:
 
-    static constexpr int energyBalanceIdx = PVOffset + 1; // TODO
+    static const int numEq = GET_PROP_VALUE(TypeTag, NumEq);
+    static constexpr int energyBalanceIdx = PVOffset + numEq - 1;
     static constexpr int temperatureIdx = energyBalanceIdx;
 
 };
diff --git a/dumux/freeflow/staggeredni/localresidual.hh b/dumux/freeflow/staggeredni/localresidual.hh
index d29b992386..f52d0ee2ca 100644
--- a/dumux/freeflow/staggeredni/localresidual.hh
+++ b/dumux/freeflow/staggeredni/localresidual.hh
@@ -42,7 +42,7 @@ namespace Dumux
 namespace Properties
 {
 // forward declaration
-NEW_PROP_TAG(EnableComponentTransport);
+//NEW_PROP_TAG(EnableComponentTransport);
 NEW_PROP_TAG(EnableEnergyBalance);
 NEW_PROP_TAG(EnableInertiaTerms);
 //NEW_PROP_TAG(ReplaceCompEqIdx);
@@ -71,29 +71,14 @@ class StaggeredNavierStokesResidualImpl<TypeTag, false, true> : public Staggered
     using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
     using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
-    using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
 
-    using DofTypeIndices = typename GET_PROP(TypeTag, DofTypeIndices);
-    typename DofTypeIndices::CellCenterIdx cellCenterIdx;
-    typename DofTypeIndices::FaceIdx faceIdx;
-
-    enum { // TODO adapt
-        pressureIdx = Indices::pressureIdx,
-        velocityIdx = Indices::velocityIdx,
-
-        massBalanceIdx = Indices::massBalanceIdx,
-        momentumBalanceIdx = Indices::momentumBalanceIdx,
+    enum {
         energyBalanceIdx = Indices::energyBalanceIdx
     };
 
-    using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
-    using GlobalFaceVars = typename GET_PROP_TYPE(TypeTag, GlobalFaceVars);
-
-//    static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles);
-
 public:
     /*!
-     * \brief Evaluate the amount the additional quantities to the stokes model
+     * \brief Evaluate the amount the additional quantities to the Stokes model
      *        (energy equation).
      *
      * The result should be averaged over the volume (e.g. phase mass
@@ -102,11 +87,10 @@ public:
     CellCenterPrimaryVariables computeStorageForCellCenter(const SubControlVolume& scv, const VolumeVariables& volVars) const
     {
         CellCenterPrimaryVariables storage(0.0);
-
-//        const Scalar density = useMoles? volVars.molarDensity() : volVars.density();
+        const Scalar density = useMoles? volVars.molarDensity() : volVars.density();
 
         // compute storage of mass
-        storage[massBalanceIdx] = volVars.density(0); // TODO ParentType?
+        storage = ParentType::computeStorageForCellCenter(scv, volVars);
 
         // compute the storage of energy
         storage[energyBalanceIdx] = volVars.density(0) * volVars.internalEnergy(0);
diff --git a/dumux/freeflow/staggeredni/properties.hh b/dumux/freeflow/staggeredni/properties.hh
index 4eda84787a..ab4022f8a4 100644
--- a/dumux/freeflow/staggeredni/properties.hh
+++ b/dumux/freeflow/staggeredni/properties.hh
@@ -42,7 +42,7 @@ namespace Properties {
 // Type tags
 //////////////////////////////////////////////////////////////////
 
-//! The type tags for the implicit single-phase problems
+//! The type tags for the non-isothermal Navier Stokes problems
 NEW_TYPE_TAG(NavierStokesNI, INHERITS_FROM(NavierStokes));
 
 //! The type tags for the corresponding non-isothermal problems
diff --git a/dumux/freeflow/staggeredni/propertydefaults.hh b/dumux/freeflow/staggeredni/propertydefaults.hh
index f85d1a272b..a43f0cdec0 100644
--- a/dumux/freeflow/staggeredni/propertydefaults.hh
+++ b/dumux/freeflow/staggeredni/propertydefaults.hh
@@ -61,11 +61,11 @@ NEW_PROP_TAG(FluxVariablesCache);
 // \{
 
 ///////////////////////////////////////////////////////////////////////////
-// default property values for the isothermal single phase model
+// default property values for the non-isothermal single phase model
 ///////////////////////////////////////////////////////////////////////////
 namespace Properties {
 
-SET_INT_PROP(NavierStokesNI, NumEqCellCenter, 2);
+SET_PROP(NavierStokesNI, NumEqCellCenter, GET_PROP_VALUE(TypeTag, NonIsothermalNumEq) + 1);
 
 //! the VolumeVariables property
 SET_TYPE_PROP(NavierStokesNI, VolumeVariables, NavierStokesNIVolumeVariables<TypeTag>);
@@ -142,6 +142,8 @@ SET_BOOL_PROP(NavierStokes, EnableEnergyBalance, true);
 // SET_BOOL_PROP(NavierStokes, EnableEnergyTransport, false);
 //
 
+SET_TYPE_PROP(NavierStokesNI, HeatConductionType, FouriersLaw<TypeTag>);
+
 //! average is used as default model to compute the effective thermal heat conductivity
 // SET_PROP(NavierStokesNI, ThermalConductivityModel)
 // { private :
@@ -169,6 +171,9 @@ SET_BOOL_PROP(NavierStokes, EnableEnergyBalance, true);
 //set isothermal NumEq
 // SET_INT_PROP(NavierStokesNI, IsothermalNumEq, 1);
 
+//set non-isothermal NumEq
+ SET_INT_PROP(NavierStokesNI, NonIsothermalNumEq, 1);
+
 
 // \}
 } // end namespace Properties
-- 
GitLab