GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p_2p/problem_stokes.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 33 37 89.2%
Functions: 4 6 66.7%
Branches: 20 52 38.5%

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 BoundaryTests
10 * \brief A simple Stokes test problem for the staggered grid (Navier-)Stokes model.
11 */
12
13 #ifndef DUMUX_STOKES_SUBPROBLEM_HH
14 #define DUMUX_STOKES_SUBPROBLEM_HH
15
16 #include <dumux/common/properties.hh>
17 #include <dumux/common/parameters.hh>
18 #include <dumux/common/numeqvector.hh>
19
20 #include <dumux/freeflow/navierstokes/boundarytypes.hh>
21 #include <dumux/freeflow/navierstokes/staggered/problem.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup BoundaryTests
27 * \brief Test problem for the one-phase (Navier-) Stokes problem.
28 *
29 * Vertical flow from top to bottom with a parabolic velocity profile.
30 */
31 template <class TypeTag>
32 class StokesSubProblem : public NavierStokesStaggeredProblem<TypeTag>
33 {
34 using ParentType = NavierStokesStaggeredProblem<TypeTag>;
35
36 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
37 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
38
39 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
40
41 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
42
43 using BoundaryTypes = Dumux::NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
44
45 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
46 using FVElementGeometry = typename GridGeometry::LocalView;
47 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
48 using Element = typename GridView::template Codim<0>::Entity;
49 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
50 using ElementFaceVariables = typename GetPropType<TypeTag, Properties::GridFaceVariables>::LocalView;
51
52 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
53
54 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
55 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
56
57 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
58
59 public:
60 1 StokesSubProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<CouplingManager> couplingManager)
61
5/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
3 : ParentType(gridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager)
62 {
63
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 inletVelocity_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Velocity");
64
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure");
65
8/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
1 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
66 1 }
67
68 /*!
69 * \brief The problem name.
70 */
71 const std::string& name() const
72 {
73
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 return problemName_;
74 }
75
76 /*!
77 * \name Problem parameters
78 */
79 // \{
80
81 /*!
82 * \brief Returns the sources within the domain.
83 *
84 * \param globalPos The global position
85 */
86 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
87 1483620 { return NumEqVector(0.0); }
88 // \}
89
90 /*!
91 * \name Boundary conditions
92 */
93 // \{
94
95 /*!
96 * \brief Specifies which kind of boundary condition should be
97 * used for which equation on a given boundary segment.
98 *
99 * \param element The finite element
100 * \param scvf The sub control volume face
101 */
102 351576 BoundaryTypes boundaryTypes(const Element& element,
103 const SubControlVolumeFace& scvf) const
104 {
105 351576 BoundaryTypes values;
106
107
2/2
✓ Branch 0 taken 113174 times.
✓ Branch 1 taken 238402 times.
351576 if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf))
108 {
109 113174 values.setCouplingNeumann(Indices::conti0EqIdx);
110 113174 values.setCouplingNeumann(Indices::momentumYBalanceIdx);
111 113174 values.setBeaversJoseph(Indices::momentumXBalanceIdx);
112 }
113 else
114 {
115 238402 values.setDirichlet(Indices::velocityXIdx);
116 238402 values.setDirichlet(Indices::velocityYIdx);
117 }
118
119 351576 return values;
120 }
121
122 /*!
123 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
124 */
125 139988 PrimaryVariables dirichletAtPos(const GlobalPosition& pos) const
126 {
127 139988 PrimaryVariables values(0.0);
128 279976 values = initialAtPos(pos);
129
130 139988 return values;
131 }
132
133 /*!
134 * \brief Evaluates the boundary conditions for a Neumann control volume.
135 *
136 * \param element The element for which the Neumann boundary condition is set
137 * \param fvGeometry The fvGeometry
138 * \param elemVolVars The element volume variables
139 * \param elemFaceVars The element face variables
140 * \param scvf The boundary sub control volume face
141 *
142 * For this method, the \a values variable stores primary variables.
143 */
144 39026 NumEqVector neumann(const Element& element,
145 const FVElementGeometry& fvGeometry,
146 const ElementVolumeVariables& elemVolVars,
147 const ElementFaceVariables& elemFaceVars,
148 const SubControlVolumeFace& scvf) const
149 {
150 39026 NumEqVector values(0.0);
151
152
1/2
✓ Branch 0 taken 39026 times.
✗ Branch 1 not taken.
39026 if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf))
153 {
154 39026 values[Indices::conti0EqIdx] = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf);
155 39026 values[Indices::momentumYBalanceIdx] = couplingManager().couplingData().momentumCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf);
156 }
157 39026 return values;
158 }
159
160 // \}
161
162 /*!
163 * \brief Get the coupling manager
164 */
165 const CouplingManager& couplingManager() const
166 859256 { return *couplingManager_; }
167
168 /*!
169 * \name Volume terms
170 */
171 // \{
172
173 /*!
174 * \brief Evaluates the initial value for a control volume.
175 *
176 * \param globalPos The global position
177 */
178 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
179 {
180 1618182 PrimaryVariables values(0.0);
181
182 1439168 values[Indices::pressureIdx] = pressure_;
183 8635008 values[Indices::velocityYIdx] = 4.0 * inletVelocity_ * globalPos[0] * (this->gridGeometry().bBoxMax()[0] - globalPos[0])
184 8635008 / (this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0])
185 10074176 / (this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0]);
186 return values;
187 }
188
189 /*!
190 * \brief Returns the intrinsic permeability of required as input parameter
191 for the Beavers-Joseph-Saffman boundary condition.
192 */
193 Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const
194 {
195 return couplingManager().couplingData().darcyPermeability(element, scvf);
196 }
197
198 /*!
199 * \brief Returns the alpha value required as input parameter for the
200 Beavers-Joseph-Saffman boundary condition.
201 */
202 Scalar alphaBJ(const SubControlVolumeFace& scvf) const
203 {
204 return 1.0;
205 }
206
207 // \}
208
209 private:
210 bool onLeftBoundary_(const GlobalPosition &globalPos) const
211 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
212
213 bool onRightBoundary_(const GlobalPosition &globalPos) const
214 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
215
216 bool onLowerBoundary_(const GlobalPosition &globalPos) const
217 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
218
219 bool onUpperBoundary_(const GlobalPosition &globalPos) const
220 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
221
222 Scalar eps_;
223 Scalar inletVelocity_;
224 Scalar pressure_;
225 std::string problemName_;
226 std::shared_ptr<CouplingManager> couplingManager_;
227 };
228 } // end namespace Dumux
229
230 #endif
231