diff --git a/examples/problems/co2ptflashproblem.hh b/examples/problems/co2ptflashproblem.hh index a75036acb..e7df55c89 100644 --- a/examples/problems/co2ptflashproblem.hh +++ b/examples/problems/co2ptflashproblem.hh @@ -77,6 +77,14 @@ struct NumComp { static constexpr int value = 3; }; +template +struct EnableDummyWater { using type = UndefinedProperty; }; + +template +struct EnableDummyWater { + static constexpr bool value = true; +}; + // Set the grid type: --->2D template struct Grid { using type = Dune::YaspGrid; }; @@ -105,9 +113,10 @@ struct FluidSystem private: using Scalar = GetPropType; static constexpr int num_comp = getPropValue(); + static constexpr bool enable_water = getPropValue(); public: - using type = Opm::GenericOilGasWaterFluidSystem; + using type = Opm::GenericOilGasWaterFluidSystem; }; // Set the material Law diff --git a/opm/models/common/multiphasebaseproperties.hh b/opm/models/common/multiphasebaseproperties.hh index f067612f9..968a750ba 100644 --- a/opm/models/common/multiphasebaseproperties.hh +++ b/opm/models/common/multiphasebaseproperties.hh @@ -83,6 +83,8 @@ struct EnableDispersion { using type = UndefinedProperty; }; //! Enable convective mixing? template struct EnableConvectiveMixing { using type = UndefinedProperty; }; +template +struct EnableWater { using type = UndefinedProperty; }; } // namespace Opm::Properties diff --git a/opm/models/ptflash/flashindices.hh b/opm/models/ptflash/flashindices.hh index 9027e4334..ac4c0ebf4 100644 --- a/opm/models/ptflash/flashindices.hh +++ b/opm/models/ptflash/flashindices.hh @@ -48,19 +48,20 @@ class FlashIndices { static constexpr int numComponents = getPropValue(); enum { enableEnergy = getPropValue() }; + enum { enableWater = getPropValue() }; using EnergyIndices = Opm::EnergyIndices; public: //! All phases active (note: immiscible/"dummy" water phase) - static constexpr bool waterEnabled = true; + static constexpr bool waterEnabled = enableWater; static constexpr bool gasEnabled = true; static constexpr bool oilEnabled = true; //! number of active phases - static constexpr int numPhases = 3; + static constexpr int numPhases = enableWater ? 3 : 2; //! number of equations/primary variables - static const int numEq = numComponents + EnergyIndices::numEq_ + 1; + static const int numEq = numComponents + EnergyIndices::numEq_ + (enableWater ? 1 : 0); // Primary variable indices @@ -71,7 +72,7 @@ public: static constexpr int z0Idx = pressure0Idx + 1; //! Index of water saturation - static constexpr int water0Idx = z0Idx + numComponents - 1; + static constexpr int water0Idx = enableWater ? z0Idx + numComponents - 1 : -1000; // equation indices diff --git a/opm/models/ptflash/flashintensivequantities.hh b/opm/models/ptflash/flashintensivequantities.hh index a7038898d..4fad4b706 100644 --- a/opm/models/ptflash/flashintensivequantities.hh +++ b/opm/models/ptflash/flashintensivequantities.hh @@ -78,6 +78,8 @@ class FlashIntensiveQuantities enum { pressure0Idx = Indices::pressure0Idx }; enum { water0Idx = Indices::water0Idx}; + static constexpr bool waterEnabled = Indices::waterEnabled; + using Scalar = GetPropType; using Evaluation = GetPropType; using FluidSystem = GetPropType; @@ -216,8 +218,12 @@ public: (R * fluidState_.temperature(FluidSystem::gasPhaseIdx)); - // Update oil/gas saturation; water saturation is a primary variable - Evaluation Sw = priVars.makeEvaluation(water0Idx, timeIdx); + // Update saturation + Evaluation Sw = 0.0; + if constexpr (waterEnabled) { + Sw = priVars.makeEvaluation(water0Idx, timeIdx); + fluidState_.setSaturation(FluidSystem::waterPhaseIdx, Sw); + } Evaluation L = fluidState_.L(); Evaluation So = Opm::max((1 - Sw) * (L * Z_L / ( L * Z_L + (1 - L) * Z_V)), 0.0); Evaluation Sg = Opm::max(1 - So - Sw, 0.0); @@ -228,7 +234,6 @@ public: fluidState_.setSaturation(FluidSystem::oilPhaseIdx, So); fluidState_.setSaturation(FluidSystem::gasPhaseIdx, Sg); - fluidState_.setSaturation(FluidSystem::waterPhaseIdx, Sw); fluidState_.setCompressFactor(FluidSystem::oilPhaseIdx, Z_L); fluidState_.setCompressFactor(FluidSystem::gasPhaseIdx, Z_V); @@ -253,7 +258,10 @@ public: // set the phase viscosity and density for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - paramCache.updatePhase(fluidState_, phaseIdx); + if (phaseIdx == static_cast(FluidSystem::oilPhaseIdx) + || phaseIdx == static_cast(FluidSystem::gasPhaseIdx)) { + paramCache.updatePhase(fluidState_, phaseIdx); + } const Evaluation& mu = FluidSystem::viscosity(fluidState_, paramCache, phaseIdx); diff --git a/opm/models/ptflash/flashlocalresidual.hh b/opm/models/ptflash/flashlocalresidual.hh index 8d6172fc1..29ac021db 100644 --- a/opm/models/ptflash/flashlocalresidual.hh +++ b/opm/models/ptflash/flashlocalresidual.hh @@ -65,6 +65,8 @@ class FlashLocalResidual: public GetPropType() }; using EnergyModule = Opm::EnergyModule; + static const bool waterEnabled = Indices::waterEnabled; + using Toolbox = Opm::MathToolbox; public: @@ -82,7 +84,7 @@ public: const auto& fs = intQuants.fluidState(); // compute water storage term - if (phaseIdx == waterPhaseIdx) { + if (waterEnabled && phaseIdx == static_cast(waterPhaseIdx)) { unsigned eqIdx = conti0EqIdx + numComponents; storage[eqIdx] = Toolbox::template decay(fs.density(phaseIdx)) @@ -160,7 +162,7 @@ public: up.fluidState().density(phaseIdx) * extQuants.volumeFlux(phaseIdx); - if (phaseIdx == waterPhaseIdx) { + if (waterEnabled && phaseIdx == static_cast(waterPhaseIdx)) { unsigned eqIdx = conti0EqIdx + numComponents; flux[eqIdx] = tmp; } @@ -176,7 +178,7 @@ public: Toolbox::value(up.fluidState().density(phaseIdx)) * extQuants.volumeFlux(phaseIdx); - if (phaseIdx == waterPhaseIdx) { + if (waterEnabled && phaseIdx == static_cast(waterPhaseIdx)) { unsigned eqIdx = conti0EqIdx + numComponents; flux[eqIdx] = tmp; } diff --git a/opm/models/ptflash/flashmodel.hh b/opm/models/ptflash/flashmodel.hh index f348523af..8a192f50e 100644 --- a/opm/models/ptflash/flashmodel.hh +++ b/opm/models/ptflash/flashmodel.hh @@ -135,6 +135,10 @@ template struct EnableEnergy { static constexpr bool value = false; }; +template +struct EnableWater +{ static constexpr int value = GetPropType::waterEnabled; }; + } // namespace Opm::Properties namespace Opm { diff --git a/opm/models/ptflash/flashnewtonmethod.hh b/opm/models/ptflash/flashnewtonmethod.hh index 093f4a6f7..5b6fa1ddb 100644 --- a/opm/models/ptflash/flashnewtonmethod.hh +++ b/opm/models/ptflash/flashnewtonmethod.hh @@ -63,6 +63,8 @@ class FlashNewtonMethod : public GetPropType() }; + static constexpr bool waterEnabled = Indices::waterEnabled; + public: /*! * \copydoc FvBaseNewtonMethod::FvBaseNewtonMethod(Problem& ) @@ -126,10 +128,12 @@ protected: clampValue_(nextValue[z0Idx + compIdx], tol, 1-tol); } - // limit change in water saturation to 0.2 - constexpr Scalar dSwMax = 0.2; - if (update[Indices::water0Idx] > dSwMax) { - nextValue[Indices::water0Idx] = currentValue[Indices::water0Idx] - dSwMax; + if constexpr (waterEnabled) { + // limit change in water saturation to 0.2 + constexpr Scalar dSwMax = 0.2; + if (update[Indices::water0Idx] > dSwMax) { + nextValue[Indices::water0Idx] = currentValue[Indices::water0Idx] - dSwMax; + } } } private: diff --git a/opm/models/ptflash/flashprimaryvariables.hh b/opm/models/ptflash/flashprimaryvariables.hh index 7f9914327..897c322ff 100644 --- a/opm/models/ptflash/flashprimaryvariables.hh +++ b/opm/models/ptflash/flashprimaryvariables.hh @@ -63,6 +63,8 @@ class FlashPrimaryVariables : public FvBasePrimaryVariables enum { pressure0Idx = Indices::pressure0Idx }; enum { water0Idx = Indices::water0Idx }; + static constexpr bool waterEnabled = Indices::waterEnabled; + // phase indices enum { gasPhaseIdx = FluidSystem::gasPhaseIdx }; enum { waterPhaseIdx = FluidSystem::waterPhaseIdx }; @@ -122,7 +124,9 @@ public: (*this)[pressure0Idx] = getValue(fluidState.pressure(oilPhaseIdx)); // assign water saturation - (*this)[water0Idx] = getValue(fluidState.saturation(waterPhaseIdx)); + if constexpr (waterEnabled) { + (*this)[water0Idx] = getValue(fluidState.saturation(waterPhaseIdx)); + } } /*! @@ -138,7 +142,9 @@ public: os << ", z_" << FluidSystem::componentName(compIdx) << " = " << this->operator[](z0Idx + compIdx); } - os << ", S_w = " << this->operator[](water0Idx); + if constexpr (waterEnabled) { + os << ", S_w = " << this->operator[](water0Idx); + } os << ")" << std::flush; } }; diff --git a/opm/simulators/flow/FlowProblemComp.hpp b/opm/simulators/flow/FlowProblemComp.hpp index 575423d32..d6e6c817f 100644 --- a/opm/simulators/flow/FlowProblemComp.hpp +++ b/opm/simulators/flow/FlowProblemComp.hpp @@ -362,7 +362,7 @@ public: Dune::FieldVector z(0.0); Scalar sumMoles = 0.0; for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - if (phaseIdx == waterPhaseIdx){ + if (Indices::waterEnabled && phaseIdx == static_cast(waterPhaseIdx)){ continue; } const auto saturation = fs.saturation(phaseIdx); @@ -494,7 +494,7 @@ protected: const bool gas_active = FluidSystem::phaseIsActive(gasPhaseIdx); const bool oil_active = FluidSystem::phaseIsActive(oilPhaseIdx); - if (water_active && Indices::numPhases > 1) + if (water_active && Indices::numPhases > 2) waterSaturationData = fp.get_double("SWAT"); else waterSaturationData.resize(numDof); diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index 2d6847fad..19e11d4cd 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -1676,17 +1676,27 @@ INSTANTIATE_TYPE(double) INSTANTIATE_TYPE(float) #endif -#define INSTANTIATE_COMP(NUM) \ - template using FS##NUM = GenericOilGasWaterFluidSystem; \ +#define INSTANTIATE_COMP_THREEPHASE(NUM) \ + template using FS##NUM = GenericOilGasWaterFluidSystem; \ template class GenericOutputBlackoilModule>; -INSTANTIATE_COMP(0) // \Note: to register the parameter ForceDisableFluidInPlaceOutput +INSTANTIATE_COMP_THREEPHASE(0) // \Note: to register the parameter ForceDisableFluidInPlaceOutput +INSTANTIATE_COMP_THREEPHASE(2) +INSTANTIATE_COMP_THREEPHASE(3) +INSTANTIATE_COMP_THREEPHASE(4) +INSTANTIATE_COMP_THREEPHASE(5) +INSTANTIATE_COMP_THREEPHASE(6) +INSTANTIATE_COMP_THREEPHASE(7) -INSTANTIATE_COMP(2) -INSTANTIATE_COMP(3) -INSTANTIATE_COMP(4) -INSTANTIATE_COMP(5) -INSTANTIATE_COMP(6) -INSTANTIATE_COMP(7) +#define INSTANTIATE_COMP_TWOPHASE(NUM) \ + template using GFS##NUM = GenericOilGasWaterFluidSystem; \ + template class GenericOutputBlackoilModule>; + +INSTANTIATE_COMP_TWOPHASE(2) +INSTANTIATE_COMP_TWOPHASE(3) +INSTANTIATE_COMP_TWOPHASE(4) +INSTANTIATE_COMP_TWOPHASE(5) +INSTANTIATE_COMP_TWOPHASE(6) +INSTANTIATE_COMP_TWOPHASE(7) } // namespace Opm