diff --git a/dumux/assembly/boxlocalassembler.hh b/dumux/assembly/boxlocalassembler.hh index 124a0fda9557b3cd14bec6f78675dd4e881b0480..fd8c7a13d45444caac7767dbdada4a52d790896e 100644 --- a/dumux/assembly/boxlocalassembler.hh +++ b/dumux/assembly/boxlocalassembler.hh @@ -58,7 +58,7 @@ class BoxLocalAssemblerBase : public FVLocalAssemblerBase<TypeTag, Assembler, Im using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; + enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() }; public: @@ -223,7 +223,7 @@ class BoxLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/tr using LocalResidual = typename GET_PROP_TYPE(TypeTag, LocalResidual); using ElementResidualVector = typename LocalResidual::ElementResidualVector; - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; + enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() }; enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension }; static constexpr bool enableGridFluxVarsCache = GET_PROP_VALUE(TypeTag, EnableGridFluxVariablesCache); @@ -342,7 +342,7 @@ class BoxLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/fa using LocalResidual = typename GET_PROP_TYPE(TypeTag, LocalResidual); using ElementResidualVector = typename LocalResidual::ElementResidualVector; - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; + enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() }; enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension }; public: diff --git a/dumux/assembly/cclocalassembler.hh b/dumux/assembly/cclocalassembler.hh index adf1520237d5b5ef54021bd3cde5570c0e2054d2..314b5702c7363983074f241108193907dd79f1b8 100644 --- a/dumux/assembly/cclocalassembler.hh +++ b/dumux/assembly/cclocalassembler.hh @@ -140,7 +140,7 @@ class CCLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/tru using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix); - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; + enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() }; enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension }; using FluxStencil = Dumux::FluxStencil<FVElementGeometry>; @@ -316,7 +316,7 @@ class CCLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/fal using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix); - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; + enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() }; public: using ParentType::ParentType; diff --git a/dumux/assembly/staggeredlocalassembler.hh b/dumux/assembly/staggeredlocalassembler.hh index 026b9ab892a82a2ffcd7aea17de53b844cbea9d0..549ba7fff0c247fa8f2907cfa165401bfa5ddb8f 100644 --- a/dumux/assembly/staggeredlocalassembler.hh +++ b/dumux/assembly/staggeredlocalassembler.hh @@ -88,8 +88,6 @@ class StaggeredLocalAssembler<TypeTag, using FaceSolutionVector = typename GET_PROP_TYPE(TypeTag, FaceSolutionVector); using FaceSolution = typename GET_PROP_TYPE(TypeTag, StaggeredFaceSolution); - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; - using Indices = typename GET_PROP_TYPE(TypeTag, Indices); using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables); diff --git a/dumux/common/properties.hh b/dumux/common/properties.hh index 9dd1e9887e5145b5a6a450189c058cd138f714da..3f47a55f4808e1a51b46955fce1f1ca0fb02a3a2 100644 --- a/dumux/common/properties.hh +++ b/dumux/common/properties.hh @@ -42,11 +42,11 @@ NEW_PROP_TAG(ModelParameterGroup); //!< Property which defines the group that NEW_PROP_TAG(ModelDefaultParameters); //!< Property which defines the group that is queried for parameters by default NEW_PROP_TAG(GridCreator); //!< Property which provides a GridCreator (manages grids) NEW_PROP_TAG(Grid); //!< The DUNE grid type -NEW_PROP_TAG(NumEq); //!< The number of equations to solve (equal to number of primary variables) NEW_PROP_TAG(Indices); //!< Enumerations for the numeric model NEW_PROP_TAG(PrimaryVariables); //!< A vector of primary variables NEW_PROP_TAG(NumEqVector); //!< A vector of size number equations that can be used for Neumann fluxes, sources, residuals, ... NEW_PROP_TAG(GridView); //!< The type of the grid view according to the grid type +NEW_PROP_TAG(ModelTraits); //!< Traits class encapsulating model specifications NEW_PROP_TAG(Problem); //!< Property to specify the type of a problem which has to be solved NEW_PROP_TAG(PointSource); //!< Property defining the type of point source used NEW_PROP_TAG(PointSourceHelper); //!< Property defining the class that computes which sub control volume point sources belong to @@ -101,19 +101,14 @@ NEW_PROP_TAG(DualGridNodalIndexSet); //!< The type used for the no // Properties used by models involving flow in porous media: ///////////////////////////////////////////////////////////// NEW_PROP_TAG(EnergyLocalResidual); //!< The local residual of the energy equation -NEW_PROP_TAG(EnableAdvection); //!< specifies if advection is considered in the model NEW_PROP_TAG(AdvectionType); //!< The type for the calculation the advective fluxes NEW_PROP_TAG(SolutionDependentAdvection); //!< specifies if the parameters for the advective fluxes depend on the solution -NEW_PROP_TAG(EnableMolecularDiffusion); //!< specifies if molecular diffusive fluxes are considered in the model NEW_PROP_TAG(MolecularDiffusionType); //!< The type for the calculation of the molecular diffusion fluxes NEW_PROP_TAG(SolutionDependentMolecularDiffusion); //!< specifies if the parameters for the diffusive fluxes depend on the solution -NEW_PROP_TAG(EnableEnergyBalance); //!< Specifies if the model solves an energy equation NEW_PROP_TAG(HeatConductionType); //!< The type for the calculation of the heat conduction fluxes NEW_PROP_TAG(SolutionDependentHeatConduction); //!< specifies if the parameters for the heat conduction fluxes depend on the solution -NEW_PROP_TAG(NumPhases); //!< Number of fluid phases in the system NEW_PROP_TAG(PhaseIdx); //!< A phase index to allow using a two-phase fluidsystem for one-phase models -NEW_PROP_TAG(NumComponents); //!< Number of fluid phases in the system NEW_PROP_TAG(SpatialParams); //!< The type of the spatial parameters object NEW_PROP_TAG(FluidSystem); //!< The type of the fluid system to use NEW_PROP_TAG(FluidState); //!< The type of the fluid state to use @@ -131,7 +126,7 @@ NEW_PROP_TAG(UseKelvinEquation); //!< If we use Kelvin equatio //////////////////////////////////////////////////////////////////////////////// // Properties used by models involving mineralization: //////////////////////////////////////////////////////////////////////////////// -NEW_PROP_TAG(NumSPhases); +NEW_PROP_TAG(NonMineralizationModelTraits); NEW_PROP_TAG(NonMineralizationVtkOutputFields); NEW_PROP_TAG(NonMineralizationVolumeVariables); @@ -142,7 +137,7 @@ NEW_PROP_TAG(IsothermalVtkOutputFields); NEW_PROP_TAG(IsothermalVolumeVariables); NEW_PROP_TAG(IsothermalLocalResidual); NEW_PROP_TAG(IsothermalIndices); -NEW_PROP_TAG(IsothermalNumEq); +NEW_PROP_TAG(IsothermalModelTraits); // specify if we evaluate the permeability in the volume (for discontinuous fields) // or at the scvf center for analytical permeability fields (e.g. convergence studies) @@ -195,7 +190,7 @@ NEW_PROP_TAG(PressureFormulation); //! the formulation of the pressure e.g most ///////////////////////////////////////////////////////////// // Properties used by the nonequilibrium model ///////////////////////////////////////////////////////////// - +NEW_PROP_TAG(EquilibriumModelTraits); NEW_PROP_TAG(EquilibriumLocalResidual); NEW_PROP_TAG(EquilibriumIndices); NEW_PROP_TAG(EquilibriumVtkOutputFields); diff --git a/dumux/common/properties/model.hh b/dumux/common/properties/model.hh index 94ab4fb27764fcbbbf5214dcbbd244985d2e2799..c4d606afd74a8f62e8c16fdeed09152b2b4a0ad5 100644 --- a/dumux/common/properties/model.hh +++ b/dumux/common/properties/model.hh @@ -43,7 +43,7 @@ NEW_TYPE_TAG(ModelProperties); SET_TYPE_PROP(ModelProperties, Scalar, double); //! Set the default vector with size number of equations to a field vector -SET_TYPE_PROP(ModelProperties, NumEqVector, Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), GET_PROP_VALUE(TypeTag, NumEq)>); +SET_TYPE_PROP(ModelProperties, NumEqVector, Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>); //! Set the default primary variable vector to a vector of size of number of equations SET_TYPE_PROP(ModelProperties, PrimaryVariables, typename GET_PROP_TYPE(TypeTag, NumEqVector)); diff --git a/dumux/common/staggeredfvproblem.hh b/dumux/common/staggeredfvproblem.hh index a6a1aa32710f92f0e5121dd8e31a97cb856a5406..d422992f221d8c8c7de047abcd59e7ec8affc85b 100644 --- a/dumux/common/staggeredfvproblem.hh +++ b/dumux/common/staggeredfvproblem.hh @@ -184,7 +184,7 @@ protected: static auto priVarIndices_(typename GET_PROP(TypeTag, DofTypeIndices)::FaceIdx) { constexpr auto numEqCellCenter = GET_PROP_VALUE(TypeTag, NumEqCellCenter); - constexpr auto numEq = GET_PROP_VALUE(TypeTag, NumEq); + constexpr auto numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); #if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) return Dune::range(numEqCellCenter, numEq); #else diff --git a/dumux/discretization/box/fickslaw.hh b/dumux/discretization/box/fickslaw.hh index c798c3c7aa23dd14a8a133a6577d3a7d77ff3703..7796a61ea2e10064e3ba16d0b5867c4ce5826928 100644 --- a/dumux/discretization/box/fickslaw.hh +++ b/dumux/discretization/box/fickslaw.hh @@ -62,8 +62,8 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::box> enum { dimWorld = GridView::dimensionworld} ; enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag,NumComponents) + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; diff --git a/dumux/discretization/box/fourierslaw.hh b/dumux/discretization/box/fourierslaw.hh index 685126cbec66c618a6185cc7e6ae286535ffd103..a3a7ba332cf360c5ab2827640e8968fdc7d43f96 100644 --- a/dumux/discretization/box/fourierslaw.hh +++ b/dumux/discretization/box/fourierslaw.hh @@ -60,7 +60,7 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethod::box> enum { dim = GridView::dimension} ; enum { dimWorld = GridView::dimensionworld} ; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases)} ; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()} ; using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; diff --git a/dumux/discretization/box/fourierslawnonequilibrium.hh b/dumux/discretization/box/fourierslawnonequilibrium.hh index a36946b0fcd2eab61f4694de2d1a09a2600fdeef..6bfe232dececc68274b7fa6197eb50109afb47b9 100644 --- a/dumux/discretization/box/fourierslawnonequilibrium.hh +++ b/dumux/discretization/box/fourierslawnonequilibrium.hh @@ -63,7 +63,7 @@ class FouriersLawNonEquilibriumImplementation<TypeTag, DiscretizationMethod::box enum { dim = GridView::dimension} ; enum { dimWorld = GridView::dimensionworld} ; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases)} ; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()} ; enum { numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid) }; enum {sPhaseIdx = FluidSystem::sPhaseIdx}; diff --git a/dumux/discretization/box/maxwellstefanslaw.hh b/dumux/discretization/box/maxwellstefanslaw.hh index 629dd6959b9c06441bb75e617e01587937236c31..5a605868bc25bcdd3e0b268de4f77853929ff2fd 100644 --- a/dumux/discretization/box/maxwellstefanslaw.hh +++ b/dumux/discretization/box/maxwellstefanslaw.hh @@ -64,8 +64,8 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::box > enum { dimWorld = GridView::dimensionworld} ; enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag,NumComponents) + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; diff --git a/dumux/discretization/cellcentered/mpfa/darcyslaw.hh b/dumux/discretization/cellcentered/mpfa/darcyslaw.hh index cf8210842946b399a7691dbdd30d7a48e897dad4..c2c00e061f85f2b2637f3443d0cf7f1614f19588 100644 --- a/dumux/discretization/cellcentered/mpfa/darcyslaw.hh +++ b/dumux/discretization/cellcentered/mpfa/darcyslaw.hh @@ -91,7 +91,7 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethod::ccmpfa> { static constexpr int dim = GridView::dimension; static constexpr int dimWorld = GridView::dimensionworld; - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet); using Stencil = typename DualGridNodalIndexSet::NodalGridStencilType; diff --git a/dumux/discretization/cellcentered/mpfa/elementfluxvariablescache.hh b/dumux/discretization/cellcentered/mpfa/elementfluxvariablescache.hh index f1b766a4f995a507c42a19ebc27b1b7fdb5327e6..e78a5dadcf33825e4ce1274d4e0986c0a8d32f77 100644 --- a/dumux/discretization/cellcentered/mpfa/elementfluxvariablescache.hh +++ b/dumux/discretization/cellcentered/mpfa/elementfluxvariablescache.hh @@ -114,6 +114,7 @@ private: template<class TypeTag> class CCMpfaElementFluxVariablesCache<TypeTag, false> { + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using GridIndexType = typename GridView::IndexSet::IndexType; using Element = typename GridView::template Codim<0>::Entity; @@ -133,12 +134,12 @@ class CCMpfaElementFluxVariablesCache<TypeTag, false> //! physics traits class to define the data handles struct PhysicsTraits { - static constexpr bool enableAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection); - static constexpr bool enableMolecularDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion); - static constexpr bool enableHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance); + static constexpr bool enableAdvection = ModelTraits::enableAdvection(); + static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion(); + static constexpr bool enableHeatConduction = ModelTraits::enableEnergyBalance(); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = ModelTraits::numPhases(); + static constexpr int numComponents = ModelTraits::numComponents(); }; public: diff --git a/dumux/discretization/cellcentered/mpfa/fickslaw.hh b/dumux/discretization/cellcentered/mpfa/fickslaw.hh index 9737cbf684003cd2a5e55ee1b7e3735a2419ba55..c9e4bd9b76ec521ef754284d1bd95c7211e4ca02 100644 --- a/dumux/discretization/cellcentered/mpfa/fickslaw.hh +++ b/dumux/discretization/cellcentered/mpfa/fickslaw.hh @@ -55,7 +55,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::ccmpfa> using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache); using BalanceEqOpts = typename GET_PROP_TYPE(TypeTag, BalanceEqOpts); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag,NumComponents); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>; //! Class that fills the cache corresponding to mpfa Fick's Law @@ -111,7 +111,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::ccmpfa> static constexpr int dim = GridView::dimension; static constexpr int dimWorld = GridView::dimensionworld; - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); public: // export filler type diff --git a/dumux/discretization/cellcentered/mpfa/fluxvariablescachefiller.hh b/dumux/discretization/cellcentered/mpfa/fluxvariablescachefiller.hh index 2e868d9c1293b2d99cc9d8d97b95077b746d1ece..ef4db7ff552b04dbd42a6a4b80eca2bf91653a0c 100644 --- a/dumux/discretization/cellcentered/mpfa/fluxvariablescachefiller.hh +++ b/dumux/discretization/cellcentered/mpfa/fluxvariablescachefiller.hh @@ -42,6 +42,7 @@ namespace Dumux template<class TypeTag> class CCMpfaFluxVariablesCacheFiller { + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using Element = typename GridView::template Codim<0>::Entity; @@ -64,9 +65,9 @@ class CCMpfaFluxVariablesCacheFiller static constexpr int dim = GridView::dimension; static constexpr int dimWorld = GridView::dimensionworld; - static constexpr bool doAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection); - static constexpr bool doDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion); - static constexpr bool doHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance); + static constexpr bool doAdvection = ModelTraits::enableAdvection(); + static constexpr bool doDiffusion = ModelTraits::enableMolecularDiffusion(); + static constexpr bool doHeatConduction = ModelTraits::enableEnergyBalance(); static constexpr bool soldependentAdvection = GET_PROP_VALUE(TypeTag, SolutionDependentAdvection); static constexpr bool soldependentDiffusion = GET_PROP_VALUE(TypeTag, SolutionDependentMolecularDiffusion); @@ -310,8 +311,8 @@ private: using DiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType); using DiffusionFiller = typename DiffusionType::Cache::Filler; - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = ModelTraits::numPhases(); + static constexpr int numComponents = ModelTraits::numComponents(); for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { @@ -497,7 +498,7 @@ private: } // assemble pressure vectors - for (unsigned int pIdx = 0; pIdx < GET_PROP_VALUE(TypeTag, NumPhases); ++pIdx) + for (unsigned int pIdx = 0; pIdx < ModelTraits::numPhases(); ++pIdx) { const auto& evv = &elemVolVars(); auto getPressure = [&evv, pIdx] (auto volVarIdx) { return (evv->operator[](volVarIdx)).pressure(pIdx); }; diff --git a/dumux/discretization/cellcentered/mpfa/gridfluxvariablescache.hh b/dumux/discretization/cellcentered/mpfa/gridfluxvariablescache.hh index 5834dbf522380aa63f37449a2220aa05e8de7bc0..21d8069e744b24633945ccbe6b88c0d755500e33 100644 --- a/dumux/discretization/cellcentered/mpfa/gridfluxvariablescache.hh +++ b/dumux/discretization/cellcentered/mpfa/gridfluxvariablescache.hh @@ -49,6 +49,7 @@ class CCMpfaGridFluxVariablesCache; template<class TypeTag> class CCMpfaGridFluxVariablesCache<TypeTag, true> { + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using Element = typename GridView::template Codim<0>::Entity; @@ -71,12 +72,12 @@ class CCMpfaGridFluxVariablesCache<TypeTag, true> //! physics traits class to define the data handles struct PhysicsTraits { - static constexpr bool enableAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection); - static constexpr bool enableMolecularDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion); - static constexpr bool enableHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance); + static constexpr bool enableAdvection = ModelTraits::enableAdvection(); + static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion(); + static constexpr bool enableHeatConduction = ModelTraits::enableEnergyBalance(); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = ModelTraits::numPhases(); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); }; public: diff --git a/dumux/discretization/cellcentered/tpfa/fickslaw.hh b/dumux/discretization/cellcentered/tpfa/fickslaw.hh index 43f990f738d1073744137fb245b2059e39e07c4a..3710b9b64a051d3b45f397cc18e6b41734093a65 100644 --- a/dumux/discretization/cellcentered/tpfa/fickslaw.hh +++ b/dumux/discretization/cellcentered/tpfa/fickslaw.hh @@ -62,8 +62,8 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::cctpfa> static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static const int numComponents = GET_PROP_VALUE(TypeTag,NumComponents); + static const int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; diff --git a/dumux/discretization/cellcentered/tpfa/fluxvariablescachefiller.hh b/dumux/discretization/cellcentered/tpfa/fluxvariablescachefiller.hh index b0118ada760834b57d5086f9b22e7b3cca80dc76..4fc0c8ed5ddae144ba61690ed7d5de8a4e4bb1b9 100644 --- a/dumux/discretization/cellcentered/tpfa/fluxvariablescachefiller.hh +++ b/dumux/discretization/cellcentered/tpfa/fluxvariablescachefiller.hh @@ -37,6 +37,7 @@ namespace Dumux template<class TypeTag> class CCTpfaFluxVariablesCacheFiller { + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::LocalView; @@ -47,9 +48,9 @@ class CCTpfaFluxVariablesCacheFiller using Element = typename GridView::template Codim<0>::Entity; - static constexpr bool doAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection); - static constexpr bool doDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion); - static constexpr bool doHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance); + static constexpr bool doAdvection = ModelTraits::enableAdvection(); + static constexpr bool doDiffusion = ModelTraits::enableMolecularDiffusion(); + static constexpr bool doHeatConduction = ModelTraits::enableEnergyBalance(); static constexpr bool soldependentAdvection = GET_PROP_VALUE(TypeTag, SolutionDependentAdvection); static constexpr bool soldependentDiffusion = GET_PROP_VALUE(TypeTag, SolutionDependentMolecularDiffusion); @@ -145,8 +146,8 @@ private: using DiffusionFiller = typename DiffusionType::Cache::Filler; using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = ModelTraits::numPhases(); + static constexpr int numComponents = ModelTraits::numComponents(); // forward to the filler of the diffusive quantities for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) diff --git a/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh b/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh index fa0a07cf99842f52bb783fe0884b5b0ef0146920..86e347b6acec29a1576a02fbad9f97a09cacfa0f 100644 --- a/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh +++ b/dumux/discretization/cellcentered/tpfa/maxwellstefanslaw.hh @@ -63,8 +63,8 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::cctpfa > static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static const int numComponents = GET_PROP_VALUE(TypeTag,NumComponents); + static const int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; diff --git a/dumux/discretization/fvproperties.hh b/dumux/discretization/fvproperties.hh index a85e48b066152bc6ef52a86f2268047a71343124..4fdee202d0a8ca409af7b0720d62476b2ffc5839 100644 --- a/dumux/discretization/fvproperties.hh +++ b/dumux/discretization/fvproperties.hh @@ -61,7 +61,7 @@ SET_BOOL_PROP(FiniteVolumeModel, EnableGridVolumeVariablesCache, false); SET_BOOL_PROP(FiniteVolumeModel, EnableGridFluxVariablesCache, false); //! Boundary types at a single degree of freedom -SET_TYPE_PROP(FiniteVolumeModel, BoundaryTypes, BoundaryTypes<GET_PROP_VALUE(TypeTag, NumEq)>); +SET_TYPE_PROP(FiniteVolumeModel, BoundaryTypes, BoundaryTypes<GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>); // TODO: bundle SolutionVector, JacobianMatrix // in LinearAlgebra traits @@ -74,7 +74,7 @@ SET_PROP(FiniteVolumeModel, JacobianMatrix) { private: using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) }; + enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() }; using MatrixBlock = typename Dune::FieldMatrix<Scalar, numEq, numEq>; public: using type = typename Dune::BCRSMatrix<MatrixBlock>; diff --git a/dumux/discretization/staggered/freeflow/fickslaw.hh b/dumux/discretization/staggered/freeflow/fickslaw.hh index 16cfba42a55445801965f16a5cffc135e2f7843e..80247a5d63bb425c7d3bdd11779b0d085d3531fa 100644 --- a/dumux/discretization/staggered/freeflow/fickslaw.hh +++ b/dumux/discretization/staggered/freeflow/fickslaw.hh @@ -60,11 +60,13 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::staggered > static constexpr int dim = GridView::dimension; static constexpr int dimWorld = GridView::dimensionworld; - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + + static constexpr int numComponents = ModelTraits::numComponents(); + static constexpr int phaseIdx = Indices::phaseIdx; static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); - static_assert(GET_PROP_VALUE(TypeTag, NumPhases) == 1, "Only one phase allowed supported!"); + static_assert(ModelTraits::numPhases() == 1, "Only one phase allowed supported!"); enum { pressureIdx = Indices::pressureIdx, diff --git a/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh b/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh index c8b0f75fb8282bc9a65ea99978bb5bc2c14fc166..124aaec012ffc29438c307f4d5f35c8f821d82a8 100644 --- a/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh +++ b/dumux/discretization/staggered/freeflow/maxwellstefanslaw.hh @@ -60,13 +60,15 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::staggered > static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_VALUE(TypeTag,NumComponents); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + + static const int numComponents = ModelTraits::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); using ReducedComponentVector = Dune::FieldVector<Scalar, numComponents-1>; using ReducedComponentMatrix = Dune::FieldMatrix<Scalar, numComponents-1, numComponents-1>; - static_assert(GET_PROP_VALUE(TypeTag, NumPhases) == 1, "Only one phase allowed supported!"); + static_assert(ModelTraits::numPhases() == 1, "Only one phase allowed supported!"); enum { pressureIdx = Indices::pressureIdx, diff --git a/dumux/discretization/staggered/freeflow/properties.hh b/dumux/discretization/staggered/freeflow/properties.hh index a1c6f6be95f121722de02a9acd4041c0462785e5..b0f0fabf6c93218ef6519287ed33d24fc64c8a7c 100644 --- a/dumux/discretization/staggered/freeflow/properties.hh +++ b/dumux/discretization/staggered/freeflow/properties.hh @@ -71,10 +71,11 @@ SET_PROP(StaggeredFreeFlowModel, NumEqCellCenter) { private: using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); static constexpr auto dim = GridView::dimension; - static constexpr auto numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr auto numEq = ModelTraits::numEq(); public: - static constexpr int value = GET_PROP_VALUE(TypeTag, NumEq) - dim; + static constexpr int value = numEq - dim; }; //! The default fv grid geometry diff --git a/dumux/freeflow/navierstokes/model.hh b/dumux/freeflow/navierstokes/model.hh index 7fc7b2029c74e7525d770a36009a712f5d264bce..43a45ea2a58c43db39bdeb815e3fa3c1980c64ce 100644 --- a/dumux/freeflow/navierstokes/model.hh +++ b/dumux/freeflow/navierstokes/model.hh @@ -65,6 +65,33 @@ namespace Dumux { +/*! + * \ingroup NavierStokesModel + * \brief Traits for the Navier-Stokes model + */ +template<int dim> +struct NavierStokesModelTraits +{ + //! There are as many momentum balance equations as dimensions + //! and one mass balance equation. + static constexpr int numEq() { return dim+1; } + + //! The number of phases is 1 + static constexpr int numPhases() { return 1; } + + //! The number of components is 1 + static constexpr int numComponents() { return 1; } + + //! Enable advection + static constexpr bool enableAdvection() { return true; } + + //! The one-phase model has no molecular diffusion + static constexpr bool enableMolecularDiffusion() { return false; } + + //! The model is isothermal + static constexpr bool enableEnergyBalance() { return false; } +}; + // \{ /////////////////////////////////////////////////////////////////////////// // properties for the single-phase Navier-Stokes model @@ -84,28 +111,18 @@ NEW_TYPE_TAG(NavierStokesNI, INHERITS_FROM(NavierStokes, NavierStokesNonIsotherm /////////////////////////////////////////////////////////////////////////// // default property values for the isothermal single phase model /////////////////////////////////////////////////////////////////////////// -SET_INT_PROP(NavierStokes, NumPhases, 1); //!< The number of phases in the 1p model is 1 -SET_INT_PROP(NavierStokes, NumComponents, 1); //!< The number of components in the 1p model is 1 SET_INT_PROP(NavierStokes, PhaseIdx, 0); //!< The default phase index - -SET_BOOL_PROP(NavierStokes, EnableAdvection, true); //!< Enable advection -SET_BOOL_PROP(NavierStokes, EnableMolecularDiffusion, false); //!< The one-phase model has no molecular diffusion -SET_BOOL_PROP(NavierStokes, EnableEnergyBalance, false); //!< The model is isothermal SET_BOOL_PROP(NavierStokes, EnableInertiaTerms, true); //!< Consider inertia terms by default SET_BOOL_PROP(NavierStokes, NormalizePressure, true); //!< Normalize the pressure term in the momentum balance by default -/*! -* \brief The number of equations. -* There are as many momentum balance equations as dimensions -* and one mass balance equation. -*/ -SET_PROP(NavierStokes, NumEq) +//!< states some specifics of the Navier-Stokes model +SET_PROP(NavierStokes, ModelTraits) { private: - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr auto dim = GridView::dimension; + using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; + static constexpr int dim = GridView::dimension; public: - static constexpr int value = dim + 1; + using type = NavierStokesModelTraits<dim>; }; /*! @@ -138,7 +155,7 @@ SET_TYPE_PROP(NavierStokes, FluxVariablesCache, FreeFlowFluxVariablesCache<TypeT SET_PROP(NavierStokes, Indices) { private: - static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; public: using type = NavierStokesIndices<dim, numEq>; @@ -155,11 +172,22 @@ public: ////////////////////////////////////////////////////////////////// // Property values for isothermal model required for the general non-isothermal model ////////////////////////////////////////////////////////////////// + +//! The model traits of the isothermal model +SET_PROP(NavierStokesNI, IsothermalModelTraits) +{ +private: + using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; + static constexpr int dim = GridView::dimension; +public: + using type = NavierStokesModelTraits<dim>; +}; + //! The indices required by the isothermal single-phase model SET_PROP(NavierStokesNI, IsothermalIndices) { private: - static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; public: using type = NavierStokesIndices<dim, numEq>; @@ -174,15 +202,6 @@ public: using type = NavierStokesVtkOutputFields<FVGridGeometry>; }; -//! The number of equations for the isothermal model -SET_PROP(NavierStokesNI, IsothermalNumEq) -{ -private: - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr auto dim = GridView::dimension; -public: - static constexpr int value = dim + 1; -}; // \} } diff --git a/dumux/freeflow/navierstokes/staggered/fluxoverplane.hh b/dumux/freeflow/navierstokes/staggered/fluxoverplane.hh index 4ad42d794541f7d691d12defa6d4eba9a90f85aa..130b83dc06a07cf40f630220b8b413f30264b9a7 100644 --- a/dumux/freeflow/navierstokes/staggered/fluxoverplane.hh +++ b/dumux/freeflow/navierstokes/staggered/fluxoverplane.hh @@ -271,7 +271,7 @@ public: */ void calculateVolumeFluxes() { - const auto isCompositional = std::integral_constant<bool, (GET_PROP_VALUE(TypeTag, NumComponents) > 1) >(); + const auto isCompositional = std::integral_constant<bool, (GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() > 1) >(); calculateVolumeFluxesImpl_(isCompositional); } @@ -400,7 +400,7 @@ private: const auto avgDensity = 0.5*density(insideVolVars) + 0.5*density(outsideVolVars); constexpr auto replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx); - constexpr auto numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + constexpr auto numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); const Scalar cumulativeFlux = [replaceCompEqIdx, numComponents, &massOrMoleFlux]() { diff --git a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh index d693511e762366607c143f7e234c5637f92d2afe..1bb579746297a77413dba03cbe9f8a64b39f665d 100644 --- a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh +++ b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh @@ -60,6 +60,7 @@ class NavierStokesFluxVariablesImpl<TypeTag, DiscretizationMethod::staggered> using FaceVariables = typename GET_PROP_TYPE(TypeTag, FaceVariables); static constexpr bool enableInertiaTerms = GET_PROP_VALUE(TypeTag, EnableInertiaTerms); + static constexpr bool normalizePressure = GET_PROP_VALUE(TypeTag, NormalizePressure); using GlobalPosition = Dune::FieldVector<Scalar, GridView::dimensionworld>; @@ -224,7 +225,7 @@ public: // The pressure term. // If specified, the pressure can be normalized using the initial value on the scfv of interest. // Can potentially help to improve the condition number of the system matrix. - const Scalar pressure = GET_PROP_VALUE(TypeTag, NormalizePressure) ? + const Scalar pressure = normalizePressure ? insideVolVars.pressure() - problem.initialAtPos(scvf.center())[Indices::pressureIdx] : insideVolVars.pressure(); @@ -513,7 +514,7 @@ private: } // Apply a pressure at the boudary. - const Scalar boundaryPressure = GET_PROP_VALUE(TypeTag, NormalizePressure) ? + const Scalar boundaryPressure = normalizePressure ? (problem.dirichlet(element, scvf)[Indices::pressureIdx] - problem.initialAtPos(scvf.center())[Indices::pressureIdx]) : problem.dirichlet(element, scvf)[Indices::pressureIdx]; diff --git a/dumux/freeflow/navierstokes/staggered/localresidual.hh b/dumux/freeflow/navierstokes/staggered/localresidual.hh index b232e7e329385f807f5e6b0a68e4abd5c1f908c5..e37e58a5ee71f76bb572fc4de594d1c10e2408e0 100644 --- a/dumux/freeflow/navierstokes/staggered/localresidual.hh +++ b/dumux/freeflow/navierstokes/staggered/localresidual.hh @@ -79,6 +79,8 @@ class NavierStokesResidualImpl<TypeTag, DiscretizationMethod::staggered> using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + public: //! Use the parent type's constructor @@ -97,7 +99,7 @@ public: CellCenterPrimaryVariables flux = fluxVars.computeFluxForCellCenter(problem, element, fvGeometry, elemVolVars, elemFaceVars, scvf, elemFluxVarsCache[scvf]); - computeFluxForCellCenterNonIsothermal_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>(), + computeFluxForCellCenterNonIsothermal_(std::integral_constant<bool, ModelTraits::enableEnergyBalance()>(), problem, element, fvGeometry, elemVolVars, elemFaceVars, scvf, elemFluxVarsCache, flux); return flux; @@ -132,7 +134,7 @@ public: CellCenterPrimaryVariables storage; storage[massBalanceIdx] = volVars.density(); - computeStorageForCellCenterNonIsothermal_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(), + computeStorageForCellCenterNonIsothermal_(std::integral_constant<bool, ModelTraits::enableEnergyBalance() >(), problem, scv, volVars, storage); return storage; diff --git a/dumux/freeflow/navierstokes/volumevariables.hh b/dumux/freeflow/navierstokes/volumevariables.hh index 4ea46d566e4400913748d576dd95e384a083fe36..535dde96f7a2dc73bcc4b30dac1f51a1993616a5 100644 --- a/dumux/freeflow/navierstokes/volumevariables.hh +++ b/dumux/freeflow/navierstokes/volumevariables.hh @@ -40,7 +40,7 @@ class NavierStokesVolumeVariablesImplementation; * The class is specialized for isothermal and non-isothermal models. */ template <class TypeTag> -using NavierStokesVolumeVariables = NavierStokesVolumeVariablesImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>; +using NavierStokesVolumeVariables = NavierStokesVolumeVariablesImplementation<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableEnergyBalance()>; /*! * \ingroup NavierStokesModel diff --git a/dumux/freeflow/navierstokesnc/model.hh b/dumux/freeflow/navierstokesnc/model.hh index d3468ef03ca839ede566b72dea4c90c73da0f3a0..bc6cfa45cf53a68e23a331821ec53561db2a9c73 100644 --- a/dumux/freeflow/navierstokesnc/model.hh +++ b/dumux/freeflow/navierstokesnc/model.hh @@ -78,8 +78,34 @@ #include <dumux/material/fluidstates/compositional.hh> -namespace Dumux +namespace Dumux { + +/*! + * \ingroup NavierStokesModel + * \brief Traits for the Navier-Stokes multi-component model + */ +template<int dim, int nComp> +struct NavierStokesNCModelTraits { + //! There are as many momentum balance equations as dimensions + //! and as many balance equations as components. + static constexpr int numEq() { return dim+nComp; } + + //! The number of phases is always 1 + static constexpr int numPhases() { return 1; } + + //! The number of components + static constexpr int numComponents() { return nComp; } + + //! Enable advection + static constexpr bool enableAdvection() { return true; } + + //! The one-phase model has no molecular diffusion + static constexpr bool enableMolecularDiffusion() { return true; } + + //! The model is isothermal + static constexpr bool enableEnergyBalance() { return false; } +}; /////////////////////////////////////////////////////////////////////////// // properties for the single-phase, multi-component Navier-Stokes model @@ -100,37 +126,19 @@ NEW_TYPE_TAG(NavierStokesNCNI, INHERITS_FROM(NavierStokesNC, NavierStokesNonIsot // default property values /////////////////////////////////////////////////////////////////////////// -/*! -* \brief Set the property for the number of components. -* -* We just forward the number from the fluid system -* -*/ -SET_PROP(NavierStokesNC, NumComponents) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); -public: - static constexpr int value = FluidSystem::numComponents; -}; - -/*! -* \brief The number of equations. -* There are as many momentum balance equations as dimensions -* and as many balance equations as components. -*/ -SET_PROP(NavierStokesNC, NumEq) +//!< states some specifics of the Navier-Stokes model +SET_PROP(NavierStokesNC, ModelTraits) { private: - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr auto dim = GridView::dimension; + using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; + static constexpr int dim = GridView::dimension; using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static constexpr int numComponents = FluidSystem::numComponents; public: - static constexpr int value = dim + FluidSystem::numComponents; + using type = NavierStokesNCModelTraits<dim, numComponents>; }; SET_INT_PROP(NavierStokesNC, PhaseIdx, 0); //!< Defines the phaseIdx -SET_BOOL_PROP(NavierStokesNC, EnableMolecularDiffusion, true); //!< Enable molecular diffusion SET_BOOL_PROP(NavierStokesNC, UseMoles, false); //!< Defines whether molar (true) or mass (false) density is used SET_INT_PROP(NavierStokesNC, ReplaceCompEqIdx, 0); //<! Set the ReplaceCompEqIdx to 0 by default @@ -147,7 +155,7 @@ SET_TYPE_PROP(NavierStokesNC, FluxVariables, NavierStokesNCFluxVariables<TypeTag SET_PROP(NavierStokesNC, Indices) { private: - static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); static constexpr int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx); @@ -187,11 +195,24 @@ SET_TYPE_PROP(NavierStokesNC, MolecularDiffusionType, FicksLaw<TypeTag>); ////////////////////////////////////////////////////////////////// // Property values for isothermal model required for the general non-isothermal model ////////////////////////////////////////////////////////////////// + +//! The model traits of the isothermal model +SET_PROP(NavierStokesNCNI, IsothermalModelTraits) +{ +private: + using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; + static constexpr int dim = GridView::dimension; + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static constexpr int numComponents = FluidSystem::numComponents; +public: + using type = NavierStokesNCModelTraits<dim, numComponents>; +}; + //! The isothermal indices SET_PROP(NavierStokesNCNI, IsothermalIndices) { private: - static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); static constexpr int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx); @@ -211,17 +232,6 @@ public: using type = NavierStokesNCVtkOutputFields<FVGridGeometry, FluidSystem, phaseIdx>; }; -//! The number of equations for the isothermal model -SET_PROP(NavierStokesNCNI, IsothermalNumEq) -{ -private: - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr auto dim = GridView::dimension; - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); -public: - static constexpr int value = dim + FluidSystem::numComponents; -}; - // \} } // end namespace Properties } // end namespace Dumux diff --git a/dumux/freeflow/navierstokesnc/staggered/fluxvariables.hh b/dumux/freeflow/navierstokesnc/staggered/fluxvariables.hh index 1135809508378aab15b403e90d34a573e41c4938..be9954fd9e5e11f98a436e28881a28a6ad11c378 100644 --- a/dumux/freeflow/navierstokesnc/staggered/fluxvariables.hh +++ b/dumux/freeflow/navierstokesnc/staggered/fluxvariables.hh @@ -58,7 +58,7 @@ class NavierStokesNCFluxVariablesImpl<TypeTag, DiscretizationMethod::staggered> using MolecularDiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType); - static constexpr auto numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr auto numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); diff --git a/dumux/freeflow/navierstokesnc/staggered/localresidual.hh b/dumux/freeflow/navierstokesnc/staggered/localresidual.hh index 51e1eff282059727655e64c69dc7ca281519f1c4..2ad8e090ea4639358d94932121894f69964d4c54 100644 --- a/dumux/freeflow/navierstokesnc/staggered/localresidual.hh +++ b/dumux/freeflow/navierstokesnc/staggered/localresidual.hh @@ -69,7 +69,9 @@ class NavierStokesNCResidualImpl<TypeTag, DiscretizationMethod::staggered> using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + + static constexpr int numComponents =ModelTraits::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); public: @@ -100,7 +102,7 @@ public: if(replaceCompEqIdx < numComponents) storage[replaceCompEqIdx] = density; - this->computeStorageForCellCenterNonIsothermal_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(), + this->computeStorageForCellCenterNonIsothermal_(std::integral_constant<bool, ModelTraits::enableEnergyBalance() >(), problem, scv, volVars, storage); return storage; diff --git a/dumux/freeflow/navierstokesnc/volumevariables.hh b/dumux/freeflow/navierstokesnc/volumevariables.hh index dc22be7e8f030d2ae03f323a4e186a9748e14314..de3800a4e698eecab1456896f079af72206f3e17 100644 --- a/dumux/freeflow/navierstokesnc/volumevariables.hh +++ b/dumux/freeflow/navierstokesnc/volumevariables.hh @@ -51,7 +51,7 @@ class NavierStokesNCVolumeVariables : public NavierStokesVolumeVariables<TypeTag using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using Element = typename GridView::template Codim<0>::Entity; - enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents), + enum { numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), numPhases = FluidSystem::numPhases, mainCompIdx = Indices::mainCompIdx, pressureIdx = Indices::pressureIdx diff --git a/dumux/freeflow/nonisothermal/model.hh b/dumux/freeflow/nonisothermal/model.hh index 69751208c8b1e0e990f04a00dbf47a29ac5b9c6c..79e2050a0a8931512240ad59871735309b37d618 100644 --- a/dumux/freeflow/nonisothermal/model.hh +++ b/dumux/freeflow/nonisothermal/model.hh @@ -40,8 +40,22 @@ #include <dumux/discretization/fourierslaw.hh> -namespace Dumux +namespace Dumux { + +/*! + * \ingroup NavierStokesNIModel + * \brief Specifies a number properties of non-isothermal free flow + * flow models based on the specifics of a given isothermal model. + * \tparam IsothermalTraits Model traits of the isothermal model + */ +template<class IsothermalTraits> +struct NavierStokesNIModelTraits : public IsothermalTraits { + //! We solve for one more equation, i.e. the energy balance + static constexpr int numEq() { return IsothermalTraits::numEq()+1; } + //! We additionally solve for the equation balance + static constexpr bool enableEnergyBalance() { return true; } +}; namespace Properties { @@ -52,24 +66,21 @@ NEW_TYPE_TAG(NavierStokesNonIsothermal); // default property values for the non-isothermal single phase model /////////////////////////////////////////////////////////////////////////// -//! The non-isothermal model has one more balance equation (energy balance) compared to the non-isothermal ones -SET_PROP(NavierStokesNonIsothermal, NumEq) +//! use the non-isothermal model traits +SET_PROP(NavierStokesNonIsothermal, ModelTraits) { private: - static constexpr auto isothermalNumEq = GET_PROP_VALUE(TypeTag, IsothermalNumEq); + using IsothermalTraits = typename GET_PROP_TYPE(TypeTag, IsothermalModelTraits); public: - static constexpr int value = isothermalNumEq + 1; + using type = NavierStokesNIModelTraits<IsothermalTraits>; }; -//! Enable the energy balance -SET_BOOL_PROP(NavierStokesNonIsothermal, EnableEnergyBalance, true); - //! The non-isothermal indices SET_PROP(NavierStokesNonIsothermal, Indices) { private: static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; - static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); using IsothermalIndices = typename GET_PROP_TYPE(TypeTag, IsothermalIndices); public: using type = NavierStokesNonIsothermalIndices<dim, numEq, IsothermalIndices>; @@ -89,6 +100,6 @@ SET_TYPE_PROP(NavierStokesNonIsothermal, HeatConductionType, FouriersLaw<TypeTag } // end namespace Properties -} +} // end namespace Dumux #endif diff --git a/dumux/io/vtkoutputmodule.hh b/dumux/io/vtkoutputmodule.hh index 73656b9d3e8731cc8e867b566cf6e5b7f0022f08..55f715fd5a1b111d49aa2b4e396188c3f4301e4b 100644 --- a/dumux/io/vtkoutputmodule.hh +++ b/dumux/io/vtkoutputmodule.hh @@ -234,7 +234,7 @@ class VtkOutputModule using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); static constexpr bool isBox = GET_PROP_TYPE(TypeTag, FVGridGeometry)::discMethod == DiscretizationMethod::box; static constexpr int dofCodim = isBox ? dim : 0; diff --git a/dumux/material/fluidmatrixinteractions/mineralization/effectivesoliddensity.hh b/dumux/material/fluidmatrixinteractions/mineralization/effectivesoliddensity.hh index ab421175f7e1b470756abb5916ab1dd49e749bf9..0017b5dc2d1058e2126a5fce6422edc0e711c27f 100644 --- a/dumux/material/fluidmatrixinteractions/mineralization/effectivesoliddensity.hh +++ b/dumux/material/fluidmatrixinteractions/mineralization/effectivesoliddensity.hh @@ -45,8 +45,8 @@ class DUNE_DEPRECATED_MSG("Implement SolidSystems instead!") EffectiveSolidDensi static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); + static const int numSolidPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numSPhases(); using Element = typename GridView::template Codim<0>:: Entity; diff --git a/dumux/material/fluidmatrixinteractions/mineralization/effectivesolidheatcapacity.hh b/dumux/material/fluidmatrixinteractions/mineralization/effectivesolidheatcapacity.hh index 30edbac49e59928963615313a560e293adbfcdcb..01f45c8442f96c2bf8f8f2c6c995d9cf3b35310d 100644 --- a/dumux/material/fluidmatrixinteractions/mineralization/effectivesolidheatcapacity.hh +++ b/dumux/material/fluidmatrixinteractions/mineralization/effectivesolidheatcapacity.hh @@ -45,8 +45,8 @@ class DUNE_DEPRECATED_MSG("Implement SolidSystems instead!") EffectiveSolidHeatC static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); + static const int numSolidPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numSPhases(); using Element = typename GridView::template Codim<0>:: Entity; diff --git a/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh b/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh index 67b5c23e4401c235873640059974dd0bd77e1cf2..89ceedf9b1b543b18e4ca69e3269d8fa48659052 100644 --- a/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh +++ b/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh @@ -44,8 +44,8 @@ class PorosityPrecipitation static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); + static const int numSolidPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numSPhases(); using Element = typename GridView::template Codim<0>:: Entity; diff --git a/dumux/material/fluidmatrixinteractions/porosityreactivebed.hh b/dumux/material/fluidmatrixinteractions/porosityreactivebed.hh index 8a18fa8c5257ab33972bfbe71211818fbdcbd0bd..e12984151868db5fa2df3beb1444520bc1599c21 100644 --- a/dumux/material/fluidmatrixinteractions/porosityreactivebed.hh +++ b/dumux/material/fluidmatrixinteractions/porosityreactivebed.hh @@ -44,8 +44,8 @@ class PorosityReactiveBed static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); + static const int numSolidPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numSPhases(); using Element = typename GridView::template Codim<0>:: Entity; diff --git a/dumux/porousmediumflow/1p/model.hh b/dumux/porousmediumflow/1p/model.hh index af4ca3b9c268ffd0d72e7ecab4c0021d16069168..ce9dd97f0ac7886e2166e4825f14375249229b9a 100644 --- a/dumux/porousmediumflow/1p/model.hh +++ b/dumux/porousmediumflow/1p/model.hh @@ -55,8 +55,24 @@ #include "volumevariables.hh" #include "vtkoutputfields.hh" -namespace Dumux +namespace Dumux { +/*! + * \ingroup OnePModel + * \brief Specifies a number properties of single-phase models. + */ +struct OnePModelTraits { + using Indices = OnePIndices; + + static constexpr int numEq() { return 1; } + static constexpr int numPhases() { return 1; } + static constexpr int numComponents() { return 1; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return false; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { //! The type tags for the isothermal single phase model NEW_TYPE_TAG(OneP, INHERITS_FROM(PorousMediumFlow)); @@ -66,16 +82,11 @@ NEW_TYPE_TAG(OnePNI, INHERITS_FROM(OneP, NonIsothermal)); /////////////////////////////////////////////////////////////////////////// // properties for the isothermal single phase model /////////////////////////////////////////////////////////////////////////// -SET_INT_PROP(OneP, NumEq, 1); //!< set the number of equations to 1 -SET_INT_PROP(OneP, NumPhases, 1); //!< The number of phases in the 1p model is 1 -SET_INT_PROP(OneP, NumComponents, 1); //!< The number of components in the 1p model is 1 -SET_TYPE_PROP(OneP, LocalResidual, ImmiscibleLocalResidual<TypeTag>); //!< The local residual function +SET_TYPE_PROP(OneP, VtkOutputFields, OnePVtkOutputFields); //!< default vtk output fields specific to this model +SET_TYPE_PROP(OneP, LocalResidual, ImmiscibleLocalResidual<TypeTag>); //!< the local residual function SET_TYPE_PROP(OneP, VolumeVariables, OnePVolumeVariables<TypeTag>); //!< the VolumeVariables property -SET_BOOL_PROP(OneP, EnableAdvection, true); //!< The one-phase model considers advection -SET_BOOL_PROP(OneP, EnableMolecularDiffusion, false); //!< The one-phase model has no molecular diffusion -SET_BOOL_PROP(OneP, EnableEnergyBalance, false); //!< Isothermal model by default -SET_TYPE_PROP(OneP, Indices, OnePIndices); //!< The indices required by the isothermal single-phase model -SET_TYPE_PROP(OneP, VtkOutputFields, OnePVtkOutputFields); //!< Set the vtk output fields specific to this model +SET_TYPE_PROP(OneP, ModelTraits, OnePModelTraits); //!< states some specifics of the one-phase model +SET_TYPE_PROP(OneP, Indices, OnePIndices); //!< Indices used by the one-phase model /*! * \brief The fluid state which is used by the volume variables to @@ -95,12 +106,11 @@ public: /////////////////////////////////////////////////////////////////////////// // properties for the non-isothermal single phase model /////////////////////////////////////////////////////////////////////////// -SET_INT_PROP(OnePNI, IsothermalNumEq, 1); //!< set number of equations of isothermal model -SET_BOOL_PROP(OnePNI, EnableEnergyBalance, true); //!< we do solve for the energy balance here -SET_TYPE_PROP(OnePNI, IsothermalVtkOutputFields, OnePVtkOutputFields); //!< the isothermal vtk output fields +SET_TYPE_PROP(OnePNI, IsothermalVtkOutputFields, OnePVtkOutputFields); //!< the isothermal vtk output fields SET_TYPE_PROP(OnePNI, IsothermalVolumeVariables, OnePVolumeVariables<TypeTag>); //!< Vol vars of the isothermal model SET_TYPE_PROP(OnePNI, IsothermalLocalResidual, ImmiscibleLocalResidual<TypeTag>); //!< Local residual of the isothermal model SET_TYPE_PROP(OnePNI, IsothermalIndices, OnePIndices); //!< Indices of the isothermal model +SET_TYPE_PROP(OnePNI, IsothermalModelTraits, OnePModelTraits); //!< The model traits of the isothermal model SET_TYPE_PROP(OnePNI, ThermalConductivityModel, ThermalConductivityAverage<typename GET_PROP_TYPE(TypeTag, Scalar)>); //!< Use the average for effective conductivities diff --git a/dumux/porousmediumflow/1pnc/model.hh b/dumux/porousmediumflow/1pnc/model.hh index dd84201f196e56693397089d11743edcb7c35c9a..36fc175a3305c1125f1dcf09b043984a10936f7c 100644 --- a/dumux/porousmediumflow/1pnc/model.hh +++ b/dumux/porousmediumflow/1pnc/model.hh @@ -63,6 +63,7 @@ #include <dumux/material/fluidstates/compositional.hh> #include <dumux/porousmediumflow/properties.hh> +#include <dumux/porousmediumflow/1p/model.hh> #include <dumux/porousmediumflow/compositional/localresidual.hh> #include <dumux/porousmediumflow/nonisothermal/model.hh> #include <dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh> @@ -73,6 +74,24 @@ namespace Dumux { +/*! + * \ingroup OnePNCModel + * \brief Specifies a number properties of models that + * consider a single-phase with multiple components. + * + * \Å£param nComp the number of components to be considered. + */ +template<int nComp> +struct OnePNCModelTraits +{ + static constexpr int numEq() { return nComp; } + static constexpr int numPhases() { return 1; } + static constexpr int numComponents() { return nComp; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; namespace Properties { @@ -88,30 +107,13 @@ NEW_TYPE_TAG(OnePNCNI, INHERITS_FROM(OnePNC, NonIsothermal)); // properties for the isothermal single phase model /////////////////////////////////////////////////////////////////////////// -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system - * - */ -SET_PROP(OnePNC, NumComponents) +//! The model traits. Per default, we use the number of components of the fluid system. +SET_PROP(OnePNC, ModelTraits) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); - public: - static constexpr auto value = FluidSystem::numComponents; -}; - -/*! - * \brief Set the property for the number of equations: For each existing component one equation has to be solved. - */ -SET_PROP(OnePNC, NumEq) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); -public: - static constexpr auto value = FluidSystem::numComponents; + using type = OnePNCModelTraits<FluidSystem::numComponents>; }; //! Set as default that no component mass balance is replaced by the total mass balance @@ -139,17 +141,11 @@ SET_PROP(OnePNC, FluidState){ //! Use the model after Millington (1961) for the effective diffusivity SET_TYPE_PROP(OnePNC, EffectiveDiffusivityModel, - DiffusivityMillingtonQuirk<typename GET_PROP_TYPE(TypeTag, Scalar)>); - + DiffusivityMillingtonQuirk<typename GET_PROP_TYPE(TypeTag, Scalar)>); -SET_INT_PROP(OnePNC, NumPhases, 1); //!< The number of phases in the 1pnc model is 1 SET_INT_PROP(OnePNC, PhaseIdx, 0); //!< The default phase index SET_TYPE_PROP(OnePNC, LocalResidual, CompositionalLocalResidual<TypeTag>); //!< The local residual function SET_TYPE_PROP(OnePNC, VolumeVariables, OnePNCVolumeVariables<TypeTag>); //!< the VolumeVariables property -SET_BOOL_PROP(OnePNC, EnableAdvection, true); //!< The one-phase model considers advection -SET_BOOL_PROP(OnePNC, EnableMolecularDiffusion, true); //!< The one-phase model has no molecular diffusion -SET_BOOL_PROP(OnePNC, EnableEnergyBalance, false); //!< Isothermal model by default - //! Set the vtk output fields specific to this model SET_PROP(OnePNC, VtkOutputFields) @@ -175,18 +171,6 @@ public: // properties for the non-isothermal single phase model /////////////////////////////////////////////////////////////////////////// -/*! - * \brief Set the property for the number of equations: For each existing component one equation has to be solved. - */ -SET_PROP(OnePNCNI, IsothermalNumEq) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); -public: - static constexpr auto value = FluidSystem::numComponents; -}; -SET_BOOL_PROP(OnePNCNI, EnableEnergyBalance, true); //!< we do solve for the energy balance here - //! the isothermal vtk output fields SET_PROP(OnePNCNI, IsothermalVtkOutputFields) { @@ -212,6 +196,15 @@ public: using type = OnePNCIndices<phaseIdx>; }; +//! model traits of the isothermal model. +SET_PROP(OnePNCNI, IsothermalModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); +public: + using type = OnePNCModelTraits<FluidSystem::numComponents>; +}; + } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/1pnc/volumevariables.hh b/dumux/porousmediumflow/1pnc/volumevariables.hh index 4ef517a69ac87210eb79c793008dbe73b94474fc..549e37b15eb973c9301a33cc1f1ea15bcb17aa6d 100644 --- a/dumux/porousmediumflow/1pnc/volumevariables.hh +++ b/dumux/porousmediumflow/1pnc/volumevariables.hh @@ -62,7 +62,7 @@ class OnePNCVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> enum { - numComponents = GET_PROP_VALUE(TypeTag, NumComponents), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), phaseIdx = Indices::phaseIdx, phaseCompIdx = Indices::phaseCompIdx, diff --git a/dumux/porousmediumflow/1pncmin/model.hh b/dumux/porousmediumflow/1pncmin/model.hh index b42dbb758299c9d48ca751785baa12a207168fb2..c33173439244a8cd476c271b2c23182cc10122e1 100644 --- a/dumux/porousmediumflow/1pncmin/model.hh +++ b/dumux/porousmediumflow/1pncmin/model.hh @@ -84,7 +84,18 @@ NEW_TYPE_TAG(OnePNCMinNI, INHERITS_FROM(OnePNCMin, NonIsothermal)); ////////////////////////////////////////////////////////////////// // Property tags for the isothermal 2pncmin model ////////////////////////////////////////////////////////////////// -SET_TYPE_PROP(OnePNCMin, NonMineralizationVolumeVariables, OnePNCVolumeVariables<TypeTag>); //!< the VolumeVariables property + +//! the VolumeVariables property +SET_TYPE_PROP(OnePNCMin, NonMineralizationVolumeVariables, OnePNCVolumeVariables<TypeTag>); + +//! The 1pnc model traits define the non-mineralization part +SET_PROP(OnePNCMin, NonMineralizationModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); +public: + using type = OnePNCModelTraits<FluidSystem::numComponents>; +}; //! Set the vtk output fields specific to this model SET_PROP(OnePNCMin, NonMineralizationVtkOutputFields) @@ -99,7 +110,9 @@ public: ////////////////////////////////////////////////////////////////// // Properties for the non-isothermal 2pncmin model ////////////////////////////////////////////////////////////////// -SET_TYPE_PROP(OnePNCMinNI, IsothermalVolumeVariables, MineralizationVolumeVariables<TypeTag>); //!< set isothermal VolumeVariables + +//! set isothermal VolumeVariables +SET_TYPE_PROP(OnePNCMinNI, IsothermalVolumeVariables, MineralizationVolumeVariables<TypeTag>); //! isothermal vtkoutput SET_PROP(OnePNCMinNI, IsothermalVtkOutputFields) @@ -112,27 +125,27 @@ public: using type = MineralizationVtkOutputFields<NonMineralizationVtkOutputFields, FluidSystem>; }; -SET_TYPE_PROP(OnePNCMinNI, IsothermalLocalResidual, MineralizationLocalResidual<TypeTag>); //!< set isothermal output fields +//! set isothermal output fields +SET_TYPE_PROP(OnePNCMinNI, IsothermalLocalResidual, MineralizationLocalResidual<TypeTag>); -SET_TYPE_PROP(OnePNCMinNI, - ThermalConductivityModel, - ThermalConductivityAverage<typename GET_PROP_TYPE(TypeTag, Scalar)>); //!< Use the average for effective conductivities - -SET_PROP(OnePNCMinNI, IsothermalNumEq) { +//! Use 1pncmin traits as isothermal model traits +SET_PROP(OnePNCMinNI, IsothermalModelTraits) +{ private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); + using OnePNCTraits = OnePNCModelTraits<FluidSystem::numComponents>; public: - static const int value = FluidSystem::numComponents + FluidSystem::numSPhases; + // the mineralization traits, based on 1pnc traits, are the isothermal traits + using type = MineralizationModelTraits<OnePNCTraits, FluidSystem::numSPhases>; }; +//! Use the average for effective conductivities +SET_TYPE_PROP(OnePNCMinNI, + ThermalConductivityModel, + ThermalConductivityAverage<typename GET_PROP_TYPE(TypeTag, Scalar)>); + //! use 1pnc indices for the isothermal indices -SET_PROP(OnePNCMinNI, IsothermalIndices) -{ -private: - static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); -public: - using type = OnePNCIndices<phaseIdx>; -}; +SET_TYPE_PROP(OnePNCMinNI, IsothermalIndices, OnePNCIndices<GET_PROP_VALUE(TypeTag, PhaseIdx)>); } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/2p/model.hh b/dumux/porousmediumflow/2p/model.hh index 5c04c81edd98ecb6f7ff9eb3d4e7a210c22d9284..36d30c1d863b7dca34ef3c1d7102002911fb8a3f 100644 --- a/dumux/porousmediumflow/2p/model.hh +++ b/dumux/porousmediumflow/2p/model.hh @@ -65,6 +65,7 @@ #include <dumux/material/spatialparams/fv.hh> #include <dumux/porousmediumflow/properties.hh> +#include <dumux/porousmediumflow/1p/model.hh> #include <dumux/porousmediumflow/immiscible/localresidual.hh> #include <dumux/porousmediumflow/nonisothermal/model.hh> @@ -74,6 +75,20 @@ namespace Dumux { +/*! + * \ingroup TwoPModel + * \brief Specifies a number properties of two-phase models. + */ +struct TwoPModelTraits +{ + static constexpr int numEq() { return 2; } + static constexpr int numPhases() { return 2; } + static constexpr int numComponents() { return 2; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return false; } + static constexpr bool enableEnergyBalance() { return false; } +}; //////////////////////////////// // properties @@ -93,17 +108,14 @@ NEW_TYPE_TAG(TwoPNI, INHERITS_FROM(TwoP, NonIsothermal)); /////////////////////////////////////////////////////////////////////////// // properties for the isothermal two-phase model /////////////////////////////////////////////////////////////////////////// -SET_INT_PROP(TwoP, NumEq, 2); //!< Set the number of equations to 2 -SET_INT_PROP(TwoP, NumPhases, 2); //!< The number of phases in the 2p model is 2 -SET_INT_PROP(TwoP, NumComponents, 2); //!< The number of components in the 2p model is 2 SET_INT_PROP(TwoP, Formulation, TwoPFormulation::pwsn); //!< Set the default formulation to pWsN -SET_BOOL_PROP(TwoP, EnableAdvection, true); //!< Enable advection -SET_BOOL_PROP(TwoP, EnableMolecularDiffusion, false); //!< The two-phase model has no molecular diffusion -SET_BOOL_PROP(TwoP, EnableEnergyBalance, false); //!< Isothermal model (non-isothermal type tag is below) SET_TYPE_PROP(TwoP, LocalResidual, ImmiscibleLocalResidual<TypeTag>); //!< Use the immiscible local residual operator for the 2p model SET_TYPE_PROP(TwoP, VolumeVariables, TwoPVolumeVariables<TypeTag>); //!< the VolumeVariables property SET_TYPE_PROP(TwoP, SpatialParams, FVSpatialParams<TypeTag>); //!< The spatial parameters. Use FVSpatialParams by default. +//! The model traits class +SET_TYPE_PROP(TwoP, ModelTraits, TwoPModelTraits); + //! Set the vtk output fields specific to the twop model SET_TYPE_PROP(TwoP, VtkOutputFields, TwoPVtkOutputFields<typename GET_PROP_TYPE(TypeTag, Indices)>); @@ -130,10 +142,12 @@ public: //////////////////////////////////////////////////////// // properties for the non-isothermal two-phase model //////////////////////////////////////////////////////// -SET_INT_PROP(TwoPNI, IsothermalNumEq, 2); //!< set isothermal NumEq SET_TYPE_PROP(TwoPNI, IsothermalVolumeVariables, TwoPVolumeVariables<TypeTag>); //!< set isothermal VolumeVariables SET_TYPE_PROP(TwoPNI, IsothermalLocalResidual, ImmiscibleLocalResidual<TypeTag>); //!< set isothermal LocalResidual +//! The isothermal model traits class +SET_TYPE_PROP(TwoPNI, IsothermalModelTraits, TwoPModelTraits); + //! Set the vtk output fields specific to the isothermal twop model SET_TYPE_PROP(TwoPNI, IsothermalVtkOutputFields, TwoPVtkOutputFields<typename GET_PROP_TYPE(TypeTag, Indices)>); diff --git a/dumux/porousmediumflow/2p/volumevariables.hh b/dumux/porousmediumflow/2p/volumevariables.hh index 3a8868db6de4841fe7a1fd48ea838370f163b945..65dfd78d45366ce3e79e55cf70cbeda1074e14b3 100644 --- a/dumux/porousmediumflow/2p/volumevariables.hh +++ b/dumux/porousmediumflow/2p/volumevariables.hh @@ -60,7 +60,7 @@ class TwoPVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> saturationIdx = Indices::saturationIdx, wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx, - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), formulation = GET_PROP_VALUE(TypeTag, Formulation) }; diff --git a/dumux/porousmediumflow/2p1c/localresidual.hh b/dumux/porousmediumflow/2p1c/localresidual.hh index d6d2da18d89548518d8eb6ea444f75bbff83bead..7a892ae01773498dd53cc9185dc7991162379dfa 100644 --- a/dumux/porousmediumflow/2p1c/localresidual.hh +++ b/dumux/porousmediumflow/2p1c/localresidual.hh @@ -54,7 +54,7 @@ class TwoPOneCLocalResidual : public ImmiscibleLocalResidual<TypeTag> // first index for the mass balance enum { conti0EqIdx = Indices::conti0EqIdx }; - static const int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static const int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); public: //! Use the parent type's constructor diff --git a/dumux/porousmediumflow/2p1c/model.hh b/dumux/porousmediumflow/2p1c/model.hh index aac8e7a92870988e3571c26b013f189fcb38b6e2..2c3f5dfbbb7633d5ad9a9d2a474a05f75800bced 100644 --- a/dumux/porousmediumflow/2p1c/model.hh +++ b/dumux/porousmediumflow/2p1c/model.hh @@ -78,6 +78,22 @@ namespace Dumux { +/*! + * \ingroup TwoPOneCModel + * \brief Specifies a number properties of models + * considering two phases with water as a single component. + */ +struct TwoPOneCModelTraits +{ + static constexpr int numEq() { return 1; } + static constexpr int numPhases() { return 2; } + static constexpr int numComponents() { return 1; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return false; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { //! The type tag for the non-isothermal two-phase one-component model. @@ -90,39 +106,6 @@ NEW_TYPE_TAG(TwoPOneCNI, INHERITS_FROM(PorousMediumFlow, NonIsothermal)); //! Determines whether Blocking ofspurious flow is used. NEW_PROP_TAG(UseBlockingOfSpuriousFlow); -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 1. - */ -SET_PROP(TwoPOneCNI, NumComponents) -{ - private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - public: - static constexpr auto value = FluidSystem::numComponents; - - static_assert(value == 1, - "Only fluid systems with 1 component are supported by the 2p1cni model!"); -}; - -/*! - * \brief Set the property for the number of fluid phases. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 2. - */ -SET_PROP(TwoPOneCNI, NumPhases) -{ - private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - public: - static constexpr auto value = FluidSystem::numPhases; - static_assert(value == 2, - "Only fluid systems with 2 phases are supported by the 2p1cni model!"); -}; - /*! * \brief The fluid state which is used by the volume variables to * store the thermodynamic state. This should be chosen @@ -138,12 +121,6 @@ public: using type = CompositionalFluidState<Scalar, FluidSystem>; }; -//! The two-phase one-component model considers advection. -SET_BOOL_PROP(TwoPOneCNI, EnableAdvection, true); - - //! The two-phase one-component model has no molecular diffusion. -SET_BOOL_PROP(TwoPOneCNI, EnableMolecularDiffusion, false); - //! Do not block spurious flows by default. SET_BOOL_PROP(TwoPOneCNI, UseBlockingOfSpuriousFlow, false); @@ -164,7 +141,7 @@ SET_PROP(TwoPOneCNI, PrimaryVariables) { private: using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>; public: using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; }; @@ -188,6 +165,17 @@ SET_TYPE_PROP(TwoPOneCNI, IsothermalVolumeVariables, TwoPOneCVolumeVariables<Typ //! Set isothermal LocalResidual. SET_TYPE_PROP(TwoPOneCNI, IsothermalLocalResidual, ImmiscibleLocalResidual<TypeTag>); +//! Set the isothermal model traits +SET_PROP(TwoPOneCNI, IsothermalModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numComponents == 1, "Only fluid systems with 1 component are supported by the 2p1cni model!"); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 phases are supported by the 2p1cni model!"); +public: + using type = TwoPOneCModelTraits; +}; + //! Set isothermal Indices. SET_PROP(TwoPOneCNI, IsothermalIndices) { @@ -200,9 +188,6 @@ public: //! The isothermal vtk output fields. SET_TYPE_PROP(TwoPOneCNI, IsothermalVtkOutputFields, TwoPOneCVtkOutputFields<typename GET_PROP_TYPE(TypeTag, Indices)>); -//! Set isothermal NumEq. -SET_INT_PROP(TwoPOneCNI, IsothermalNumEq, 1); - } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/2p1c/volumevariables.hh b/dumux/porousmediumflow/2p1c/volumevariables.hh index 79dccb2aa79a2070361536fca1823ea85f27f398..f39e7c54690683a9e6e679ef1fb36fe32919d17c 100644 --- a/dumux/porousmediumflow/2p1c/volumevariables.hh +++ b/dumux/porousmediumflow/2p1c/volumevariables.hh @@ -51,7 +51,7 @@ class TwoPOneCVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> using Indices = typename GET_PROP_TYPE(TypeTag, Indices); enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), wPhaseIdx = Indices::wPhaseIdx, nPhaseIdx = Indices::nPhaseIdx, diff --git a/dumux/porousmediumflow/2p2c/model.hh b/dumux/porousmediumflow/2p2c/model.hh index 86b53313581161c84e5901bb9366a1d625a81252..51b951b0b38b0c87a761f643fbe2238d260f72e0 100644 --- a/dumux/porousmediumflow/2p2c/model.hh +++ b/dumux/porousmediumflow/2p2c/model.hh @@ -97,6 +97,22 @@ #include "vtkoutputfields.hh" namespace Dumux { + +/*! + * \ingroup TwoPTwoCModel + * \brief Specifies a number properties of two-phase two-component models. + */ +struct TwoPTwoCModelTraits +{ + static constexpr int numEq() { return 2; } + static constexpr int numPhases() { return 2; } + static constexpr int numComponents() { return 2; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { ////////////////////////////////////////////////////////////////// @@ -109,33 +125,17 @@ NEW_TYPE_TAG(TwoPTwoCNI, INHERITS_FROM(TwoPTwoC, NonIsothermal)); // Property values ////////////////////////////////////////////////////////////////// -//! Set the number of equations to 2 -SET_INT_PROP(TwoPTwoC, NumEq, 2); - -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system and use a static - * assert to make sure it is 2. - */ -SET_PROP(TwoPTwoC, NumComponents) -{ - static constexpr int value = 2; - static_assert(GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents == value, - "Only fluid systems with 2 components are supported by the 2p-2c model!"); -}; - /*! - * \brief Set the property for the number of fluid phases. - * - * We just forward the number from the fluid system and use a static - * assert to make sure it is 2. + * \brief Set the model traits property. */ -SET_PROP(TwoPTwoC, NumPhases) +SET_PROP(TwoPTwoC, ModelTraits) { - static constexpr int value = 2; - static_assert(GET_PROP_TYPE(TypeTag, FluidSystem)::numPhases == value, - "Only fluid systems with 2 phases are supported by the 2p-2c model!"); +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numComponents == 2, "Only fluid systems with 2 components are supported by the 2p-2c model!"); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 phases are supported by the 2p-2c model!"); +public: + using type = TwoPTwoCModelTraits; }; //! Set the vtk output fields specific to this model @@ -168,20 +168,11 @@ public: SET_INT_PROP(TwoPTwoC, Formulation, TwoPTwoCFormulation::pwsn); //! Set as default that no component mass balance is replaced by the total mass balance -SET_INT_PROP(TwoPTwoC, ReplaceCompEqIdx, GET_PROP_VALUE(TypeTag, NumComponents)); +SET_INT_PROP(TwoPTwoC, ReplaceCompEqIdx, GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()); //! Use the compositional local residual operator SET_TYPE_PROP(TwoPTwoC, LocalResidual, CompositionalLocalResidual<TypeTag>); -//! Enable advection -SET_BOOL_PROP(TwoPTwoC, EnableAdvection, true); - -//! Enable molecular diffusion -SET_BOOL_PROP(TwoPTwoC, EnableMolecularDiffusion, true); - -//! Isothermal model by default -SET_BOOL_PROP(TwoPTwoC, EnableEnergyBalance, false); - //! The primary variable switch for the 2p2c model SET_TYPE_PROP(TwoPTwoC, PrimaryVariableSwitch, TwoPTwoCPrimaryVariableSwitch<TypeTag>); @@ -190,7 +181,7 @@ SET_PROP(TwoPTwoC, PrimaryVariables) { private: using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>; public: using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; }; @@ -234,6 +225,17 @@ public: //! Set isothermal Indices SET_TYPE_PROP(TwoPTwoCNI, IsothermalIndices, TwoPTwoCIndices<typename GET_PROP_TYPE(TypeTag, FluidSystem), /*PVOffset=*/0>); +//! Set the isothermal model traits +SET_PROP(TwoPTwoCNI, IsothermalModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numComponents == 2, "Only fluid systems with 2 components are supported by the 2p-2c model!"); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 phases are supported by the 2p-2c model!"); +public: + using type = TwoPTwoCModelTraits; +}; + //! Set isothermal output fields SET_PROP(TwoPTwoCNI, IsothermalVtkOutputFields) { @@ -245,8 +247,6 @@ public: using type = TwoPTwoCVtkOutputFields<FluidSystem, Indices>; }; -// Set isothermal NumEq -SET_INT_PROP(TwoPTwoCNI, IsothermalNumEq, 2); } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/2p2c/volumevariables.hh b/dumux/porousmediumflow/2p2c/volumevariables.hh index 4d9e26526dc448c0cb44e568d8bfef6fa72ca0b5..789340d4f1ccbd55c2426dd596ec7fced6a2379b 100644 --- a/dumux/porousmediumflow/2p2c/volumevariables.hh +++ b/dumux/porousmediumflow/2p2c/volumevariables.hh @@ -100,8 +100,8 @@ class TwoPTwoCVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> using MiscibleMultiPhaseComposition = Dumux::MiscibleMultiPhaseComposition<Scalar, FluidSystem, useKelvinEquation>; - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); public: //! The type of the object returned by the fluidState() method using FluidState = typename GET_PROP_TYPE(TypeTag, FluidState); diff --git a/dumux/porousmediumflow/2pnc/model.hh b/dumux/porousmediumflow/2pnc/model.hh index 76485dfb9139ec5b1e9eea64c07050375393307c..378df7e2b72fa3419c9cb048b777b08da7c1d2a2 100644 --- a/dumux/porousmediumflow/2pnc/model.hh +++ b/dumux/porousmediumflow/2pnc/model.hh @@ -106,6 +106,25 @@ namespace Dumux { +/*! + * \ingroup TwoPNCModel + * \brief Specifies a number properties of two-phase n-component models. + * + * \Å£param nComp the number of components to be considered. + */ +template<int nComp> +struct TwoPNCModelTraits +{ + static constexpr int numEq() { return nComp; } + static constexpr int numPhases() { return 2; } + static constexpr int numComponents() { return nComp; } + static constexpr int numMajorComponents() { return 2; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { ////////////////////////////////////////////////////////////////// @@ -122,7 +141,7 @@ SET_PROP(TwoPNC, PrimaryVariables) { private: using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>; public: using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; }; @@ -131,6 +150,17 @@ SET_TYPE_PROP(TwoPNC, PrimaryVariableSwitch, TwoPNCPrimaryVariableSwitch<TypeTag SET_TYPE_PROP(TwoPNC, VolumeVariables, TwoPNCVolumeVariables<TypeTag>); //!< the VolumeVariables property SET_TYPE_PROP(TwoPNC, SpatialParams, FVSpatialParams<TypeTag>); //!< Use the FVSpatialParams by default +//! Set the model traits +SET_PROP(TwoPNC, ModelTraits) +{ +private: + //! we use the number of components specified by the fluid system here + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 fluid phases are supported by the 2p-nc model!"); +public: + using type = TwoPNCModelTraits<FluidSystem::numComponents>; +}; + //! Set the vtk output fields specific to this model SET_PROP(TwoPNC, VtkOutputFields) { @@ -144,15 +174,10 @@ public: SET_TYPE_PROP(TwoPNC, LocalResidual, CompositionalLocalResidual<TypeTag>); //!< Use the compositional local residual -SET_INT_PROP(TwoPNC, NumComponents, GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents); //!< Use the number of components of the fluid system SET_INT_PROP(TwoPNC, ReplaceCompEqIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents); //!< Per default, no component mass balance is replaced -SET_INT_PROP(TwoPNC, NumEq, GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents); //!< We solve one equation per component SET_INT_PROP(TwoPNC, Formulation, TwoPNCFormulation::pwsn); //!< Default formulation is pw-Sn, overwrite if necessary SET_BOOL_PROP(TwoPNC, SetMoleFractionsForWettingPhase, true); //!< Set the primary variables mole fractions for the wetting or non-wetting phase -SET_BOOL_PROP(TwoPNC, EnableAdvection, true); //!< Enable advection -SET_BOOL_PROP(TwoPNC, EnableMolecularDiffusion, true); //!< Enable molecular diffusion -SET_BOOL_PROP(TwoPNC, EnableEnergyBalance, false); //!< This is the isothermal variant of the model SET_BOOL_PROP(TwoPNC, UseMoles, true); //!< Use mole fractions in the balance equations by default //! The indices required by the isothermal 2pnc model @@ -167,28 +192,6 @@ public: //! Use the model after Millington (1961) for the effective diffusivity SET_TYPE_PROP(TwoPNC, EffectiveDiffusivityModel, DiffusivityMillingtonQuirk<typename GET_PROP_TYPE(TypeTag, Scalar)>); -//! The major components belonging to the existing phases, e.g. 2 for water and air being the major components in a liquid-gas-phase system -SET_PROP(TwoPNC, NumMajorComponents) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - -public: - static const int value = FluidSystem::numPhases; - static_assert(value == 2, "The model is restricted to two phases, thus number of major components must also be two."); -}; - -//! We use the number of phases of the fluid system. Make sure it is 2! -SET_PROP(TwoPNC, NumPhases) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - -public: - static const int value = FluidSystem::numPhases; - static_assert(value == 2, "Only fluid systems with 2 fluid phases are supported by the 2p-nc model!"); -}; - //! This model uses the compositional fluid state SET_PROP(TwoPNC, FluidState) { @@ -205,6 +208,17 @@ public: SET_TYPE_PROP(TwoPNCNI, IsothermalVolumeVariables, TwoPNCVolumeVariables<TypeTag>); //!< set isothermal VolumeVariables SET_TYPE_PROP(TwoPNCNI, IsothermalLocalResidual, CompositionalLocalResidual<TypeTag>); //!< set isothermal LocalResidual +//! Set the isothermal model traits +SET_PROP(TwoPNCNI, IsothermalModelTraits) +{ +private: + //! we use the number of components specified by the fluid system here + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 fluid phases are supported by the 2p-nc model!"); +public: + using type = TwoPNCModelTraits<FluidSystem::numComponents>; +}; + //! Set isothermal output fields SET_PROP(TwoPNCNI, IsothermalVtkOutputFields) { @@ -236,16 +250,6 @@ public: using type = ThermalConductivitySomerton<Scalar, Indices>; }; -//! set isothermal NumEq -SET_PROP(TwoPNCNI, IsothermalNumEq) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); - -public: - static const int value = FluidSystem::numComponents; -}; - } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/2pnc/primaryvariableswitch.hh b/dumux/porousmediumflow/2pnc/primaryvariableswitch.hh index a5e7a41cc189a2f74061762163ec625e1d822d15..1c879493636c39cd9c39b0e76808dfd9632578f5 100644 --- a/dumux/porousmediumflow/2pnc/primaryvariableswitch.hh +++ b/dumux/porousmediumflow/2pnc/primaryvariableswitch.hh @@ -50,8 +50,8 @@ class TwoPNCPrimaryVariableSwitch using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static const int numMajorComponents = GET_PROP_VALUE(TypeTag, NumMajorComponents); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); + static const int numMajorComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numMajorComponents(); enum { diff --git a/dumux/porousmediumflow/2pnc/volumevariables.hh b/dumux/porousmediumflow/2pnc/volumevariables.hh index ec6380fdf63707910f52e370a1bd1dbab50e6768..ab9e9dd9e3efa87f77938f99f4371d79619f6f89 100644 --- a/dumux/porousmediumflow/2pnc/volumevariables.hh +++ b/dumux/porousmediumflow/2pnc/volumevariables.hh @@ -64,9 +64,9 @@ class TwoPNCVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents), - numMajorComponents = GET_PROP_VALUE(TypeTag, NumMajorComponents), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), + numMajorComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numMajorComponents(), // formulations formulation = GET_PROP_VALUE(TypeTag, Formulation), diff --git a/dumux/porousmediumflow/2pncmin/model.hh b/dumux/porousmediumflow/2pncmin/model.hh index 15872278ef90fcd5672a401fea94700614fe44f5..12609ccbc53fc511a4e065f461286c1b57fb3155 100644 --- a/dumux/porousmediumflow/2pncmin/model.hh +++ b/dumux/porousmediumflow/2pncmin/model.hh @@ -121,11 +121,35 @@ public: using type = TwoPNCVtkOutputFields<FluidSystem, Indices>; }; +//! The 2pnc model traits define the non-mineralization part +SET_PROP(TwoPNCMin, NonMineralizationModelTraits) +{ +private: + //! we use the number of components specified by the fluid system here + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 fluid phases are supported by the 2p-nc model!"); +public: + using type = TwoPNCModelTraits<FluidSystem::numComponents>; +}; + ////////////////////////////////////////////////////////////////// // Properties for the non-isothermal 2pncmin model ////////////////////////////////////////////////////////////////// SET_TYPE_PROP(TwoPNCMinNI, IsothermalVolumeVariables, MineralizationVolumeVariables<TypeTag>); //!< set isothermal VolumeVariables +//! Use 2pncmin traits as isothermal model traits +SET_PROP(TwoPNCMinNI, IsothermalModelTraits) +{ +private: + //! we use the number of components specified by the fluid system here + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numPhases == 2, "Only fluid systems with 2 fluid phases are supported by the 2p-nc model!"); + using TwoPNCTraits = TwoPNCModelTraits<FluidSystem::numComponents>; +public: + // the mineralization traits, based on 2pnc traits, are the isothermal traits + using type = MineralizationModelTraits<TwoPNCTraits, FluidSystem::numSPhases>; +}; + //! isothermal vtkoutput SET_PROP(TwoPNCMinNI, IsothermalVtkOutputFields) { diff --git a/dumux/porousmediumflow/3p/model.hh b/dumux/porousmediumflow/3p/model.hh index 709c1152641e468ae41fb7375c9541f0264696a2..807ae3f4e75ea12fe247182ab9813f5274b23b36 100644 --- a/dumux/porousmediumflow/3p/model.hh +++ b/dumux/porousmediumflow/3p/model.hh @@ -71,6 +71,22 @@ #include "vtkoutputfields.hh" namespace Dumux { + +/*! + * \ingroup ThreePModel + * \brief Specifies a number properties of three-phase models. + */ +struct ThreePModelTraits +{ + static constexpr int numEq() { return 3; } + static constexpr int numPhases() { return 3; } + static constexpr int numComponents() { return 3; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return false; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { ////////////////////////////////////////////////////////////////// @@ -84,55 +100,21 @@ NEW_TYPE_TAG(ThreePNI, INHERITS_FROM(ThreeP, NonIsothermal)); ////////////////////////////////////////////////////////////////// // Properties for the isothermal 3p model ////////////////////////////////////////////////////////////////// -/*! - * \brief Set the property for the number of fluid phases. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 3. - */ -SET_PROP(ThreeP, NumPhases) -{ - private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - - public: - static const int value = FluidSystem::numPhases; - static_assert(value == 3, - "Only fluid systems with 3 phases are supported by the 3p model!"); -}; -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 3. - */ -SET_PROP(ThreeP, NumComponents) +//! Set the model traits +SET_PROP(ThreeP, ModelTraits) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - + static_assert(FluidSystem::numPhases == 3, "Only fluid systems with 3 phases are supported by the 3p model!"); + static_assert(FluidSystem::numComponents == 3, "Only fluid systems with 3 components are supported by the 3p model!"); public: - static const int value = FluidSystem::numComponents; - static_assert(value == 3, - "Only fluid systems with 3 components are supported by the 3p model!"); + using type = ThreePModelTraits; }; -//! Set the number of equations to 3 -SET_INT_PROP(ThreeP, NumEq, 3); - //! The local residual function of the conservation equations SET_TYPE_PROP(ThreeP, LocalResidual, ImmiscibleLocalResidual<TypeTag>); -//! Enable advection -SET_BOOL_PROP(ThreeP, EnableAdvection, true); - -//! Disable molecular diffusion for the 3p model -SET_BOOL_PROP(ThreeP, EnableMolecularDiffusion, false); - -//! Isothermal model by default -SET_BOOL_PROP(ThreeP, EnableEnergyBalance, false); - //! The VolumeVariables property SET_TYPE_PROP(ThreeP, VolumeVariables, ThreePVolumeVariables<TypeTag>); @@ -219,9 +201,16 @@ public: using type = ThreePIndices<FluidSystem,/*PVOffset=*/0>; }; - -//! Set isothermal NumEq -SET_INT_PROP(ThreePNI, IsothermalNumEq, 3); +//! Set isothermal model traits +SET_PROP(ThreePNI, IsothermalModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numPhases == 3, "Only fluid systems with 3 phases are supported by the 3p model!"); + static_assert(FluidSystem::numComponents == 3, "Only fluid systems with 3 components are supported by the 3p model!"); +public: + using type = ThreePModelTraits; +}; } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/3p/volumevariables.hh b/dumux/porousmediumflow/3p/volumevariables.hh index cfb6e044800f605749e8ffb09bfdc6e59cb2b185..3a447893771d700d27deb7bdd65638a9c767195a 100644 --- a/dumux/porousmediumflow/3p/volumevariables.hh +++ b/dumux/porousmediumflow/3p/volumevariables.hh @@ -55,7 +55,7 @@ class ThreePVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using Element = typename GridView::template Codim<0>::Entity; enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), wPhaseIdx = Indices::wPhaseIdx, gPhaseIdx = Indices::gPhaseIdx, diff --git a/dumux/porousmediumflow/3p3c/localresidual.hh b/dumux/porousmediumflow/3p3c/localresidual.hh index fe8f616183218198b550103232a76876dd4fe6c4..b3c76110a0d0dd5a205ae241fff49f1c8db0d44d 100644 --- a/dumux/porousmediumflow/3p3c/localresidual.hh +++ b/dumux/porousmediumflow/3p3c/localresidual.hh @@ -57,8 +57,8 @@ class ThreePThreeCLocalResidual: public GET_PROP_TYPE(TypeTag, BaseLocalResidual using EnergyLocalResidual = typename GET_PROP_TYPE(TypeTag, EnergyLocalResidual); enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), conti0EqIdx = Indices::conti0EqIdx,//!< index of the mass conservation equation for the water component conti1EqIdx = Indices::conti1EqIdx,//!< index of the mass conservation equation for the contaminant component diff --git a/dumux/porousmediumflow/3p3c/model.hh b/dumux/porousmediumflow/3p3c/model.hh index 438d45a073f1b250f55135b805ea16adf99674f6..632393eed345806053d09202e60d42aeda3697d9 100644 --- a/dumux/porousmediumflow/3p3c/model.hh +++ b/dumux/porousmediumflow/3p3c/model.hh @@ -97,6 +97,22 @@ #include "localresidual.hh" namespace Dumux { + +/*! + * \ingroup ThreePThreeCModel + * \brief Specifies a number properties of two-phase models. + */ +struct ThreePThreeCModelTraits +{ + static constexpr int numEq() { return 3; } + static constexpr int numPhases() { return 3; } + static constexpr int numComponents() { return 3; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { //! The type tags for the isothermal three-phase three-component model NEW_TYPE_TAG(ThreePThreeC, INHERITS_FROM(PorousMediumFlow)); @@ -106,34 +122,20 @@ NEW_TYPE_TAG(ThreePThreeCNI, INHERITS_FROM(ThreePThreeC, NonIsothermal)); ////////////////////////////////////////////////////////////////// // Property values ////////////////////////////////////////////////////////////////// -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 3. - */ -SET_PROP(ThreePThreeC, NumComponents) -{ - static const int value = 3; - static_assert(value == GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents, - "Only fluid systems with 3 components are supported by the 3p3c model!"); -}; -/*! - * \brief Set the property for the number of fluid phases. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 3. - */ -SET_PROP(ThreePThreeC, NumPhases) +//! Set the model traits +SET_PROP(ThreePThreeC, ModelTraits) { - static const int value = 3; - static_assert(value == GET_PROP_TYPE(TypeTag, FluidSystem)::numPhases, - "Only fluid systems with 3 phases are supported by the 3p3c model!"); +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numComponents == 3, "Only fluid systems with 3 components are supported by the 3p3c model!"); + static_assert(FluidSystem::numPhases == 3, "Only fluid systems with 3 phases are supported by the 3p3c model!"); +public: + using type = ThreePThreeCModelTraits; }; //! Set as default that no component mass balance is replaced by the total mass balance -SET_INT_PROP(ThreePThreeC, ReplaceCompEqIdx, GET_PROP_VALUE(TypeTag, NumComponents)); +SET_INT_PROP(ThreePThreeC, ReplaceCompEqIdx, GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()); /*! * \brief The fluid state which is used by the volume variables to * store the thermodynamic state. This should be chosen @@ -148,21 +150,9 @@ SET_PROP(ThreePThreeC, FluidState){ using type = CompositionalFluidState<Scalar, FluidSystem>; }; -//! Set the number of equations to 3 -SET_INT_PROP(ThreePThreeC, NumEq, 3); - //! The local residual function of the conservation equations SET_TYPE_PROP(ThreePThreeC, LocalResidual, ThreePThreeCLocalResidual<TypeTag>); -//! Enable advection -SET_BOOL_PROP(ThreePThreeC, EnableAdvection, true); - -//! Enable molecular diffusion -SET_BOOL_PROP(ThreePThreeC, EnableMolecularDiffusion, true); - -//! Isothermal model by default -SET_BOOL_PROP(ThreePThreeC, EnableEnergyBalance, false); - //! The primary variable switch for the 3p3c model SET_TYPE_PROP(ThreePThreeC, PrimaryVariableSwitch, ThreePThreeCPrimaryVariableSwitch<TypeTag>); @@ -171,7 +161,7 @@ SET_PROP(ThreePThreeC, PrimaryVariables) { private: using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>; public: using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; }; @@ -246,7 +236,15 @@ public: }; //! Set isothermal NumEq -SET_INT_PROP(ThreePThreeCNI, IsothermalNumEq, 3); +SET_PROP(ThreePThreeCNI, IsothermalModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + static_assert(FluidSystem::numComponents == 3, "Only fluid systems with 3 components are supported by the 3p3c model!"); + static_assert(FluidSystem::numPhases == 3, "Only fluid systems with 3 phases are supported by the 3p3c model!"); +public: + using type = ThreePThreeCModelTraits; +}; //! Set the isothermal vktoutputfields SET_PROP(ThreePThreeCNI, IsothermalVtkOutputFields) diff --git a/dumux/porousmediumflow/3p3c/volumevariables.hh b/dumux/porousmediumflow/3p3c/volumevariables.hh index 7f4de97783cc15fb16683326f4bad08287426fd0..977ef7ed5803da15b5dc078aeaf1cd5cb2720ed7 100644 --- a/dumux/porousmediumflow/3p3c/volumevariables.hh +++ b/dumux/porousmediumflow/3p3c/volumevariables.hh @@ -59,8 +59,8 @@ class ThreePThreeCVolumeVariables : public PorousMediumFlowVolumeVariables<TypeT using ComputeFromReferencePhase = Dumux::ComputeFromReferencePhase<Scalar, FluidSystem>; using Indices = typename GET_PROP_TYPE(TypeTag, Indices); enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), wCompIdx = Indices::wCompIdx, gCompIdx = Indices::gCompIdx, diff --git a/dumux/porousmediumflow/3pwateroil/localresidual.hh b/dumux/porousmediumflow/3pwateroil/localresidual.hh index a62a0bd42cf0ce748018d46656b3ffb61911eaad..2a6e504db3d906b07b7fb09254cf43a5b2f2d2d3 100644 --- a/dumux/porousmediumflow/3pwateroil/localresidual.hh +++ b/dumux/porousmediumflow/3pwateroil/localresidual.hh @@ -60,8 +60,8 @@ protected: enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), conti0EqIdx = Indices::conti0EqIdx,//!< Index of the mass conservation equation for the water component conti1EqIdx = Indices::conti1EqIdx,//!< Index of the mass conservation equation for the contaminant component diff --git a/dumux/porousmediumflow/3pwateroil/model.hh b/dumux/porousmediumflow/3pwateroil/model.hh index 376c5d95ce792e05d8e7072c2c40574cced0d332..a2b8404f46761cfbc8981502cf2e5d101fdbdbf1 100644 --- a/dumux/porousmediumflow/3pwateroil/model.hh +++ b/dumux/porousmediumflow/3pwateroil/model.hh @@ -91,11 +91,22 @@ namespace Dumux { + /*! * \ingroup ThreePWaterOilModel - * \brief Adaption of the fully implicit scheme to the three-phase two-component flow model. - * + * \brief Specifies a number properties of the three-phase two-component model. */ +struct ThreePWaterOilModelTraits +{ + static constexpr int numEq() { return 2; } + static constexpr int numPhases() { return 3; } + static constexpr int numComponents() { return 2; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { NEW_TYPE_TAG(ThreePWaterOilNI, INHERITS_FROM(PorousMediumFlow, NonIsothermal)); @@ -104,39 +115,15 @@ NEW_TYPE_TAG(ThreePWaterOilNI, INHERITS_FROM(PorousMediumFlow, NonIsothermal)); // Property values ////////////////////////////////////////////////////////////////// -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 2. - */ -SET_PROP(ThreePWaterOilNI, NumComponents) -{ - private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - - public: - static const int value = FluidSystem::numComponents; - - static_assert(value == 2, - "Only fluid systems with 2 components are supported by the 3p2cni model!"); -}; - -/*! - * \brief Set the property for the number of fluid phases. - * - * We just forward the number from the fluid system and use an static - * assert to make sure it is 2. - */ -SET_PROP(ThreePWaterOilNI, NumPhases) +//! Set the isothermal model traits property +SET_PROP(ThreePWaterOilNI, IsothermalModelTraits) { - private: +private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - - public: - static const int value = FluidSystem::numPhases; - static_assert(value == 3, - "Only fluid systems with 3 phases are supported by the 3p2cni model!"); + static_assert(FluidSystem::numComponents == 2, "Only fluid systems with 2 components are supported by the 3p2cni model!"); + static_assert(FluidSystem::numPhases == 3, "Only fluid systems with 3 phases are supported by the 3p2cni model!"); +public: + using type = ThreePWaterOilModelTraits; }; /*! @@ -157,16 +144,7 @@ SET_PROP(ThreePWaterOilNI, FluidState){ SET_TYPE_PROP(ThreePWaterOilNI, LocalResidual, ThreePWaterOilLocalResidual<TypeTag>); //! Set as default that no component mass balance is replaced by the total mass balance -SET_INT_PROP(ThreePWaterOilNI, ReplaceCompEqIdx, GET_PROP_VALUE(TypeTag, NumComponents)); - -//! Enable advection -SET_BOOL_PROP(ThreePWaterOilNI, EnableAdvection, true); - -//! disable molecular diffusion for the 3p model -SET_BOOL_PROP(ThreePWaterOilNI, EnableMolecularDiffusion, true); - -//! Isothermal model by default -SET_BOOL_PROP(ThreePWaterOilNI, EnableEnergyBalance, true); +SET_INT_PROP(ThreePWaterOilNI, ReplaceCompEqIdx, GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()); //! The primary variable switch for the 3p3c model SET_TYPE_PROP(ThreePWaterOilNI, PrimaryVariableSwitch, ThreePWaterOilPrimaryVariableSwitch<TypeTag>); @@ -176,7 +154,7 @@ SET_PROP(ThreePWaterOilNI, PrimaryVariables) { private: using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>; public: using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; }; @@ -234,11 +212,6 @@ public: using type = ThreePWaterOilIndices<FluidSystem, /*PVOffset=*/0>; }; -//set isothermal NumEq -SET_INT_PROP(ThreePWaterOilNI, IsothermalNumEq, 2); - } - - } - +} #endif diff --git a/dumux/porousmediumflow/3pwateroil/volumevariables.hh b/dumux/porousmediumflow/3pwateroil/volumevariables.hh index 87830c85b3a9118097bd5f93c2aac303a5611f21..823adbbc501c1ef55911299d94dd528cf52c38bb 100644 --- a/dumux/porousmediumflow/3pwateroil/volumevariables.hh +++ b/dumux/porousmediumflow/3pwateroil/volumevariables.hh @@ -63,8 +63,8 @@ class ThreePWaterOilVolumeVariables : public PorousMediumFlowVolumeVariables<Typ using SubControlVolume = typename FVElementGeometry::SubControlVolume; enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents), + numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(), + numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(), wCompIdx = Indices::wCompIdx, nCompIdx = Indices::nCompIdx, diff --git a/dumux/porousmediumflow/co2/volumevariables.hh b/dumux/porousmediumflow/co2/volumevariables.hh index d67f0dd579a1bae77224034a1851a73bed3de16e..b193b4659c2be37c808412a72fe0aa8b8a6301d3 100644 --- a/dumux/porousmediumflow/co2/volumevariables.hh +++ b/dumux/porousmediumflow/co2/volumevariables.hh @@ -49,7 +49,7 @@ class TwoPTwoCCO2VolumeVariables : public TwoPTwoCVolumeVariables<TypeTag> using MaterialLaw = typename GET_PROP_TYPE(TypeTag, MaterialLaw); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; enum { wCompIdx = Indices::wCompIdx, diff --git a/dumux/porousmediumflow/compositional/localresidual.hh b/dumux/porousmediumflow/compositional/localresidual.hh index 7edf93259be4c545b4dc909a6fb8441485777b0e..dcb303ec835a254a5c465c92ea9f97b85ce57dee 100644 --- a/dumux/porousmediumflow/compositional/localresidual.hh +++ b/dumux/porousmediumflow/compositional/localresidual.hh @@ -55,9 +55,10 @@ class CompositionalLocalResidual: public GET_PROP_TYPE(TypeTag, BaseLocalResidua using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using EnergyLocalResidual = typename GET_PROP_TYPE(TypeTag, EnergyLocalResidual); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = ModelTraits::numPhases(); + static constexpr int numComponents = ModelTraits::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); enum { conti0EqIdx = Indices::conti0EqIdx }; diff --git a/dumux/porousmediumflow/fluxvariables.hh b/dumux/porousmediumflow/fluxvariables.hh index 31d8045235b49c1abb0dfc97217edb24266d8ce8..40af4a14f16b4905dc2f1323f1d06d4b98eb9495 100644 --- a/dumux/porousmediumflow/fluxvariables.hh +++ b/dumux/porousmediumflow/fluxvariables.hh @@ -44,6 +44,7 @@ class PorousMediumFluxVariables : public FluxVariablesBase<TypeTag, PorousMedium using ParentType = FluxVariablesBase<TypeTag, ThisType>; using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using FVElementGeometry = typename FVGridGeometry::LocalView; using GridView = typename FVGridGeometry::GridView; @@ -55,8 +56,10 @@ class PorousMediumFluxVariables : public FluxVariablesBase<TypeTag, PorousMedium using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache); - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents) + enum + { + numPhases = ModelTraits::numPhases(), + numComponents = ModelTraits::numComponents() }; public: @@ -64,9 +67,9 @@ public: using MolecularDiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType); using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType); - static constexpr bool enableAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection); - static constexpr bool enableMolecularDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion); - static constexpr bool enableEnergyBalance = GET_PROP_VALUE(TypeTag, EnableEnergyBalance); + static constexpr bool enableAdvection = ModelTraits::enableAdvection(); + static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion(); + static constexpr bool enableEnergyBalance = ModelTraits::enableEnergyBalance(); static constexpr bool enableThermalNonEquilibrium = GET_PROP_VALUE(TypeTag, EnableThermalNonEquilibrium); //! The constructor diff --git a/dumux/porousmediumflow/fluxvariablescache.hh b/dumux/porousmediumflow/fluxvariablescache.hh index 0550d8b4a6e1761973d9c62830505b639c70c391..8c13835056a8c607f4f02efd527e721610fae8b4 100644 --- a/dumux/porousmediumflow/fluxvariablescache.hh +++ b/dumux/porousmediumflow/fluxvariablescache.hh @@ -137,18 +137,18 @@ template<class TypeTag> class EnergyCacheChooser<TypeTag, true> : public GET_PRO // specialization for the cell centered tpfa method template<class TypeTag> class PorousMediumFluxVariablesCacheImplementation<TypeTag, DiscretizationMethod::cctpfa> -: public AdvectionCacheChooser<TypeTag, GET_PROP_VALUE(TypeTag, EnableAdvection)> -, public DiffusionCacheChooser<TypeTag, GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion)> -, public EnergyCacheChooser<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)> +: public AdvectionCacheChooser<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableAdvection()> +, public DiffusionCacheChooser<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableMolecularDiffusion()> +, public EnergyCacheChooser<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableEnergyBalance()> {}; //! specialization of the flux variables cache for the cell centered finite volume mpfa scheme //! stores data which is commonly used by all the different types of processes template<class TypeTag> class PorousMediumFluxVariablesCacheImplementation<TypeTag, DiscretizationMethod::ccmpfa> -: public AdvectionCacheChooser<TypeTag, GET_PROP_VALUE(TypeTag, EnableAdvection)> -, public DiffusionCacheChooser<TypeTag, GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion)> -, public EnergyCacheChooser<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)> +: public AdvectionCacheChooser<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableAdvection()> +, public DiffusionCacheChooser<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableMolecularDiffusion()> +, public EnergyCacheChooser<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableEnergyBalance()> { using GridIndexType = typename GET_PROP_TYPE(TypeTag, GridView)::IndexSet::IndexType; diff --git a/dumux/porousmediumflow/immiscible/localresidual.hh b/dumux/porousmediumflow/immiscible/localresidual.hh index b7bd6864a576769db6ae38f7893cc148270ab25a..200079cc4f7b60b7e8f37b03f8c5c6ab10a495de 100644 --- a/dumux/porousmediumflow/immiscible/localresidual.hh +++ b/dumux/porousmediumflow/immiscible/localresidual.hh @@ -55,7 +55,7 @@ class ImmiscibleLocalResidual : public GET_PROP_TYPE(TypeTag, BaseLocalResidual) // first index for the mass balance enum { conti0EqIdx = Indices::conti0EqIdx }; - static const int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static const int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); public: using ParentType::ParentType; diff --git a/dumux/porousmediumflow/mineralization/localresidual.hh b/dumux/porousmediumflow/mineralization/localresidual.hh index 97f3e17c69a2909e10f816b913a6f42e492ad580..0eddfe8366e930de1e403a9c1d7350f23000b3a0 100644 --- a/dumux/porousmediumflow/mineralization/localresidual.hh +++ b/dumux/porousmediumflow/mineralization/localresidual.hh @@ -44,10 +44,11 @@ class MineralizationLocalResidual: public CompositionalLocalResidual<TypeTag> using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); using Problem = typename GET_PROP_TYPE(TypeTag, Problem); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numSPhases = GET_PROP_VALUE(TypeTag, NumSPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = ModelTraits::numPhases(); + static constexpr int numSPhases = ModelTraits::numSPhases(); + static constexpr int numComponents = ModelTraits::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); enum { conti0EqIdx = Indices::conti0EqIdx }; diff --git a/dumux/porousmediumflow/mineralization/model.hh b/dumux/porousmediumflow/mineralization/model.hh index 482d3415a3c7bf1c0dd020b56762bf32045e738d..4c5b3cfef6a87e61a9f4f69de80c72334fa96456 100644 --- a/dumux/porousmediumflow/mineralization/model.hh +++ b/dumux/porousmediumflow/mineralization/model.hh @@ -36,12 +36,41 @@ #include "vtkoutputfields.hh" namespace Dumux { + +/*! + * \ingroup OnePModel + * \brief Specifies a number properties of + * models that consider mineralization proceses. + * + * \Å£param NonMinTraits traits class of the underlying model + * not considering mineralization. + * \tparam numPS number of precipitating solid phases to be considered. + */ +template<class NonMinTraits, int numPS> +struct MineralizationModelTraits : public NonMinTraits +{ + //! the number of precipitating mineral phases + static constexpr int numSPhases() { return numPS; } + //! we additionally solve one equation per precipitating mineral phase + static constexpr int numEq() { return NonMinTraits::numEq() + numPS; } +}; + namespace Properties { ////////////////////////////////////////////////////////////////// // Type tags ////////////////////////////////////////////////////////////////// NEW_TYPE_TAG(Mineralization); +//! Set the model traits class +SET_PROP(Mineralization, ModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + using NonMinTraits = typename GET_PROP_TYPE(TypeTag, NonMineralizationModelTraits); +public: + using type = MineralizationModelTraits<NonMinTraits, FluidSystem::numSPhases>; +}; + //! Set the general mineralization volume variables SET_TYPE_PROP(Mineralization, VolumeVariables, MineralizationVolumeVariables<TypeTag>); @@ -59,25 +88,6 @@ public: using type = MineralizationVtkOutputFields<NonMineralizationVtkOutputFields, FluidSystem>; }; -//! Set the property for the number of solid phases, excluding the non-reactive matrix. -SET_PROP(Mineralization, NumSPhases) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); -public: - static const int value = FluidSystem::numSPhases; -}; - -//! Set the property for the number of equations. For each component and each -//precipitated mineral/solid phase one equation has to be solved. -SET_PROP(Mineralization, NumEq) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, PTAG(FluidSystem)); -public: - static const int value = FluidSystem::numComponents + FluidSystem::numSPhases; -}; - } // end namespace Properties } // end namespace Dumux diff --git a/dumux/porousmediumflow/mineralization/volumevariables.hh b/dumux/porousmediumflow/mineralization/volumevariables.hh index 2e8b5941ef74c0bd900b710cc5ac98c0671450ee..77057c55d1c60148a12e55097979cd552636ff6e 100644 --- a/dumux/porousmediumflow/mineralization/volumevariables.hh +++ b/dumux/porousmediumflow/mineralization/volumevariables.hh @@ -47,12 +47,12 @@ class MineralizationVolumeVariables : public GET_PROP_TYPE(TypeTag, NonMineraliz using SubControlVolume = typename FVElementGeometry::SubControlVolume; using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using Element = typename GridView::template Codim<0>::Entity; - + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); enum { - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), - numSPhases = GET_PROP_VALUE(TypeTag, NumSPhases), - numComponents = GET_PROP_VALUE(TypeTag, NumComponents) + numPhases = ModelTraits::numPhases(), + numSPhases = ModelTraits::numSPhases(), + numComponents = ModelTraits::numComponents() }; public: diff --git a/dumux/porousmediumflow/mpnc/indices.hh b/dumux/porousmediumflow/mpnc/indices.hh index ff11f57995c49920c51acc6543dc254bc633c1f9..994e85a0a48585f98b4e0c5a2ae3d6b324a89ab3 100644 --- a/dumux/porousmediumflow/mpnc/indices.hh +++ b/dumux/porousmediumflow/mpnc/indices.hh @@ -46,24 +46,18 @@ struct MpNcPressureFormulation * \brief The primary variable and equation indices for the MpNc model. * * \tparam FluidSystem The fluid system class - * \tparam numEquationBalance Number of balance equations: all transport equations and the constraint equations + * \tparam numEqBalance Number of balance equations: all transport equations and the constraint equations * \tparam PVOffset The first index in a primary variable vector. */ -template <class FluidSystem, int numEquationBalance, int BasePVOffset = 0> +template <class FluidSystem, int numEqBalance, int BasePVOffset = 0> class MPNCIndices { enum { numPhases = FluidSystem::numPhases }; - static const int numEqBalance = numEquationBalance; public: - // Phase indices + //! Phase indices static const int wPhaseIdx = FluidSystem::wPhaseIdx; //!< Index of the wetting phase static const int nPhaseIdx = FluidSystem::nPhaseIdx; //!< Index of the non-wetting phase - /*! - * \brief The number of primary variables / equations. - */ - // temperature + Mass Balance + constraints for switch stuff - static const unsigned int numPrimaryVars = numEqBalance ; /*! * \brief Index of the saturation of the first phase in a vector diff --git a/dumux/porousmediumflow/mpnc/localresidual.hh b/dumux/porousmediumflow/mpnc/localresidual.hh index bf0d088680c0798396b6cd8094be7631cf0f1012..2605a68f736955313112d5acbee19630dab4fe9b 100644 --- a/dumux/porousmediumflow/mpnc/localresidual.hh +++ b/dumux/porousmediumflow/mpnc/localresidual.hh @@ -52,7 +52,7 @@ class MPNCLocalResidual : public CompositionalLocalResidual<TypeTag> using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); - enum {numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; + enum {numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()}; enum {phase0NcpIdx = Indices::phase0NcpIdx}; public: diff --git a/dumux/porousmediumflow/mpnc/model.hh b/dumux/porousmediumflow/mpnc/model.hh index cbde34dd594ac6ea49a60d058b10a61ef6bb6cad..ea90fd024e9aaea28797e4977f9ec15fe6dd9133 100644 --- a/dumux/porousmediumflow/mpnc/model.hh +++ b/dumux/porousmediumflow/mpnc/model.hh @@ -120,6 +120,30 @@ */ namespace Dumux { + +/*! + * \ingroup MPNCModel + * \brief Specifies a number properties of the m-phase n-component model. + * + * \tparam nPhases the number of phases to be considered + * \tparam nComp the number of components to be considered + */ +template<int nPhases, int nComp> +struct MPNCModelTraits +{ + static constexpr int numEq() { return numTransportEq()+numConstraintEq(); } + static constexpr int numPhases() { return nPhases; } + static constexpr int numComponents() { return nComp; } + static constexpr int numTransportEq() { return nComp;} + static constexpr int numConstraintEq() { return nPhases; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } + static constexpr bool enableThermalNonEquilibrium() { return false; } + static constexpr bool enableChemicalNonEquilibrium() { return false; } +}; + namespace Properties { @@ -140,63 +164,25 @@ SET_PROP(MPNC, Indices) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numEquationBalance = GET_PROP_VALUE(TypeTag, NumEqBalance); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); public: - using type = MPNCIndices<FluidSystem, numEquationBalance, /*PVOffset=*/0>; + using type = MPNCIndices<FluidSystem, numEq, /*PVOffset=*/0>; }; -//! Use ImplicitSpatialParams by default. -SET_TYPE_PROP(MPNC, SpatialParams, FVSpatialParams<TypeTag>); //! Use the MpNc local residual for the MpNc model SET_TYPE_PROP(MPNC, LocalResidual, MPNCLocalResidual<TypeTag>); -/*! - * \brief Set the property for the number of equations and primary variables. - */ -SET_PROP(MPNC, NumEq) -{ -private: - using Indices = typename GET_PROP_TYPE(TypeTag, Indices); -public: - static const unsigned int value = Indices::numPrimaryVars; -}; -/*! - * \brief Set the property for the number of components. - * - * We just forward the number from the fluid system. - */ -SET_PROP(MPNC, NumComponents) +//! Set the model traits property +SET_PROP(MPNC, ModelTraits) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - public: - static const unsigned int value = FluidSystem::numComponents; + using type = MPNCModelTraits<FluidSystem::numPhases, FluidSystem::numComponents>; }; -/*! - * \brief Set the property for the number of fluid phases. - */ -SET_PROP(MPNC, NumPhases) -{ -private: - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - -public: - static const unsigned int value = FluidSystem::numPhases; -}; - -/*! - * \brief Set the property for the number of equations without energyEquations. - * In other models this would just be number of mass balance equations. but in Mpnc we have additional ncp-equations which also need to be added - */ -SET_INT_PROP(MPNC, NumEqBalance, GET_PROP_VALUE(TypeTag, NumPhases)+GET_PROP_VALUE(TypeTag, NumPhases)); - -//! the VolumeVariables property -SET_TYPE_PROP(MPNC, VolumeVariables, MPNCVolumeVariables<TypeTag>); - //! This model uses the compositional fluid state SET_PROP(MPNC, FluidState) { @@ -207,14 +193,16 @@ public: using type = CompositionalFluidState<Scalar, FluidSystem>; }; -SET_INT_PROP(MPNC, ReplaceCompEqIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents); //! Per default, no component mass balance is replaced - -SET_BOOL_PROP(MPNC, UseMoles, true); //! Use mole fractions in the balance equations by default - +//! Use ImplicitSpatialParams by default. +SET_TYPE_PROP(MPNC, SpatialParams, FVSpatialParams<TypeTag>); +//! the VolumeVariables property +SET_TYPE_PROP(MPNC, VolumeVariables, MPNCVolumeVariables<TypeTag>); +//! Per default, no component mass balance is replaced +SET_INT_PROP(MPNC, ReplaceCompEqIdx, GET_PROP_TYPE(TypeTag, FluidSystem)::numComponents); +//! Use mole fractions in the balance equations by default +SET_BOOL_PROP(MPNC, UseMoles, true); //! Use the model after Millington (1961) for the effective diffusivity SET_TYPE_PROP(MPNC, EffectiveDiffusivityModel, DiffusivityMillingtonQuirk<typename GET_PROP_TYPE(TypeTag, Scalar)>); - - //! Set the default pressure formulation to the pressure of the (most) wetting phase SET_INT_PROP(MPNC, PressureFormulation, @@ -231,33 +219,30 @@ public: using type = MPNCVtkOutputFields<FluidSystem, Indices>; }; -SET_BOOL_PROP(MPNC, EnableAdvection, true); //! Enable advection -SET_BOOL_PROP(MPNC, EnableMolecularDiffusion, true); //! Enable molecular diffusion -SET_BOOL_PROP(MPNC, EnableEnergyBalance, false); //! This is the isothermal variant of the model - -SET_BOOL_PROP(MPNC, EnableThermalNonEquilibrium, false); -SET_BOOL_PROP(MPNC, EnableChemicalNonEquilibrium, false); - -SET_INT_PROP(MPNC, NumEnergyEqFluid, 0); -SET_INT_PROP(MPNC, NumEnergyEqSolid, 0); - - ///////////////////////////////////////////////// // Properties for the non-isothermal mpnc model ///////////////////////////////////////////////// SET_TYPE_PROP(MPNCNI, IsothermalVolumeVariables, MPNCVolumeVariables<TypeTag>); //! set isothermal VolumeVariables SET_TYPE_PROP(MPNCNI, IsothermalLocalResidual, MPNCLocalResidual<TypeTag>); //! set isothermal LocalResidual + +//! set the isothermal model traits +SET_PROP(MPNCNI, IsothermalModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); +public: + using type = MPNCModelTraits<FluidSystem::numPhases, FluidSystem::numComponents>; +}; + //! set isothermal Indices SET_PROP(MPNCNI, IsothermalIndices) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numEquationBalance = GET_PROP_VALUE(TypeTag, NumEqBalance); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, IsothermalModelTraits)::numEq(); public: - using type = MPNCIndices<FluidSystem, numEquationBalance, /*PVOffset=*/0>; + using type = MPNCIndices<FluidSystem, numEq, /*PVOffset=*/0>; }; -//! set isothermal NumEq -SET_INT_PROP(MPNCNI, IsothermalNumEq, GET_PROP_VALUE(TypeTag, NumEq)); ///////////////////////////////////////////////// // Properties for the non-equilibrium mpnc model @@ -271,7 +256,6 @@ SET_PROP(MPNCNonequil, EquilibriumVtkOutputFields) private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); - public: using type = MPNCVtkOutputFields<FluidSystem, Indices>; }; @@ -280,13 +264,23 @@ SET_PROP(MPNCNonequil, EquilibriumIndices) { private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numEquationBalance = GET_PROP_VALUE(TypeTag, NumEqBalance); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + + //! the mpnc indices need the number of all transport equations plus constraint equations + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numTransportEq() + +GET_PROP_TYPE(TypeTag, ModelTraits)::numConstraintEq(); public: - using type = MPNCIndices<FluidSystem, numEquationBalance, /*PVOffset=*/0>; + using type = MPNCIndices<FluidSystem, numEq, /*PVOffset=*/0>; }; -//number of balance equations means all transport equations and the constraint equations, energy equations come on top of that -SET_INT_PROP(MPNCNonequil, NumEqBalance, GET_PROP_VALUE(TypeTag, NumPhases)*GET_PROP_VALUE(TypeTag, NumComponents)+GET_PROP_VALUE(TypeTag, NumPhases)); +//! set equilibrium model traits +SET_PROP(MPNCNonequil, EquilibriumModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); +public: + using type = MPNCModelTraits<FluidSystem::numPhases, FluidSystem::numComponents>; +}; //! in case we do not assume full non-equilibrium one needs a thermal conductivity SET_PROP(MPNCNonequil, ThermalConductivityModel) diff --git a/dumux/porousmediumflow/mpnc/volumevariables.hh b/dumux/porousmediumflow/mpnc/volumevariables.hh index f741cda0323e80a3470c627464da25a41bd8d625..a67412966aad97c7b2d1ab3425851440632890b9 100644 --- a/dumux/porousmediumflow/mpnc/volumevariables.hh +++ b/dumux/porousmediumflow/mpnc/volumevariables.hh @@ -67,16 +67,15 @@ class MPNCVolumeVariables leastWettingFirst = MpNcPressureFormulation::leastWettingFirst }; - enum {numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; - enum {numComponents = GET_PROP_VALUE(TypeTag, NumComponents)}; + enum {numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()}; + enum {numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()}; enum {s0Idx = Indices::s0Idx}; enum {p0Idx = Indices::p0Idx}; enum {fug0Idx = Indices::fug0Idx}; - static constexpr bool enableThermalNonEquilibrium = GET_PROP_VALUE(TypeTag, EnableThermalNonEquilibrium); - static constexpr bool enableChemicalNonEquilibrium = GET_PROP_VALUE(TypeTag, EnableChemicalNonEquilibrium); - - static constexpr bool enableDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion); + static constexpr bool enableThermalNonEquilibrium = GET_PROP_TYPE(TypeTag, ModelTraits)::enableThermalNonEquilibrium(); + static constexpr bool enableChemicalNonEquilibrium = GET_PROP_TYPE(TypeTag, ModelTraits)::enableChemicalNonEquilibrium(); + static constexpr bool enableDiffusion = GET_PROP_TYPE(TypeTag, ModelTraits)::enableMolecularDiffusion(); using ComponentVector = Dune::FieldVector<Scalar, numComponents>; diff --git a/dumux/porousmediumflow/nonequilibrium/gridvariables.hh b/dumux/porousmediumflow/nonequilibrium/gridvariables.hh index 3f5a0cecb4f628d683ec64ae4b45159ca0ffc3f4..269866951fddc3835c6307ebb63c81ef744e6745 100644 --- a/dumux/porousmediumflow/nonequilibrium/gridvariables.hh +++ b/dumux/porousmediumflow/nonequilibrium/gridvariables.hh @@ -56,7 +56,7 @@ class NonEquilibriumGridVariables enum { dimWorld = GridView::dimensionworld }; using GlobalPosition = Dune::FieldVector<typename GridView::Grid::ctype, dimWorld>; - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); static constexpr bool isBox = FVGridGeometry::discMethod == DiscretizationMethod::box; public: diff --git a/dumux/porousmediumflow/nonequilibrium/indices.hh b/dumux/porousmediumflow/nonequilibrium/indices.hh index 3ff9b9d5906e5435504c07586744ba170e39ea65..fba15c9b0238e1fe4efeae70ded202018497fdd2 100644 --- a/dumux/porousmediumflow/nonequilibrium/indices.hh +++ b/dumux/porousmediumflow/nonequilibrium/indices.hh @@ -33,21 +33,13 @@ namespace Dumux * \ingroup PorousmediumNonEquilibriumModel * \brief The primary variable and equation indices for the MpNc model. */ -template <class EquilibriumIndices, class FluidSystem, int numEnergyEquationFluid, int numEnergyEquationSolid, int numEquationBalance, int BasePVOffset = 0> +template <class EquilibriumIndices, class FluidSystem, int numEnergyEquationFluid, int numEnergyEquationSolid, int numEq, int BasePVOffset = 0> class NonEquilbriumIndices: public EquilibriumIndices { public: enum { numPhases = FluidSystem::numPhases }; enum { numEnergyEqFluid = numEnergyEquationFluid }; enum { numEnergyEqSolid = numEnergyEquationSolid }; - /*! \todo Replacing the sum below with GET_PROP_VALUE(TypeTag, NumEq) - * yields a compilation error with clang, due to complex - * interdependencies of MPNC and NonEquilibrium type tags and - * Indices classes. This should be fixed. - */ - static const unsigned int numEq = numEquationBalance - + numEnergyEqFluid - + numEnergyEqSolid; /*! * \brief Index for the temperature of the wetting phase in a vector of primary diff --git a/dumux/porousmediumflow/nonequilibrium/localresidual.hh b/dumux/porousmediumflow/nonequilibrium/localresidual.hh index 72ef5af0783ecf81816b72564aa5c69e67752963..20d59a876ff4a7c5ddd6c64be439461b7cb502c4 100644 --- a/dumux/porousmediumflow/nonequilibrium/localresidual.hh +++ b/dumux/porousmediumflow/nonequilibrium/localresidual.hh @@ -35,7 +35,7 @@ template<class TypeTag, bool enableThermalNonEquilibrium, bool enableChemicalNon class NonEquilibriumLocalResidualImplementation; template <class TypeTag> -using NonEquilibriumLocalResidual = NonEquilibriumLocalResidualImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableThermalNonEquilibrium), GET_PROP_VALUE(TypeTag, EnableChemicalNonEquilibrium)>; +using NonEquilibriumLocalResidual = NonEquilibriumLocalResidualImplementation<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableThermalNonEquilibrium(), GET_PROP_TYPE(TypeTag, ModelTraits)::enableChemicalNonEquilibrium()>; /*! * \ingroup PorousmediumNonEquilibriumModel @@ -59,8 +59,8 @@ class NonEquilibriumLocalResidualImplementation<TypeTag, true, false>: public GE using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); using EnergyLocalResidual = typename GET_PROP_TYPE(TypeTag, EnergyLocalResidual); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); enum { conti0EqIdx = Indices::conti0EqIdx }; public: using ParentType::ParentType; @@ -174,8 +174,8 @@ class NonEquilibriumLocalResidualImplementation<TypeTag, true, true>: public GET using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using MolecularDiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); using ComponentVector = Dune::FieldVector<Scalar, numComponents>; diff --git a/dumux/porousmediumflow/nonequilibrium/model.hh b/dumux/porousmediumflow/nonequilibrium/model.hh index 4885f6e1c4f73e92c2fa360c3eb51272e8ef642f..9b4f8b2389426c4ef3e79b49f724d8929967e46d 100644 --- a/dumux/porousmediumflow/nonequilibrium/model.hh +++ b/dumux/porousmediumflow/nonequilibrium/model.hh @@ -46,6 +46,31 @@ */ namespace Dumux { + +/*! + * \ingroup PorousmediumNonEquilibriumModel + * \brief Specifies a number properties of porous-medium flow non-equilibrium models. + * + * \tparam ET The model traits of the underlying model assuming equilibrium + * \tparam chem Boolean to indicate if chemical non-equilibrium is to be considered + * \tparam therm Boolean to indicate if thermal non-equilibrium is to be considered + * \tparam numEF Number of energy balance equations to be solved for the fluids + * \tparam numES Number of energy balance equations to be solved for the solids + */ +template<class ET, bool chem, bool therm, int numEF, int numES> +struct NonEquilibriumModelTraits : public ET +{ + static constexpr int numEq() { return numEnergyEqFluid()+numEnergyEqSolid()+numTransportEq()+ET::numConstraintEq(); } + static constexpr int numTransportEq() { return chem ? ET::numPhases()*ET::numComponents() : ET::numPhases(); } + + static constexpr int numEnergyEqFluid() { return therm ? numEF : 0; } + static constexpr int numEnergyEqSolid() { return therm ? numES : 0; } + + static constexpr bool enableEnergyBalance() { return ET::enableEnergyBalance() || therm; } + static constexpr bool enableThermalNonEquilibrium() { return therm; } + static constexpr bool enableChemicalNonEquilibrium() { return chem; } +}; + namespace Properties { @@ -58,21 +83,36 @@ NEW_TYPE_TAG(NonEquilibrium); // Properties for the non-equilibrium mpnc model ///////////////////////////////////////////////// +//! Set the model traits +SET_PROP(NonEquilibrium, ModelTraits) +{ +private: + using EquiTraits = typename GET_PROP_TYPE(TypeTag, EquilibriumModelTraits); + static constexpr bool enableTNE = GET_PROP_VALUE(TypeTag, EnableThermalNonEquilibrium); + static constexpr bool enableCNE = GET_PROP_VALUE(TypeTag, EnableChemicalNonEquilibrium); + static constexpr int numEF = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid); + static constexpr int numES = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid); +public: + using type = NonEquilibriumModelTraits<EquiTraits, enableCNE, enableTNE, numEF, numES>; +}; + +//! Per default, we consider both thermal and chemical non-equilibrium SET_BOOL_PROP(NonEquilibrium, EnableThermalNonEquilibrium, true); -//TODO: make that more logical: when enableEnergyBalance is false, thermalnonequilibrium should also not be computed. -SET_BOOL_PROP(NonEquilibrium, EnableEnergyBalance, true); SET_BOOL_PROP(NonEquilibrium, EnableChemicalNonEquilibrium, true); -SET_INT_PROP(NonEquilibrium, NumEnergyEqFluid, GET_PROP_VALUE(TypeTag, NumPhases)); +//! Default values for the number of energy balance equations SET_INT_PROP(NonEquilibrium, NumEnergyEqSolid, 1); +SET_PROP(NonEquilibrium, NumEnergyEqFluid) +{ +private: + using EquiTraits = typename GET_PROP_TYPE(TypeTag, EquilibriumModelTraits); +public: + static const int value = EquiTraits::numPhases(); +}; SET_TYPE_PROP(NonEquilibrium, EnergyLocalResidual, EnergyLocalResidualNonEquilibrium<TypeTag, GET_PROP_VALUE(TypeTag, NumEnergyEqFluid)>); SET_TYPE_PROP(NonEquilibrium, LocalResidual, NonEquilibriumLocalResidual<TypeTag>); - -SET_TYPE_PROP(NonEquilibrium, HeatConductionType , FouriersLawNonEquilibrium<TypeTag>); - -//! add the energy balances and chemical nonequilibrium numeq = numPhases*numComp+numEnergy -SET_INT_PROP(NonEquilibrium, NumEq, GET_PROP_VALUE(TypeTag, NumEqBalance) + GET_PROP_VALUE(TypeTag, NumEnergyEqFluid) + GET_PROP_VALUE(TypeTag, NumEnergyEqSolid)); +SET_TYPE_PROP(NonEquilibrium, HeatConductionType, FouriersLawNonEquilibrium<TypeTag>); //! indices for non-isothermal models SET_PROP(NonEquilibrium, Indices) @@ -80,11 +120,12 @@ SET_PROP(NonEquilibrium, Indices) private: using EquilibriumIndices = typename GET_PROP_TYPE(TypeTag, EquilibriumIndices); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numEnergyEquationFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid); - static constexpr int numEnergyEquationSolid = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid); - static constexpr int numEquationBalance = GET_PROP_VALUE(TypeTag, NumEqBalance); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + static constexpr int numEF = ModelTraits::numEnergyEqFluid(); + static constexpr int numES = ModelTraits::numEnergyEqSolid(); + static constexpr int numEq = ModelTraits::numEq(); public: - using type = NonEquilbriumIndices<EquilibriumIndices, FluidSystem, numEnergyEquationFluid, numEnergyEquationSolid, numEquationBalance, 0>; + using type = NonEquilbriumIndices<EquilibriumIndices, FluidSystem, numEF, numES, numEq, 0>; }; SET_PROP(NonEquilibrium, FluidState) @@ -106,13 +147,13 @@ private: using EquilibriumVtkOutputFields = typename GET_PROP_TYPE(TypeTag, EquilibriumVtkOutputFields); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid); - static constexpr int numEnergyEqSolid = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid); + static constexpr int numEF = GET_PROP_TYPE(TypeTag, ModelTraits)::numEnergyEqFluid(); + static constexpr int numES = GET_PROP_TYPE(TypeTag, ModelTraits)::numEnergyEqSolid(); public: - using type = NonEquilibriumVtkOutputFields<EquilibriumVtkOutputFields, FluidSystem, numEnergyEqFluid, numEnergyEqSolid>; + using type = NonEquilibriumVtkOutputFields<EquilibriumVtkOutputFields, FluidSystem, numEF, numES>; }; -SET_PROP(NonEquilibrium, NusseltFormulation ) +SET_PROP(NonEquilibrium, NusseltFormulation) { private: using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); diff --git a/dumux/porousmediumflow/nonequilibrium/thermal/localresidual.hh b/dumux/porousmediumflow/nonequilibrium/thermal/localresidual.hh index f9caee373c348e0bdf27ac901da2df52b7f4ac74..0b92e94363df8b9601cb063c52abe108d780956c 100644 --- a/dumux/porousmediumflow/nonequilibrium/thermal/localresidual.hh +++ b/dumux/porousmediumflow/nonequilibrium/thermal/localresidual.hh @@ -61,7 +61,7 @@ class EnergyLocalResidualNonEquilibrium<TypeTag, 1/*numEnergyEqFluid*/> enum { energyEq0Idx = Indices::energyEq0Idx }; enum { energyEqSolidIdx = Indices::energyEqSolidIdx}; - enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) }; + enum { numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; enum { wPhaseIdx = FluidSystem::wPhaseIdx}; enum { nPhaseIdx = FluidSystem::nPhaseIdx}; enum { sPhaseIdx = FluidSystem::sPhaseIdx}; @@ -325,19 +325,19 @@ class EnergyLocalResidualNonEquilibrium<TypeTag, 2 /*numEnergyEqFluid*/> using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; enum { numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid) }; enum { numEnergyEqSolid = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid) }; enum { energyEq0Idx = Indices::energyEq0Idx }; enum { energyEqSolidIdx = Indices::energyEqSolidIdx}; enum { conti0EqIdx = Indices::conti0EqIdx }; - enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) }; + enum { numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; enum { wPhaseIdx = FluidSystem::wPhaseIdx}; enum { nPhaseIdx = FluidSystem::nPhaseIdx}; enum { sPhaseIdx = FluidSystem::sPhaseIdx}; - static constexpr bool enableChemicalNonEquilibrium = GET_PROP_VALUE(TypeTag, EnableChemicalNonEquilibrium); + static constexpr bool enableChemicalNonEquilibrium = GET_PROP_TYPE(TypeTag, ModelTraits)::enableChemicalNonEquilibrium(); public: diff --git a/dumux/porousmediumflow/nonequilibrium/volumevariables.hh b/dumux/porousmediumflow/nonequilibrium/volumevariables.hh index 84387435791c9c974fcd5d95681497af2a3a8ece..162e651e295857156a49db32f40672233f6250f9 100644 --- a/dumux/porousmediumflow/nonequilibrium/volumevariables.hh +++ b/dumux/porousmediumflow/nonequilibrium/volumevariables.hh @@ -51,7 +51,7 @@ class NonEquilibriumVolumeVariablesImplementation; template <class TypeTag> using NonEquilibriumVolumeVariables = -NonEquilibriumVolumeVariablesImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableChemicalNonEquilibrium), GET_PROP_VALUE(TypeTag, EnableThermalNonEquilibrium)>; +NonEquilibriumVolumeVariablesImplementation<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableChemicalNonEquilibrium(), GET_PROP_TYPE(TypeTag, ModelTraits)::enableThermalNonEquilibrium()>; template <class TypeTag> class NonEquilibriumVolumeVariablesImplementation<TypeTag, false/*enableChemicalNonEquilibrium*/, false/*enableThermalNonEquilibrium*/> @@ -111,7 +111,7 @@ class NonEquilibriumVolumeVariablesImplementation<TypeTag, /*enableChemicalNonEq using ParameterCache = typename FluidSystem::ParameterCache; using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; enum { nusseltFormulation = GET_PROP_VALUE(TypeTag, NusseltFormulation)} ; enum { numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid) }; enum { numEnergyEqSolid = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid) }; @@ -290,8 +290,8 @@ class NonEquilibriumVolumeVariablesImplementation<TypeTag, true/*enableChemicalN using ParameterCache = typename FluidSystem::ParameterCache; using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); - enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) }; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) }; + enum { numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; enum { wPhaseIdx = FluidSystem::wPhaseIdx }; enum { nPhaseIdx = FluidSystem::nPhaseIdx }; enum { nCompIdx = FluidSystem::nCompIdx } ; @@ -507,8 +507,8 @@ class NonEquilibriumVolumeVariablesImplementation<TypeTag, true/*enableChemicalN using ParameterCache = typename FluidSystem::ParameterCache; using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); - enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) }; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) }; + enum { numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; enum { wPhaseIdx = FluidSystem::wPhaseIdx }; enum { nPhaseIdx = FluidSystem::nPhaseIdx }; enum { sPhaseIdx = FluidSystem::sPhaseIdx }; diff --git a/dumux/porousmediumflow/nonisothermal/localresidual.hh b/dumux/porousmediumflow/nonisothermal/localresidual.hh index 75b6aa4e496c4d063aa671b1869cdec3c901f135..cba5152c46859780eb8c7ae2ec4c0382f6d8faa1 100644 --- a/dumux/porousmediumflow/nonisothermal/localresidual.hh +++ b/dumux/porousmediumflow/nonisothermal/localresidual.hh @@ -34,7 +34,7 @@ template<class TypeTag, bool enableEneryBalance> class EnergyLocalResidualImplementation; template<class TypeTag> -using EnergyLocalResidual = EnergyLocalResidualImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>; +using EnergyLocalResidual = EnergyLocalResidualImplementation<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableEnergyBalance()>; /*! * \ingroup NIModel diff --git a/dumux/porousmediumflow/nonisothermal/model.hh b/dumux/porousmediumflow/nonisothermal/model.hh index f64ab0abaf7750bea0337287021ba3e1d32090b2..b842926d2de489bfbbb42e6551c78d533e0c5844 100644 --- a/dumux/porousmediumflow/nonisothermal/model.hh +++ b/dumux/porousmediumflow/nonisothermal/model.hh @@ -57,22 +57,42 @@ #include "indices.hh" #include "vtkoutputfields.hh" -namespace Dumux { +namespace Dumux +{ +/*! + * \ingroup OnePModel + * \brief Specifies a number properties of non-isothermal porous medium + * flow models based on the specifics of a given isothermal model. + * \tparam IsothermalTraits Model traits of the isothermal model + */ +template<class IsothermalTraits> +struct PorousMediumFlowNIModelTraits : public IsothermalTraits +{ + //! We solve for one more equation, i.e. the energy balance + static constexpr int numEq() { return IsothermalTraits::numEq()+1; } + //! We additionally solve for the equation balance + static constexpr bool enableEnergyBalance() { return true; } +}; + namespace Properties { NEW_TYPE_TAG(NonIsothermal); -SET_BOOL_PROP(NonIsothermal, EnableEnergyBalance, true); - -//! add the energy balance -SET_INT_PROP(NonIsothermal, NumEq, GET_PROP_VALUE(TypeTag, IsothermalNumEq) + 1); +//! use the non-isothermal model traits +SET_PROP(NonIsothermal, ModelTraits) +{ +private: + using IsothermalTraits = typename GET_PROP_TYPE(TypeTag, IsothermalModelTraits); +public: + using type = PorousMediumFlowNIModelTraits<IsothermalTraits>; +}; //! indices for non-isothermal models SET_PROP(NonIsothermal, Indices) { private: using IsothermalIndices = typename GET_PROP_TYPE(TypeTag, IsothermalIndices); - static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); public: using type = EnergyIndices<IsothermalIndices, numEq, 0>; }; diff --git a/dumux/porousmediumflow/richards/model.hh b/dumux/porousmediumflow/richards/model.hh index cf64d86b31ea7e408459c8998f078c924550c888..eda18be7da9f6cbb37273121e6803b6e39fdf611 100644 --- a/dumux/porousmediumflow/richards/model.hh +++ b/dumux/porousmediumflow/richards/model.hh @@ -115,6 +115,24 @@ namespace Dumux { +/*! + * \ingroup RichardsModel + * \brief Specifies a number properties of the Richards model. + * + * \tparam enableDiff specifies if diffusion of water in air is to be considered. + */ +template<bool enableDiff> +struct RichardsModelTraits +{ + static constexpr int numEq() { return 1; } + static constexpr int numPhases() { return 2; } + static constexpr int numComponents() { return 1; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return enableDiff; } + static constexpr bool enableEnergyBalance() { return false; } +}; + // \{ /////////////////////////////////////////////////////////////////////////// // properties for the isothermal Richards model. @@ -132,14 +150,6 @@ NEW_TYPE_TAG(RichardsNI, INHERITS_FROM(Richards, NonIsothermal)); ////////////////////////////////////////////////////////////////// // Properties values ////////////////////////////////////////////////////////////////// -//! Number of equations required by the model -SET_INT_PROP(Richards, NumEq, 1); - -//! Number of fluid phases considered -SET_INT_PROP(Richards, NumPhases, 2); - -//! Number of components considered (only water) -SET_INT_PROP(Richards, NumComponents, 1); //! The local residual operator SET_TYPE_PROP(Richards, LocalResidual, RichardsLocalResidual<TypeTag>); @@ -156,19 +166,16 @@ public: using type = RichardsVtkOutputFields<Indices, enableWaterDiffusionInAir>; }; +//! The model traits +SET_TYPE_PROP(Richards, ModelTraits, RichardsModelTraits<GET_PROP_VALUE(TypeTag, EnableWaterDiffusionInAir)>); + //! The class for the volume averaged quantities SET_TYPE_PROP(Richards, VolumeVariables, RichardsVolumeVariables<TypeTag>); -//! Enable advection -SET_BOOL_PROP(Richards, EnableAdvection, true); - //! The default richards model computes no diffusion in the air phase //! Turning this on leads to the extended Richards equation (see e.g. Vanderborght et al. 2017) SET_BOOL_PROP(Richards, EnableWaterDiffusionInAir, false); -//! we need to set this to true so that we can calculate the WaterDiffusionInAir whenever we want and still use the same fluxVarsCache for all models -SET_BOOL_PROP(Richards, EnableMolecularDiffusion, GET_PROP_VALUE(TypeTag, EnableWaterDiffusionInAir)); - //! Use the model after Millington (1961) for the effective diffusivity SET_TYPE_PROP(Richards, EffectiveDiffusivityModel, DiffusivityMillingtonQuirk<typename GET_PROP_TYPE(TypeTag, Scalar)>); @@ -176,9 +183,6 @@ SET_TYPE_PROP(Richards, EffectiveDiffusivityModel, //! The default is not to use the kelvin equation for the water vapor pressure (dependency on pc) SET_BOOL_PROP(Richards, UseKelvinEquation, false); -//! Isothermal model by default -SET_BOOL_PROP(Richards, EnableEnergyBalance, false); - //! The class with all index definitions for the model SET_TYPE_PROP(Richards, Indices, RichardsIndices); @@ -187,7 +191,7 @@ SET_PROP(Richards, PrimaryVariables) { private: using PrimaryVariablesVector = Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), - GET_PROP_VALUE(TypeTag, NumEq)>; + GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>; public: using type = SwitchablePrimaryVariables<PrimaryVariablesVector, int>; }; @@ -242,18 +246,18 @@ public: // Property values for isothermal model required for the general non-isothermal model ////////////////////////////////////////////////////////////////// -//set isothermal VolumeVariables +//! set isothermal model traits +SET_TYPE_PROP(RichardsNI, IsothermalModelTraits, RichardsModelTraits<GET_PROP_VALUE(TypeTag, EnableWaterDiffusionInAir)>); + +//! set isothermal VolumeVariables SET_TYPE_PROP(RichardsNI, IsothermalVolumeVariables, RichardsVolumeVariables<TypeTag>); -//set isothermal LocalResidual +//! set isothermal LocalResidual SET_TYPE_PROP(RichardsNI, IsothermalLocalResidual, RichardsLocalResidual<TypeTag>); -//set isothermal Indices +//! set isothermal Indices SET_TYPE_PROP(RichardsNI, IsothermalIndices, RichardsIndices); -//set isothermal NumEq -SET_INT_PROP(RichardsNI, IsothermalNumEq, 1); - //! Set the vtk output fields specific to this model SET_PROP(RichardsNI, IsothermalVtkOutputFields) { diff --git a/dumux/porousmediumflow/richards/volumevariables.hh b/dumux/porousmediumflow/richards/volumevariables.hh index 1b36f3364d9eef1c4d665d14c76cc7afcc5cea01..7ecd32cfa36bd161520d2fb0f01fbddf8003521a 100644 --- a/dumux/porousmediumflow/richards/volumevariables.hh +++ b/dumux/porousmediumflow/richards/volumevariables.hh @@ -82,7 +82,7 @@ class RichardsVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag> static constexpr bool useKelvinVaporPressure = GET_PROP_VALUE(TypeTag, UseKelvinEquation); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); public: diff --git a/dumux/porousmediumflow/richardsnc/model.hh b/dumux/porousmediumflow/richardsnc/model.hh index a26e6dfeacc84f4361490969e83af2b36b4fb3d5..102f262f5721da47d1baf1398e96a5f7e88b371a 100644 --- a/dumux/porousmediumflow/richardsnc/model.hh +++ b/dumux/porousmediumflow/richardsnc/model.hh @@ -89,6 +89,24 @@ namespace Dumux { +/*! + * \ingroup RichardsNCModel + * \brief Specifies a number properties of the Richards n-components model. + * + * \tparam nComp the number of components to be considered. + */ +template<int nComp> +struct RichardsNCModelTraits +{ + static constexpr int numEq() { return nComp; } + static constexpr int numPhases() { return 2; } + static constexpr int numComponents() { return nComp; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; + namespace Properties { @@ -105,26 +123,18 @@ NEW_TYPE_TAG(RichardsNCNI, INHERITS_FROM(RichardsNC, NonIsothermal)); ////////////////////////////////////////////////////////////////// // Property values ////////////////////////////////////////////////////////////////// -SET_PROP(RichardsNC, NumEq) -{ - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int value = FluidSystem::numComponents; -}; - -SET_PROP(RichardsNC, NumPhases) -{ - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int value = FluidSystem::numPhases; - static_assert(value == 1, "You can only use one-phasic fluid systems with the Richards n-component model!"); -}; -SET_PROP(RichardsNC, NumComponents) +//! Set the model traits class +SET_PROP(RichardsNC, ModelTraits) { +private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int value = FluidSystem::numComponents; +public: + using type = RichardsNCModelTraits<FluidSystem::numComponents>; }; -SET_BOOL_PROP(RichardsNC, UseMoles, true); //!< Define that per default mole fractions are used in the balance equations +//! Define that per default mole fractions are used in the balance equations +SET_BOOL_PROP(RichardsNC, UseMoles, true); //! Use the dedicated local residual SET_TYPE_PROP(RichardsNC, LocalResidual, CompositionalLocalResidual<TypeTag>); @@ -183,11 +193,6 @@ SET_PROP(RichardsNC, EffectiveDiffusivityModel) using type = DiffusivityMillingtonQuirk<Scalar>; }; -//physical processes to be considered by the isothermal model -SET_BOOL_PROP(RichardsNC, EnableAdvection, true); -SET_BOOL_PROP(RichardsNC, EnableMolecularDiffusion, true); -SET_BOOL_PROP(RichardsNC, EnableEnergyBalance, false); - //! average is used as default model to compute the effective thermal heat conductivity SET_PROP(RichardsNCNI, ThermalConductivityModel) { @@ -199,20 +204,22 @@ SET_PROP(RichardsNCNI, ThermalConductivityModel) // Property values for isothermal model required for the general non-isothermal model ////////////////////////////////////////////////////////////////// -//set isothermal VolumeVariables +//! set isothermal VolumeVariables SET_TYPE_PROP(RichardsNCNI, IsothermalVolumeVariables, RichardsNCVolumeVariables<TypeTag>); -//set isothermal LocalResidual +//! set isothermal LocalResidual SET_TYPE_PROP(RichardsNCNI, IsothermalLocalResidual, CompositionalLocalResidual<TypeTag>); -//set isothermal Indices +//! set isothermal Indices SET_TYPE_PROP(RichardsNCNI, IsothermalIndices, RichardsNCIndices<>); -//set isothermal NumEq -SET_PROP(RichardsNCNI, IsothermalNumEq) +//! set isothermal model traits +SET_PROP(RichardsNCNI, IsothermalModelTraits) { +private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int value = FluidSystem::numComponents; +public: + using type = RichardsNCModelTraits<FluidSystem::numComponents>; }; } // end namespace Properties diff --git a/dumux/porousmediumflow/richardsnc/volumevariables.hh b/dumux/porousmediumflow/richardsnc/volumevariables.hh index 03c7045c1c34b69ae2e2ff9218338a48a56522db..668e212a7a8a126f9a358098bfc7ad00024317c5 100644 --- a/dumux/porousmediumflow/richardsnc/volumevariables.hh +++ b/dumux/porousmediumflow/richardsnc/volumevariables.hh @@ -327,7 +327,7 @@ class RichardsNCVolumeVariables : public RichardsBaseVolumeVariables<TypeTag> static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; using Element = typename GridView::template Codim<0>::Entity; diff --git a/dumux/porousmediumflow/sequential/properties.hh b/dumux/porousmediumflow/sequential/properties.hh index f39e8fe491487b648e90d3e92eb04df9bd97eb7d..d153c0e1b01583fe06ea6f953bb0562313cc5c48 100644 --- a/dumux/porousmediumflow/sequential/properties.hh +++ b/dumux/porousmediumflow/sequential/properties.hh @@ -76,6 +76,12 @@ NEW_PROP_TAG( TimeManager ); //!< Manages the simulation time NEW_PROP_TAG( BoundaryTypes ); //!< Stores the boundary types of a single degree of freedom NEW_PROP_TAG( MaxIntersections ); //!< Gives maximum number of intersections of an element and neighboring elements NEW_PROP_TAG( PressureCoefficientMatrix ); //!< Gives maximum number of intersections of an element and neighboring elements + +//! Some properties that became obsolete in dumux, but are still necessary +//! for sequential models until they are integrated in the general framework +NEW_PROP_TAG( NumEq ); //!< The number of equations to solve (equal to number of primary variables) +NEW_PROP_TAG( NumPhases ); //!< Number of fluid phases in the system +NEW_PROP_TAG( NumComponents ); //!< Number of fluid components in the system } } @@ -103,6 +109,19 @@ namespace Properties //! Type of the jacobian matrix needed for compatibility with implicit models for the amg backend SET_TYPE_PROP(SequentialModel, JacobianMatrix, typename GET_PROP_TYPE(TypeTag, PressureCoefficientMatrix)); +//! Dummy model traits for compatibility with the rest of dumux +//! until the sequential models are incorporated into the general framework +SET_PROP(SequentialModel, ModelTraits) +{ +private: + struct DummyTraits + { + static constexpr int numEq() { return GET_PROP_VALUE(TypeTag, NumEq); } + }; +public: + using type = DummyTraits; +}; + //! Use the leaf grid view if not defined otherwise SET_PROP(SequentialModel, GridView) { diff --git a/dumux/porousmediumflow/tracer/localresidual.hh b/dumux/porousmediumflow/tracer/localresidual.hh index e1625c135281dfcfdf980ba8b83a1d0f050c3b8d..ea1fa8d1bcb7d5cf5fed7be8fe9dd56c1ad15e80 100644 --- a/dumux/porousmediumflow/tracer/localresidual.hh +++ b/dumux/porousmediumflow/tracer/localresidual.hh @@ -56,7 +56,7 @@ class TracerLocalResidual: public GET_PROP_TYPE(TypeTag, BaseLocalResidual) using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); static constexpr int phaseIdx = 0; diff --git a/dumux/porousmediumflow/tracer/model.hh b/dumux/porousmediumflow/tracer/model.hh index b36fbb8ade55cf432ef7aa976226a4d11135cbbd..105c49a8add5daf28145b97f6a80f3a076d4a582 100644 --- a/dumux/porousmediumflow/tracer/model.hh +++ b/dumux/porousmediumflow/tracer/model.hh @@ -63,6 +63,24 @@ namespace Dumux { +/*! + * \ingroup RichardsNCModel + * \brief Specifies a number properties of the Richards n-components model. + * + * \tparam nComp the number of components to be considered. + */ +template<int nComp> +struct TracerModelTraits +{ + static constexpr int numEq() { return nComp; } + static constexpr int numPhases() { return 1; } + static constexpr int numComponents() { return nComp; } + + static constexpr bool enableAdvection() { return true; } + static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableEnergyBalance() { return false; } +}; + // \{ namespace Properties { @@ -77,23 +95,19 @@ NEW_TYPE_TAG(Tracer, INHERITS_FROM(PorousMediumFlow)); /////////////////////////////////////////////////////////////////////////// // properties for the tracer model /////////////////////////////////////////////////////////////////////////// -SET_INT_PROP(Tracer, NumPhases, 1); //!< The number of phases -SET_PROP(Tracer, NumEq) //!< set the number of equations -{ - using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int value = FluidSystem::numComponents; - static_assert(GET_PROP_VALUE(TypeTag, NumComponents) == value, "Number of equation has to be equal to number of components."); -}; +//! Define that mole fractions are used in the balance equations +SET_BOOL_PROP(Tracer, UseMoles, true); -SET_PROP(Tracer, NumComponents) //!< set the number of components +//! set the model traits +SET_PROP(Tracer, ModelTraits) { +private: using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int value = FluidSystem::numComponents; +public: + using type = TracerModelTraits<FluidSystem::numComponents>; }; -SET_BOOL_PROP(Tracer, UseMoles, true); //!< Define that mole fractions are used in the balance equations - //! Use the tracer local residual function for the tracer model SET_TYPE_PROP(Tracer, LocalResidual, TracerLocalResidual<TypeTag>); @@ -106,7 +120,6 @@ public: using type = TracerVtkOutputFields<FluidSystem>; }; - //! define the VolumeVariables SET_TYPE_PROP(Tracer, VolumeVariables, TracerVolumeVariables<TypeTag>); @@ -121,11 +134,6 @@ SET_TYPE_PROP(Tracer, SpatialParams, FVSpatialParamsOneP<TypeTag>); //! Use simple model with constant tortuosity as pm diffusivity model SET_TYPE_PROP(Tracer, EffectiveDiffusivityModel, DiffusivityConstantTortuosity<typename GET_PROP_TYPE(TypeTag, Scalar)>); - -// physical processes to be considered by the isothermal model -SET_BOOL_PROP(Tracer, EnableAdvection, true); -SET_BOOL_PROP(Tracer, EnableMolecularDiffusion, true); -SET_BOOL_PROP(Tracer, EnableEnergyBalance, false); } // end namespace Properties // \} } // end namespace Dumux diff --git a/dumux/porousmediumflow/volumevariables.hh b/dumux/porousmediumflow/volumevariables.hh index a3aae7b439eac67866b09f12c3ef500abcf3395d..a939ee9b2e7239bcc48f9ea04ddb38974654570f 100644 --- a/dumux/porousmediumflow/volumevariables.hh +++ b/dumux/porousmediumflow/volumevariables.hh @@ -40,7 +40,7 @@ class PorousMediumFlowVolumeVariablesImplementation; * is specialized for isothermal and non-isothermal models. */ template <class TypeTag> -using PorousMediumFlowVolumeVariables = PorousMediumFlowVolumeVariablesImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>; +using PorousMediumFlowVolumeVariables = PorousMediumFlowVolumeVariablesImplementation<TypeTag, GET_PROP_TYPE(TypeTag, ModelTraits)::enableEnergyBalance()>; /*! * \ingroup PorousmediumFlow diff --git a/test/freeflow/navierstokes/test_channel.cc b/test/freeflow/navierstokes/test_channel.cc index 0eb767476e34b4cf53fdcb23b2e765076fe2f054..5e861a42fbbff5d3f6159528e16760c4c6815cde 100644 --- a/test/freeflow/navierstokes/test_channel.cc +++ b/test/freeflow/navierstokes/test_channel.cc @@ -223,7 +223,7 @@ int main(int argc, char** argv) try // calculate and print mass fluxes over the planes flux.calculateMassOrMoleFluxes(); - if(GET_PROP_VALUE(TypeTag, EnableEnergyBalance)) + if(GET_PROP_TYPE(TypeTag, ModelTraits)::enableEnergyBalance()) { std::cout << "mass / energy flux at middle is: " << flux.netFlux("middle") << std::endl; std::cout << "mass / energy flux at outlet is: " << flux.netFlux("outlet") << std::endl; diff --git a/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh b/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh index 3293859c72e643eb2c137f7605a7cb92f2e28436..bc96dfb653763b6764630df51872fbfd77aad6a9 100644 --- a/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh +++ b/test/porousmediumflow/1pncmin/implicit/thermochemreaction.hh @@ -46,8 +46,8 @@ class ThermoChemReaction using Indices = typename GET_PROP_TYPE(TypeTag, Indices); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); - static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); - static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases); + static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); + static const int numSolidPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numSPhases(); enum{ // Indices of the primary variables diff --git a/test/porousmediumflow/1pncmin/implicit/thermochemspatialparams.hh b/test/porousmediumflow/1pncmin/implicit/thermochemspatialparams.hh index 8f2a534621aaa19b73803213728b9a1aeea45448..561a578d20e925d14b440eff2dcf4302953ced86 100644 --- a/test/porousmediumflow/1pncmin/implicit/thermochemspatialparams.hh +++ b/test/porousmediumflow/1pncmin/implicit/thermochemspatialparams.hh @@ -64,12 +64,13 @@ class ThermoChemSpatialParams : public FVSpatialParamsOneP<TypeTag> using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); using CoordScalar = typename GridView::ctype; using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); enum { dimWorld=GridView::dimensionworld, - numSPhases = GET_PROP_VALUE(TypeTag, NumSPhases), - numPhases = GET_PROP_VALUE(TypeTag, NumPhases), + numSPhases = ModelTraits::numSPhases(), + numPhases = ModelTraits::numPhases(), cPhaseIdx = FluidSystem::cPhaseIdx, hPhaseIdx = FluidSystem::hPhaseIdx }; diff --git a/test/porousmediumflow/2p2c/implicit/mpnccomparison/2p2c_comparison_problem.hh b/test/porousmediumflow/2p2c/implicit/mpnccomparison/2p2c_comparison_problem.hh index 42c8ca38b56be4f400ca19ffca1bc21213acef9c..3b01a027ad9cec55f5e603d882a225141eea64b1 100644 --- a/test/porousmediumflow/2p2c/implicit/mpnccomparison/2p2c_comparison_problem.hh +++ b/test/porousmediumflow/2p2c/implicit/mpnccomparison/2p2c_comparison_problem.hh @@ -109,8 +109,8 @@ class TwoPTwoCComparisonProblem // world dimension enum {dimWorld = GridView::dimensionworld}; - enum {numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; - enum {numComponents = GET_PROP_VALUE(TypeTag, NumComponents)}; + enum {numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()}; + enum {numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()}; enum {nPhaseIdx = FluidSystem::nPhaseIdx}; enum {wPhaseIdx = FluidSystem::wPhaseIdx}; enum {wCompIdx = FluidSystem::wCompIdx}; diff --git a/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh b/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh index c9799fbd22dc794756bb125756f7ba19d6621eab..d4797d87da943eb9b3e5994bdbebc08b6e541d12 100644 --- a/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh +++ b/test/porousmediumflow/mpnc/implicit/2p2ccomparison/mpnc_comparison_problem.hh @@ -70,8 +70,6 @@ SET_TYPE_PROP(MPNCComparisonTypeTag, // decide which type to use for floating values (double / quad) SET_TYPE_PROP(MPNCComparisonTypeTag, Scalar, double); -SET_BOOL_PROP(MPNCComparisonTypeTag, EnableMolecularDiffusion, true); - SET_BOOL_PROP(MPNCComparisonTypeTag, UseMoles, true); SET_PROP(MPNCComparisonTypeTag, VtkOutputFields) @@ -115,8 +113,8 @@ class MPNCComparisonProblem // world dimension enum {dimWorld = GridView::dimensionworld}; - enum {numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; - enum {numComponents = GET_PROP_VALUE(TypeTag, NumComponents)}; + enum {numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()}; + enum {numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()}; enum {nPhaseIdx = FluidSystem::nPhaseIdx}; enum {wPhaseIdx = FluidSystem::wPhaseIdx}; enum {wCompIdx = FluidSystem::wCompIdx}; diff --git a/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh b/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh index c52dc47cce7d4f667a843e75ea6b86257907d905..ba88ad0b9fb0e8edbe8d6376f20084400412633e 100644 --- a/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh +++ b/test/porousmediumflow/mpnc/implicit/combustionproblem1c.hh @@ -44,6 +44,13 @@ namespace Dumux template<class TypeTag> class CombustionProblemOneComponent; +//! Custom model traits to deactivate diffusion for this test +template<int numP, int numC> +struct CombustionModelTraits : public MPNCModelTraits<numP, numC> +{ + static constexpr bool enableMolecularDiffusion() { return false; } +}; + namespace Properties { NEW_TYPE_TAG(CombustionOneComponentTypeTag, INHERITS_FROM(MPNCNonequil, CombustionSpatialParams)); @@ -70,8 +77,14 @@ SET_INT_PROP(CombustionOneComponentTypeTag, SET_TYPE_PROP(CombustionOneComponentTypeTag, Scalar, double ); // quad / double -// Specify whether diffusion is enabled -SET_BOOL_PROP(CombustionOneComponentTypeTag, EnableMolecularDiffusion, false); +// We use different model traits for the equilibrium part because we want to deactivate diffusion +SET_PROP(CombustionOneComponentTypeTag, EquilibriumModelTraits) +{ +private: + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); +public: + using type = CombustionModelTraits<FluidSystem::numPhases, FluidSystem::numComponents>; +}; //! Franz Lindners simple lumping SET_PROP(CombustionOneComponentTypeTag, ThermalConductivityModel) @@ -99,7 +112,6 @@ SET_INT_PROP(CombustionOneComponentTypeTag, NumEnergyEqSolid, 1); // by default chemical non equilibrium is enabled in the nonequil model, switch that off here SET_BOOL_PROP(CombustionOneComponentTypeTag, EnableChemicalNonEquilibrium, false); -SET_INT_PROP(CombustionOneComponentTypeTag, NumEqBalance, GET_PROP_VALUE(TypeTag, NumPhases)+GET_PROP_VALUE(TypeTag, NumPhases)); //################# } @@ -131,8 +143,8 @@ class CombustionProblemOneComponent: public PorousMediumFlowProblem<TypeTag> using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); enum {dimWorld = GridView::dimensionworld}; - enum {numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; - enum {numComponents = GET_PROP_VALUE(TypeTag, NumComponents)}; + enum {numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()}; + enum {numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()}; enum {s0Idx = Indices::s0Idx}; enum {p0Idx = Indices::p0Idx}; enum {conti00EqIdx = Indices::conti0EqIdx}; diff --git a/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh b/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh index 92f40e485d1cfee111366e29c1cd5bdf6d0376ca..63b04283ba414ea1a015165c39c4a87bf855c767 100644 --- a/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh +++ b/test/porousmediumflow/mpnc/implicit/evaporationatmosphereproblem.hh @@ -118,19 +118,19 @@ class EvaporationAtmosphereProblem: public PorousMediumFlowProblem<TypeTag> using MaterialLaw = typename GET_PROP_TYPE(TypeTag, MaterialLaw); using ParameterCache = typename FluidSystem::ParameterCache; using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - enum { dimWorld = GridView::dimensionworld}; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; - enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents)}; - enum { s0Idx = Indices::s0Idx}; - enum { p0Idx = Indices::p0Idx}; + enum { dimWorld = GridView::dimensionworld }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; + enum { numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents() }; + enum { s0Idx = Indices::s0Idx }; + enum { p0Idx = Indices::p0Idx }; enum { conti00EqIdx = Indices::conti0EqIdx }; - enum { energyEq0Idx = Indices::energyEqIdx}; - enum { wPhaseIdx = FluidSystem::wPhaseIdx}; - enum { nPhaseIdx = FluidSystem::nPhaseIdx}; - enum { wCompIdx = FluidSystem::H2OIdx}; - enum { nCompIdx = FluidSystem::N2Idx}; - enum { numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid)}; - enum { numEnergyEqSolid = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid)}; + enum { energyEq0Idx = Indices::energyEqIdx }; + enum { wPhaseIdx = FluidSystem::wPhaseIdx }; + enum { nPhaseIdx = FluidSystem::nPhaseIdx }; + enum { wCompIdx = FluidSystem::H2OIdx }; + enum { nCompIdx = FluidSystem::N2Idx }; + enum { numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid) }; + enum { numEnergyEqSolid = GET_PROP_VALUE(TypeTag, NumEnergyEqSolid) }; static constexpr bool enableChemicalNonEquilibrium = GET_PROP_VALUE(TypeTag, EnableChemicalNonEquilibrium); using ConstraintSolver = MiscibleMultiPhaseComposition<Scalar, FluidSystem>; diff --git a/test/porousmediumflow/mpnc/implicit/evaporationatmospherespatialparams.hh b/test/porousmediumflow/mpnc/implicit/evaporationatmospherespatialparams.hh index 5cfb989ee3517bf6e4a3396cb0a346ff273cb6de..bdc6321968fb1af748f91b6205a7a8ab9468872a 100644 --- a/test/porousmediumflow/mpnc/implicit/evaporationatmospherespatialparams.hh +++ b/test/porousmediumflow/mpnc/implicit/evaporationatmospherespatialparams.hh @@ -162,7 +162,7 @@ class EvaporationAtmosphereSpatialParams : public FVSpatialParams<TypeTag> using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); enum { dimWorld = GridView::dimensionworld }; - enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases) }; + enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases() }; using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; using FluidState = typename GET_PROP_TYPE(TypeTag, FluidState); diff --git a/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh b/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh index 7beefdc96f1774d418fd89f1f11aa6c9bbf9b53e..254547d31e92fe1f15d6c43b5a7d518ded60814e 100644 --- a/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh +++ b/test/porousmediumflow/mpnc/implicit/obstacleproblem.hh @@ -126,8 +126,8 @@ class ObstacleProblem using ParameterCache = typename FluidSystem::ParameterCache; enum {dimWorld = GridView::dimensionworld}; - enum {numPhases = GET_PROP_VALUE(TypeTag, NumPhases)}; - enum {numComponents = GET_PROP_VALUE(TypeTag, NumComponents)}; + enum {numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()}; + enum {numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()}; enum {nPhaseIdx = FluidSystem::nPhaseIdx}; enum {wPhaseIdx = FluidSystem::wPhaseIdx}; enum {wCompIdx = FluidSystem::wCompIdx}; diff --git a/tutorial/ex2/mylocalresidual.hh b/tutorial/ex2/mylocalresidual.hh index 1ad4063a8de8a0492c64a10c2e3d5bb9eda769ce..ed03160ffde951e7e74c1ed98f75da9f6f7d4972 100644 --- a/tutorial/ex2/mylocalresidual.hh +++ b/tutorial/ex2/mylocalresidual.hh @@ -56,8 +56,8 @@ class MyCompositionalLocalResidual: public GET_PROP_TYPE(TypeTag, BaseLocalResid using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using EnergyLocalResidual = typename GET_PROP_TYPE(TypeTag, EnergyLocalResidual); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); enum { conti0EqIdx = Indices::conti0EqIdx }; diff --git a/tutorial/solution/ex2/mylocalresidual.hh b/tutorial/solution/ex2/mylocalresidual.hh index f304b22a467a888e76f5ba65e7136954060414f1..33cdbb163960381a69b626ec34065183200d4403 100644 --- a/tutorial/solution/ex2/mylocalresidual.hh +++ b/tutorial/solution/ex2/mylocalresidual.hh @@ -57,8 +57,8 @@ class MyCompositionalLocalResidual: public GET_PROP_TYPE(TypeTag, BaseLocalResid using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using EnergyLocalResidual = typename GET_PROP_TYPE(TypeTag, EnergyLocalResidual); - static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases); - static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents); + static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); + static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); enum { conti0EqIdx = Indices::conti0EqIdx };