From fa48965bb35debcc45675900ad64b3453895821e Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Sat, 18 May 2019 15:23:14 +0200
Subject: [PATCH] [material] Simplify interface for effective thermal
 conductivity laws

This will lead to a more unified interface for effective laws.
Any dependence on spatial parameters ca be introduced via
the volume variables and seems misplaced here. Also, effective
diffusion laws do not have such a blown-up interface anyway.
---
 .../1p/thermalconductivityaverage.hh          | 34 +++++++------
 .../2p/thermalconductivityjohansen.hh         | 29 +++++++----
 .../thermalconductivitysimplefluidlumping.hh  | 40 +++++++++------
 .../2p/thermalconductivitysomerton.hh         | 29 +++++++----
 .../3p/thermalconductivitysomerton3p.hh       | 50 +++++++++++--------
 5 files changed, 109 insertions(+), 73 deletions(-)

diff --git a/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh b/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh
index e3fb2f519e..59a449a750 100644
--- a/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh
+++ b/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh
@@ -26,6 +26,7 @@
 
 #include <algorithm>
 
+#include <dune/common/deprecated.hh>
 
 namespace Dumux {
 
@@ -38,27 +39,32 @@ class ThermalConductivityAverage
 {
 public:
     /*!
-     * \brief Relation for a simple effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
-     *
-     * \param volVars volume variables
-     * \param spatialParams spatial parameters
-     * \param element element (to be passed to spatialParams)
-     * \param fvGeometry fvGeometry (to be passed to spatialParams)
-     * \param scv scv (to be passed to spatialParams)
-     *
-     * \return effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
+     * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
      */
-    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry, class SubControlVolume>
+    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
+    DUNE_DEPRECATED_MSG("Signature deprecated. Use signature with volume variables only!")
     static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
                                                const SpatialParams& spatialParams,
                                                const Element& element,
                                                const FVGeometry& fvGeometry,
-                                               const SubControlVolume& scv)
+                                               const typename FVGeometry::SubControlVolume& scv)
+    {
+        return effectiveThermalConductivity(volVars);
+    }
+
+    /*!
+     * \brief Relation for a simple effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
+     *
+     * \param volVars volume variables
+     * \return effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
+     */
+    template<class VolumeVariables>
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
     {
         //Get the thermal conductivities and the porosity from the volume variables
-        Scalar lambdaW = volVars.fluidThermalConductivity(0);
-        Scalar lambdaSolid = volVars.solidThermalConductivity();
-        Scalar porosity = volVars.porosity();
+        const Scalar lambdaW = volVars.fluidThermalConductivity(0);
+        const Scalar lambdaSolid = volVars.solidThermalConductivity();
+        const Scalar porosity = volVars.porosity();
 
         return lambdaSolid*(1-porosity) + lambdaW*porosity;
     }
diff --git a/dumux/material/fluidmatrixinteractions/2p/thermalconductivityjohansen.hh b/dumux/material/fluidmatrixinteractions/2p/thermalconductivityjohansen.hh
index aa77b0cf62..c98ef3ab5b 100644
--- a/dumux/material/fluidmatrixinteractions/2p/thermalconductivityjohansen.hh
+++ b/dumux/material/fluidmatrixinteractions/2p/thermalconductivityjohansen.hh
@@ -27,6 +27,8 @@
 #include <cmath>
 #include <algorithm>
 
