diff --git a/dumux/porousmediumflow/2pnc/implicit/model.hh b/dumux/porousmediumflow/2pnc/implicit/model.hh index 70d80dc92919f9bd242d546cce19e66bb3131fc6..af6cd2f524e6d7711549e98c515c276f2861acb9 100644 --- a/dumux/porousmediumflow/2pnc/implicit/model.hh +++ b/dumux/porousmediumflow/2pnc/implicit/model.hh @@ -210,7 +210,7 @@ public: { auto& phasePresence = outputModule.createScalarField("phase presence", dofCodim); for (std::size_t i = 0; i < phasePresence.size(); ++i) - phasePresence[i] = priVarSwitch().phasePresence(i); + phasePresence[i] = this->curSol()[i].state(); } /*! @@ -272,9 +272,8 @@ public: void updateFailed() { ParentType::updateFailed(); - + // reset privar switch flag switchFlag_ = false; - priVarSwitch_().resetPhasePresence(); } /*! @@ -287,9 +286,7 @@ public: void advanceTimeLevel() { ParentType::advanceTimeLevel(); - - // update the phase state - priVarSwitch_().updateOldPhasePresence(); + // reset privar switch flag switchFlag_ = false; } @@ -317,7 +314,7 @@ public: if (!outStream.good()) DUNE_THROW(Dune::IOError, "Could not serialize entity " << dofIdxGlobal); - outStream << priVarSwitch().phasePresence(dofIdxGlobal) << " "; + outStream << this->curSol()[dofIdxGlobal].state() << " "; } /*! @@ -341,8 +338,8 @@ public: int phasePresence; inStream >> phasePresence; - priVarSwitch_().setPhasePresence(dofIdxGlobal, phasePresence); - priVarSwitch_().setOldPhasePresence(dofIdxGlobal, phasePresence); + this->curSol()[dofIdxGlobal].setState(phasePresence); + this->prevSol()[dofIdxGlobal].setState(phasePresence); } const TwoPNCPrimaryVariableSwitch<TypeTag>& priVarSwitch() const diff --git a/dumux/porousmediumflow/2pnc/implicit/primaryvariableswitch.hh b/dumux/porousmediumflow/2pnc/implicit/primaryvariableswitch.hh index e0356298bc7031cc4d0597a7de33270ecb04d55b..ea00b94729859bbbbd1d0afbe20417010b1587dc 100644 --- a/dumux/porousmediumflow/2pnc/implicit/primaryvariableswitch.hh +++ b/dumux/porousmediumflow/2pnc/implicit/primaryvariableswitch.hh @@ -82,7 +82,7 @@ protected: { // evaluate primary variable switch bool wouldSwitch = false; - int phasePresence = this->phasePresence_[dofIdxGlobal]; + int phasePresence = priVars.state(); int newPhasePresence = phasePresence; //check if a primary variable switch is necessary @@ -187,7 +187,7 @@ protected: } - this->phasePresence_[dofIdxGlobal] = newPhasePresence; + priVars.setState(newPhasePresence); this->wasSwitched_[dofIdxGlobal] = wouldSwitch; return phasePresence != newPhasePresence; } diff --git a/dumux/porousmediumflow/2pnc/implicit/propertydefaults.hh b/dumux/porousmediumflow/2pnc/implicit/propertydefaults.hh index 2a4529a1f77030ad9bbe63291812dc8b7452cc3e..7c5d3d40e42ff09904824eef911eea13a4009c55 100644 --- a/dumux/porousmediumflow/2pnc/implicit/propertydefaults.hh +++ b/dumux/porousmediumflow/2pnc/implicit/propertydefaults.hh @@ -36,6 +36,7 @@ #include "primaryvariableswitch.hh" #include <dumux/porousmediumflow/compositional/localresidual.hh> +#include <dumux/porousmediumflow/compositional/switchableprimaryvariables.hh> #include <dumux/porousmediumflow/nonisothermal/implicit/propertydefaults.hh> #include <dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh> #include <dumux/porousmediumflow/implicit/darcyfluxvariables.hh> @@ -166,6 +167,9 @@ SET_TYPE_PROP(TwoPNC, Model, TwoPNCModel<TypeTag>); //! The primary variable switch for the 2pnc model SET_TYPE_PROP(TwoPNC, PrimaryVariableSwitch, TwoPNCPrimaryVariableSwitch<TypeTag>); +//! The primary variables vector for the 2pnc model +SET_TYPE_PROP(TwoPNC, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); + //! the VolumeVariables property SET_TYPE_PROP(TwoPNC, VolumeVariables, TwoPNCVolumeVariables<TypeTag>); diff --git a/dumux/porousmediumflow/2pnc/implicit/volumevariables.hh b/dumux/porousmediumflow/2pnc/implicit/volumevariables.hh index 84ff5891ccd752ccea4134169e16ecd1f4ed1b1c..48675bd47035a413bbd1f837172948dda555143a 100644 --- a/dumux/porousmediumflow/2pnc/implicit/volumevariables.hh +++ b/dumux/porousmediumflow/2pnc/implicit/volumevariables.hh @@ -177,8 +177,8 @@ public: Scalar t = ParentType::temperature(elemSol, problem, element, scv); fluidState.setTemperature(t); - auto phasePresence = problem.model().priVarSwitch().phasePresence(scv.dofIndex()); auto&& priVars = ParentType::extractDofPriVars(elemSol, scv); + const auto phasePresence = priVars.state(); ///////////// // set the saturations diff --git a/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh b/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh index 1bf5cf015e20a73eb3b2ed1131253315d21fb447..cc4fad9e8ba2ea43f67f59ba89e0193c71d0c7fc 100644 --- a/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh +++ b/test/porousmediumflow/2pnc/implicit/fuelcellproblem.hh @@ -85,6 +85,7 @@ class FuelCellProblem : public ImplicitPorousMediaProblem<TypeTag> using TimeManager = typename GET_PROP_TYPE(TypeTag, TimeManager); using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); + using Sources = typename GET_PROP_TYPE(TypeTag, NumEqVector); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume); @@ -178,12 +179,12 @@ public: { return temperature_; } //! \copydoc Dumux::ImplicitProblem::source() - PrimaryVariables source(const Element &element, - const FVElementGeometry& fvGeometry, - const ElementVolumeVariables& elemVolVars, - const SubControlVolume &scv) const + Sources source(const Element &element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const SubControlVolume &scv) const { - PrimaryVariables values(0.0); + Sources values(0.0); const auto& globalPos = scv.dofPosition(); //reaction sources from electro chemistry @@ -255,14 +256,6 @@ public: { return initial_(globalPos); } - /*! - * \brief Evaluate the initial phase state at a given position - * - * \param globalPos The global position - */ - int initialPhasePresenceAtPos(const GlobalPosition &globalPos) - { return Indices::bothPhases; } - /*! * \brief Adds additional VTK output data to the VTKWriter. Function is called by the output module on every write. */ @@ -315,6 +308,7 @@ private: PrimaryVariables initial_(const GlobalPosition &globalPos) const { PrimaryVariables priVars(0.0); + priVars.setState(Indices::bothPhases); Scalar pg = 1.0e5; priVars[pressureIdx] = pg;