diff --git a/exercises/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh b/exercises/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh index f4efefb08f2f00b9582cf3c3ca8039df4343fb28..1fe98c085805a45045474cece286db0f4561b399 100644 --- a/exercises/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh +++ b/exercises/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh @@ -26,6 +26,7 @@ #include <dune/grid/yaspgrid.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/freeflow/navierstokes/problem.hh> @@ -44,11 +45,12 @@ NEW_TYPE_TAG(StokesTypeTag, INHERITS_FROM(StaggeredFreeFlowModel, NavierStokesNC // Set the grid type SET_TYPE_PROP(StokesTypeTag, Grid, Dune::YaspGrid<2, Dune::EquidistantOffsetCoordinates<typename GET_PROP_TYPE(TypeTag, Scalar), 2> >); -// Set the fluid system -SET_TYPE_PROP(StokesTypeTag, FluidSystem, FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// Set phase index (gas) -SET_INT_PROP(StokesTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx); +// The fluid system +SET_PROP(StokesTypeTag, FluidSystem) +{ + using H2OAir = FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>; + using type = FluidSystems::OnePAdapter<H2OAir, H2OAir::gasPhaseIdx>; +}; // Do not replace one equation with a total mass balance SET_INT_PROP(StokesTypeTag, ReplaceCompEqIdx, 3); @@ -101,10 +103,6 @@ class StokesSubProblem : public NavierStokesProblem<TypeTag> static constexpr bool useMoles = GET_PROP_TYPE(TypeTag, ModelTraits)::useMoles(); - static constexpr auto dim = GET_PROP_TYPE(TypeTag, ModelTraits)::dim(); - static constexpr auto phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); - static constexpr auto transportCompIdx = 1 - phaseIdx; - public: StokesSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) @@ -159,27 +157,27 @@ public: if(onLeftBoundary_(globalPos)) { - values.setDirichlet(transportCompIdx + dim); + values.setDirichlet(Indices::conti0EqIdx + 1); values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); } else if(onRightBoundary_(globalPos)) { values.setDirichlet(Indices::pressureIdx); - values.setOutflow(transportCompIdx + dim); + values.setOutflow(Indices::conti0EqIdx + 1); } else { values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); - values.setNeumann(phaseIdx + dim); - values.setNeumann(transportCompIdx + dim); + values.setNeumann(Indices::conti0EqIdx); + values.setNeumann(Indices::conti0EqIdx + 1); } if (couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) { - values.setCouplingNeumann(phaseIdx + dim); - values.setCouplingNeumann(transportCompIdx + dim); + values.setCouplingNeumann(Indices::conti0EqIdx); + values.setCouplingNeumann(Indices::conti0EqIdx + 1); values.setCouplingNeumann(Indices::momentumYBalanceIdx); values.setBJS(Indices::momentumXBalanceIdx); } @@ -257,11 +255,11 @@ public: { FluidState fluidState; updateFluidStateForBC_(fluidState, pressure_); - const Scalar density = FluidSystem::density(fluidState, phaseIdx); + const Scalar density = FluidSystem::density(fluidState, 0); PrimaryVariables values(0.0); values[Indices::pressureIdx] = pressure_ + density*this->gravity()[1]*(globalPos[1] - this->fvGridGeometry().bBoxMin()[1]); - values[transportCompIdx + dim] = moleFraction_; + values[Indices::conti0EqIdx + 1] = moleFraction_; values[Indices::velocityXIdx] = 4.0 * velocity_ * (globalPos[1] - this->fvGridGeometry().bBoxMin()[1]) * (this->fvGridGeometry().bBoxMax()[1] - globalPos[1]) / (height_() * height_()); @@ -307,22 +305,22 @@ private: void updateFluidStateForBC_(FluidState& fluidState, const Scalar pressure) const { fluidState.setTemperature(temperature()); - fluidState.setPressure(phaseIdx, pressure); - fluidState.setSaturation(phaseIdx, 1.0); - fluidState.setMoleFraction(phaseIdx, transportCompIdx, moleFraction_); - fluidState.setMoleFraction(phaseIdx, phaseIdx, 1.0 - moleFraction_); + fluidState.setPressure(0, pressure); + fluidState.setSaturation(0, 1.0); + fluidState.setMoleFraction(0, 1, moleFraction_); + fluidState.setMoleFraction(0, 0, 1.0 - moleFraction_); typename FluidSystem::ParameterCache paramCache; - paramCache.updatePhase(fluidState, phaseIdx); + paramCache.updatePhase(fluidState, 0); - const Scalar density = FluidSystem::density(fluidState, paramCache, phaseIdx); - fluidState.setDensity(phaseIdx, density); + const Scalar density = FluidSystem::density(fluidState, paramCache, 0); + fluidState.setDensity(0, density); - const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx); - fluidState.setMolarDensity(phaseIdx, molarDensity); + const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, 0); + fluidState.setMolarDensity(0, molarDensity); - const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, phaseIdx); - fluidState.setEnthalpy(phaseIdx, enthalpy); + const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, 0); + fluidState.setEnthalpy(0, enthalpy); } // the height of the free-flow domain const Scalar height_() const diff --git a/exercises/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh b/exercises/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh index d95c094ea59e2dafb18eb5a0e5552340df6fc116..0e48d23560788095b46c641d55c64606f9ecf6d6 100644 --- a/exercises/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh +++ b/exercises/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh @@ -28,6 +28,7 @@ #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/io/gnuplotinterface.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/material/fluidmatrixinteractions/diffusivityconstanttortuosity.hh> @@ -49,10 +50,11 @@ NEW_TYPE_TAG(DarcyTypeTag, INHERITS_FROM(CCTpfaModel, OnePNC)); SET_TYPE_PROP(DarcyTypeTag, Problem, Dumux::DarcySubProblem<TypeTag>); // The fluid system -SET_TYPE_PROP(DarcyTypeTag, FluidSystem, FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// Use gas as phase -SET_INT_PROP(DarcyTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx); +SET_PROP(DarcyTypeTag, FluidSystem) +{ + using H2OAir = FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>; + using type = FluidSystems::OnePAdapter<H2OAir, H2OAir::gasPhaseIdx>; +}; // Use moles SET_BOOL_PROP(DarcyTypeTag, UseMoles, true); @@ -96,8 +98,8 @@ class DarcySubProblem : public PorousMediumFlowProblem<TypeTag> // primary variable indices conti0EqIdx = Indices::conti0EqIdx, pressureIdx = Indices::pressureIdx, - phaseIdx = Indices::fluidSystemPhaseIdx, - transportCompIdx = 1-phaseIdx + phaseIdx = 0, + transportCompIdx = 1 }; using Element = typename GridView::template Codim<0>::Entity; @@ -181,11 +183,8 @@ public: for (auto&& scv : scvs(fvGeometry)) { const auto& volVars = elemVolVars[scv]; - for(int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) - { - // insert calculation of the water mass here - waterMass += 0.0; - } + // insert calculation of the water mass here + waterMass += 0.0; } } diff --git a/exercises/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh b/exercises/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh index 117f518e8ac6e7f87c772f79752f971d3bf5dc8e..861e86ce9ff366b24376846708bb88fec1a7e4c3 100644 --- a/exercises/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh +++ b/exercises/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh @@ -25,6 +25,7 @@ #include <dune/grid/yaspgrid.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/discretization/staggered/freeflow/properties.hh> @@ -43,11 +44,13 @@ NEW_TYPE_TAG(ZeroEqTypeTag, INHERITS_FROM(StaggeredFreeFlowModel, NavierStokesNC // Set the grid type SET_TYPE_PROP(ZeroEqTypeTag, Grid, Dune::YaspGrid<2, Dune::TensorProductCoordinates<typename GET_PROP_TYPE(TypeTag, Scalar), 2> >); -// set the fluid system -SET_TYPE_PROP(ZeroEqTypeTag, FluidSystem, FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// set phase index (air) -SET_INT_PROP(ZeroEqTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx); +// The fluid system +SET_PROP(ZeroEqTypeTag, FluidSystem) +{ + using H2OAir = FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>; + static constexpr auto phaseIdx = H2OAir::gasPhaseIdx; // simulate the air phase + using type = FluidSystems::OnePAdapter<H2OAir, phaseIdx>; +}; SET_INT_PROP(ZeroEqTypeTag, ReplaceCompEqIdx, 3); @@ -98,9 +101,6 @@ class FreeFlowSubProblem : public NavierStokesProblem<TypeTag> static constexpr bool useMoles = GET_PROP_TYPE(TypeTag, ModelTraits)::useMoles(); - static constexpr auto phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); - static constexpr auto transportCompIdx = 1 - phaseIdx; - public: FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) @@ -157,7 +157,7 @@ public: { values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); - values.setDirichlet(Indices::conti0EqIdx); + values.setDirichlet(Indices::conti0EqIdx + 1); values.setDirichlet(Indices::energyBalanceIdx); } @@ -182,7 +182,7 @@ public: if (onRightBoundary_(globalPos)) { values.setDirichlet(Indices::pressureIdx); - values.setOutflow(Indices::conti0EqIdx); + values.setOutflow(Indices::conti0EqIdx + 1); values.setOutflow(Indices::energyBalanceIdx); } @@ -268,11 +268,11 @@ public: FluidState fluidState; updateFluidStateForBC_(fluidState, refTemperature(), refPressure(), refMoleFrac()); - const Scalar density = FluidSystem::density(fluidState, phaseIdx); + const Scalar density = FluidSystem::density(fluidState, 0); PrimaryVariables values(0.0); values[Indices::pressureIdx] = refPressure() + density*this->gravity()[1]*(globalPos[1] - this->fvGridGeometry().bBoxMin()[1]); - values[Indices::conti0EqIdx] = refMoleFrac(); + values[Indices::conti0EqIdx + 1] = refMoleFrac(); values[Indices::velocityXIdx] = refVelocity(); values[Indices::temperatureIdx] = refTemperature(); @@ -338,22 +338,22 @@ private: const Scalar pressure, const Scalar moleFraction) const { fluidState.setTemperature(temperature); - fluidState.setPressure(phaseIdx, pressure); - fluidState.setSaturation(phaseIdx, 1.0); - fluidState.setMoleFraction(phaseIdx, transportCompIdx, moleFraction); - fluidState.setMoleFraction(phaseIdx, phaseIdx, 1.0 - moleFraction); + fluidState.setPressure(0, pressure); + fluidState.setSaturation(0, 1.0); + fluidState.setMoleFraction(0, 1, moleFraction); + fluidState.setMoleFraction(0, 0, 1.0 - moleFraction); typename FluidSystem::ParameterCache paramCache; - paramCache.updatePhase(fluidState, phaseIdx); + paramCache.updatePhase(fluidState, 0); - const Scalar density = FluidSystem::density(fluidState, paramCache, phaseIdx); - fluidState.setDensity(phaseIdx, density); + const Scalar density = FluidSystem::density(fluidState, paramCache, 0); + fluidState.setDensity(0, density); - const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx); - fluidState.setMolarDensity(phaseIdx, molarDensity); + const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, 0); + fluidState.setMolarDensity(0, molarDensity); - const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, phaseIdx); - fluidState.setEnthalpy(phaseIdx, enthalpy); + const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, 0); + fluidState.setEnthalpy(0, enthalpy); } // the height of the free-flow domain diff --git a/exercises/solution/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh b/exercises/solution/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh index f4efefb08f2f00b9582cf3c3ca8039df4343fb28..3d59b25a071ed0e71a0c3baac902b4847a2ce840 100644 --- a/exercises/solution/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh +++ b/exercises/solution/exercise-coupling-ff-pm/models/ex_models_ffproblem.hh @@ -26,6 +26,7 @@ #include <dune/grid/yaspgrid.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/freeflow/navierstokes/problem.hh> @@ -44,11 +45,12 @@ NEW_TYPE_TAG(StokesTypeTag, INHERITS_FROM(StaggeredFreeFlowModel, NavierStokesNC // Set the grid type SET_TYPE_PROP(StokesTypeTag, Grid, Dune::YaspGrid<2, Dune::EquidistantOffsetCoordinates<typename GET_PROP_TYPE(TypeTag, Scalar), 2> >); -// Set the fluid system -SET_TYPE_PROP(StokesTypeTag, FluidSystem, FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// Set phase index (gas) -SET_INT_PROP(StokesTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx); +// The fluid system +SET_PROP(StokesTypeTag, FluidSystem) +{ + using H2OAir = FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>; + using type = FluidSystems::OnePAdapter<H2OAir, H2OAir::gasPhaseIdx>; +}; // Do not replace one equation with a total mass balance SET_INT_PROP(StokesTypeTag, ReplaceCompEqIdx, 3); @@ -102,8 +104,7 @@ class StokesSubProblem : public NavierStokesProblem<TypeTag> static constexpr bool useMoles = GET_PROP_TYPE(TypeTag, ModelTraits)::useMoles(); static constexpr auto dim = GET_PROP_TYPE(TypeTag, ModelTraits)::dim(); - static constexpr auto phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); - static constexpr auto transportCompIdx = 1 - phaseIdx; + static constexpr auto transportCompIdx = 1; public: StokesSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) @@ -159,27 +160,27 @@ public: if(onLeftBoundary_(globalPos)) { - values.setDirichlet(transportCompIdx + dim); + values.setDirichlet(Indices::conti0EqIdx + 1); values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); } else if(onRightBoundary_(globalPos)) { values.setDirichlet(Indices::pressureIdx); - values.setOutflow(transportCompIdx + dim); + values.setOutflow(Indices::conti0EqIdx + 1); } else { values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); - values.setNeumann(phaseIdx + dim); - values.setNeumann(transportCompIdx + dim); + values.setNeumann(Indices::conti0EqIdx); + values.setNeumann(Indices::conti0EqIdx + 1); } if (couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) { - values.setCouplingNeumann(phaseIdx + dim); - values.setCouplingNeumann(transportCompIdx + dim); + values.setCouplingNeumann(Indices::conti0EqIdx); + values.setCouplingNeumann(Indices::conti0EqIdx + 1); values.setCouplingNeumann(Indices::momentumYBalanceIdx); values.setBJS(Indices::momentumXBalanceIdx); } @@ -257,11 +258,11 @@ public: { FluidState fluidState; updateFluidStateForBC_(fluidState, pressure_); - const Scalar density = FluidSystem::density(fluidState, phaseIdx); + const Scalar density = FluidSystem::density(fluidState, 0); PrimaryVariables values(0.0); values[Indices::pressureIdx] = pressure_ + density*this->gravity()[1]*(globalPos[1] - this->fvGridGeometry().bBoxMin()[1]); - values[transportCompIdx + dim] = moleFraction_; + values[Indices::conti0EqIdx + 1] = moleFraction_; values[Indices::velocityXIdx] = 4.0 * velocity_ * (globalPos[1] - this->fvGridGeometry().bBoxMin()[1]) * (this->fvGridGeometry().bBoxMax()[1] - globalPos[1]) / (height_() * height_()); @@ -307,22 +308,22 @@ private: void updateFluidStateForBC_(FluidState& fluidState, const Scalar pressure) const { fluidState.setTemperature(temperature()); - fluidState.setPressure(phaseIdx, pressure); - fluidState.setSaturation(phaseIdx, 1.0); - fluidState.setMoleFraction(phaseIdx, transportCompIdx, moleFraction_); - fluidState.setMoleFraction(phaseIdx, phaseIdx, 1.0 - moleFraction_); + fluidState.setPressure(0, pressure); + fluidState.setSaturation(0, 1.0); + fluidState.setMoleFraction(0, 1, moleFraction_); + fluidState.setMoleFraction(0, 0, 1.0 - moleFraction_); typename FluidSystem::ParameterCache paramCache; - paramCache.updatePhase(fluidState, phaseIdx); + paramCache.updatePhase(fluidState, 0); - const Scalar density = FluidSystem::density(fluidState, paramCache, phaseIdx); - fluidState.setDensity(phaseIdx, density); + const Scalar density = FluidSystem::density(fluidState, paramCache, 0); + fluidState.setDensity(0, density); - const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx); - fluidState.setMolarDensity(phaseIdx, molarDensity); + const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, 0); + fluidState.setMolarDensity(0, molarDensity); - const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, phaseIdx); - fluidState.setEnthalpy(phaseIdx, enthalpy); + const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, 0); + fluidState.setEnthalpy(0, enthalpy); } // the height of the free-flow domain const Scalar height_() const diff --git a/exercises/solution/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh b/exercises/solution/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh index 110997ef51ae1b122d613e1af834ef861c33051d..18ad042dfdb65cbfc9a61389f8a7084a21e34eed 100644 --- a/exercises/solution/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh +++ b/exercises/solution/exercise-coupling-ff-pm/models/ex_models_pmproblem.hh @@ -26,6 +26,7 @@ #include <dune/grid/yaspgrid.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/discretization/cellcentered/tpfa/properties.hh> #include <dumux/io/gnuplotinterface.hh> #include <dumux/material/fluidsystems/h2oair.hh> @@ -58,12 +59,15 @@ NEW_TYPE_TAG(DarcyTypeTag, INHERITS_FROM(CCTpfaModel, OnePNC)); SET_TYPE_PROP(DarcyTypeTag, Problem, Dumux::DarcySubProblem<TypeTag>); // The fluid system -SET_TYPE_PROP(DarcyTypeTag, FluidSystem, FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// Use gas as phase +SET_PROP(DarcyTypeTag, FluidSystem) +{ + using H2OAir = FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>; #if EXNUMBER == 0 -SET_INT_PROP(DarcyTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx); + using type = FluidSystems::OnePAdapter<H2OAir, H2OAir::gasPhaseIdx>; +#else + using type = H2OAir; #endif +}; // Use moles SET_BOOL_PROP(DarcyTypeTag, UseMoles, true); @@ -123,8 +127,8 @@ class DarcySubProblem : public PorousMediumFlowProblem<TypeTag> #elif EXNUMBER >= 1 transportCompIdx = Indices::switchIdx #else - phaseIdx = Indices::fluidSystemPhaseIdx, - transportCompIdx = 1-phaseIdx + phaseIdx = 0, + transportCompIdx = 1 #endif }; diff --git a/exercises/solution/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh b/exercises/solution/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh index 604cd024a422fefca6c1244981527de306be968d..b02930b9ba255a3cd6982de4dc102e21c2635780 100644 --- a/exercises/solution/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh +++ b/exercises/solution/exercise-coupling-ff-pm/turbulence/ex_turbulence_ffproblem.hh @@ -25,6 +25,7 @@ #include <dune/grid/yaspgrid.hh> +#include <dumux/material/fluidsystems/1padapter.hh> #include <dumux/material/fluidsystems/h2oair.hh> #include <dumux/discretization/staggered/freeflow/properties.hh> @@ -52,11 +53,13 @@ NEW_TYPE_TAG(ZeroEqTypeTag, INHERITS_FROM(StaggeredFreeFlowModel, NavierStokesNC // Set the grid type SET_TYPE_PROP(ZeroEqTypeTag, Grid, Dune::YaspGrid<2, Dune::TensorProductCoordinates<typename GET_PROP_TYPE(TypeTag, Scalar), 2> >); -// set the fluid system -SET_TYPE_PROP(ZeroEqTypeTag, FluidSystem, FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// set phase index (air) -SET_INT_PROP(ZeroEqTypeTag, PhaseIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::gasPhaseIdx); +// The fluid system +SET_PROP(ZeroEqTypeTag, FluidSystem) +{ + using H2OAir = FluidSystems::H2OAir<typename GET_PROP_TYPE(TypeTag, Scalar)>; + static constexpr auto phaseIdx = H2OAir::gasPhaseIdx; // simulate the air phase + using type = FluidSystems::OnePAdapter<H2OAir, phaseIdx>; +}; SET_INT_PROP(ZeroEqTypeTag, ReplaceCompEqIdx, 3); @@ -113,9 +116,6 @@ class FreeFlowSubProblem : public NavierStokesProblem<TypeTag> static constexpr bool useMoles = GET_PROP_TYPE(TypeTag, ModelTraits)::useMoles(); - static constexpr auto phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); - static constexpr auto transportCompIdx = 1 - phaseIdx; - public: FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) @@ -172,7 +172,7 @@ public: { values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); - values.setDirichlet(Indices::conti0EqIdx); + values.setDirichlet(Indices::conti0EqIdx + 1); values.setDirichlet(Indices::energyBalanceIdx); } @@ -201,7 +201,7 @@ public: if (onRightBoundary_(globalPos)) { values.setDirichlet(Indices::pressureIdx); - values.setOutflow(Indices::conti0EqIdx); + values.setOutflow(Indices::conti0EqIdx + 1); values.setOutflow(Indices::energyBalanceIdx); } @@ -299,11 +299,11 @@ public: FluidState fluidState; updateFluidStateForBC_(fluidState, refTemperature(), refPressure(), refMoleFrac()); - const Scalar density = FluidSystem::density(fluidState, phaseIdx); + const Scalar density = FluidSystem::density(fluidState, 0); PrimaryVariables values(0.0); values[Indices::pressureIdx] = refPressure() + density*this->gravity()[1]*(globalPos[1] - this->fvGridGeometry().bBoxMin()[1]); - values[Indices::conti0EqIdx] = refMoleFrac(); + values[Indices::conti0EqIdx + 1] = refMoleFrac(); values[Indices::velocityXIdx] = refVelocity(); values[Indices::temperatureIdx] = refTemperature(); @@ -369,22 +369,22 @@ private: const Scalar pressure, const Scalar moleFraction) const { fluidState.setTemperature(temperature); - fluidState.setPressure(phaseIdx, pressure); - fluidState.setSaturation(phaseIdx, 1.0); - fluidState.setMoleFraction(phaseIdx, transportCompIdx, moleFraction); - fluidState.setMoleFraction(phaseIdx, phaseIdx, 1.0 - moleFraction); + fluidState.setPressure(0, pressure); + fluidState.setSaturation(0, 1.0); + fluidState.setMoleFraction(0, 1, moleFraction); + fluidState.setMoleFraction(0, 0, 1.0 - moleFraction); typename FluidSystem::ParameterCache paramCache; - paramCache.updatePhase(fluidState, phaseIdx); + paramCache.updatePhase(fluidState, 0); - const Scalar density = FluidSystem::density(fluidState, paramCache, phaseIdx); - fluidState.setDensity(phaseIdx, density); + const Scalar density = FluidSystem::density(fluidState, paramCache, 0); + fluidState.setDensity(0, density); - const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, phaseIdx); - fluidState.setMolarDensity(phaseIdx, molarDensity); + const Scalar molarDensity = FluidSystem::molarDensity(fluidState, paramCache, 0); + fluidState.setMolarDensity(0, molarDensity); - const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, phaseIdx); - fluidState.setEnthalpy(phaseIdx, enthalpy); + const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, 0); + fluidState.setEnthalpy(0, enthalpy); } // the height of the free-flow domain