From 9801affffe263521e8a3eb2602e4e73dc482eb21 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Mon, 3 Sep 2018 08:14:30 +0200 Subject: [PATCH] [freeflow] Remove wallFunctions from common problem * move to RANS problem --- dumux/freeflow/navierstokes/problem.hh | 25 ------------ .../navierstokes/staggered/fluxvariables.hh | 33 ++++++++++++--- .../navierstokes/staggered/localresidual.hh | 40 ++++++++++++++----- dumux/freeflow/rans/problem.hh | 37 +++++++++++++++++ 4 files changed, 96 insertions(+), 39 deletions(-) diff --git a/dumux/freeflow/navierstokes/problem.hh b/dumux/freeflow/navierstokes/problem.hh index b7e293907e..27504abbd5 100644 --- a/dumux/freeflow/navierstokes/problem.hh +++ b/dumux/freeflow/navierstokes/problem.hh @@ -76,8 +76,6 @@ class NavierStokesProblem : public NavierStokesParentProblem using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); - using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables); - using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables); using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices; enum { @@ -185,29 +183,6 @@ public: return pseudo3DWallFriction(velocity, viscosity, height, factor); } - //! \brief Checks whether a wall function should be used - bool useWallFunction(const Element& element, - const SubControlVolumeFace& localSubFace, - const int& eqIdx) const - { return false; } - - //! \brief Returns an additional wall function momentum flux (only needed for RANS models) - FacePrimaryVariables wallFunction(const Element& element, - const FVElementGeometry& fvGeometry, - const ElementVolumeVariables& elemVolVars, - const ElementFaceVariables& elemFaceVars, - const SubControlVolumeFace& scvf, - const SubControlVolumeFace& localSubFace) const - { return FacePrimaryVariables(0.0); } - - //! \brief Returns an additional wall function flux for cell-centered quantities (only needed for RANS models) - CellCenterPrimaryVariables wallFunction(const Element& element, - const FVElementGeometry& fvGeometry, - const ElementVolumeVariables& elemVolVars, - const ElementFaceVariables& elemFaceVars, - const SubControlVolumeFace& scvf) const - { return CellCenterPrimaryVariables(0.0); } - /*! * \brief Returns the intrinsic permeability of required as input parameter for the Beavers-Joseph-Saffman boundary condition * diff --git a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh index 657639ce3e..b36bb5aa1f 100644 --- a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh +++ b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh @@ -319,12 +319,8 @@ public: } // Handle wall-function fluxes (only required for RANS models) - if(problem.useWallFunction(element, localSubFace, Indices::velocity(scvf.directionIndex()))) - { - normalFlux += problem.wallFunction(element, fvGeometry, elemVolVars, elemFaceVars, scvf, localSubFace)[Indices::velocity(scvf.directionIndex())] - * elemVolVars[normalFace.insideScvIdx()].extrusionFactor() * normalFace.area() * 0.5; + if (incorporateWallFunction_(normalFlux, problem, element, fvGeometry, scvf, normalFace, localSubFace, elemVolVars, elemFaceVars)) continue; - } } // If there is no symmetry or Neumann boundary condition for the given sub face, proceed to calculate the tangential momentum flux. @@ -599,6 +595,33 @@ private: const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()]; return harmonicMean(insideVolVars.extrusionFactor(), outsideVolVars.extrusionFactor()); } + + //! do nothing if no turbulence model is used + template = 0> + bool incorporateWallFunction_(Args&&... args) const + { return false; }; + + //! if a turbulence model is used, ask the problem is a wall function shall be employed and get the flux accordingly + template = 0> + bool incorporateWallFunction_(FacePrimaryVariables& normalFlux, + const Problem& problem, + const Element& element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf, + const SubControlVolumeFace& normalFace, + const SubControlVolumeFace& localSubFace, + const ElementVolumeVariables& elemVolVars, + const ElementFaceVariables& elemFaceVars) const + { + if (problem.useWallFunction(element, localSubFace, Indices::velocity(scvf.directionIndex()))) + { + normalFlux += problem.wallFunction(element, fvGeometry, elemVolVars, elemFaceVars, scvf, localSubFace)[Indices::velocity(scvf.directionIndex())] + * elemVolVars[normalFace.insideScvIdx()].extrusionFactor() * normalFace.area() * 0.5; + return true; + } + else + return false; + }; }; } // end namespace diff --git a/dumux/freeflow/navierstokes/staggered/localresidual.hh b/dumux/freeflow/navierstokes/staggered/localresidual.hh index 4c9d615720..1e85a56bf4 100644 --- a/dumux/freeflow/navierstokes/staggered/localresidual.hh +++ b/dumux/freeflow/navierstokes/staggered/localresidual.hh @@ -253,15 +253,7 @@ protected: } // account for wall functions, if used - for(int eqIdx = 0; eqIdx < numEqCellCenter; ++eqIdx) - { - // use a wall function - if(problem.useWallFunction(element, scvf, eqIdx + cellCenterOffset)) - { - boundaryFlux[eqIdx] = problem.wallFunction(element, fvGeometry, elemVolVars, elemFaceVars, scvf)[eqIdx] - * extrusionFactor * scvf.area(); - } - } + incorporateWallFunction_(boundaryFlux, problem, element, fvGeometry, scvf, elemVolVars, elemFaceVars); // add the flux over the boundary scvf to the residual residual += boundaryFlux; @@ -333,6 +325,36 @@ protected: private: + //! do nothing if no turbulence model is used + template = 0> + void incorporateWallFunction_(Args&&... args) const + {}; + + //! if a turbulence model is used, ask the problem is a wall function shall be employed and get the flux accordingly + template = 0> + void incorporateWallFunction_(CellCenterResidual& boundaryFlux, + const Problem& problem, + const Element& element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf, + const ElementVolumeVariables& elemVolVars, + const ElementFaceVariables& elemFaceVars) const + { + static constexpr auto numEqCellCenter = CellCenterResidual::dimension; + const auto extrusionFactor = elemVolVars[scvf.insideScvIdx()].extrusionFactor(); + + // account for wall functions, if used + for(int eqIdx = 0; eqIdx < numEqCellCenter; ++eqIdx) + { + // use a wall function + if(problem.useWallFunction(element, scvf, eqIdx + cellCenterOffset)) + { + boundaryFlux[eqIdx] = problem.wallFunction(element, fvGeometry, elemVolVars, elemFaceVars, scvf)[eqIdx] + * extrusionFactor * scvf.area(); + } + } + }; + //! Returns the implementation of the problem (i.e. static polymorphism) Implementation &asImp_() { return *static_cast(this); } diff --git a/dumux/freeflow/rans/problem.hh b/dumux/freeflow/rans/problem.hh index 468194bb86..09fe625e98 100644 --- a/dumux/freeflow/rans/problem.hh +++ b/dumux/freeflow/rans/problem.hh @@ -55,11 +55,13 @@ class RANSProblem : public NavierStokesProblem using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using FVElementGeometry = typename FVGridGeometry::LocalView; using GridView = typename FVGridGeometry::GridView; + using Element = typename GridView::template Codim<0>::Entity; using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using PrimaryVariables = typename VolumeVariables::PrimaryVariables; using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables); + using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables); using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices; using GlobalPosition = typename SubControlVolumeFace::GlobalPosition; @@ -415,6 +417,41 @@ public: } } + /*! + * \brief Returns whether a wall function should be used at a given face + * + * \param element The element. + * \param scvf The sub control volume face. + * \param eqIdx The equation index. + */ + bool useWallFunction(const Element& element, + const SubControlVolumeFace& scvf, + const int& eqIdx) const + { return false; } + + /*! + * \brief Returns an additional wall function momentum flux + */ + template + FacePrimaryVariables wallFunction(const Element& element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const ElementFaceVariables& elemFaceVars, + const SubControlVolumeFace& scvf, + const SubControlVolumeFace& localSubFace) const + { return FacePrimaryVariables(0.0); } + + /*! + * \brief Returns an additional wall function flux for cell-centered quantities + */ + template + CellCenterPrimaryVariables wallFunction(const Element& element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const ElementFaceVariables& elemFaceVars, + const SubControlVolumeFace& scvf) const + { return CellCenterPrimaryVariables(0.0); } + /*! * \brief Returns whether a given sub control volume face is on a wall * -- GitLab