diff --git a/dumux/assembly/staggeredlocalassembler.hh b/dumux/assembly/staggeredlocalassembler.hh index 587a2bf462640783373697d015ed2ad81e817296..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_TYPE(TypeTag, ModelTraits)::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/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/discretization/staggered/properties.hh b/dumux/discretization/staggered/properties.hh index 4bf13dec7c4c8c62648bf38b5d4f67c4d2055d41..afe98aab5dd7185ed50bed8a61b49894a09ee28e 100644 --- a/dumux/discretization/staggered/properties.hh +++ b/dumux/discretization/staggered/properties.hh @@ -86,20 +86,6 @@ SET_TYPE_PROP(StaggeredModel, ElementFluxVariablesCache, StaggeredElementFluxVar //! Set the face solution type SET_TYPE_PROP(StaggeredModel, StaggeredFaceSolution, StaggeredFaceSolution<TypeTag>); -//! Dummy model traits struct until the model traits -//! are actually implemented for models using staggered grid -SET_PROP(StaggeredModel, ModelTraits) -{ -private: - struct DummyTraits - { - static constexpr int numEq() { return GET_PROP_VALUE(TypeTag, NumEq); } - static constexpr int numPhases() { return GET_PROP_VALUE(TypeTag, NumPhases); } - }; -public: - using type = DummyTraits; -}; - //! Set the grid variables (volume, flux and face variables) SET_PROP(StaggeredModel, GridVariables) { 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..b74b74ddb91ea06b57f6df41194366bc8e3cea45 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); } 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/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;