From 2a0bcdfb1f820f8eac24d32d273dbcc396b9f233 Mon Sep 17 00:00:00 2001
From: Katharina Heck <katharina.heck@iws.uni-stuttgart.de>
Date: Wed, 29 Aug 2018 14:07:24 +0200
Subject: [PATCH] [feature][mineralization] add solidsystem as a template
 parameter in primaryvariablename in all porous medium models that are able to
 use restart and add primaryvariablename for mineralization

---
 dumux/io/loadsolution.hh                       | 8 ++++----
 dumux/porousmediumflow/1p/model.hh             | 2 +-
 dumux/porousmediumflow/1pnc/model.hh           | 2 +-
 dumux/porousmediumflow/2p/model.hh             | 2 +-
 dumux/porousmediumflow/2p1c/model.hh           | 2 +-
 dumux/porousmediumflow/2p2c/model.hh           | 2 +-
 dumux/porousmediumflow/2pnc/model.hh           | 2 +-
 dumux/porousmediumflow/3p/model.hh             | 2 +-
 dumux/porousmediumflow/3p3c/model.hh           | 2 +-
 dumux/porousmediumflow/3pwateroil/model.hh     | 2 +-
 dumux/porousmediumflow/mineralization/model.hh | 9 +++++++++
 dumux/porousmediumflow/nonisothermal/model.hh  | 4 ++--
 dumux/porousmediumflow/richards/model.hh       | 2 +-
 dumux/porousmediumflow/richardsnc/model.hh     | 2 +-
 dumux/porousmediumflow/tracer/model.hh         | 2 +-
 15 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/dumux/io/loadsolution.hh b/dumux/io/loadsolution.hh
index 5519764afb..e01e338230 100644
--- a/dumux/io/loadsolution.hh
+++ b/dumux/io/loadsolution.hh
@@ -232,7 +232,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
  * \brief helper function to determine the primary variable names of a model with privar state
  * \note use this as input for the load solution function
  */
-template<class ModelTraits, class FluidSystem = void>
+template<class ModelTraits, class FluidSystem = void, class SolidSystem = void>
 std::function<std::string(int,int)> createPVNameFunctionWithState(const std::string& paramGroup = "")
 {
     return  [paramGroup](int pvIdx, int state = 0)
@@ -250,7 +250,7 @@ std::function<std::string(int,int)> createPVNameFunctionWithState(const std::str
                     return pvName[pvIdx];
                 }
                 else
-                    return ModelTraits::template primaryVariableName<FluidSystem>(pvIdx, state);
+                    return ModelTraits::template primaryVariableName<FluidSystem, SolidSystem>(pvIdx, state);
             };
 }
 