+#include <dune/common/deprecated.hh>
+
 namespace Dumux {
 
 struct JohansenIndices
@@ -65,15 +67,24 @@ template<class Scalar, class Indices = JohansenIndices>
 class ThermalConductivityJohansen
 {
 public:
+    /*!
+     * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Johansen (1975) \cite johansen1977 <BR>
+     */
+    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
+    DUNE_DEPRECATED_MSG("Signature deprecated. Use signature with volume variables only!")
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
+                                               const SpatialParams& spatialParams,
+                                               const Element& element,
+                                               const FVGeometry& fvGeometry,
+                                               const typename FVGeometry::SubControlVolume& scv)
+    {
+        return effectiveThermalConductivity(volVars);
+    }
+
     /*!
      * \brief Returns the effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Johansen (1975) \cite johansen1977 .
      *
      * \param volVars volume variables
-     * \param spatialParams spatial parameters
-     * \param element element (to be passed to spatialParams)
-     * \param fvGeometry fvGeometry (to be passed to spatialParams)
-     * \param scv the sub control volume (to be passed to spatialParams)
-     *
      * \return Effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Johansen (1975) \cite johansen1977 <BR>
      *
      * This formulation is semi-empirical and fitted to quartz sand.
@@ -85,12 +96,8 @@ public:
      *                    of Sci. and Technol., Trondheim. (Draft Transl. 637. 1977. U.S. Army
      *                    Corps of Eng., Cold Regions Res. and Eng. Lab., Hanover, NH.) \cite johansen1977
      */
-    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry, class SubControlVolume>
-    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
-                                               const SpatialParams& spatialParams,
-                                               const Element& element,
-                                               const FVGeometry& fvGeometry,
-                                               const SubControlVolume& scv)
+    template<class VolumeVariables>
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
     {
         const Scalar sw = volVars.saturation(Indices::wPhaseIdx);
         const Scalar lambdaW = volVars.fluidThermalConductivity(Indices::wPhaseIdx);
diff --git a/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysimplefluidlumping.hh b/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysimplefluidlumping.hh
index 6af6c99348..07cee18245 100644
--- a/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysimplefluidlumping.hh
+++ b/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysimplefluidlumping.hh
@@ -27,6 +27,8 @@
 #include <assert.h>
 #include <algorithm>
 
+#include <dune/common/deprecated.hh>
+
 namespace Dumux {
 
 /*!
@@ -40,29 +42,35 @@ class ThermalConductivitySimpleFluidLumping
 
 public:
     /*!
-     * \brief Effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
-     *
-     * \param volVars volume variables
-     * \param spatialParams spatial parameters
-     * \param element element (to be passed to spatialParams)
-     * \param fvGeometry fvGeometry (to be passed to spatialParams)
-     * \param scv the sub-control volume
-     * \todo TODO: Fix this law for changing wettability
-     * \return effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
+     * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
      */
-    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry, class SubControlVolume>
+    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
+    DUNE_DEPRECATED_MSG("Signature deprecated. Use signature with volume variables only!")
     static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
                                                const SpatialParams& spatialParams,
                                                const Element& element,
                                                const FVGeometry& fvGeometry,
-                                               SubControlVolume& scv)
+                                               const typename FVGeometry::SubControlVolume& scv)
+    {
+        return effectiveThermalConductivity(volVars);
+    }
+
+    /*!
+     * \brief Effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
+     *
+     * \param volVars volume variables
+     * \return effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$
+     * \todo TODO: Fix this law for changing wettability
+     */
+    template<class VolumeVariables>
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
     {
         using FluidSystem = typename VolumeVariables::FluidSystem;
-        Scalar sw = volVars.saturation(FluidSystem::phase0Idx);
-        Scalar lambdaW = volVars.fluidThermalConductivity(FluidSystem::phase0Idx);
-        Scalar lambdaN = volVars.fluidThermalConductivity(FluidSystem::phase1Idx);
-        Scalar lambdaSolid = volVars.solidThermalConductivity();
-        Scalar porosity = volVars.porosity();
+        const Scalar sw = volVars.saturation(FluidSystem::phase0Idx);
+        const Scalar lambdaW = volVars.fluidThermalConductivity(FluidSystem::phase0Idx);
+        const Scalar lambdaN = volVars.fluidThermalConductivity(FluidSystem::phase1Idx);
+        const Scalar lambdaSolid = volVars.solidThermalConductivity();
+        const Scalar porosity = volVars.porosity();
 
         return effectiveThermalConductivity(sw, lambdaW, lambdaN, lambdaSolid, porosity);
     }
diff --git a/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysomerton.hh b/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysomerton.hh
index c8e42067e5..187381ea85 100644
--- a/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysomerton.hh
+++ b/dumux/material/fluidmatrixinteractions/2p/thermalconductivitysomerton.hh
@@ -27,6 +27,8 @@
 #include <algorithm>
 #include <cmath>
 
+#include <dune/common/deprecated.hh>
+
 namespace Dumux {
 
 /*!
@@ -59,15 +61,24 @@ template<class Scalar>
 class ThermalConductivitySomerton
 {
 public:
+    /*!
+     * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Somerton (1974) \cite somerton1974 <BR>
+     */
+    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
+    DUNE_DEPRECATED_MSG("Signature deprecated. Use signature with volume variables only!")
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
+                                               const SpatialParams& spatialParams,
+                                               const Element& element,
+                                               const FVGeometry& fvGeometry,
+                                               const typename FVGeometry::SubControlVolume& scv)
+    {
+        return effectiveThermalConductivity(volVars);
+    }
+
     /*!
      * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Somerton (1974) \cite somerton1974 <BR>
      *
      * \param volVars volume variables
-     * \param spatialParams spatial parameters
-     * \param element element (to be passed to spatialParams)
-     * \param fvGeometry fvGeometry (to be passed to spatialParams)
-     * \param scv the sub control volume (to be passed to spatialParams)
-     *
      * \return effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Somerton (1974) \cite somerton1974 <BR>
      *
      * This gives an interpolation of the effective thermal conductivities of a porous medium
@@ -76,12 +87,8 @@ public:
      * fluid conductivities and interpolated with the square root of the wetting saturation.
      * See f.e. Ebigbo, A.: Thermal Effects of Carbon Dioxide Sequestration in the Subsurface, Diploma thesis \cite ebigbo2005 .
      */
