Skip to content
Snippets Groups Projects
Commit a4088dd5 authored by Timo Koch's avatar Timo Koch
Browse files

[pm] Free PrivarswitchNewtonSolver of TypeTag

parent cb716050
No related branches found
No related tags found
1 merge request!833Feature/less typetag dependencies
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <memory> #include <memory>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh> #include <dumux/common/parameters.hh>
#include <dumux/discretization/methods.hh> #include <dumux/discretization/methods.hh>
#include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/elementsolution.hh>
...@@ -42,13 +41,12 @@ namespace Dumux { ...@@ -42,13 +41,12 @@ namespace Dumux {
* \todo make this independent of TypeTag by making PrimaryVariableSwitch a template argument * \todo make this independent of TypeTag by making PrimaryVariableSwitch a template argument
* and extracting everything model specific from there * 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> class PriVarSwitchNewtonSolver : public NewtonSolver<Assembler, LinearSolver>
{ {
using Scalar = typename Assembler::Scalar; using Scalar = typename Assembler::Scalar;
using ParentType = NewtonSolver<Assembler, LinearSolver>; using ParentType = NewtonSolver<Assembler, LinearSolver>;
using SolutionVector = typename Assembler::ResidualType; using SolutionVector = typename Assembler::ResidualType;
using PrimaryVariableSwitch = typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch);
static constexpr auto discMethod = Assembler::FVGridGeometry::discMethod; static constexpr auto discMethod = Assembler::FVGridGeometry::discMethod;
static constexpr bool isBox = discMethod == DiscretizationMethod::box; static constexpr bool isBox = discMethod == DiscretizationMethod::box;
...@@ -104,17 +102,19 @@ public: ...@@ -104,17 +102,19 @@ public:
switchedInLastIteration_ = priVarSwitch_->update(uCurrentIter, gridVariables, switchedInLastIteration_ = priVarSwitch_->update(uCurrentIter, gridVariables,
problem, fvGridGeometry); problem, fvGridGeometry);
constexpr bool volVarCachingEnabled = std::decay_t<decltype(gridVariables.curGridVolVars())>::cachingEnabled;
constexpr bool fluxVarCachingEnabled = std::decay_t<decltype(gridVariables.gridFluxVarsCache())>::cachingEnabled;
if(switchedInLastIteration_) if(switchedInLastIteration_)
{ {
for (const auto& element : elements(fvGridGeometry.gridView())) 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 // 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); element, assembler, uCurrentIter, uLastIter);
// if the flux variables are cached globally, we need to update those where the primary variables have been switched // if the flux variables are cached globally, we need to update those where the primary variables have been switched
// (not needed for box discretization) // (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); element, assembler, uCurrentIter, uLastIter);
} }
} }
......
...@@ -130,8 +130,9 @@ int main(int argc, char** argv) try ...@@ -130,8 +130,9 @@ int main(int argc, char** argv) try
auto linearSolver = std::make_shared<LinearSolver>(leafGridView, fvGridGeometry->dofMapper()); auto linearSolver = std::make_shared<LinearSolver>(leafGridView, fvGridGeometry->dofMapper());
// the non-linear solver // the non-linear solver
using NewtonMethod = Dumux::PriVarSwitchNewtonSolver<TypeTag, Assembler, LinearSolver>; using NewtonSolver = PriVarSwitchNewtonSolver<Assembler, LinearSolver,
NewtonMethod nonLinearSolver(assembler, linearSolver); typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch)>;
NewtonSolver nonLinearSolver(assembler, linearSolver);
// time loop // time loop
timeLoop->start(); do timeLoop->start(); do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment