From a01a8f2874593aa573157ae304215f8317a4ec40 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Thu, 5 Jul 2018 11:56:43 +0200 Subject: [PATCH 1/4] [navierstokes] Allow use of 2p immiscible fluid systems for Stokes * this makes coupling with, e.g., Darcy domains much easiert, as the same fluid system can be used for both domains * add fluidSystemPhaseIdx to model traits and indices, where necessary * add some docu --- .../freeflow/compositional/kepsilonncmodel.hh | 2 +- dumux/freeflow/compositional/komegancmodel.hh | 12 ++++++--- .../compositional/lowrekepsilonncmodel.hh | 12 ++++++--- .../compositional/navierstokesncmodel.hh | 16 +++++++++--- dumux/freeflow/compositional/oneeqncmodel.hh | 12 ++++++--- dumux/freeflow/navierstokes/indices.hh | 5 ++-- dumux/freeflow/navierstokes/model.hh | 25 ++++++++++++------- dumux/freeflow/rans/model.hh | 17 ++++++++++--- dumux/freeflow/rans/oneeq/indices.hh | 5 ++-- dumux/freeflow/rans/oneeq/model.hh | 15 +++++++---- dumux/freeflow/rans/twoeq/kepsilon/indices.hh | 5 ++-- dumux/freeflow/rans/twoeq/kepsilon/model.hh | 15 +++++++---- dumux/freeflow/rans/twoeq/komega/indices.hh | 5 ++-- dumux/freeflow/rans/twoeq/komega/model.hh | 15 +++++++---- .../rans/twoeq/lowrekepsilon/indices.hh | 5 ++-- .../rans/twoeq/lowrekepsilon/model.hh | 15 +++++++---- 16 files changed, 125 insertions(+), 56 deletions(-) diff --git a/dumux/freeflow/compositional/kepsilonncmodel.hh b/dumux/freeflow/compositional/kepsilonncmodel.hh index 2697a5e0ae..154e295ca6 100644 --- a/dumux/freeflow/compositional/kepsilonncmodel.hh +++ b/dumux/freeflow/compositional/kepsilonncmodel.hh @@ -68,7 +68,7 @@ struct KEpsilonNCModelTraits : NavierStokesNCModelTraits>; + using Indices = FreeflowNCIndices>; }; //!< states some specifics of the isothermal multi-component low-Reynolds k-epsilon model diff --git a/dumux/freeflow/compositional/komegancmodel.hh b/dumux/freeflow/compositional/komegancmodel.hh index 5259887a2f..efdffd868f 100644 --- a/dumux/freeflow/compositional/komegancmodel.hh +++ b/dumux/freeflow/compositional/komegancmodel.hh @@ -56,9 +56,15 @@ NEW_TYPE_TAG(KOmegaNC, INHERITS_FROM(NavierStokesNC)); /*! * \ingroup FreeflowNCModel * \brief Traits for the low-Reynolds k-epsilon multi-component model + * + * \tparam dimension The dimension of the problem + * \tparam nComp The number of components to be considered + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system + * \tparam replaceCompEqIdx The index of the component balance equation that should be replaced by a total mass/mole balance + * \tparam useM Use molar or mass balances */ -template -struct KOmegaNCModelTraits : NavierStokesNCModelTraits +template +struct KOmegaNCModelTraits : NavierStokesNCModelTraits { //! There are as many momentum balance equations as dimensions //! and as many balance equations as components. @@ -68,7 +74,7 @@ struct KOmegaNCModelTraits : NavierStokesNCModelTraits>; + using Indices = FreeflowNCIndices>; }; //!< states some specifics of the isothermal multi-component low-Reynolds k-epsilon model diff --git a/dumux/freeflow/compositional/lowrekepsilonncmodel.hh b/dumux/freeflow/compositional/lowrekepsilonncmodel.hh index 4918178db8..c11340df6f 100644 --- a/dumux/freeflow/compositional/lowrekepsilonncmodel.hh +++ b/dumux/freeflow/compositional/lowrekepsilonncmodel.hh @@ -56,9 +56,15 @@ NEW_TYPE_TAG(LowReKEpsilonNC, INHERITS_FROM(NavierStokesNC)); /*! * \ingroup FreeflowNCModel * \brief Traits for the low-Reynolds k-epsilon multi-component model + * + * \tparam dimension The dimension of the problem + * \tparam nComp The number of components to be considered + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system + * \tparam replaceCompEqIdx The index of the component balance equation that should be replaced by a total mass/mole balance + * \tparam useM Use molar or mass balances */ -template -struct LowReKEpsilonNCModelTraits : NavierStokesNCModelTraits +template +struct LowReKEpsilonNCModelTraits : NavierStokesNCModelTraits { //! There are as many momentum balance equations as dimensions //! and as many balance equations as components. @@ -68,7 +74,7 @@ struct LowReKEpsilonNCModelTraits : NavierStokesNCModelTraits>; + using Indices = FreeflowNCIndices>; }; //!< states some specifics of the isothermal multi-component low-Reynolds k-epsilon model diff --git a/dumux/freeflow/compositional/navierstokesncmodel.hh b/dumux/freeflow/compositional/navierstokesncmodel.hh index 56f25d472e..0c8e4056ae 100644 --- a/dumux/freeflow/compositional/navierstokesncmodel.hh +++ b/dumux/freeflow/compositional/navierstokesncmodel.hh @@ -76,9 +76,15 @@ namespace Dumux { /*! * \ingroup FreeflowNCModel * \brief Traits for the multi-component free-flow model + * + * \tparam dimension The dimension of the problem + * \tparam nComp The number of components to be considered + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system + * \tparam replaceCompEqIdx The index of the component balance equation that should be replaced by a total mass/mole balance + * \tparam useM Use molar or mass balances */ -template -struct NavierStokesNCModelTraits : NavierStokesModelTraits +template +struct NavierStokesNCModelTraits : NavierStokesModelTraits { //! There are as many momentum balance equations as dimensions //! and as many balance equations as components. @@ -94,7 +100,7 @@ struct NavierStokesNCModelTraits : NavierStokesModelTraits static constexpr bool enableMolecularDiffusion() { return true; } //! the indices - using Indices = FreeflowNCIndices>; + using Indices = FreeflowNCIndices>; }; /////////////////////////////////////////////////////////////////////////// @@ -127,6 +133,10 @@ private: static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); static constexpr int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); + + static_assert(phaseIdx >= 0 && phaseIdx < FluidSystem::numPhases, + "PhaseIdx must be non-negative and smaller than the number of phases"); + public: using type = NavierStokesNCModelTraits; }; diff --git a/dumux/freeflow/compositional/oneeqncmodel.hh b/dumux/freeflow/compositional/oneeqncmodel.hh index 98827f942d..a4b379e475 100644 --- a/dumux/freeflow/compositional/oneeqncmodel.hh +++ b/dumux/freeflow/compositional/oneeqncmodel.hh @@ -56,9 +56,15 @@ NEW_TYPE_TAG(OneEqNC, INHERITS_FROM(NavierStokesNC)); /*! * \ingroup FreeflowNCModel * \brief Traits for the one-equation multi-component model + * + * \tparam dimension The dimension of the problem + * \tparam nComp The number of components to be considered + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system + * \tparam replaceCompEqIdx The index of the component balance equation that should be replaced by a total mass/mole balance + * \tparam useM Use molar or mass balances */ -template -struct OneEqNCModelTraits : NavierStokesNCModelTraits +template +struct OneEqNCModelTraits : NavierStokesNCModelTraits { //! There are as many momentum balance equations as dimensions //! and as many balance equations as components. @@ -68,7 +74,7 @@ struct OneEqNCModelTraits : NavierStokesNCModelTraits>; + using Indices = FreeflowNCIndices>; }; //!< states some specifics of the isothermal multi-component one-equation model diff --git a/dumux/freeflow/navierstokes/indices.hh b/dumux/freeflow/navierstokes/indices.hh index f775628766..9bf4c76fea 100644 --- a/dumux/freeflow/navierstokes/indices.hh +++ b/dumux/freeflow/navierstokes/indices.hh @@ -31,8 +31,9 @@ namespace Dumux { * \brief The common indices for the isothermal Navier-Stokes model. * * \tparam dimension The dimension of the problem + * \tparam fsPhaseIdx The the index of the phase used for the fluid system */ -template +template struct NavierStokesIndices { static constexpr int dimXIdx = 0; //!< Index of the x-component of a vector of size dim @@ -63,7 +64,7 @@ struct NavierStokesIndices } //! The index of the fluid phase in the fluid system (for compatibility reasons) - static constexpr int fluidSystemPhaseIdx = 0; + static constexpr int fluidSystemPhaseIdx = fsPhaseIdx; }; } // end namespace Dumux diff --git a/dumux/freeflow/navierstokes/model.hh b/dumux/freeflow/navierstokes/model.hh index 3d4ef75503..1dd6562323 100644 --- a/dumux/freeflow/navierstokes/model.hh +++ b/dumux/freeflow/navierstokes/model.hh @@ -70,8 +70,11 @@ namespace Dumux { /*! * \ingroup NavierStokesModel * \brief Traits for the Navier-Stokes model + * + * \tparam dimension The dimension of the problem + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template +template struct NavierStokesModelTraits { //! The dimension of the model @@ -100,7 +103,7 @@ struct NavierStokesModelTraits static constexpr bool usesTurbulenceModel() { return false; } //! the indices - using Indices = NavierStokesIndices; + using Indices = NavierStokesIndices; }; /*! @@ -152,9 +155,13 @@ SET_PROP(NavierStokes, ModelTraits) { private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; - static constexpr int dim = GridView::dimension; + static constexpr auto dim = GridView::dimension; + static constexpr auto phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + + static_assert(phaseIdx >= 0 && phaseIdx < GET_PROP_TYPE(TypeTag, FluidSystem)::numPhases, + "PhaseIdx must be non-negative and smaller than the number of phases"); public: - using type = NavierStokesModelTraits; + using type = NavierStokesModelTraits; }; /*! @@ -183,9 +190,8 @@ private: using FST = typename GET_PROP_TYPE(TypeTag, FluidState); using MT = typename GET_PROP_TYPE(TypeTag, ModelTraits); - static_assert(MT::numPhases() == 1 && MT::numComponents() == 1 && - FSY::numPhases == 1 && FSY::numComponents == 1, - "The Navier-Stokes model only works with a single-phase fluid system."); + static_assert(!FSY::isMiscible(), + "The Navier-Stokes model only works with immiscible fluid systems."); using Traits = NavierStokesVolumeVariablesTraits; public: @@ -215,8 +221,9 @@ SET_PROP(NavierStokesNI, ModelTraits) { private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; - static constexpr int dim = GridView::dimension; - using IsothermalTraits = NavierStokesModelTraits; + static constexpr auto dim = GridView::dimension; + static constexpr auto fluidSystemPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + using IsothermalTraits = NavierStokesModelTraits; public: using type = FreeflowNIModelTraits; }; diff --git a/dumux/freeflow/rans/model.hh b/dumux/freeflow/rans/model.hh index 4723967012..f52023f155 100644 --- a/dumux/freeflow/rans/model.hh +++ b/dumux/freeflow/rans/model.hh @@ -65,9 +65,12 @@ SET_BOOL_PROP(RANS, EnableInertiaTerms, true); //!< Explicitly force the conside /*! * \ingroup RANSModel * \brief Traits for the Reynolds-averaged Navier-Stokes model + * + * \tparam dimension The dimension of the problem + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct RANSModelTraits : NavierStokesModelTraits +template +struct RANSModelTraits : NavierStokesModelTraits { //! The model does include a turbulence model static constexpr bool usesTurbulenceModel() { return true; } @@ -79,8 +82,12 @@ SET_PROP(RANS, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + + static_assert(phaseIdx >= 0 && phaseIdx < GET_PROP_TYPE(TypeTag, FluidSystem)::numPhases, + "PhaseIdx must be non-negative and smaller than the number of phases"); public: - using type = RANSModelTraits; + using type = RANSModelTraits; }; //! The specific vtk output fields @@ -105,7 +112,9 @@ SET_PROP(RANSNI, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; - using IsothermalTraits = RANSModelTraits; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + + using IsothermalTraits = RANSModelTraits; public: using type = FreeflowNIModelTraits; }; diff --git a/dumux/freeflow/rans/oneeq/indices.hh b/dumux/freeflow/rans/oneeq/indices.hh index 4ad0551ab0..92cd6727f4 100644 --- a/dumux/freeflow/rans/oneeq/indices.hh +++ b/dumux/freeflow/rans/oneeq/indices.hh @@ -35,9 +35,10 @@ namespace Dumux { * * \tparam dimension The dimension of the problem * \tparam numComponents The number of considered transported components + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct OneEqIndices : public NavierStokesIndices +template +struct OneEqIndices : public NavierStokesIndices { public: static constexpr auto viscosityTildeEqIdx = dimension + numComponents; diff --git a/dumux/freeflow/rans/oneeq/model.hh b/dumux/freeflow/rans/oneeq/model.hh index 8dde555d5a..cdf9e90c7f 100644 --- a/dumux/freeflow/rans/oneeq/model.hh +++ b/dumux/freeflow/rans/oneeq/model.hh @@ -94,9 +94,12 @@ namespace Properties { /*! * \ingroup OneEqModel * \brief Traits for the Spalart-Allmaras model + * + * \tparam dimension The dimension of the problem + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct OneEqModelTraits : RANSModelTraits +template +struct OneEqModelTraits : RANSModelTraits { //! The dimension of the model static constexpr int dim() { return dimension; } @@ -109,7 +112,7 @@ struct OneEqModelTraits : RANSModelTraits static constexpr int numComponents() { return 1; } //! the indices - using Indices = OneEqIndices; + using Indices = OneEqIndices; }; /////////////////////////////////////////////////////////////////////////// @@ -125,8 +128,9 @@ SET_PROP(OneEq, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); public: - using type = OneEqModelTraits; + using type = OneEqModelTraits; }; //! The flux variables @@ -184,7 +188,8 @@ SET_PROP(OneEqNI, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; - using IsothermalTraits = OneEqModelTraits; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + using IsothermalTraits = OneEqModelTraits; public: using type = FreeflowNIModelTraits; }; diff --git a/dumux/freeflow/rans/twoeq/kepsilon/indices.hh b/dumux/freeflow/rans/twoeq/kepsilon/indices.hh index 98a2fb402e..f690645d28 100644 --- a/dumux/freeflow/rans/twoeq/kepsilon/indices.hh +++ b/dumux/freeflow/rans/twoeq/kepsilon/indices.hh @@ -35,9 +35,10 @@ namespace Dumux { * * \tparam dimension The dimension of the problem * \tparam numComponents The number of considered transported components + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct KEpsilonIndices : public NavierStokesIndices +template +struct KEpsilonIndices : public NavierStokesIndices { public: static constexpr auto turbulentKineticEnergyEqIdx = dimension + numComponents; diff --git a/dumux/freeflow/rans/twoeq/kepsilon/model.hh b/dumux/freeflow/rans/twoeq/kepsilon/model.hh index a280b4c2c0..ea1a23bf8b 100644 --- a/dumux/freeflow/rans/twoeq/kepsilon/model.hh +++ b/dumux/freeflow/rans/twoeq/kepsilon/model.hh @@ -81,9 +81,12 @@ namespace Properties { /*! * \ingroup KEpsilonModel * \brief Traits for the k-epsilon model + * + * \tparam dimension The dimension of the problem + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct KEpsilonModelTraits : RANSModelTraits +template +struct KEpsilonModelTraits : RANSModelTraits { //! The dimension of the model static constexpr int dim() { return dimension; } @@ -96,7 +99,7 @@ struct KEpsilonModelTraits : RANSModelTraits static constexpr int numComponents() { return 1; } //! the indices - using Indices = KEpsilonIndices; + using Indices = KEpsilonIndices; }; /////////////////////////////////////////////////////////////////////////// @@ -112,8 +115,9 @@ SET_PROP(KEpsilon, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); public: - using type = KEpsilonModelTraits; + using type = KEpsilonModelTraits; }; //! The flux variables @@ -171,7 +175,8 @@ SET_PROP(KEpsilonNI, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; - using IsothermalTraits = KEpsilonModelTraits; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + using IsothermalTraits = KEpsilonModelTraits; public: using type = FreeflowNIModelTraits; }; diff --git a/dumux/freeflow/rans/twoeq/komega/indices.hh b/dumux/freeflow/rans/twoeq/komega/indices.hh index bfdfaf381f..0bbe07a04a 100644 --- a/dumux/freeflow/rans/twoeq/komega/indices.hh +++ b/dumux/freeflow/rans/twoeq/komega/indices.hh @@ -35,9 +35,10 @@ namespace Dumux { * * \tparam dimension The dimension of the problem * \tparam numComponents The number of considered transported components + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct KOmegaIndices : public NavierStokesIndices +template +struct KOmegaIndices : public NavierStokesIndices { public: static constexpr auto turbulentKineticEnergyEqIdx = dimension + numComponents; diff --git a/dumux/freeflow/rans/twoeq/komega/model.hh b/dumux/freeflow/rans/twoeq/komega/model.hh index eb300623f1..41460e66d9 100644 --- a/dumux/freeflow/rans/twoeq/komega/model.hh +++ b/dumux/freeflow/rans/twoeq/komega/model.hh @@ -88,9 +88,12 @@ namespace Properties { /*! *\ingroup KOmegaModel * \brief Traits for the k-omega model + * + * \tparam dimension The dimension of the problem + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct KOmegaModelTraits : RANSModelTraits +template +struct KOmegaModelTraits : RANSModelTraits { //! The dimension of the model static constexpr int dim() { return dimension; } @@ -103,7 +106,7 @@ struct KOmegaModelTraits : RANSModelTraits static constexpr int numComponents() { return 1; } //! The indices - using Indices = KOmegaIndices; + using Indices = KOmegaIndices; }; /////////////////////////////////////////////////////////////////////////// @@ -119,8 +122,9 @@ SET_PROP(KOmega, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); public: - using type = KOmegaModelTraits; + using type = KOmegaModelTraits; }; //! The flux variables @@ -179,7 +183,8 @@ SET_PROP(KOmegaNI, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; - using IsothermalTraits = KOmegaModelTraits; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + using IsothermalTraits = KOmegaModelTraits; public: using type = FreeflowNIModelTraits; }; diff --git a/dumux/freeflow/rans/twoeq/lowrekepsilon/indices.hh b/dumux/freeflow/rans/twoeq/lowrekepsilon/indices.hh index 0fb86e5fd2..85c1b14091 100644 --- a/dumux/freeflow/rans/twoeq/lowrekepsilon/indices.hh +++ b/dumux/freeflow/rans/twoeq/lowrekepsilon/indices.hh @@ -35,9 +35,10 @@ namespace Dumux { * * \tparam dimension The dimension of the problem * \tparam numComponents The number of considered transported components + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct LowReKEpsilonIndices : public NavierStokesIndices +template +struct LowReKEpsilonIndices : public NavierStokesIndices { public: static constexpr auto turbulentKineticEnergyEqIdx = dimension + numComponents; diff --git a/dumux/freeflow/rans/twoeq/lowrekepsilon/model.hh b/dumux/freeflow/rans/twoeq/lowrekepsilon/model.hh index 3bad183a27..0b56c0bb70 100644 --- a/dumux/freeflow/rans/twoeq/lowrekepsilon/model.hh +++ b/dumux/freeflow/rans/twoeq/lowrekepsilon/model.hh @@ -97,9 +97,12 @@ namespace Properties { /*! * \ingroup LowReKEpsilonModel * \brief Traits for the low-Reynolds k-epsilon model + * + * \tparam dimension The dimension of the problem + * \tparam fluidSystemPhaseIdx The the index of the phase used for the fluid system */ -template -struct LowReKEpsilonModelTraits : RANSModelTraits +template +struct LowReKEpsilonModelTraits : RANSModelTraits { //! The dimension of the model static constexpr int dim() { return dimension; } @@ -112,7 +115,7 @@ struct LowReKEpsilonModelTraits : RANSModelTraits static constexpr int numComponents() { return 1; } //! the indices - using Indices = LowReKEpsilonIndices; + using Indices = LowReKEpsilonIndices; }; /////////////////////////////////////////////////////////////////////////// @@ -128,8 +131,9 @@ SET_PROP(LowReKEpsilon, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); public: - using type = LowReKEpsilonModelTraits; + using type = LowReKEpsilonModelTraits; }; //! The flux variables @@ -187,7 +191,8 @@ SET_PROP(LowReKEpsilonNI, ModelTraits) private: using GridView = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::GridView; static constexpr int dim = GridView::dimension; - using IsothermalTraits = LowReKEpsilonModelTraits; + static constexpr int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); + using IsothermalTraits = LowReKEpsilonModelTraits; public: using type = FreeflowNIModelTraits; }; -- GitLab From 04d9b1c8908ea0b11774b31f46f1765cf236c989 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Mon, 2 Jul 2018 14:27:32 +0200 Subject: [PATCH 2/4] [freeflow][volVars] Add default phaseIdx to make compatible with PM volVars --- .../freeflow/compositional/volumevariables.hh | 30 ++++++++++++++++--- .../freeflow/navierstokes/volumevariables.hh | 10 +++---- dumux/freeflow/volumevariables.hh | 4 +-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/dumux/freeflow/compositional/volumevariables.hh b/dumux/freeflow/compositional/volumevariables.hh index aa76e966ac..286d6f456e 100644 --- a/dumux/freeflow/compositional/volumevariables.hh +++ b/dumux/freeflow/compositional/volumevariables.hh @@ -156,14 +156,14 @@ public: * \brief Return the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within * the control volume. */ - Scalar pressure() const + Scalar pressure(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.pressure(fluidSystemPhaseIdx); } /*! * \brief Return the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the * control volume. */ - Scalar density() const + Scalar density(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.density(fluidSystemPhaseIdx); } /*! @@ -187,9 +187,20 @@ public: * \brief Return the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the * control volume. */ - Scalar viscosity() const + Scalar viscosity(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.viscosity(fluidSystemPhaseIdx); } + /*! + * \brief Returns the mass fraction of a component in the phase \f$\mathrm{[-]}\f$ + * + * \param phaseIdx the index of the phase + * \param compIdx the index of the component + */ + Scalar massFraction(int phaseIdx, int compIdx) const + { + return fluidState_.massFraction(fluidSystemPhaseIdx, compIdx); + } + /*! * \brief Returns the mass fraction of a component in the phase \f$\mathrm{[-]}\f$ * @@ -200,6 +211,17 @@ public: return fluidState_.massFraction(fluidSystemPhaseIdx, compIdx); } + /*! + * \brief Returns the mole fraction of a component in the phase \f$\mathrm{[-]}\f$ + * + * \param phaseIdx the index of the phase + * \param compIdx the index of the component + */ + Scalar moleFraction(int phaseIdx, int compIdx) const + { + return fluidState_.moleFraction(fluidSystemPhaseIdx, compIdx); + } + /*! * \brief Returns the mole fraction of a component in the phase \f$\mathrm{[-]}\f$ * @@ -213,7 +235,7 @@ public: /*! * \brief Returns the mass density of a given phase \f$\mathrm{[kg/m^3]}\f$ */ - Scalar molarDensity() const + Scalar molarDensity(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.molarDensity(fluidSystemPhaseIdx); } diff --git a/dumux/freeflow/navierstokes/volumevariables.hh b/dumux/freeflow/navierstokes/volumevariables.hh index 9006aebf49..5cd11521ce 100644 --- a/dumux/freeflow/navierstokes/volumevariables.hh +++ b/dumux/freeflow/navierstokes/volumevariables.hh @@ -111,14 +111,14 @@ public: * \brief Return the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within * the control volume. */ - Scalar pressure() const + Scalar pressure(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.pressure(fluidSystemPhaseIdx); } /*! * \brief Return the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the * control volume. */ - Scalar density() const + Scalar density(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.density(fluidSystemPhaseIdx); } /*! @@ -135,7 +135,7 @@ public: * \brief Returns the mass density of a given phase within the * control volume. */ - Scalar molarDensity() const + Scalar molarDensity(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.molarDensity(fluidSystemPhaseIdx); } @@ -144,7 +144,7 @@ public: * \brief Returns the molar mass of a given phase within the * control volume. */ - Scalar molarMass() const + Scalar molarMass(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.averageMolarMass(fluidSystemPhaseIdx); } @@ -153,7 +153,7 @@ public: * \brief Return the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the * control volume. */ - Scalar viscosity() const + Scalar viscosity(int phaseIdx = fluidSystemPhaseIdx) const { return fluidState_.viscosity(fluidSystemPhaseIdx); } /*! diff --git a/dumux/freeflow/volumevariables.hh b/dumux/freeflow/volumevariables.hh index 7fe634f3e7..91937670f2 100644 --- a/dumux/freeflow/volumevariables.hh +++ b/dumux/freeflow/volumevariables.hh @@ -171,14 +171,14 @@ public: * \brief Returns the total internal energy of a phase in the * sub-control volume. */ - Scalar internalEnergy() const + Scalar internalEnergy(int phaseIdx = fluidSystemPhaseIdx) const { return ParentType::asImp_().fluidState().internalEnergy(fluidSystemPhaseIdx); } /*! * \brief Returns the total enthalpy of a phase in the sub-control * volume. */ - Scalar enthalpy() const + Scalar enthalpy(int phaseIdx = fluidSystemPhaseIdx) const { return ParentType::asImp_().fluidState().enthalpy(fluidSystemPhaseIdx); } /*! -- GitLab From 905ab559394b8207c8936f20b48346452e7c0e02 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Wed, 6 Jun 2018 14:55:23 +0200 Subject: [PATCH 3/4] [staggeredFVProblem] Fix bug in initialization --- dumux/common/staggeredfvproblem.hh | 42 ++++++++++-------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/dumux/common/staggeredfvproblem.hh b/dumux/common/staggeredfvproblem.hh index bed5fa94eb..43ddd021c3 100644 --- a/dumux/common/staggeredfvproblem.hh +++ b/dumux/common/staggeredfvproblem.hh @@ -69,6 +69,9 @@ class StaggeredFVProblem : public FVProblem static constexpr auto cellCenterIdx = FVGridGeometry::cellCenterIdx(); static constexpr auto faceIdx = FVGridGeometry::faceIdx(); + static constexpr auto numEqCellCenter = GET_PROP_VALUE(TypeTag, NumEqCellCenter); + static constexpr auto numEqFace = GET_PROP_VALUE(TypeTag, NumEqFace); + public: /*! * \brief Constructor @@ -174,24 +177,24 @@ public: //! Applys the initial cell center solution void applyInitialCellCenterSolution(SolutionVector& sol, - const SubControlVolume& scv, - const PrimaryVariables& initSol) const + const SubControlVolume& scv, + const PrimaryVariables& initSol) const { - constexpr auto numEqCellCenter = GET_PROP_VALUE(TypeTag, NumEqCellCenter); - constexpr auto numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq(); - constexpr auto offset = numEq - numEqCellCenter; + // while the container within the actual solution vector holds numEqCellCenter + // elements, we need to specify an offset to get the correct entry of the initial solution + static constexpr auto offset = PrimaryVariables::dimension - numEqCellCenter; - for(auto&& i : priVarIndices_(cellCenterIdx)) - sol[cellCenterIdx][scv.dofIndex()][i] = initSol[i + offset]; + for(int pvIdx = 0; pvIdx < numEqCellCenter; ++pvIdx) + sol[cellCenterIdx][scv.dofIndex()][pvIdx] = initSol[pvIdx + offset]; } //! Applys the initial face solution void applyInitialFaceSolution(SolutionVector& sol, - const SubControlVolumeFace& scvf, - const PrimaryVariables& initSol) const + const SubControlVolumeFace& scvf, + const PrimaryVariables& initSol) const { - for(auto&& i : priVarIndices_(faceIdx)) - sol[faceIdx][scvf.dofIndex()][i] = initSol[i]; + for(int pvIdx = 0; pvIdx < numEqFace; ++pvIdx) + sol[faceIdx][scvf.dofIndex()][pvIdx] = initSol[pvIdx]; } protected: @@ -202,23 +205,6 @@ protected: //! \copydoc asImp_() const Implementation &asImp_() const { return *static_cast(this); } - - //! Helper function that returns an iterable range of primary variable indices. - //! Specialization for cell center dofs. - static auto priVarIndices_(typename FVGridGeometry::DofTypeIndices::CellCenterIdx) - { - constexpr auto numEqCellCenter = GET_PROP_VALUE(TypeTag, NumEqCellCenter); - return Dune::range(0, numEqCellCenter); - } - - //! Helper function that returns an iterable range of primary variable indices. - //! Specialization for face dofs. - static auto priVarIndices_(typename FVGridGeometry::DofTypeIndices::FaceIdx) - { - constexpr auto numEqFace = GET_PROP_VALUE(TypeTag, NumEqFace); - return Dune::range(0, numEqFace); - } - }; } // end namespace Dumux -- GitLab From 2093804a1bc52a2da68a41f623c66f10bbacf7a7 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Wed, 30 May 2018 13:56:36 +0200 Subject: [PATCH 4/4] [staggered][freeflow] Fix handling of Neumann BCs * fluxes over all faces (except the one on the boundary) need to be considerd --- dumux/freeflow/navierstokes/staggered/fluxvariables.hh | 2 +- dumux/freeflow/navierstokes/staggered/localresidual.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh index 381d4f202c..d3ed268b86 100644 --- a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh +++ b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh @@ -248,7 +248,7 @@ public: // Handle inflow or outflow conditions. // Treat the staggered half-volume adjacent to the boundary as if it was on the opposite side of the boundary. // The respective face's outer normal vector will point in the same direction as the scvf's one. - if(scvf.boundary()) + if(scvf.boundary() && problem.boundaryTypes(element, scvf).isDirichlet(Indices::pressureIdx)) frontalFlux += inflowOutflowBoundaryFlux_(problem, element, scvf, elemVolVars, elemFaceVars); // Account for the staggered face's area. For rectangular elements, this equals the area of the scvf diff --git a/dumux/freeflow/navierstokes/staggered/localresidual.hh b/dumux/freeflow/navierstokes/staggered/localresidual.hh index 3f2b0a71a0..9b7e6fa865 100644 --- a/dumux/freeflow/navierstokes/staggered/localresidual.hh +++ b/dumux/freeflow/navierstokes/staggered/localresidual.hh @@ -299,7 +299,7 @@ protected: residual = problem.neumann(element, fvGeometry, elemVolVars, elemFaceVars, scvf)[Indices::velocity(scvf.directionIndex())] * extrusionFactor * scvf.area(); - // treat the remaining (normal) faces of the staggered control volume + // treat the remaining (frontal and lateral) faces of the staggered control volume residual += computeFluxForFace(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, elemFluxVarsCache); } else if(bcTypes.isSymmetry()) -- GitLab