diff --git a/dumux/porousmediumflow/3p3c/implicit/model.hh b/dumux/porousmediumflow/3p3c/implicit/model.hh index 5d50e45d429fe4ce7c9ce5f6157e47516ac83227..15f401091437774ae3ff4b846e21b28d94773650 100644 --- a/dumux/porousmediumflow/3p3c/implicit/model.hh +++ b/dumux/porousmediumflow/3p3c/implicit/model.hh @@ -106,6 +106,7 @@ class ThreePThreeCModel: public GET_PROP_TYPE(TypeTag, BaseModel) using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); enum { @@ -198,27 +199,49 @@ public: // update the secondary variables if global caching is enabled // \note we only updated if phase presence changed as the volume variables // are already updated once by the switch - if (switchFlag_) + for (const auto& element : elements(this->problem_().gridView())) { - for (const auto& element : elements(this->problem_().gridView())) - { - // make sure FVElementGeometry & vol vars are bound to the element - auto fvGeometry = localView(this->globalFvGeometry()); - fvGeometry.bindElement(element); + // make sure FVElementGeometry & vol vars are bound to the element + auto fvGeometry = localView(this->globalFvGeometry()); + fvGeometry.bindElement(element); + if (switchFlag_) + { for (auto&& scv : scvs(fvGeometry)) { auto dofIdxGlobal = scv.dofIndex(); if (priVarSwitch_().wasSwitched(dofIdxGlobal)) { - - this->nonConstCurGlobalVolVars().volVars(scv).update(this->curSol()[dofIdxGlobal], - this->problem_(), - element, - scv); + const auto eIdx = this->problem_().elementMapper().index(element); + const auto elemSol = this->elementSolution(element, this->curSol()); + this->nonConstCurGlobalVolVars().volVars(eIdx, scv.indexInElement()).update(elemSol, + this->problem_(), + element, + scv); } } + } + // handle the boundary volume variables for cell-centered models + if(!isBox) + { + for (auto&& scvf : scvfs(fvGeometry)) + { + // if we are not on a boundary, skip the rest + if (!scvf.boundary()) + continue; + + // check if boundary is a pure dirichlet boundary + const auto bcTypes = this->problem_().boundaryTypes(element, scvf); + if (bcTypes.hasOnlyDirichlet()) + { + const auto insideScvIdx = scvf.insideScvIdx(); + const auto& insideScv = fvGeometry.scv(insideScvIdx); + const auto elemSol = ElementSolutionVector{this->problem_().dirichlet(element, scvf)}; + + this->nonConstCurGlobalVolVars().volVars(scvf.outsideScvIdx(), 0/*indexInElement*/).update(elemSol, this->problem_(), element, insideScv); + } + } } } }