Commit e9cde7e4 by Kilian Weishaupt Committed by Timo Koch

### [porousmediumflow] Use adapted NewtonSolver

```* export PrivarSwitch in VolVars
* do not set PriVarSwitch property in model.hh anymore```
parent 335433aa
 ... ... @@ -76,7 +76,6 @@ #include "localresidual.hh" #include "indices.hh" #include "volumevariables.hh" #include "primaryvariableswitch.hh" namespace Dumux { ... ... @@ -191,10 +190,6 @@ public: using type = TwoPOneCVolumeVariables; }; //! The primary variable switch for the 2p1cni model. template struct PrimaryVariableSwitch { using type = TwoPOneCPrimaryVariableSwitch; }; //! The primary variables vector for the 2p1cni model. template struct PrimaryVariables ... ...
 ... ... @@ -34,6 +34,8 @@ #include #include #include "primaryvariableswitch.hh" namespace Dumux { /*! ... ... @@ -91,6 +93,8 @@ public: using SolidState = typename Traits::SolidState; //! export type of solid system using SolidSystem = typename Traits::SolidSystem; //! export the primary variable switch using PrimaryVariableSwitch = TwoPOneCPrimaryVariableSwitch; //! return the two-phase formulation used here static constexpr TwoPFormulation priVarFormulation() { return formulation; } ... ...
 ... ... @@ -34,6 +34,7 @@ #include #include #include #include namespace Dumux { ... ... @@ -93,6 +94,8 @@ public: using SolidState = typename Traits::SolidState; //! export type of solid system using SolidSystem = typename Traits::SolidSystem; //! export the primary variable switch using PrimaryVariableSwitch = TwoPNCPrimaryVariableSwitch; //! return whether moles or masses are balanced static constexpr bool useMoles() { return ModelTraits::useMoles(); } ... ...
 ... ... @@ -102,7 +102,6 @@ #include #include "volumevariables.hh" #include "primaryvariableswitch.hh" #include "iofields.hh" #include "indices.hh" ... ... @@ -182,9 +181,6 @@ public: using type = SwitchablePrimaryVariables; }; template struct PrimaryVariableSwitch { using type = TwoPNCPrimaryVariableSwitch; }; //!< The primary variable switch for the 2pnc model //! Set the volume variables property template struct VolumeVariables ... ...
 ... ... @@ -35,11 +35,10 @@ namespace Dumux { * \ingroup TwoPNCModel * \brief The primary variable switch controlling the phase presence state variable */ template class TwoPNCPrimaryVariableSwitch : public PrimaryVariableSwitch> : public PrimaryVariableSwitch { using ParentType = PrimaryVariableSwitch>; using ParentType = PrimaryVariableSwitch; friend ParentType; public: using ParentType::ParentType; ... ...
 ... ... @@ -41,6 +41,8 @@ #include #include "primaryvariableswitch.hh" namespace Dumux { /*! ... ... @@ -98,6 +100,8 @@ public: using SolidState = typename Traits::SolidState; //! export type of solid system using SolidSystem = typename Traits::SolidSystem; //! export the primary variable switch using PrimaryVariableSwitch = TwoPNCPrimaryVariableSwitch; //! return whether moles or masses are balanced static constexpr bool useMoles() { return Traits::ModelTraits::useMoles(); } ... ...
 ... ... @@ -96,7 +96,6 @@ #include "indices.hh" #include "volumevariables.hh" #include "iofields.hh" #include "primaryvariableswitch.hh" #include "localresidual.hh" namespace Dumux { ... ... @@ -198,10 +197,6 @@ struct FluidState{ template struct LocalResidual { using type = ThreePThreeCLocalResidual; }; //! The primary variable switch for the 3p3c model template struct PrimaryVariableSwitch { using type = ThreePThreeCPrimaryVariableSwitch; }; //! The primary variables vector for the 3p3c model template struct PrimaryVariables ... ...
 ... ... @@ -33,6 +33,8 @@ #include #include #include "primaryvariableswitch.hh" namespace Dumux { /*! ... ... @@ -93,6 +95,8 @@ public: using SolidState = typename Traits::SolidState; //! export type of solid system using SolidSystem = typename Traits::SolidSystem; //! export the primary variable switch using PrimaryVariableSwitch = ThreePThreeCPrimaryVariableSwitch; /*! * \brief Update all quantities for a given control volume ... ...
 ... ... @@ -88,7 +88,6 @@ #include "model.hh" #include "volumevariables.hh" #include "localresidual.hh" #include "primaryvariableswitch.hh" #include "iofields.hh" namespace Dumux { ... ... @@ -181,10 +180,6 @@ struct LocalResidual { using type = ThreePWater template struct ReplaceCompEqIdx { static constexpr int value = GetPropType::numComponents(); }; //! The primary variable switch for the 3p3c model template struct PrimaryVariableSwitch { using type = ThreePWaterOilPrimaryVariableSwitch; }; //! The primary variables vector for the 3p3c model template struct PrimaryVariables ... ...
This diff is collapsed.
 ... ... @@ -39,6 +39,8 @@ #include #include #include "primaryvariableswitch.hh" namespace Dumux { /*! ... ... @@ -55,7 +57,6 @@ class ThreePWaterOilVolumeVariables using EnergyVolVars = EnergyVolumeVariables >; using Scalar = typename Traits::PrimaryVariables::value_type; using ModelTraits = typename Traits::ModelTraits; using Indices = typename ModelTraits::Indices; using FS = typename Traits::FluidSystem; static constexpr int numFluidComps = ParentType::numComponents(); ... ... @@ -69,19 +70,19 @@ class ThreePWaterOilVolumeVariables gPhaseIdx = FS::gPhaseIdx, nPhaseIdx = FS::nPhaseIdx, switch1Idx = Indices::switch1Idx, switch2Idx = Indices::switch2Idx, pressureIdx = Indices::pressureIdx switch1Idx = ModelTraits::Indices::switch1Idx, switch2Idx = ModelTraits::Indices::switch2Idx, pressureIdx = ModelTraits::Indices::pressureIdx }; // present phases enum { threePhases = Indices::threePhases, wPhaseOnly = Indices::wPhaseOnly, gnPhaseOnly = Indices::gnPhaseOnly, wnPhaseOnly = Indices::wnPhaseOnly, gPhaseOnly = Indices::gPhaseOnly, wgPhaseOnly = Indices::wgPhaseOnly threePhases = ModelTraits::Indices::threePhases, wPhaseOnly = ModelTraits::Indices::wPhaseOnly, gnPhaseOnly = ModelTraits::Indices::gnPhaseOnly, wnPhaseOnly = ModelTraits::Indices::wnPhaseOnly, gPhaseOnly = ModelTraits::Indices::gPhaseOnly, wgPhaseOnly = ModelTraits::Indices::wgPhaseOnly }; public: ... ... @@ -89,10 +90,17 @@ public: using FluidState = typename Traits::FluidState; //! The type of the fluid system using FluidSystem = typename Traits::FluidSystem; //! export the indices using Indices = typename ModelTraits::Indices; //! export type of solid state using SolidState = typename Traits::SolidState; //! export type of solid system using SolidSystem = typename Traits::SolidSystem; //! export the primary variable switch using PrimaryVariableSwitch = ThreePWaterOilPrimaryVariableSwitch; //! state if only the gas phase is allowed to disappear static constexpr bool onlyGasPhaseCanDisappear() { return Traits::ModelTraits::onlyGasPhaseCanDisappear(); } /*! * \copydoc ImplicitVolumeVariables::update ... ... @@ -107,13 +115,11 @@ public: const auto& priVars = elemSol[scv.localDofIndex()]; const auto phasePresence = priVars.state(); bool onlyGasPhaseCanDisappear = Traits::ModelTraits::onlyGasPhaseCanDisappear(); // capillary pressure parameters using MaterialLaw = typename Problem::SpatialParams::MaterialLaw; const auto& materialParams = problem.spatialParams().materialLawParams(element, scv, elemSol); if(!onlyGasPhaseCanDisappear) if(!onlyGasPhaseCanDisappear()) { /* first the saturations */ if (phasePresence == threePhases) ... ...
 ... ... @@ -26,7 +26,6 @@ #include #include #include "primaryvariableswitch.hh" #include "volumevariables.hh" /*! ... ... @@ -80,12 +79,6 @@ struct TwoPTwoCCO2 { using InheritsFrom = std::tuple; }; struct TwoPTwoCCO2NI { using InheritsFrom = std::tuple; }; } // end namespace TTag //! the CO2 privarswitch and VolumeVariables properties template struct PrimaryVariableSwitch { using type = TwoPTwoCCO2PrimaryVariableSwitch; }; template struct PrimaryVariableSwitch { using type = TwoPTwoCCO2PrimaryVariableSwitch; }; //! the co2 volume variables use the same traits as the 2p2c model template struct VolumeVariables ... ...
 ... ... @@ -34,6 +34,8 @@ #include #include #include "primaryvariableswitch.hh" namespace Dumux { /*! ... ... @@ -91,6 +93,8 @@ public: using SolidState = typename Traits::SolidState; //! export type of solid system using SolidSystem = typename Traits::SolidSystem; //! export the type of the primary variable switch using PrimaryVariableSwitch = TwoPTwoCCO2PrimaryVariableSwitch; //! return whether moles or masses are balanced ... ...
 ... ... @@ -43,12 +43,11 @@ public: template NoPrimaryVariableSwitch(Args&&...) {} template void init(Args&&...) {} template void reset(Args&&...) {} template bool wasSwitched(Args&&...) const { return false; } template bool update(Args&&...) { return false; } template void updateSwitchedVolVars(Args&&...) {} template void updateSwitchedFluxVarsCache(Args&&...) {} template bool update_(Args&&...) {return false; } }; /*! ... ... @@ -59,11 +58,9 @@ template class PrimaryVariableSwitch { public: PrimaryVariableSwitch(const std::size_t& numDofs, int verbosity = 1) PrimaryVariableSwitch(int verbosity = 1) : verbosity_(verbosity) { wasSwitched_.resize(numDofs, false); } {} //! If the primary variables were recently switched bool wasSwitched(std::size_t dofIdxGlobal) const ... ... @@ -71,6 +68,12 @@ public: return wasSwitched_[dofIdxGlobal]; } //! Reset all flags void reset(const std::size_t numDofs) { wasSwitched_.resize(numDofs, false); } /*! * \brief Update the variable switch / phase presence * ... ...
 ... ... @@ -5,6 +5,5 @@ localresidual.hh model.hh newtonsolver.hh primaryvariableswitch.hh privarswitchnewtonsolver.hh volumevariables.hh DESTINATION \${CMAKE_INSTALL_INCLUDEDIR}/dumux/porousmediumflow/richards)
 ... ... @@ -113,7 +113,6 @@ #include "volumevariables.hh" #include "iofields.hh" #include "localresidual.hh" #include "primaryvariableswitch.hh" namespace Dumux { ... ... @@ -239,10 +238,6 @@ public: using type = SwitchablePrimaryVariables; }; //! The primary variable switch for the richards model template struct PrimaryVariableSwitch { using type = ExtendedRichardsPrimaryVariableSwitch; }; /*! *\brief The fluid system used by the model. * ... ...
 ... ... @@ -25,7 +25,7 @@ #define DUMUX_RICHARDS_NEWTON_SOLVER_HH #include #include #include #include namespace Dumux { ... ... @@ -39,15 +39,15 @@ namespace Dumux { * \todo make this typetag independent by extracting anything model specific from assembler * or from possible ModelTraits. */ template class RichardsNewtonSolver : public RichardsPrivarSwitchNewtonSolver template class RichardsNewtonSolver : public NewtonSolver { using Scalar = typename Assembler::Scalar; using ParentType = RichardsPrivarSwitchNewtonSolver; using ParentType = NewtonSolver; using SolutionVector = typename Assembler::ResidualType; using MaterialLaw = typename Assembler::Problem::SpatialParams::MaterialLaw; using Indices = typename GetPropType::Indices; using Indices = typename Assembler::GridVariables::VolumeVariables::Indices; enum { pressureIdx = Indices::pressureIdx }; public: ... ...
 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=4 sw=4 sts=4: /***************************************************************************** * See the file COPYING for full copying permissions. * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * *****************************************************************************/ /*! * \file * \ingroup RichardsModel * \brief A Richards model newton solver. */ #ifndef DUMUX_RICHARDS_PRIVAR_SWITCH_NEWTON_SOLVER_HH #define DUMUX_RICHARDS_PRIVAR_SWITCH_NEWTON_SOLVER_HH #include #include #include #include namespace Dumux { template class RichardsPrivarSwitchNewtonSolverImplementation; /*! * \ingroup RichardsModel * \brief A base for the richards newton solver which derives from the right base newton solver. */ template using RichardsPrivarSwitchNewtonSolver = RichardsPrivarSwitchNewtonSolverImplementation ()>; /*! * \ingroup RichardsModel * \brief the case without a primary variables switch */ template class RichardsPrivarSwitchNewtonSolverImplementation : public NewtonSolver { using ParentType = NewtonSolver; public: using ParentType::ParentType; }; /*! * \ingroup RichardsModel * \brief the case with switchable primary variables */ template class RichardsPrivarSwitchNewtonSolverImplementation : public PriVarSwitchNewtonSolver> { using PrimaryVariableSwitch = GetPropType; using ParentType = PriVarSwitchNewtonSolver; public: using ParentType::ParentType; }; } // end namespace Dumux #endif
 ... ... @@ -34,8 +34,21 @@ #include #include #include "primaryvariableswitch.hh" namespace Dumux { namespace Detail { //! helper structs to conditionally use a primary variable switch or not struct VolVarsWithPVSwitch { using PrimaryVariableSwitch = ExtendedRichardsPrimaryVariableSwitch; }; struct VolVarsWithOutPVSwitch {}; } /*! * \ingroup RichardsModel * \brief Volume averaged quantities required by the Richards model. ... ... @@ -47,6 +60,8 @@ template class RichardsVolumeVariables : public PorousMediumFlowVolumeVariables , public EnergyVolumeVariables > , public std::conditional_t { using ParentType = PorousMediumFlowVolumeVariables; using EnergyVolVars = EnergyVolumeVariables >; ... ...
 ... ... @@ -42,7 +42,7 @@ #include #include #include #include #include ... ... @@ -128,8 +128,7 @@ int main(int argc, char** argv) try auto linearSolver = std::make_shared(); // the non-linear solver using PrimaryVariableSwitch = GetPropType; using NewtonSolver = Dumux::PriVarSwitchNewtonSolver; using NewtonSolver = NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); // time loop ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment