From 74f28cad71f140f952a7f8781b10b9eb24e18ba1 Mon Sep 17 00:00:00 2001 From: Timo Koch <timokoch@math.uio.no> Date: Wed, 28 Feb 2024 19:51:51 +0000 Subject: [PATCH] [freeflow][slip] Improve naming scheme of new SlipVelocity classes Add more documentation --- .../navierstokes/momentum/fluxhelper.hh | 45 +++++++++++------ dumux/freeflow/navierstokes/slipcondition.hh | 48 ++++++++++++++----- .../1p_1p/problem_freeflow.hh | 4 +- .../1p_1p/convergence/problem_freeflow.hh | 4 +- .../1p_1p/problem_freeflow.hh | 4 +- 5 files changed, 74 insertions(+), 31 deletions(-) diff --git a/dumux/freeflow/navierstokes/momentum/fluxhelper.hh b/dumux/freeflow/navierstokes/momentum/fluxhelper.hh index 44ea7a5ea0..c1cf53d8df 100644 --- a/dumux/freeflow/navierstokes/momentum/fluxhelper.hh +++ b/dumux/freeflow/navierstokes/momentum/fluxhelper.hh @@ -10,8 +10,8 @@ * \ingroup NavierStokesModel * \copydoc Dumux::NavierStokesMomentumBoundaryFlux */ -#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_BOUNDARY_FLUXHELPER_HH -#define DUMUX_NAVIERSTOKES_MOMENTUM_BOUNDARY_FLUXHELPER_HH +#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MOMENTUM_BOUNDARY_FLUXHELPER_HH +#define DUMUX_FREEFLOW_NAVIERSTOKES_MOMENTUM_BOUNDARY_FLUXHELPER_HH #include <dumux/common/math.hh> #include <dumux/common/parameters.hh> @@ -21,15 +21,32 @@ namespace Dumux { -template<class DiscretizationMethod, class SlipVelocityHelper = void> +/*! + * \ingroup NavierStokesModel + * \brief Class to compute the boundary flux for the momentum balance of the Navier-Stokes model + * This helper class is typically used in the Neumann function of the momentum problem. + * + * \tparam DiscretizationMethod The discretization method used for the momentum problem + * \tparam SlipVelocityPolicy The policy to compute the slip velocity at the boundary + * + * The slip velocity policy is a class with a static member function `velocity` + * that computes the slip velocity at the boundary. + */ +template<class DiscretizationMethod, class SlipVelocityPolicy = void> struct NavierStokesMomentumBoundaryFlux; /*! * \ingroup NavierStokesModel - * \brief Struct containing flux helper functions to be used in the momentum problem's Neumann function. + * \brief Class to compute the boundary flux for the momentum balance of the Navier-Stokes model + * This helper class is typically used in the Neumann function of the momentum problem. + * + * \tparam SlipVelocityPolicy The policy to compute the slip velocity at the boundary + * + * The slip velocity policy is a class with a static member function `velocity` + * that computes the slip velocity at the boundary. */ -template<class SlipVelocityHelper> -struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, SlipVelocityHelper> +template<class SlipVelocityPolicy> +struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, SlipVelocityPolicy> { /*! * \brief Returns the momentum flux a fixed-pressure boundary. @@ -243,7 +260,7 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip * */ - if constexpr (!std::is_void_v<SlipVelocityHelper>) + if constexpr (!std::is_void_v<SlipVelocityPolicy>) { const Scalar velI = elemVolVars[scvf.insideScvIdx()].velocity(); @@ -258,7 +275,7 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip return tangentialVelocityGradient; }(); - const Scalar slipVelocity = SlipVelocityHelper::velocity(problem, fvGeometry, scvf, elemVolVars, velGradJI)[scv.dofAxis()]; + const Scalar slipVelocity = SlipVelocityPolicy::velocity(problem, fvGeometry, scvf, elemVolVars, velGradJI)[scv.dofAxis()]; const Scalar velGradIJ = (slipVelocity - velI) / distance * scvf.directionSign(); flux[scv.dofAxis()] -= (mu * (velGradIJ + velGradJI))*scvf.directionSign(); @@ -302,7 +319,7 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip } } else - DUNE_THROW(Dune::InvalidStateException, "SlipVelocityHelper needs to be specified as template argument"); + DUNE_THROW(Dune::InvalidStateException, "SlipVelocityPolicy needs to be specified as template argument"); } else if (scv.boundary() && problem.onSlipBoundary(fvGeometry, fvGeometry.frontalScvfOnBoundary(scv))) { @@ -327,7 +344,7 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip * */ - if constexpr (!std::is_void_v<SlipVelocityHelper>) + if constexpr (!std::is_void_v<SlipVelocityPolicy>) { const Scalar velJ = elemVolVars[orthogonalScvf.insideScvIdx()].velocity(); @@ -343,7 +360,7 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip return tangentialVelocityGradient; }(); - const Scalar slipVelocity = SlipVelocityHelper::velocity(problem, fvGeometry, orthogonalScvf, elemVolVars, velGradIJ)[scvf.normalAxis()]; + const Scalar slipVelocity = SlipVelocityPolicy::velocity(problem, fvGeometry, orthogonalScvf, elemVolVars, velGradIJ)[scvf.normalAxis()]; const Scalar velGradJI = (slipVelocity - velJ) / distance * orthogonalScvf.directionSign(); flux[scv.dofAxis()] -= (mu * (velGradIJ + velGradJI))*scvf.directionSign(); @@ -386,7 +403,7 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip } } else - DUNE_THROW(Dune::InvalidStateException, "SlipVelocityHelper needs to be specified as template argument"); + DUNE_THROW(Dune::InvalidStateException, "SlipVelocityPolicy needs to be specified as template argument"); } return flux; @@ -394,9 +411,9 @@ struct NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, Slip }; using NavierStokesMomentumBoundaryFluxHelper - [[deprecated("Replace with implementation class `NavierStokesMomentumBoundaryFlux`with template arguments `DiscretizationMethod` and `SlipVelocityHelper`. This will be removed after 3.9.")]] + [[deprecated("Replace with implementation class `NavierStokesMomentumBoundaryFlux`with template arguments `DiscretizationMethod` and `SlipVelocityPolicy`. This will be removed after 3.9.")]] = NavierStokesMomentumBoundaryFlux<DiscretizationMethods::FCStaggered, - SlipVelocityHelper<DiscretizationMethods::FCStaggered, SlipConditions::BJ>>; + NavierStokesSlipVelocity<DiscretizationMethods::FCStaggered, NavierStokes::SlipConditions::BJ>>; } // end namespace Dumux diff --git a/dumux/freeflow/navierstokes/slipcondition.hh b/dumux/freeflow/navierstokes/slipcondition.hh index 58dd3e21d7..5888d263c8 100644 --- a/dumux/freeflow/navierstokes/slipcondition.hh +++ b/dumux/freeflow/navierstokes/slipcondition.hh @@ -9,37 +9,63 @@ * \ingroup NavierStokesModel * \brief Navier Stokes slip condition */ -#ifndef DUMUX_NAVIERSTOKES_SLIPCONDITION_HH -#define DUMUX_NAVIERSTOKES_SLIPCONDITION_HH +#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_SLIPCONDITION_HH +#define DUMUX_FREEFLOW_NAVIERSTOKES_SLIPCONDITION_HH +#include <dumux/common/tag.hh> #include <dumux/discretization/method.hh> -namespace Dumux { - -namespace SlipConditions { +namespace Dumux::NavierStokes::SlipConditions { +/*! + * \ingroup NavierStokesModel + * \brief Tag for the Beavers-Joseph slip condition + */ struct BJ : public Utility::Tag<BJ> { static std::string name() { return "Beavers-Joseph"; } }; +/*! + * \ingroup NavierStokesModel + * \brief Tag for the Beavers-Joseph-Saffman slip condition + */ struct BJS : public Utility::Tag<BJS> { static std::string name() { return "Beavers-Joseph-Saffman"; } }; +/*! + * \ingroup NavierStokesModel + * \brief Tag for the Beavers-Joseph slip condition + */ inline constexpr BJ bj{}; + +/*! + * \ingroup NavierStokesModel + * \brief Tag for the Beavers-Joseph-Saffman slip condition + */ inline constexpr BJS bjs{}; -} // end namespace SlipModel +} // end namespace Dumux::NavierStokes::SlipConditions +namespace Dumux { + +/*! + * \ingroup NavierStokesModel + * \brief Navier Stokes slip velocity policy + */ template<class DiscretizationMethod, class SlipCondition> -class SlipVelocityHelper; +class NavierStokesSlipVelocity; /*! * \ingroup NavierStokesModel * \brief Navier Stokes slip velocity helper for fcstaggered discretization + * + * For now, this class implements the Beavers-Joseph or the Beavers-Joseph-Saffman condition + * which models the slip velocity at a porous boundary. The condition is chosen by passing + * the corresponding SlipCondition tag to the class. */ -template< class SlipCondition> -struct SlipVelocityHelper<DiscretizationMethods::FCStaggered, SlipCondition> +template<class SlipCondition> +struct NavierStokesSlipVelocity<DiscretizationMethods::FCStaggered, SlipCondition> { static constexpr SlipCondition slipCondition{}; @@ -67,9 +93,9 @@ struct SlipVelocityHelper<DiscretizationMethods::FCStaggered, SlipCondition> Vector porousMediumVelocity(0.0); - if constexpr (slipCondition == SlipConditions::bj) + if constexpr (slipCondition == NavierStokes::SlipConditions::bj) porousMediumVelocity = problem.porousMediumVelocity(fvGeometry, scvf); - else if (!(slipCondition == SlipConditions::bjs)) + else if (!(slipCondition == NavierStokes::SlipConditions::bjs)) DUNE_THROW(Dune::NotImplemented, "Fcstaggered currently only implements BJ or BJS slip conditions"); const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); diff --git a/test/multidomain/boundary/freeflowporenetwork/1p_1p/problem_freeflow.hh b/test/multidomain/boundary/freeflowporenetwork/1p_1p/problem_freeflow.hh index b8c9ef89b0..0c2cde8305 100644 --- a/test/multidomain/boundary/freeflowporenetwork/1p_1p/problem_freeflow.hh +++ b/test/multidomain/boundary/freeflowporenetwork/1p_1p/problem_freeflow.hh @@ -166,8 +166,8 @@ public: { BoundaryFluxes values(0.0); const auto& globalPos = scvf.ipGlobal(); - using SlipVelocityHelper = SlipVelocityHelper<typename GridGeometry::DiscretizationMethod, SlipConditions::BJ>; - using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod, SlipVelocityHelper>; + using SlipVelocityPolicy = NavierStokesSlipVelocity<typename GridGeometry::DiscretizationMethod, NavierStokes::SlipConditions::BJ>; + using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod, SlipVelocityPolicy>; if constexpr (ParentType::isMomentumProblem()) { diff --git a/test/multidomain/boundary/freeflowporousmedium/1p_1p/convergence/problem_freeflow.hh b/test/multidomain/boundary/freeflowporousmedium/1p_1p/convergence/problem_freeflow.hh index 7910f3bac7..3b3912ef11 100644 --- a/test/multidomain/boundary/freeflowporousmedium/1p_1p/convergence/problem_freeflow.hh +++ b/test/multidomain/boundary/freeflowporousmedium/1p_1p/convergence/problem_freeflow.hh @@ -164,8 +164,8 @@ public: { BoundaryFluxes values(0.0); const auto& globalPos = scvf.ipGlobal(); - using SlipVelocityHelper = SlipVelocityHelper<typename GridGeometry::DiscretizationMethod, SlipConditions::BJS>; - using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod, SlipVelocityHelper>; + using SlipVelocityPolicy = NavierStokesSlipVelocity<typename GridGeometry::DiscretizationMethod, NavierStokes::SlipConditions::BJS>; + using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod, SlipVelocityPolicy>; // momentum boundary conditions if constexpr (ParentType::isMomentumProblem()) diff --git a/test/multidomain/boundary/freeflowporousmedium/1p_1p/problem_freeflow.hh b/test/multidomain/boundary/freeflowporousmedium/1p_1p/problem_freeflow.hh index 4639936c7e..a11c9c9397 100644 --- a/test/multidomain/boundary/freeflowporousmedium/1p_1p/problem_freeflow.hh +++ b/test/multidomain/boundary/freeflowporousmedium/1p_1p/problem_freeflow.hh @@ -180,8 +180,8 @@ public: { BoundaryFluxes values(0.0); const auto& globalPos = scvf.ipGlobal(); - using SlipVelocityHelper = SlipVelocityHelper<typename GridGeometry::DiscretizationMethod, SlipConditions::BJS>; - using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod, SlipVelocityHelper>; + using SlipVelocityPolicy = NavierStokesSlipVelocity<typename GridGeometry::DiscretizationMethod, NavierStokes::SlipConditions::BJS>; + using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod, SlipVelocityPolicy>; if constexpr (ParentType::isMomentumProblem()) { -- GitLab