-    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
-    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
-                                               const SpatialParams& spatialParams,
-                                               const Element& element,
-                                               const FVGeometry& fvGeometry,
-                                               const typename FVGeometry::SubControlVolume& scv)
+    template<class VolumeVariables>
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
     {
         using FluidSystem = typename VolumeVariables::FluidSystem;
         static_assert(FluidSystem::numPhases == 2, "ThermalConductivitySomerton only works for two-phase fluid systems!");
diff --git a/dumux/material/fluidmatrixinteractions/3p/thermalconductivitysomerton3p.hh b/dumux/material/fluidmatrixinteractions/3p/thermalconductivitysomerton3p.hh
index 07a25aa533..b66b26e708 100644
--- a/dumux/material/fluidmatrixinteractions/3p/thermalconductivitysomerton3p.hh
+++ b/dumux/material/fluidmatrixinteractions/3p/thermalconductivitysomerton3p.hh
@@ -27,6 +27,8 @@
 #include <algorithm>
 #include <cmath>
 
+#include <dune/common/deprecated.hh>
+
 namespace Dumux {
 
 /*!
@@ -64,14 +66,24 @@ template<class Scalar>
 class ThermalConductivitySomerton
 {
 public:
+    /*!
+     * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Somerton (1974) extended for a three phase system
+     */
+    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
+    DUNE_DEPRECATED_MSG("Signature deprecated. Use signature with volume variables only!")
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
+                                               const SpatialParams& spatialParams,
+                                               const Element& element,
+                                               const FVGeometry& fvGeometry,
+                                               const typename FVGeometry::SubControlVolume& scv)
+    {
+        return effectiveThermalConductivity(volVars);
+    }
+
     /*!
      * \brief effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Somerton (1974) extended for a three phase system
      *
      * \param volVars volume variables
-     * \param spatialParams spatial parameters
-     * \param element element (to be passed to spatialParams)
-     * \param fvGeometry fvGeometry (to be passed to spatialParams)
-     * \param scv The sub control volume
      *
      * \return effective thermal conductivity \f$\mathrm{[W/(m K)]}\f$ after Somerton (1974)
      *
@@ -80,22 +92,18 @@ public:
      * These two effective conductivities are computed as geometric mean of the solid and the
      * fluid conductivities and interpolated with the square root of the wetting saturation.
      */
-    template<class VolumeVariables, class SpatialParams, class Element, class FVGeometry>
-    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars,
-                                               const SpatialParams& spatialParams,
-                                               const Element& element,
-                                               const FVGeometry& fvGeometry,
-                                               const typename FVGeometry::SubControlVolume& scv)
+    template<class VolumeVariables>
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
     {
         using FluidSystem = typename VolumeVariables::FluidSystem;
 
-        Scalar sw = volVars.saturation(FluidSystem::wPhaseIdx);
-        Scalar sn = volVars.saturation(FluidSystem::nPhaseIdx);
-        Scalar lambdaW = volVars.fluidThermalConductivity(FluidSystem::wPhaseIdx);
-        Scalar lambdaN = volVars.fluidThermalConductivity(FluidSystem::nPhaseIdx);
-        Scalar lambdaG = volVars.fluidThermalConductivity(FluidSystem::gPhaseIdx);
-        Scalar lambdaSolid = volVars.solidThermalConductivity();
-        Scalar porosity = volVars.porosity();
+        const Scalar sw = volVars.saturation(FluidSystem::wPhaseIdx);
+        const Scalar sn = volVars.saturation(FluidSystem::nPhaseIdx);
+        const Scalar lambdaW = volVars.fluidThermalConductivity(FluidSystem::wPhaseIdx);
+        const Scalar lambdaN = volVars.fluidThermalConductivity(FluidSystem::nPhaseIdx);
+        const Scalar lambdaG = volVars.fluidThermalConductivity(FluidSystem::gPhaseIdx);
+        const Scalar lambdaSolid = volVars.solidThermalConductivity();
+        const Scalar porosity = volVars.porosity();
 
         return effectiveThermalConductivity(sw, sn, lambdaW, lambdaN, lambdaG, lambdaSolid, porosity);
     }
@@ -131,10 +139,10 @@ public:
 //        const Scalar lSn = 0.65; //pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaN, porosity);
 //        const Scalar lSg = 0.35; //pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaG, porosity);
         // porosity weighted geometric mean
-        Scalar lSw = pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaW, porosity);
-        Scalar lSn = pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaN, porosity);
-        Scalar lSg = pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaG, porosity);
-        Scalar lambdaEff = lSg + sqrt(satW) * (lSw - lSg) + sqrt(satN) * (lSn -lSg);
+        const Scalar lSw = pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaW, porosity);
+        const Scalar lSn = pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaN, porosity);
+        const Scalar lSg = pow(lambdaSolid, (1.0 - porosity)) * pow(lambdaG, porosity);
+        const Scalar lambdaEff = lSg + sqrt(satW) * (lSw - lSg) + sqrt(satN) * (lSn -lSg);
 
         return lambdaEff;
 
-- 
GitLab