@@ -259,7 +259,7 @@ std::function<std::string(int,int)> createPVNameFunctionWithState(const std::str
  * \brief helper function to determine the primary variable names of a model without state
  * \note use this as input for the load solution function
  */
-template<class ModelTraits, class FluidSystem = void>
+template<class ModelTraits, class FluidSystem = void, class SolidSystem = void>
 std::function<std::string(int,int)> createPVNameFunction(const std::string& paramGroup = "")
 {
     if (hasParamInGroup(paramGroup, "LoadSolution.PriVarNames"))
@@ -268,7 +268,7 @@ std::function<std::string(int,int)> createPVNameFunction(const std::string& para
         return [n = std::move(pvName)](int pvIdx, int state = 0){ return n[pvIdx]; };
     }
     else
-        return [](int pvIdx, int state = 0){ return ModelTraits::template primaryVariableName<FluidSystem>(pvIdx, state); };
+        return [](int pvIdx, int state = 0){ return ModelTraits::template primaryVariableName<FluidSystem, SolidSystem>(pvIdx, state); };
 }
 
 /*!
diff --git a/dumux/porousmediumflow/1p/model.hh b/dumux/porousmediumflow/1p/model.hh
index 44e6c1b650..51b0bc168a 100644
--- a/dumux/porousmediumflow/1p/model.hh
+++ b/dumux/porousmediumflow/1p/model.hh
@@ -75,7 +75,7 @@ struct OnePModelTraits
     static constexpr bool enableMolecularDiffusion() { return false; }
     static constexpr bool enableEnergyBalance() { return false; }
 
-    template <class FluidSystem = void>
+    template <class FluidSystem = void, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx = 0, int state = 0)
     {
         return "p";
diff --git a/dumux/porousmediumflow/1pnc/model.hh b/dumux/porousmediumflow/1pnc/model.hh
index c525fe8ab9..fdc27342d6 100644
--- a/dumux/porousmediumflow/1pnc/model.hh
+++ b/dumux/porousmediumflow/1pnc/model.hh
@@ -98,7 +98,7 @@ struct OnePNCModelTraits
     static constexpr bool enableMolecularDiffusion() { return true; }
     static constexpr bool enableEnergyBalance() { return false; }
 
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state = 0)
     {
         const std::string xString = useMoles() ? "x" : "X";
diff --git a/dumux/porousmediumflow/2p/model.hh b/dumux/porousmediumflow/2p/model.hh
index 4a363dacf9..b73fa645cc 100644
--- a/dumux/porousmediumflow/2p/model.hh
+++ b/dumux/porousmediumflow/2p/model.hh
@@ -99,7 +99,7 @@ struct TwoPModelTraits
     static constexpr bool enableMolecularDiffusion() { return false; }
     static constexpr bool enableEnergyBalance() { return false; }
 
-    template <class FluidSystem = void>
+    template <class FluidSystem = void, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state = 0)
     {
         if (priVarFormulation() == TwoPFormulation::p0s1)
diff --git a/dumux/porousmediumflow/2p1c/model.hh b/dumux/porousmediumflow/2p1c/model.hh
index 01db1d71d6..1da0530204 100644
--- a/dumux/porousmediumflow/2p1c/model.hh
+++ b/dumux/porousmediumflow/2p1c/model.hh
@@ -103,7 +103,7 @@ struct TwoPOneCNIModelTraits
 
     static constexpr TwoPFormulation priVarFormulation() { return f; }
 
-    template <class FluidSystem = void>
+    template <class FluidSystem = void, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state)
     {
         if (priVarFormulation() == TwoPFormulation::p0s1)
diff --git a/dumux/porousmediumflow/2p2c/model.hh b/dumux/porousmediumflow/2p2c/model.hh
index 91e8149308..08f9138bb8 100644
--- a/dumux/porousmediumflow/2p2c/model.hh
+++ b/dumux/porousmediumflow/2p2c/model.hh
@@ -103,7 +103,7 @@ namespace Dumux {
 template<TwoPFormulation formulation, bool useMol, int replCompEqIdx = 2>
 struct TwoPTwoCModelTraits : public TwoPNCModelTraits</*numComps=*/2, useMol, /*setMFracForFirstPhase=*/true, formulation, replCompEqIdx>
 {
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state)
     {
         static const std::string xString = useMol ? "x" : "X";
diff --git a/dumux/porousmediumflow/2pnc/model.hh b/dumux/porousmediumflow/2pnc/model.hh
index ba6238a919..5815573505 100644
--- a/dumux/porousmediumflow/2pnc/model.hh
+++ b/dumux/porousmediumflow/2pnc/model.hh
@@ -135,7 +135,7 @@ struct TwoPNCModelTraits
 
     static constexpr TwoPFormulation priVarFormulation() { return formulation; }
 
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state)
     {
         const std::string xString = useMoles() ? "x" : "X";
diff --git a/dumux/porousmediumflow/3p/model.hh b/dumux/porousmediumflow/3p/model.hh
index 858dd85e5d..2156f7b7db 100644
--- a/dumux/porousmediumflow/3p/model.hh
+++ b/dumux/porousmediumflow/3p/model.hh
@@ -90,7 +90,7 @@ struct ThreePModelTraits
     static constexpr bool enableMolecularDiffusion() { return false; }
     static constexpr bool enableEnergyBalance() { return false; }
 
-    template <class FluidSystem = void>
+    template <class FluidSystem = void, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state = 0)
     {
         switch (pvIdx)
diff --git a/dumux/porousmediumflow/3p3c/model.hh b/dumux/porousmediumflow/3p3c/model.hh
index 0e24f410d6..9d5cd0172a 100644
--- a/dumux/porousmediumflow/3p3c/model.hh
+++ b/dumux/porousmediumflow/3p3c/model.hh
@@ -122,7 +122,7 @@ struct ThreePThreeCModelTraits
     static constexpr bool useConstraintSolver() { return useCS; }
     static constexpr bool useMoles() { return useMol; }
 
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state)
     {
         switch (state)
diff --git a/dumux/porousmediumflow/3pwateroil/model.hh b/dumux/porousmediumflow/3pwateroil/model.hh
index b3bdb846cb..f33abc1f82 100644
--- a/dumux/porousmediumflow/3pwateroil/model.hh
+++ b/dumux/porousmediumflow/3pwateroil/model.hh
@@ -112,7 +112,7 @@ struct ThreePWaterOilModelTraits
 
     static constexpr bool onlyGasPhaseCanDisappear() { return onlyGasPhase; }
 
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state)
     {
         switch (state)
diff --git a/dumux/porousmediumflow/mineralization/model.hh b/dumux/porousmediumflow/mineralization/model.hh
index 3e7f01258a..45f6dd5942 100644
--- a/dumux/porousmediumflow/mineralization/model.hh
+++ b/dumux/porousmediumflow/mineralization/model.hh
@@ -51,6 +51,15 @@ struct MineralizationModelTraits : public NonMinTraits
     static constexpr int numInertSolidComps() { return numInertSC; }
     //! we additionally solve one equation per precipitating mineral phase
     static constexpr int numEq() { return NonMinTraits::numEq() + numSC - numInertSC; }
+
+    template <class FluidSystem, class SolidSystem>
+    static std::string primaryVariableName(int pvIdx, int state = 0)
+    {
+        if (pvIdx < NonMinTraits::numEq())
+            return NonMinTraits::template primaryVariableName<FluidSystem, SolidSystem>(pvIdx, state);
+        else
+            return "precipitateVolumeFraction^" + SolidSystem::componentName(pvIdx -NonMinTraits::numEq());
+    }
 };
 } // end namespace Dumux
 
diff --git a/dumux/porousmediumflow/nonisothermal/model.hh b/dumux/porousmediumflow/nonisothermal/model.hh
index 1af387e242..edf37038be 100644
--- a/dumux/porousmediumflow/nonisothermal/model.hh
+++ b/dumux/porousmediumflow/nonisothermal/model.hh
@@ -75,11 +75,11 @@ struct PorousMediumFlowNIModelTraits : public IsothermalTraits
     //! The indices related to the non-isothermal model
     using Indices = EnergyIndices< typename IsothermalTraits::Indices, numEq()>;
 
-    template <class FluidSystem = void>
+    template <class FluidSystem = void, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state = 0)
     {
         if (pvIdx < numEq() - 1)
-            return IsothermalTraits::template primaryVariableName<FluidSystem>(pvIdx, state);
+            return IsothermalTraits::template primaryVariableName<FluidSystem, SolidSystem>(pvIdx, state);
         else
             return "T";
     }
diff --git a/dumux/porousmediumflow/richards/model.hh b/dumux/porousmediumflow/richards/model.hh
index 365e077131..330b3b927e 100644
--- a/dumux/porousmediumflow/richards/model.hh
+++ b/dumux/porousmediumflow/richards/model.hh
@@ -136,7 +136,7 @@ struct RichardsModelTraits
     static constexpr bool enableMolecularDiffusion() { return enableDiff; }
     static constexpr bool enableEnergyBalance() { return false; }
 
-    template<class FluidSystem = void>
+    template<class FluidSystem = void, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state)
     {
         if (state == Indices::gasPhaseOnly)
diff --git a/dumux/porousmediumflow/richardsnc/model.hh b/dumux/porousmediumflow/richardsnc/model.hh
index 4b7490301f..812e485435 100644
--- a/dumux/porousmediumflow/richardsnc/model.hh
+++ b/dumux/porousmediumflow/richardsnc/model.hh
@@ -115,7 +115,7 @@ struct RichardsNCModelTraits
 
     static constexpr bool useMoles() { return useMol; }
 
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state = 0)
     {
         const std::string xString = useMoles() ? "x" : "X";
diff --git a/dumux/porousmediumflow/tracer/model.hh b/dumux/porousmediumflow/tracer/model.hh
index c157b2eaa7..e6793e455a 100644
--- a/dumux/porousmediumflow/tracer/model.hh
+++ b/dumux/porousmediumflow/tracer/model.hh
@@ -86,7 +86,7 @@ struct TracerModelTraits
 
     static constexpr bool useMoles() { return useMol; }
 
-    template <class FluidSystem>
+    template <class FluidSystem, class SolidSystem = void>
     static std::string primaryVariableName(int pvIdx, int state = 0)
     {
         const std::string xString = useMoles() ? "x" : "X";
-- 
GitLab