diff --git a/dumux/porousmediumflow/2pncmin/implicit/model.hh b/dumux/porousmediumflow/2pncmin/implicit/model.hh index 140e8ebcc3ff3d6d04f88adf6b9217076588f2e7..b418c7e07e82c62150c79d4f533b1d3a4b353128 100644 --- a/dumux/porousmediumflow/2pncmin/implicit/model.hh +++ b/dumux/porousmediumflow/2pncmin/implicit/model.hh @@ -201,7 +201,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(); } /*! @@ -281,9 +281,8 @@ public: void updateFailed() { ParentType::updateFailed(); - + // reset privar switch flag switchFlag_ = false; - priVarSwitch_().resetPhasePresence(); } /*! @@ -296,9 +295,7 @@ public: void advanceTimeLevel() { ParentType::advanceTimeLevel(); - - // update the phase state - priVarSwitch_().updateOldPhasePresence(); + // reset privar switch flag switchFlag_ = false; } @@ -328,7 +325,7 @@ public: if (!outStream.good()) DUNE_THROW(Dune::IOError, "Could not serialize entity " << dofIdxGlobal); - outStream << priVarSwitch().phasePresence(dofIdxGlobal) << " "; + outStream << this->curSol()[dofIdxGlobal].state() << " "; } /*! @@ -352,8 +349,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 Dumux::TwoPNCMinPrimaryVariableSwitch<TypeTag>& priVarSwitch() const diff --git a/dumux/porousmediumflow/2pncmin/implicit/primaryvariableswitch.hh b/dumux/porousmediumflow/2pncmin/implicit/primaryvariableswitch.hh index b8dbc2071dca57c67a7b9c33a4118f6b3dd7955f..6d20ae0309bd08ad11695ae2560db63042ae9027 100644 --- a/dumux/porousmediumflow/2pncmin/implicit/primaryvariableswitch.hh +++ b/dumux/porousmediumflow/2pncmin/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 @@ -179,7 +179,7 @@ protected: } } - this->phasePresence_[dofIdxGlobal] = newPhasePresence; + priVars.setState(newPhasePresence); this->wasSwitched_[dofIdxGlobal] = wouldSwitch; return phasePresence != newPhasePresence; } diff --git a/dumux/porousmediumflow/2pncmin/implicit/propertydefaults.hh b/dumux/porousmediumflow/2pncmin/implicit/propertydefaults.hh index 6f9ef2fab548587006fdac99158f3c53c0d09250..22f4c295d35085e4957e716951cd54a2d550dbdd 100644 --- a/dumux/porousmediumflow/2pncmin/implicit/propertydefaults.hh +++ b/dumux/porousmediumflow/2pncmin/implicit/propertydefaults.hh @@ -35,6 +35,7 @@ #include "properties.hh" #include "primaryvariableswitch.hh" +#include <dumux/porousmediumflow/compositional/switchableprimaryvariables.hh> #include <dumux/porousmediumflow/2pnc/implicit/newtoncontroller.hh> #include <dumux/porousmediumflow/implicit/darcyfluxvariables.hh> #include <dumux/material/spatialparams/implicit.hh> @@ -122,6 +123,9 @@ SET_TYPE_PROP(TwoPNCMin, VolumeVariables, TwoPNCMinVolumeVariables<TypeTag>); //! the primary variable switch SET_TYPE_PROP(TwoPNCMin, PrimaryVariableSwitch, TwoPNCMinPrimaryVariableSwitch<TypeTag>); +//! The primary variables vector for the 2pncmin model +SET_TYPE_PROP(TwoPNCMin, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); + //! The indices required by the isothermal 2pNcMin model SET_TYPE_PROP(TwoPNCMin, Indices, TwoPNCMinIndices <TypeTag, /*PVOffset=*/0>); diff --git a/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh b/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh index 5d4253b14f04db600e4fe0eebfd568fbb91febf0..f7c915715f4335f98d9506ddf3e344a0926a294d 100644 --- a/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh +++ b/dumux/porousmediumflow/2pncmin/implicit/volumevariables.hh @@ -172,8 +172,8 @@ public: Scalar t = BaseType::temperature(elemSol, problem, element, scv); fluidState.setTemperature(t); - auto phasePresence = problem.model().priVarSwitch().phasePresence(scv.dofIndex()); - auto&& priVars = isBox ? elemSol[scv.indexInElement()] : elemSol[0]; + const auto& priVars = ParentType::extractDofPriVars(elemSol, scv); + const auto phasePresence = priVars.state(); ///////////// // set the saturations diff --git a/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh b/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh index dcedc51a19588181bee6388ad9104981bd97518b..a28f5ee1f5c4adf86f5c8c95c3ca8cc534899d14 100644 --- a/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh +++ b/test/porousmediumflow/2pncmin/implicit/dissolutionproblem.hh @@ -130,6 +130,7 @@ class DissolutionProblem : public ImplicitPorousMediaProblem<TypeTag> using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); + using Sources = typename GET_PROP_TYPE(TypeTag, NumEqVector); using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); using TimeManager = typename GET_PROP_TYPE(TypeTag, TimeManager); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); @@ -249,6 +250,7 @@ public: PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const { PrimaryVariables priVars(0.0); + priVars.setState(bothPhases); const Scalar rmax = this->bBoxMax()[0]; const Scalar rmin = this->bBoxMin()[0]; @@ -273,19 +275,6 @@ public: return priVars; } - /*! - * \brief Evaluate the boundary conditions for a neumann - * boundary segment. - * - * For this method, the \a priVars parameter stores the mass flux - * in normal direction of each component. Negative values mean - * influx. - */ - PrimaryVariables neumannAtPos(const GlobalPosition& globalPos) const - { - return PrimaryVariables(0.0); - } - /*! * \brief Evaluate the initial value for a control volume. * @@ -297,11 +286,12 @@ public: * For this method, the \a values parameter stores primary * variables. */ - PrimaryVariables initial(const SubControlVolume &scv) const + PrimaryVariables initial(const Element &element) const { PrimaryVariables priVars(0.0); + priVars.setState(bothPhases); - const auto& globalPos = scv.dofPosition(); + const auto& globalPos = element.geometry().center(); priVars[pressureIdx] = reservoirPressure_; priVars[switchIdx] = initLiqSaturation_; // Sl primary variable @@ -339,12 +329,12 @@ public: * that the conserved quantity is created, negative ones mean that it vanishes. * E.g. for the mass balance that would be a mass rate in \f$ [ kg / (m^3 \cdot s)] \f$. */ - 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 source(0.0); + Sources source(0.0); const auto& volVars = elemVolVars[scv]; @@ -380,16 +370,6 @@ public: return source; } - /*! - * \brief Return the initial phase state inside a control volume. - * - * \param scv The sub control volume - */ - int initialPhasePresence(const SubControlVolume& scv) const - { - return bothPhases; - } - private: /*!