From 0778c59deb5cac3f5c0a7d202b274daf06c63bdb Mon Sep 17 00:00:00 2001
From: Simon Scholz <simon.scholz@iws.uni-stuttgart.de>
Date: Fri, 20 Jul 2018 10:49:17 +0200
Subject: [PATCH] [1pncmin] fix phaseIdx

---
 dumux/porousmediumflow/1pncmin/model.hh       |  4 ++--
 .../1pncmin/implicit/test_1pncminni_fv.cc     |  2 +-
 .../1pncmin/implicit/thermochemproblem.hh     | 15 ++++++------
 .../1pncmin/implicit/thermochemreaction.hh    | 24 ++++++++++---------
 4 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/dumux/porousmediumflow/1pncmin/model.hh b/dumux/porousmediumflow/1pncmin/model.hh
index 1b9c076254..149202319b 100644
--- a/dumux/porousmediumflow/1pncmin/model.hh
+++ b/dumux/porousmediumflow/1pncmin/model.hh
@@ -123,7 +123,7 @@ SET_PROP(OnePNCMin, ModelTraits)
 private:
     using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
     using SolidSystem = typename GET_PROP_TYPE(TypeTag, SolidSystem);
-    using NonMinTraits = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, PhaseIdx), GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>;
+    using NonMinTraits = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>;
 public:
     using type = MineralizationModelTraits<NonMinTraits, SolidSystem::numComponents, SolidSystem::numInertComponents>;
 };
@@ -155,7 +155,7 @@ SET_PROP(OnePNCMinNI, ModelTraits)
 private:
     using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
     using SolidSystem = typename GET_PROP_TYPE(TypeTag, SolidSystem);
-    using OnePNCTraits = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, PhaseIdx), GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>;
+    using OnePNCTraits = OnePNCModelTraits<FluidSystem::numComponents, GET_PROP_VALUE(TypeTag, UseMoles), GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx)>;
     using IsothermalTraits = MineralizationModelTraits<OnePNCTraits, SolidSystem::numComponents, SolidSystem::numInertComponents>;
 public:
     using type = PorousMediumFlowNIModelTraits<IsothermalTraits>;
diff --git a/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc b/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc
index 12a429b089..2f09fdd81f 100644
--- a/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc
+++ b/test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc
@@ -136,7 +136,7 @@ int main(int argc, char** argv) try
     auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
 
     // intialize the vtk output module
-    VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
+    VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
     using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
     VtkOutputFields::init(vtkWriter);
 
diff --git a/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh b/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh
index 6f49329b1c..6f483698ec 100644
--- a/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh
+++ b/test/porousmediumflow/1pncmin/implicit/thermochemproblem.hh
@@ -32,6 +32,7 @@
 #include <dumux/discretization/cellcentered/tpfa/properties.hh>
 #include <dumux/discretization/cellcentered/mpfa/properties.hh>
 #include <dumux/porousmediumflow/problem.hh>
+#include <dumux/material/fluidsystems/1padapter.hh>
 #include <dumux/material/fluidsystems/h2on2.hh>
 #include <dumux/material/fluidmatrixinteractions/1p/thermalconductivityaverage.hh>
 #include <dumux/material/components/cao2h2.hh>
@@ -41,7 +42,6 @@
 #include "thermochemreaction.hh"
 #include "modifiedcao.hh"
 
-
 namespace Dumux {
 
 template <class TypeTag>
@@ -55,17 +55,16 @@ NEW_TYPE_TAG(ThermoChemBoxTypeTag, INHERITS_FROM(BoxModel, ThermoChemTypeTag));
 SET_TYPE_PROP(ThermoChemTypeTag, Grid, Dune::YaspGrid<2>);
 // Set the problem property
 SET_TYPE_PROP(ThermoChemTypeTag, Problem, ThermoChemProblem<TypeTag>);
-// Set fluid configuration
 
+// The fluid system
 SET_PROP(ThermoChemTypeTag, FluidSystem)
-{ /*private:*/
+{
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
-    using type = FluidSystems::H2ON2<Scalar>;
+    using H2ON2 = FluidSystems::H2ON2<Scalar>;
+    static constexpr auto phaseIdx = H2ON2::gasPhaseIdx; // simulate the air phase
+    using type = FluidSystems::OnePAdapter<H2ON2, phaseIdx>;
 };
 
-// set phase index (gas)
-SET_INT_PROP(ThermoChemTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx);
-
 SET_PROP(ThermoChemTypeTag, SolidSystem)
 {
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
@@ -125,7 +124,7 @@ class ThermoChemProblem : public PorousMediumFlowProblem<TypeTag>
     {
         // Indices of the primary variables
         pressureIdx = Indices::pressureIdx, //gas-phase pressure
-        H2OIdx = FluidSystem::H2OIdx, // mole fraction water
+        H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx), // mole fraction water
 
         CaOIdx = FluidSystem::numComponents,
         CaO2H2Idx = FluidSystem::numComponents+1,
diff --git a/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh b/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh
index 01c45a4049..71334ec2df 100644
--- a/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh
+++ b/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh
@@ -34,8 +34,8 @@ namespace Dumux {
  *
  * It contains simple and advanced reaction kinetics according to Nagel et al. (2014).
  */
-class ThermoChemReaction
-{
+class ThermoChemReaction {
+
 public:
     /*!
      * \brief evaluates the reaction kinetics (see Nagel et al. 2014)
@@ -47,6 +47,7 @@ public:
         using FluidSystem = typename VolumeVariables::FluidSystem;
         using SolidSystem = typename VolumeVariables::SolidSystem;
 
+        static constexpr auto H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx);
         static constexpr int cPhaseIdx = SolidSystem::comp0Idx;
         static constexpr int hPhaseIdx = SolidSystem::comp1Idx;
 
@@ -58,12 +59,12 @@ public:
 
         Scalar moleFractionVapor = 1e-3;
 
-        if(volVars.moleFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx) > 1e-3)
-            moleFractionVapor = volVars.moleFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx);
+        if(volVars.moleFraction(0, H2OIdx) > 1e-3)
+            moleFractionVapor = volVars.moleFraction(0, H2OIdx);
 
-        if(volVars.moleFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx) >= 1.0) moleFractionVapor = 1;
+        if(volVars.moleFraction(0, H2OIdx) >= 1.0) moleFractionVapor = 1;
 
-        Scalar pV = volVars.pressure(FluidSystem::gasPhaseIdx) *moleFractionVapor;
+        Scalar pV = volVars.pressure(0) *moleFractionVapor;
         Scalar vaporPressure = pV*1.0e-5;
         Scalar pFactor = log(vaporPressure);
 
@@ -166,6 +167,7 @@ public:
         using FluidSystem = typename VolumeVariables::FluidSystem;
         using SolidSystem = typename VolumeVariables::SolidSystem;
 
+        static constexpr auto H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx);
         static constexpr int cPhaseIdx = SolidSystem::comp0Idx;
         static constexpr int hPhaseIdx = SolidSystem::comp1Idx;
 
@@ -177,12 +179,12 @@ public:
 
         Scalar moleFractionVapor = 1e-3;
 
-        if(volVars.moleFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx) > 1e-3)
-            moleFractionVapor = volVars.moleFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx);
+        if(volVars.moleFraction(0, H2OIdx) > 1e-3)
+            moleFractionVapor = volVars.moleFraction(0, H2OIdx);
 
-        if(volVars.moleFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx) >= 1.0) moleFractionVapor = 1;
+        if(volVars.moleFraction(0, H2OIdx) >= 1.0) moleFractionVapor = 1;
 
-        Scalar pV = volVars.pressure(FluidSystem::gasPhaseIdx) *moleFractionVapor;
+        Scalar pV = volVars.pressure(0) *moleFractionVapor;
         Scalar vaporPressure = pV*1.0e-5;
         Scalar pFactor = log(vaporPressure);
 
@@ -209,7 +211,7 @@ public:
 
          //discharge or hydration
         if (T < Teq){
-            Scalar massFracH2O_fPhase = volVars.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::H2OIdx);
+            Scalar massFracH2O_fPhase = volVars.massFraction(0, H2OIdx);
             Scalar krh = 0.2;
 
             Scalar rHydration = - massFracH2O_fPhase* (volVars.solidComponentDensity(hPhaseIdx)- realSolidDensityAverage)
-- 
GitLab