GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/slipcondition.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 3 3 100.0%
Branches: 11 18 61.1%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup NavierStokesModel
10 * \brief Navier Stokes slip condition
11 */
12 #ifndef DUMUX_FREEFLOW_NAVIERSTOKES_SLIPCONDITION_HH
13 #define DUMUX_FREEFLOW_NAVIERSTOKES_SLIPCONDITION_HH
14
15 #include <dune/common/fvector.hh>
16 #include <dumux/common/tag.hh>
17 #include <dumux/common/parameters.hh>
18 #include <dumux/discretization/method.hh>
19
20 namespace Dumux::NavierStokes::SlipConditions {
21
22 /*!
23 * \ingroup NavierStokesModel
24 * \brief Tag for the Beavers-Joseph slip condition
25 */
26 struct BJ : public Utility::Tag<BJ> {
27 static std::string name() { return "Beavers-Joseph"; }
28 };
29
30 /*!
31 * \ingroup NavierStokesModel
32 * \brief Tag for the Beavers-Joseph-Saffman slip condition
33 */
34 struct BJS : public Utility::Tag<BJS> {
35 static std::string name() { return "Beavers-Joseph-Saffman"; }
36 };
37
38 /*!
39 * \ingroup NavierStokesModel
40 * \brief Tag for the Beavers-Joseph slip condition
41 */
42 inline constexpr BJ bj{};
43
44 /*!
45 * \ingroup NavierStokesModel
46 * \brief Tag for the Beavers-Joseph-Saffman slip condition
47 */
48 inline constexpr BJS bjs{};
49
50 } // end namespace Dumux::NavierStokes::SlipConditions
51
52 namespace Dumux {
53
54 /*!
55 * \ingroup NavierStokesModel
56 * \brief Navier Stokes slip velocity policy
57 */
58 template<class DiscretizationMethod, class SlipCondition>
59 class NavierStokesSlipVelocity;
60
61 /*!
62 * \ingroup NavierStokesModel
63 * \brief Navier Stokes slip velocity helper for fcstaggered discretization
64 *
65 * For now, this class implements the Beavers-Joseph or the Beavers-Joseph-Saffman condition
66 * which models the slip velocity at a porous boundary. The condition is chosen by passing
67 * the corresponding SlipCondition tag to the class.
68 */
69 template<class SlipCondition>
70 class NavierStokesSlipVelocity<DiscretizationMethods::FCStaggered, SlipCondition>
71 {
72 public:
73 static constexpr SlipCondition slipCondition{};
74
75 /*!
76 * \brief Returns the slip velocity at a porous boundary based on the Beavers-Joseph(-Saffman) condition.
77 * \note This only returns a vector filled with one component of the slip velocity (corresponding to the dof axis of the scv the svf belongs to)
78 * \param problem The problem
79 * \param fvGeometry The finite-volume geometry
80 * \param scvf The sub control volume face
81 * \param elemVolVars The volume variables for the element
82 * \param tangentialVelocityDeriv Pre-calculated velocity derivative
83 */
84 template<class Problem, class FVElementGeometry, class ElementVolumeVariables, class Scalar>
85 147310 static auto velocity(const Problem& problem,
86 const FVElementGeometry& fvGeometry,
87 const typename FVElementGeometry::SubControlVolumeFace& scvf,
88 const ElementVolumeVariables& elemVolVars,
89 Scalar tangentialVelocityDeriv)
90 {
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147310 times.
147310 assert(scvf.isLateral());
92
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147310 times.
147310 assert(scvf.boundary());
93
94 static constexpr int dimWorld = FVElementGeometry::GridGeometry::GridView::dimensionworld;
95 using Vector = Dune::FieldVector<Scalar, dimWorld>;
96
97 147310 Vector porousMediumVelocity(0.0);
98
99 if constexpr (slipCondition == NavierStokes::SlipConditions::bj)
100 3606 porousMediumVelocity = problem.porousMediumVelocity(fvGeometry, scvf);
101 else if (!(slipCondition == NavierStokes::SlipConditions::bjs))
102 DUNE_THROW(Dune::NotImplemented, "Fcstaggered currently only implements BJ or BJS slip conditions");
103
104
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147310 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147310 times.
294620 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
105
106 // create a unit normal vector oriented in positive coordinate direction
107 147310 Vector tangent(0.0);
108 147310 tangent[scv.dofAxis()] = 1.0;
109
110 // du/dy + dv/dx = beta * (u_boundary-uPM)
111 // beta = alpha/sqrt(K)
112 147310 const Scalar betaBJ = problem.betaBJ(fvGeometry, scvf, tangent);
113 589240 const Scalar distanceNormalToBoundary = (scvf.ipGlobal() - scv.dofPosition()).two_norm();
114
115
5/8
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 147294 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 16 times.
✗ Branch 10 not taken.
147310 static const bool onlyNormalGradient = getParamFromGroup<bool>(problem.paramGroup(), "FreeFlow.EnableUnsymmetrizedVelocityGradientForBeaversJoseph", false);
116
2/2
✓ Branch 0 taken 63680 times.
✓ Branch 1 taken 83630 times.
147310 if (onlyNormalGradient)
117 63680 tangentialVelocityDeriv = 0.0;
118
119 294620 const Scalar scalarSlipVelocity = (tangentialVelocityDeriv*distanceNormalToBoundary
120 147310 + porousMediumVelocity * tangent * betaBJ * distanceNormalToBoundary
121 147310 + elemVolVars[scv].velocity()) / (betaBJ*distanceNormalToBoundary + 1.0);
122
123 294620 return scalarSlipVelocity*tangent;
124 }
125 };
126
127 } // end namespace Dumux
128
129 #endif
130