From f3d5fd83e391adc6e0510c3ee4d3073ae2eeb643 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Wed, 28 Feb 2018 19:22:37 +0100 Subject: [PATCH] [navierstokes] Make indices independent of TypeTag --- dumux/freeflow/navierstokes/indices.hh | 15 ++++++++------- dumux/freeflow/navierstokes/model.hh | 18 ++++++++++++++++-- dumux/freeflow/navierstokesnc/indices.hh | 16 +++++++++------- dumux/freeflow/navierstokesnc/model.hh | 22 ++++++++++++++++++++-- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/dumux/freeflow/navierstokes/indices.hh b/dumux/freeflow/navierstokes/indices.hh index d80b698c5a..bb358ffb95 100644 --- a/dumux/freeflow/navierstokes/indices.hh +++ b/dumux/freeflow/navierstokes/indices.hh @@ -26,16 +26,18 @@ #include <dumux/common/properties.hh> -namespace Dumux -{ +namespace Dumux { + // \{ /*! * \ingroup NavierStokesModel * \brief The common indices for the isothermal Navier-Stokes model. * + * \tparam dimension The dimension of the problem + * \tparam numEquations the number of model equations * \tparam PVOffset The first index in a primary variable vector. */ -template <class TypeTag, int PVOffset = 0> +template <int dimension, int numEquations, int PVOffset = 0> struct NavierStokesIndices { @@ -47,10 +49,9 @@ struct NavierStokesIndices static constexpr int conti0EqIdx = massBalanceIdx; //!< Index of the mass balance equation static constexpr int pressureIdx = massBalanceIdx; //!< Index of the pressure in a solution vector - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr auto dim = GridView::dimension; - static constexpr auto numEq = GET_PROP_VALUE(TypeTag, NumEq); - static constexpr auto momentumBalanceOffset = GET_PROP_VALUE(TypeTag, NumEq) - dim; + static constexpr auto dim = dimension; + static constexpr auto numEq = numEquations; + static constexpr auto momentumBalanceOffset = numEquations - dim; static constexpr int momentumBalanceIdx = PVOffset + momentumBalanceOffset; //!< Index of the momentum balance equation static constexpr int momentumXBalanceIdx = momentumBalanceIdx; //!< Index of the momentum balance equation diff --git a/dumux/freeflow/navierstokes/model.hh b/dumux/freeflow/navierstokes/model.hh index 0d543fd675..ccaf1d7902 100644 --- a/dumux/freeflow/navierstokes/model.hh +++ b/dumux/freeflow/navierstokes/model.hh @@ -135,7 +135,14 @@ SET_TYPE_PROP(NavierStokes, FluxVariables, NavierStokesFluxVariables<TypeTag>); SET_TYPE_PROP(NavierStokes, FluxVariablesCache, FreeFlowFluxVariablesCache<TypeTag>); //! The indices required by the isothermal single-phase model -SET_TYPE_PROP(NavierStokes, Indices, NavierStokesIndices<TypeTag>); +SET_PROP(NavierStokes, Indices) +{ +private: + static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; +public: + using type = NavierStokesIndices<dim, numEq>; +}; //! The specific vtk output fields SET_TYPE_PROP(NavierStokes, VtkOutputFields, NavierStokesVtkOutputFields<TypeTag>); @@ -144,7 +151,14 @@ SET_TYPE_PROP(NavierStokes, VtkOutputFields, NavierStokesVtkOutputFields<TypeTag // Property values for isothermal model required for the general non-isothermal model ////////////////////////////////////////////////////////////////// //! The indices required by the isothermal single-phase model -SET_TYPE_PROP(NavierStokesNI, IsothermalIndices, NavierStokesIndices<TypeTag>); +SET_PROP(NavierStokesNI, IsothermalIndices) +{ +private: + static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); + static constexpr int dim = GET_PROP_TYPE(TypeTag, GridView)::dimension; +public: + using type = NavierStokesIndices<dim, numEq>; +}; //! The specific isothermal vtk output fields SET_TYPE_PROP(NavierStokesNI, IsothermalVtkOutputFields, NavierStokesVtkOutputFields<TypeTag>); diff --git a/dumux/freeflow/navierstokesnc/indices.hh b/dumux/freeflow/navierstokesnc/indices.hh index 3acd99e6e0..8a03f81643 100644 --- a/dumux/freeflow/navierstokesnc/indices.hh +++ b/dumux/freeflow/navierstokesnc/indices.hh @@ -27,8 +27,8 @@ #include <dumux/freeflow/navierstokes/indices.hh> #include <dumux/common/properties.hh> -namespace Dumux -{ +namespace Dumux { + // \{ /*! * \ingroup NavierStokesNCModel @@ -36,19 +36,21 @@ namespace Dumux * * \tparam PVOffset The first index in a primary variable vector. */ -template <class TypeTag, int PVOffset = 0> -struct NavierStokesNCIndices : public NavierStokesIndices<TypeTag, PVOffset> +template <int dimension, int numEquations, + int thePhaseIdx, int theReplaceCompEqIdx, + int PVOffset = 0> +struct NavierStokesNCIndices : public NavierStokesIndices<dimension, numEquations, PVOffset> { private: - using ParentType = NavierStokesIndices<TypeTag, PVOffset>; + using ParentType = NavierStokesIndices<dimension, numEquations, PVOffset>; public: - static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); //!< The phase index + static constexpr int phaseIdx = thePhaseIdx; //!< The phase index static constexpr int mainCompIdx = phaseIdx; //!< The index of the main component //! The index of the component whose mass balance will be replaced by the total one - static constexpr int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx); + static constexpr int replaceCompEqIdx = theReplaceCompEqIdx; }; // \} diff --git a/dumux/freeflow/navierstokesnc/model.hh b/dumux/freeflow/navierstokesnc/model.hh index 4d9ac3f420..83b4384f04 100644 --- a/dumux/freeflow/navierstokesnc/model.hh +++ b/dumux/freeflow/navierstokesnc/model.hh @@ -144,7 +144,16 @@ SET_TYPE_PROP(NavierStokesNC, VolumeVariables, NavierStokesNCVolumeVariables<Typ SET_TYPE_PROP(NavierStokesNC, FluxVariables, NavierStokesNCFluxVariables<TypeTag>); //! The indices -SET_TYPE_PROP(NavierStokesNC, Indices, NavierStokesNCIndices<TypeTag>); +SET_PROP(NavierStokesNC, Indices) +{ +private: + static constexpr int numEq = GET_PROP_VALUE(TypeTag, 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); +public: + using type = NavierStokesNCIndices<dim, numEq, phaseIdx, replaceCompEqIdx>; +}; //! The vtk output fields SET_TYPE_PROP(NavierStokesNC, VtkOutputFields, NavierStokesNCVtkOutputFields<TypeTag>); @@ -171,7 +180,16 @@ SET_TYPE_PROP(NavierStokesNC, MolecularDiffusionType, FicksLaw<TypeTag>); // Property values for isothermal model required for the general non-isothermal model ////////////////////////////////////////////////////////////////// //! The isothermal indices -SET_TYPE_PROP(NavierStokesNCNI, IsothermalIndices, NavierStokesNCIndices<TypeTag>); +SET_PROP(NavierStokesNCNI, IsothermalIndices) +{ +private: + static constexpr int numEq = GET_PROP_VALUE(TypeTag, 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); +public: + using type = NavierStokesNCIndices<dim, numEq, phaseIdx, replaceCompEqIdx>; +}; //! The isothermal vtk output fields SET_TYPE_PROP(NavierStokesNCNI, IsothermalVtkOutputFields, NavierStokesNCVtkOutputFields<TypeTag>); -- GitLab