Commit 9801afff authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[freeflow] Remove wallFunctions from common problem

* move to RANS problem
parent c5787288
......@@ -76,8 +76,6 @@ class NavierStokesProblem : public NavierStokesParentProblem<TypeTag>
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
*
......
......@@ -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<class ...Args, bool turbulenceModel = ModelTraits::usesTurbulenceModel(), std::enable_if_t<!turbulenceModel, int> = 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<bool turbulenceModel = ModelTraits::usesTurbulenceModel(), std::enable_if_t<turbulenceModel, int> = 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
......
......@@ -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<class ...Args, bool turbulenceModel = ModelTraits::usesTurbulenceModel(), std::enable_if_t<!turbulenceModel, int> = 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<bool turbulenceModel = ModelTraits::usesTurbulenceModel(), std::enable_if_t<turbulenceModel, int> = 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<Implementation *>(this); }
......
......@@ -55,11 +55,13 @@ class RANSProblem : public NavierStokesProblem<TypeTag>
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<class ElementVolumeVariables, class ElementFaceVariables>
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<class ElementVolumeVariables, class ElementFaceVariables>
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
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment