diff --git a/dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh b/dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh index f2c1af54436644e2fa6111b1d95e1301581fbd47..29de016a9ee8e9367d4717c4934c3b3e87186179 100644 --- a/dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh +++ b/dumux/discretization/staggered/freeflow/subcontrolvolumeface.hh @@ -95,6 +95,22 @@ struct FreeFlowStaggeredDefaultScvfGeometryTraits using GlobalPosition = typename CornerStorage::value_type; }; +/*! + * \ingroup StaggeredDiscretization + * \brief Helper function to turn a given cell scvface into a fake boundary face + * \note This function is considered internal to staggered freeflow and may change or be deleted at any time without deprecation warning + */ +template<class SubControlVolumeFace> +SubControlVolumeFace makeStaggeredBoundaryFace(const SubControlVolumeFace& scvf, + const typename SubControlVolumeFace::GlobalPosition& newCenter) +{ + auto bf = scvf; + bf.setCenter(newCenter); + bf.setBoundary(true); + bf.setIsGhostFace(true); + return bf; +} + /*! * \ingroup StaggeredDiscretization * \brief Class for a sub control volume face in the staggered method, i.e a part of the boundary @@ -382,21 +398,17 @@ public: } } - /*! - * \brief Returns a copy of the own scvf whith a user-specified center position. - * This is needed for retrieving boundary conditions when the actual center does not coincide with the position - * on which the boundary condition is defined. - * - * \param pos The desired position of the boundary scvf's center - */ - FreeFlowStaggeredSubControlVolumeFace makeBoundaryFace(const GlobalPosition& pos) const - { - FreeFlowStaggeredSubControlVolumeFace boundaryFace = *this; - boundaryFace.center_ = pos; - boundaryFace.boundary_ = true; - boundaryFace.isGhostFace_ = true; - return boundaryFace; - } + //! set the center to a different position + void setCenter(const GlobalPosition& center) + { center_ = center; } + + //! set the boudnary flag + void setBoundary(bool boundaryFlag) + { boundary_ = boundaryFlag; } + + //! set the ghost face flag + void setIsGhostFace(bool isGhostFaceFlag) + { isGhostFace_ = isGhostFaceFlag; } private: Dune::GeometryType geomType_; @@ -420,4 +432,4 @@ private: } // end namespace Dumux -#endif // DUMUX_DISCRETIZATION_STAGGERED_FREE_FLOW_SUBCONTROLVOLUMEFACE_HH +#endif diff --git a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh index 4363a3269a858d53e862a6910e6695bdc580727c..e7d3e43fe300a1e821c736d5cf44364440fd471e 100644 --- a/dumux/freeflow/navierstokes/staggered/fluxvariables.hh +++ b/dumux/freeflow/navierstokes/staggered/fluxvariables.hh @@ -328,8 +328,8 @@ public: // Get the location of the lateral staggered face's center. FaceLateralSubControlVolumeFace lateralScvf(lateralStaggeredSCVFCenter_(lateralFace, scvf, localSubFaceIdx), 0.5*lateralFace.area()); const auto& lateralStaggeredFaceCenter = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx); - lateralFlux += problem.neumann(element, fvGeometry, elemVolVars, elemFaceVars, - scvf.makeBoundaryFace(lateralStaggeredFaceCenter))[Indices::velocity(lateralFace.directionIndex())] + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(scvf, lateralStaggeredFaceCenter); + lateralFlux += problem.neumann(element, fvGeometry, elemVolVars, elemFaceVars, lateralBoundaryFace)[Indices::velocity(lateralFace.directionIndex())] * extrusionFactor_(elemVolVars, lateralFace) * lateralScvf.area() * lateralFace.directionSign(); continue; @@ -344,8 +344,8 @@ public: { FaceLateralSubControlVolumeFace lateralScvf(lateralStaggeredSCVFCenter_(lateralFace, scvf, localSubFaceIdx), 0.5*lateralFace.area()); const auto& lateralStaggeredFaceCenter = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx); - lateralFlux += problem.neumann(element, fvGeometry, elemVolVars, elemFaceVars, - lateralFace.makeBoundaryFace(lateralStaggeredFaceCenter))[Indices::velocity(scvf.directionIndex())] + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(lateralFace, lateralStaggeredFaceCenter); + lateralFlux += problem.neumann(element, fvGeometry, elemVolVars, elemFaceVars, lateralBoundaryFace)[Indices::velocity(scvf.directionIndex())] * extrusionFactor_(elemVolVars, lateralFace) * lateralScvf.area() * lateralFace.directionSign(); continue; @@ -368,7 +368,7 @@ public: // the staggered faces's center. FaceLateralSubControlVolumeFace lateralScvf(lateralStaggeredSCVFCenter_(lateralFace, scvf, localSubFaceIdx), 0.5*lateralFace.area()); const auto& lateralStaggeredFaceCenter = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx); - const auto lateralBoundaryFace = lateralFace.makeBoundaryFace(lateralStaggeredFaceCenter); + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(lateralFace, lateralStaggeredFaceCenter); lateralFlux += problem.neumann(element, fvGeometry, elemVolVars, elemFaceVars, lateralBoundaryFace)[Indices::velocity(scvf.directionIndex())] * elemVolVars[lateralFace.insideScvIdx()].extrusionFactor() * lateralScvf.area(); continue; @@ -511,7 +511,8 @@ private: // Construct a temporary scvf which corresponds to the staggered sub face, featuring the location // the staggered faces's center. const auto& lateralBoundaryFacePos = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx); - return problem.dirichlet(element, scvf.makeBoundaryFace(lateralBoundaryFacePos))[Indices::velocity(lateralFace.directionIndex())]; + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(scvf, lateralBoundaryFacePos); + return problem.dirichlet(element, lateralBoundaryFace)[Indices::velocity(lateralFace.directionIndex())]; } else if (bcTypes.isBeaversJoseph(Indices::velocity(lateralFace.directionIndex()))) { @@ -680,7 +681,7 @@ private: if (problem.useWallFunction(element, lateralFace, Indices::velocity(scvf.directionIndex()))) { FaceLateralSubControlVolumeFace lateralScvf(lateralStaggeredSCVFCenter_(lateralFace, scvf, localSubFaceIdx), 0.5*lateralFace.area()); - const auto lateralBoundaryFace = lateralFace.makeBoundaryFace(lateralStaggeredFaceCenter_(scvf, localSubFaceIdx)); + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(lateralFace, lateralStaggeredFaceCenter_(scvf, localSubFaceIdx)); lateralFlux += problem.wallFunction(element, fvGeometry, elemVolVars, elemFaceVars, scvf, lateralBoundaryFace)[Indices::velocity(scvf.directionIndex())] * extrusionFactor_(elemVolVars, lateralFace) * lateralScvf.area(); return true; diff --git a/dumux/freeflow/navierstokes/staggered/staggeredupwindhelper.hh b/dumux/freeflow/navierstokes/staggered/staggeredupwindhelper.hh index a558e43b8d23642ba1eeb6ed216568084d1aed23..48220c853f43e1f07d7a42e2e87f00444c62adfc 100644 --- a/dumux/freeflow/navierstokes/staggered/staggeredupwindhelper.hh +++ b/dumux/freeflow/navierstokes/staggered/staggeredupwindhelper.hh @@ -407,7 +407,7 @@ private: // ---------------# const auto& lateralFace = fvGeometry_.scvf(scvf.insideScvIdx(), scvf.pairData(localSubFaceIdx).localLateralFaceIdx); - const auto ghostFace = lateralFace.makeBoundaryFace(scvf.pairData(localSubFaceIdx).lateralStaggeredFaceCenter); + const auto ghostFace = makeStaggeredBoundaryFace(lateralFace, scvf.pairData(localSubFaceIdx).lateralStaggeredFaceCenter); const auto& problem = elemVolVars_.gridVolVars().problem(); return problem.dirichlet(element, ghostFace)[Indices::velocity(scvf.directionIndex())]; } @@ -444,7 +444,8 @@ private: // Get the boundary types of the lateral opposite boundary face const auto& problem = elemVolVars_.gridVolVars().problem(); - const auto lateralOppositeFaceBoundaryTypes = problem.boundaryTypes(element, lateralOppositeScvf.makeBoundaryFace(center)); + const auto lateralOppositeBoundaryFace = makeStaggeredBoundaryFace(lateralOppositeScvf, center); + const auto lateralOppositeFaceBoundaryTypes = problem.boundaryTypes(element, lateralOppositeBoundaryFace); return getParallelVelocityFromBoundary_(element, scvf, faceVars, currentScvfBoundaryTypes, lateralOppositeFaceBoundaryTypes, localOppositeSubFaceIdx); } diff --git a/dumux/freeflow/navierstokes/staggered/velocitygradients.hh b/dumux/freeflow/navierstokes/staggered/velocitygradients.hh index a9c3c452b31e9d5ed9ba383d29cf3a592bd87986..b2c9d33a1cd97925efb797a6ad9c9f69d02ad781 100644 --- a/dumux/freeflow/navierstokes/staggered/velocitygradients.hh +++ b/dumux/freeflow/navierstokes/staggered/velocitygradients.hh @@ -119,7 +119,8 @@ public: { // Sample the value of the Dirichlet BC at the center of the staggered lateral face. const auto& lateralBoundaryFacePos = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx); - return problem.dirichlet(element, lateralScvf.makeBoundaryFace(lateralBoundaryFacePos))[Indices::velocity(scvf.directionIndex())]; + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(lateralScvf, lateralBoundaryFacePos); + return problem.dirichlet(element, lateralBoundaryFace)[Indices::velocity(scvf.directionIndex())]; } else if (lateralFaceBoundaryTypes->isBeaversJoseph(Indices::velocity(scvf.directionIndex()))) { @@ -198,7 +199,8 @@ public: { // Sample the value of the Dirichlet BC at the center of the lateral face intersecting with the boundary. const auto& lateralBoundaryFacePos = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx); - return problem.dirichlet(element, scvf.makeBoundaryFace(lateralBoundaryFacePos))[Indices::velocity(lateralScvf.directionIndex())]; + const auto lateralBoundaryFace = makeStaggeredBoundaryFace(scvf, lateralBoundaryFacePos); + return problem.dirichlet(element, lateralBoundaryFace)[Indices::velocity(lateralScvf.directionIndex())]; } else if (currentScvfBoundaryTypes->isBeaversJoseph(Indices::velocity(lateralScvf.directionIndex()))) {