diff --git a/dumux/nonlinear/privarswitchnewtonsolver.hh b/dumux/nonlinear/privarswitchnewtonsolver.hh index 55905ea4848f6776323c3034869ceb28e496abf7..39359fdc1ec8fd18a40e5ff8340fe9d4fbac7b25 100644 --- a/dumux/nonlinear/privarswitchnewtonsolver.hh +++ b/dumux/nonlinear/privarswitchnewtonsolver.hh @@ -28,7 +28,6 @@ #include <memory> -#include <dumux/common/properties.hh> #include <dumux/common/parameters.hh> #include <dumux/discretization/methods.hh> #include <dumux/discretization/elementsolution.hh> @@ -42,13 +41,12 @@ namespace Dumux { * \todo make this independent of TypeTag by making PrimaryVariableSwitch a template argument * and extracting everything model specific from there */ -template <class TypeTag, class Assembler, class LinearSolver> +template <class Assembler, class LinearSolver, class PrimaryVariableSwitch> class PriVarSwitchNewtonSolver : public NewtonSolver<Assembler, LinearSolver> { using Scalar = typename Assembler::Scalar; using ParentType = NewtonSolver<Assembler, LinearSolver>; using SolutionVector = typename Assembler::ResidualType; - using PrimaryVariableSwitch = typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch); static constexpr auto discMethod = Assembler::FVGridGeometry::discMethod; static constexpr bool isBox = discMethod == DiscretizationMethod::box; @@ -104,17 +102,19 @@ public: switchedInLastIteration_ = priVarSwitch_->update(uCurrentIter, gridVariables, problem, fvGridGeometry); + constexpr bool volVarCachingEnabled = std::decay_t<decltype(gridVariables.curGridVolVars())>::cachingEnabled; + constexpr bool fluxVarCachingEnabled = std::decay_t<decltype(gridVariables.gridFluxVarsCache())>::cachingEnabled; if(switchedInLastIteration_) { for (const auto& element : elements(fvGridGeometry.gridView())) { // if the volume variables are cached globally, we need to update those where the primary variables have been switched - updateSwitchedVolVars_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableGridVolumeVariablesCache)>(), + updateSwitchedVolVars_(std::integral_constant<bool, volVarCachingEnabled>(), element, assembler, uCurrentIter, uLastIter); // if the flux variables are cached globally, we need to update those where the primary variables have been switched // (not needed for box discretization) - updateSwitchedFluxVarsCache_(std::integral_constant<bool, (GET_PROP_VALUE(TypeTag, EnableGridFluxVariablesCache) && !isBox)>(), + updateSwitchedFluxVarsCache_(std::integral_constant<bool, (fluxVarCachingEnabled && !isBox)>(), element, assembler, uCurrentIter, uLastIter); } } diff --git a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc index efac6ec2c78eb6e0fcbd2a5e7eda5fae2950e080..c7fc2a9a98d281fe268b3a2de6e079494535c446 100644 --- a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc +++ b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc @@ -130,8 +130,9 @@ int main(int argc, char** argv) try auto linearSolver = std::make_shared<LinearSolver>(leafGridView, fvGridGeometry->dofMapper()); // the non-linear solver - using NewtonMethod = Dumux::PriVarSwitchNewtonSolver<TypeTag, Assembler, LinearSolver>; - NewtonMethod nonLinearSolver(assembler, linearSolver); + using NewtonSolver = PriVarSwitchNewtonSolver<Assembler, LinearSolver, + typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch)>; + NewtonSolver nonLinearSolver(assembler, linearSolver); // time loop timeLoop->start(); do