From 8c083b6212655e04e136abc0847c0ab6808b8b9f Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Wed, 28 Feb 2018 20:02:56 +0100 Subject: [PATCH] [compositional] Free switchable privars from typetag --- dumux/porousmediumflow/2p1c/model.hh | 11 ++++++++++- dumux/porousmediumflow/2p2c/model.hh | 17 ++++++++++++----- dumux/porousmediumflow/2pnc/model.hh | 13 ++++++++++++- dumux/porousmediumflow/3p3c/model.hh | 11 ++++++++++- dumux/porousmediumflow/3pwateroil/model.hh | 12 ++++++++++-- .../compositional/switchableprimaryvariables.hh | 11 +++-------- dumux/porousmediumflow/richards/model.hh | 13 +++++++++++-- 7 files changed, 68 insertions(+), 20 deletions(-) diff --git a/dumux/porousmediumflow/2p1c/model.hh b/dumux/porousmediumflow/2p1c/model.hh index 90aa3d692c..84a2864261 100644 --- a/dumux/porousmediumflow/2p1c/model.hh +++ b/dumux/porousmediumflow/2p1c/model.hh @@ -57,6 +57,8 @@ #ifndef DUMUX_2P1C_MODEL_HH #define DUMUX_2P1C_MODEL_HH +#include <dune/common/fvector.hh> + #include <dumux/common/properties.hh> #include <dumux/material/fluidmatrixinteractions/2p/thermalconductivitysomerton.hh> @@ -158,7 +160,14 @@ SET_TYPE_PROP(TwoPOneCNI, VolumeVariables, TwoPOneCVolumeVariables<TypeTag>); SET_TYPE_PROP(TwoPOneCNI, PrimaryVariableSwitch, TwoPOneCPrimaryVariableSwitch<TypeTag>); //! The primary variables vector for the 2p1cni model. -SET_TYPE_PROP(TwoPOneCNI, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); +SET_PROP(TwoPOneCNI, PrimaryVariables) +{ +private: + using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), + GET_PROP_VALUE(TypeTag, NumEq)>; +public: + using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; +}; //! Somerton is used as default model to compute the effective thermal heat conductivity. SET_PROP(TwoPOneCNI, ThermalConductivityModel) diff --git a/dumux/porousmediumflow/2p2c/model.hh b/dumux/porousmediumflow/2p2c/model.hh index d97f2bcc03..88de9c13f9 100644 --- a/dumux/porousmediumflow/2p2c/model.hh +++ b/dumux/porousmediumflow/2p2c/model.hh @@ -77,6 +77,8 @@ #ifndef DUMUX_2P2C_MODEL_HH #define DUMUX_2P2C_MODEL_HH +#include <dune/common/fvector.hh> + // property forward declarations #include <dumux/common/properties.hh> #include <dumux/porousmediumflow/properties.hh> @@ -94,11 +96,9 @@ #include "primaryvariableswitch.hh" #include "vtkoutputfields.hh" -namespace Dumux -{ +namespace Dumux { +namespace Properties { -namespace Properties -{ ////////////////////////////////////////////////////////////////// // Type tags ////////////////////////////////////////////////////////////////// @@ -178,7 +178,14 @@ SET_BOOL_PROP(TwoPTwoC, EnableEnergyBalance, false); SET_TYPE_PROP(TwoPTwoC, PrimaryVariableSwitch, TwoPTwoCPrimaryVariableSwitch<TypeTag>); //! The primary variables vector for the 2p2c model -SET_TYPE_PROP(TwoPTwoC, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); +SET_PROP(TwoPTwoC, PrimaryVariables) +{ +private: + using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), + GET_PROP_VALUE(TypeTag, NumEq)>; +public: + using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; +}; //! Use the 2p2c VolumeVariables SET_TYPE_PROP(TwoPTwoC, VolumeVariables, TwoPTwoCVolumeVariables<TypeTag>); diff --git a/dumux/porousmediumflow/2pnc/model.hh b/dumux/porousmediumflow/2pnc/model.hh index 5f08da5aa6..c6c0efe7cf 100644 --- a/dumux/porousmediumflow/2pnc/model.hh +++ b/dumux/porousmediumflow/2pnc/model.hh @@ -85,6 +85,8 @@ #ifndef DUMUX_2PNC_MODEL_HH #define DUMUX_2PNC_MODEL_HH +#include <dune/common/fvector.hh> + #include <dumux/common/properties.hh> #include <dumux/material/spatialparams/fv.hh> @@ -115,7 +117,16 @@ NEW_TYPE_TAG(TwoPNCNI, INHERITS_FROM(TwoPNC, NonIsothermal)); ////////////////////////////////////////////////////////////////// // Properties for the isothermal 2pnc model ////////////////////////////////////////////////////////////////// -SET_TYPE_PROP(TwoPNC, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); //!< The primary variables vector for the 2pnc model +//! The primary variables vector for the 2pnc model +SET_PROP(TwoPNC, PrimaryVariables) +{ +private: + using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), + GET_PROP_VALUE(TypeTag, NumEq)>; +public: + using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; +}; + SET_TYPE_PROP(TwoPNC, PrimaryVariableSwitch, TwoPNCPrimaryVariableSwitch<TypeTag>); //!< The primary variable switch for the 2pnc model SET_TYPE_PROP(TwoPNC, VolumeVariables, TwoPNCVolumeVariables<TypeTag>); //!< the VolumeVariables property SET_TYPE_PROP(TwoPNC, Indices, TwoPNCIndices <TypeTag, /*PVOffset=*/0>); //!< The indices required by the isothermal 2pnc model diff --git a/dumux/porousmediumflow/3p3c/model.hh b/dumux/porousmediumflow/3p3c/model.hh index 85e5c9f2f7..36d70f7963 100644 --- a/dumux/porousmediumflow/3p3c/model.hh +++ b/dumux/porousmediumflow/3p3c/model.hh @@ -78,6 +78,8 @@ #ifndef DUMUX_3P3C_MODEL_HH #define DUMUX_3P3C_MODEL_HH +#include <dune/common/fvector.hh> + #include <dumux/common/properties.hh> #include <dumux/porousmediumflow/properties.hh> #include <dumux/porousmediumflow/nonisothermal/model.hh> @@ -165,7 +167,14 @@ SET_BOOL_PROP(ThreePThreeC, EnableEnergyBalance, false); SET_TYPE_PROP(ThreePThreeC, PrimaryVariableSwitch, ThreePThreeCPrimaryVariableSwitch<TypeTag>); //! The primary variables vector for the 3p3c model -SET_TYPE_PROP(ThreePThreeC, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); +SET_PROP(ThreePThreeC, PrimaryVariables) +{ +private: + using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), + GET_PROP_VALUE(TypeTag, NumEq)>; +public: + using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; +}; //! the VolumeVariables property SET_TYPE_PROP(ThreePThreeC, VolumeVariables, ThreePThreeCVolumeVariables<TypeTag>); diff --git a/dumux/porousmediumflow/3pwateroil/model.hh b/dumux/porousmediumflow/3pwateroil/model.hh index 89d56e6d4f..a985d08037 100644 --- a/dumux/porousmediumflow/3pwateroil/model.hh +++ b/dumux/porousmediumflow/3pwateroil/model.hh @@ -71,8 +71,9 @@ #ifndef DUMUX_3P2CNI_MODEL_HH #define DUMUX_3P2CNI_MODEL_HH -#include <dumux/common/properties.hh> +#include <dune/common/fvector.hh> +#include <dumux/common/properties.hh> #include <dumux/material/spatialparams/fv.hh> #include <dumux/material/fluidmatrixinteractions/3p/thermalconductivitysomerton3p.hh> #include <dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh> @@ -171,7 +172,14 @@ SET_BOOL_PROP(ThreePWaterOilNI, EnableEnergyBalance, true); SET_TYPE_PROP(ThreePWaterOilNI, PrimaryVariableSwitch, ThreePWaterOilPrimaryVariableSwitch<TypeTag>); //! The primary variables vector for the 3p3c model -SET_TYPE_PROP(ThreePWaterOilNI, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); +SET_PROP(ThreePWaterOilNI, PrimaryVariables) +{ +private: + using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), + GET_PROP_VALUE(TypeTag, NumEq)>; +public: + using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; +}; //! Determines whether a constraint solver should be used explicitly SET_BOOL_PROP(ThreePWaterOilNI, OnlyGasPhaseCanDisappear, true); diff --git a/dumux/porousmediumflow/compositional/switchableprimaryvariables.hh b/dumux/porousmediumflow/compositional/switchableprimaryvariables.hh index a721f37e9e..407e1cd905 100644 --- a/dumux/porousmediumflow/compositional/switchableprimaryvariables.hh +++ b/dumux/porousmediumflow/compositional/switchableprimaryvariables.hh @@ -25,8 +25,6 @@ #define DUMUX_SWITCHABLE_PRIMARY_VARIABLES_HH #include <dune/common/exceptions.hh> -#include <dune/common/fvector.hh> -#include <dumux/common/properties.hh> namespace Dumux { @@ -34,12 +32,10 @@ namespace Dumux { * \ingroup PorousmediumCompositional * \brief A primary variable vector with a state to allow variable switches */ -template<class TypeTag, class StateType> -class SwitchablePrimaryVariables : public Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)> +template<class PrimaryVariables, class StateType> +class SwitchablePrimaryVariables : public PrimaryVariables { - using ParentType = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + using ParentType = PrimaryVariables; public: //! inherit the constructors using ParentType::ParentType; @@ -74,7 +70,6 @@ public: private: StateType state_; bool stateIsSet_{false}; - }; } // end namespace Dumux diff --git a/dumux/porousmediumflow/richards/model.hh b/dumux/porousmediumflow/richards/model.hh index 8a080f62d9..2c8e2c1490 100644 --- a/dumux/porousmediumflow/richards/model.hh +++ b/dumux/porousmediumflow/richards/model.hh @@ -91,6 +91,8 @@ #ifndef DUMUX_RICHARDS_MODEL_HH #define DUMUX_RICHARDS_MODEL_HH +#include <dune/common/fvector.hh> + #include <dumux/common/properties.hh> #include <dumux/porousmediumflow/immiscible/localresidual.hh> @@ -170,8 +172,15 @@ SET_BOOL_PROP(Richards, EnableEnergyBalance, false); //! The class with all index definitions for the model SET_TYPE_PROP(Richards, Indices, RichardsIndices); -//! The class with all index definitions for the model -SET_TYPE_PROP(Richards, PrimaryVariables, SwitchablePrimaryVariables<TypeTag, int>); +//! The primary variables vector for the richards model +SET_PROP(Richards, PrimaryVariables) +{ +private: + using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), + GET_PROP_VALUE(TypeTag, NumEq)>; +public: + using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; +}; //! The primary variable switch for the richards model SET_TYPE_PROP(Richards, PrimaryVariableSwitch, ExtendedRichardsPrimaryVariableSwitch<TypeTag>); -- GitLab