From f24e25bd970ba504b836e6f574cc568dd7b44770 Mon Sep 17 00:00:00 2001
From: IvBu <st116086@stud.uni-stuttgart.de>
Date: Mon, 3 Jun 2024 15:37:47 +0200
Subject: [PATCH] [fluidmatrixinteraction] Relocate thermal conductivity
 computation to outside of 1p.

---
 .../1p/thermalconductivityaverage.hh          | 64 ++---------------
 .../thermalconductivityaverage.hh             | 69 +++++++++++++++++++
 dumux/porousmediumflow/1p/model.hh            |  2 +-
 dumux/porousmediumflow/1pnc/model.hh          |  2 +-
 dumux/porousmediumflow/1pncmin/model.hh       |  2 +-
 dumux/porousmediumflow/2p2c/model.hh          |  2 +-
 dumux/porousmediumflow/mpnc/model.hh          |  2 +-
 dumux/porousmediumflow/richardsnc/model.hh    |  2 +-
 .../1p/nonisothermal/properties_conduction.hh |  2 +-
 .../1p/nonisothermal/properties_convection.hh |  2 +-
 10 files changed, 81 insertions(+), 68 deletions(-)
 create mode 100644 dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh

diff --git a/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh b/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh
index 720e485960..919209d4cf 100644
--- a/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh
+++ b/dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh
@@ -4,66 +4,10 @@
 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
 // SPDX-License-Identifier: GPL-3.0-or-later
 //
-#ifndef DUMUX_MATERIAL_THERMALCONDUCTIVITY_AVERAGE_HH
-#define DUMUX_MATERIAL_THERMALCONDUCTIVITY_AVERAGE_HH
+#ifndef DUMUX_MATERIAL_THERMALCONDUCTIVITY_AVERAGE_DEPRECATED_HH
+#define DUMUX_MATERIAL_THERMALCONDUCTIVITY_AVERAGE_DEPRECATED_HH
 
-#include <algorithm>
-
-namespace Dumux {
-
-/*!
- * \addtogroup EffectiveHeatConductivity
- * \copydetails Dumux::ThermalConductivityAverage
- */
-
-/*!
- * \ingroup EffectiveHeatConductivity
- * \brief Effective thermal conductivity based on weighted arithmetic average
- *
- * ### Average (multiple fluid phases, one solid phase)
- *
- * The effective thermal conductivity of `ThermalConductivityAverage`
- * is calculated as a weighted arithmetic average of the thermal
- * conductivities of the solid and the fluid phases. The weights are determined by the volume
- * fraction the phase occupies. Denoting the volume fractions by \f$ n_\alpha \f$, we have
- * \f[
- * \lambda_\text{eff} = \sum_\alpha \lambda_\alpha n_\alpha / \sum_\alpha n_\alpha,
- * \f]
- * summing over both fluid and solid phases. With the porosity \f$ \phi \f$ as
- * the sum of all fluid volume fractions, we can equivalently write
- * \f[
- * \lambda_\text{eff} = \lambda_\text{s} (1-\phi) + \lambda_\text{f} \phi,
- * \f]
- * where \f$ \lambda_\text{s} \f$ is the thermal conductivity of the solid phase,
- * and the effective thermal conductivity of the liquid phases is computed as
- * an arithmetic average weighted with the fluid saturations.
- */
-template<class Scalar>
-class ThermalConductivityAverage
-{
-public:
-    /*!
-     * \brief Effective thermal conductivity in \f$\mathrm{W/(m K)}\f$
-     * \param volVars volume variables
-     * \return Effective thermal conductivity in \f$\mathrm{W/(m K)}\f$
-     */
-    template<class VolumeVariables>
-    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
-    {
-        constexpr int numFluidPhases = VolumeVariables::numFluidPhases();
-
-        // Get the thermal conductivities and the porosity from the volume variables
-        Scalar lambdaFluid = 0.0;
-        for (int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
-            lambdaFluid += volVars.fluidThermalConductivity(phaseIdx)*volVars.saturation(phaseIdx);
-
-        const Scalar lambdaSolid = volVars.solidThermalConductivity();
-        const Scalar porosity = volVars.porosity();
-
-        return lambdaSolid*(1-porosity) + lambdaFluid*porosity;
-    }
-};
-
-} // end namespace Dumux
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
+#warning "This header is deprecated and will be removed after 3.9. Use ThermalConductivityAverage from dumux/material/fluidmatrixinteractions."
 
 #endif
diff --git a/dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh b/dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh
new file mode 100644
index 0000000000..9563f9c245
--- /dev/null
+++ b/dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh
@@ -0,0 +1,69 @@
+// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// vi: set et ts=4 sw=4 sts=4:
+//
+// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+#ifndef DUMUX_MATERIAL_THERMALCONDUCTIVITY_AVERAGED_HH
+#define DUMUX_MATERIAL_THERMALCONDUCTIVITY_AVERAGED_HH
+
+#include <algorithm>
+
+namespace Dumux {
+
+/*!
+ * \addtogroup EffectiveHeatConductivity
+ * \copydetails Dumux::ThermalConductivityAverage
+ */
+
+/*!
+ * \ingroup EffectiveHeatConductivity
+ * \brief Effective thermal conductivity based on weighted arithmetic average
+ *
+ * ### Average (multiple fluid phases, one solid phase)
+ *
+ * The effective thermal conductivity of `ThermalConductivityAverage`
+ * is calculated as a weighted arithmetic average of the thermal
+ * conductivities of the solid and the fluid phases. The weights are determined by the volume
+ * fraction the phase occupies. Denoting the volume fractions by \f$ n_\alpha \f$, we have
+ * \f[
+ * \lambda_\text{eff} = \sum_\alpha \lambda_\alpha n_\alpha / \sum_\alpha n_\alpha,
+ * \f]
+ * summing over both fluid and solid phases. With the porosity \f$ \phi \f$ as
+ * the sum of all fluid volume fractions, we can equivalently write
+ * \f[
+ * \lambda_\text{eff} = \lambda_\text{s} (1-\phi) + \lambda_\text{f} \phi,
+ * \f]
+ * where \f$ \lambda_\text{s} \f$ is the thermal conductivity of the solid phase,
+ * and the effective thermal conductivity of the liquid phases is computed as
+ * an arithmetic average weighted with the fluid saturations.
+ */
+template<class Scalar>
+class ThermalConductivityAverage
+{
+public:
+    /*!
+     * \brief Effective thermal conductivity in \f$\mathrm{W/(m K)}\f$
+     * \param volVars volume variables
+     * \return Effective thermal conductivity in \f$\mathrm{W/(m K)}\f$
+     */
+    template<class VolumeVariables>
+    static Scalar effectiveThermalConductivity(const VolumeVariables& volVars)
+    {
+        constexpr int numFluidPhases = VolumeVariables::numFluidPhases();
+
+        // Get the thermal conductivities and the porosity from the volume variables
+        Scalar lambdaFluid = 0.0;
+        for (int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
+            lambdaFluid += volVars.fluidThermalConductivity(phaseIdx)*volVars.saturation(phaseIdx);
+
+        const Scalar lambdaSolid = volVars.solidThermalConductivity();
+        const Scalar porosity = volVars.porosity();
+
+        return lambdaSolid*(1-porosity) + lambdaFluid*porosity;
+    }
+};
+
+} // end namespace Dumux
+
+#endif
diff --git a/dumux/porousmediumflow/1p/model.hh b/dumux/porousmediumflow/1p/model.hh
index bb0dbffcbd..a0cf76492d 100644
--- a/dumux/porousmediumflow/1p/model.hh
+++ b/dumux/porousmediumflow/1p/model.hh
@@ -35,7 +35,7 @@
 
 #include <dumux/common/properties.hh>
 
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 #include <dumux/material/fluidstates/immiscible.hh>
 
 #include <dumux/porousmediumflow/properties.hh>
diff --git a/dumux/porousmediumflow/1pnc/model.hh b/dumux/porousmediumflow/1pnc/model.hh
index 58024ae384..4c737d11e9 100644
--- a/dumux/porousmediumflow/1pnc/model.hh
+++ b/dumux/porousmediumflow/1pnc/model.hh
@@ -50,7 +50,7 @@
 
 #include <dumux/common/properties.hh>
 
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 #include <dumux/material/fluidstates/compositional.hh>
 
 #include <dumux/porousmediumflow/properties.hh>
diff --git a/dumux/porousmediumflow/1pncmin/model.hh b/dumux/porousmediumflow/1pncmin/model.hh
index ffee022ef4..6dd903471d 100644
--- a/dumux/porousmediumflow/1pncmin/model.hh
+++ b/dumux/porousmediumflow/1pncmin/model.hh
@@ -85,7 +85,7 @@
 
 #include <dumux/porousmediumflow/nonisothermal/indices.hh>
 #include <dumux/porousmediumflow/nonisothermal/iofields.hh>
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 
 namespace Dumux {
 namespace Properties {
diff --git a/dumux/porousmediumflow/2p2c/model.hh b/dumux/porousmediumflow/2p2c/model.hh
index 39f9699987..4d80ea4304 100644
--- a/dumux/porousmediumflow/2p2c/model.hh
+++ b/dumux/porousmediumflow/2p2c/model.hh
@@ -80,7 +80,7 @@
 #include <dumux/porousmediumflow/nonequilibrium/model.hh>
 #include <dumux/porousmediumflow/nonequilibrium/volumevariables.hh>
 #include <dumux/material/fluidmatrixinteractions/2p/thermalconductivity/somerton.hh>
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 
 #include "volumevariables.hh"
 
diff --git a/dumux/porousmediumflow/mpnc/model.hh b/dumux/porousmediumflow/mpnc/model.hh
index da1228b47c..e5f0fa5978 100644
--- a/dumux/porousmediumflow/mpnc/model.hh
+++ b/dumux/porousmediumflow/mpnc/model.hh
@@ -95,7 +95,7 @@
 #include <dumux/material/fluidstates/nonequilibrium.hh>
 #include <dumux/material/fluidstates/compositional.hh>
 #include <dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh>
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 #include <dumux/material/fluidmatrixinteractions/2p/thermalconductivity/somerton.hh>
 
 #include <dumux/porousmediumflow/properties.hh>
diff --git a/dumux/porousmediumflow/richardsnc/model.hh b/dumux/porousmediumflow/richardsnc/model.hh
index 813666b637..52c537726d 100644
--- a/dumux/porousmediumflow/richardsnc/model.hh
+++ b/dumux/porousmediumflow/richardsnc/model.hh
@@ -43,7 +43,7 @@
 #include <dumux/common/properties.hh>
 
 #include <dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh>
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 #include <dumux/material/components/simpleh2o.hh>
 #include <dumux/material/components/constant.hh>
 #include <dumux/material/fluidsystems/liquidphase2c.hh>
diff --git a/test/porousmediumflow/1p/nonisothermal/properties_conduction.hh b/test/porousmediumflow/1p/nonisothermal/properties_conduction.hh
index ce68a49ced..6579bac72c 100644
--- a/test/porousmediumflow/1p/nonisothermal/properties_conduction.hh
+++ b/test/porousmediumflow/1p/nonisothermal/properties_conduction.hh
@@ -27,7 +27,7 @@
 #include <dumux/porousmediumflow/1p/model.hh>
 
 #include <dumux/material/fluidsystems/1pliquid.hh>
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 
 #include "problem_conduction.hh"
 #include "spatialparams.hh"
diff --git a/test/porousmediumflow/1p/nonisothermal/properties_convection.hh b/test/porousmediumflow/1p/nonisothermal/properties_convection.hh
index 0524301904..34b484304e 100644
--- a/test/porousmediumflow/1p/nonisothermal/properties_convection.hh
+++ b/test/porousmediumflow/1p/nonisothermal/properties_convection.hh
@@ -27,7 +27,7 @@
 #include <dumux/porousmediumflow/1p/model.hh>
 
 #include <dumux/material/fluidsystems/1pliquid.hh>
-#include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
+#include <dumux/material/fluidmatrixinteractions/thermalconductivityaverage.hh>
 
 #include "problem_convection.hh"
 #include "spatialparams.hh"
-- 
GitLab