GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p_1p/problem_stokes.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 46 50 92.0%
Functions: 4 6 66.7%
Branches: 95 144 66.0%

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 <dune/grid/yaspgrid.hh>
17 #include <dumux/common/numeqvector.hh>
18 #include <dumux/discretization/staggered/freeflow/properties.hh>
19
20 #include <dumux/freeflow/navierstokes/boundarytypes.hh>
21 #include <dumux/freeflow/navierstokes/model.hh>
22 #include <dumux/freeflow/navierstokes/staggered/problem.hh>
23
24 #include <dumux/material/fluidsystems/1pliquid.hh>
25 #include <dumux/material/components/simpleh2o.hh>
26
27 namespace Dumux {
28
29 /*!
30 * \ingroup BoundaryTests
31 * \brief Test problem for the one-phase (Navier-) Stokes problem.
32 *
33 * Horizontal flow from left to right with a parabolic velocity profile.
34 */
35 template <class TypeTag>
36 class StokesSubProblem : public NavierStokesStaggeredProblem<TypeTag>
37 {
38 using ParentType = NavierStokesStaggeredProblem<TypeTag>;
39
40 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
41 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
42
43 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
44
45 using BoundaryTypes = Dumux::NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
46
47 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
48 using FVElementGeometry = typename GridGeometry::LocalView;
49 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
50 using Element = typename GridView::template Codim<0>::Entity;
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 2 StokesSubProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<CouplingManager> couplingManager)
61
5/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 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.
6 : ParentType(gridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager)
62 {
63
9/26
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 2 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
4 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
64
65 // determine whether to simulate a vertical or horizontal flow configuration
66 2 verticalFlow_ = problemName_.find("vertical") != std::string::npos;
67 2 }
68
69 /*!
70 * \name Problem parameters
71 */
72 // \{
73
74 /*!
75 * \brief The problem name.
76 */
77 const std::string& name() const
78 {
79
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 return problemName_;
80 }
81
82 /*!
83 * \brief Returns the sources within the domain.
84 *
85 * \param globalPos The global position
86 */
87 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
88 75040 { return NumEqVector(0.0); }
89
90 // \}
91
92 /*!
93 * \name Boundary conditions
94 */
95 // \{
96
97 /*!
98 * \brief Specifies which kind of boundary condition should be
99 * used for which equation on a given boundary segment.
100 *
101 * \param element The finite element
102 * \param scvf The sub control volume face
103 */
104 18688 BoundaryTypes boundaryTypes(const Element& element,
105 const SubControlVolumeFace& scvf) const
106 {
107 18688 BoundaryTypes values;
108
109
2/2
✓ Branch 0 taken 8920 times.
✓ Branch 1 taken 9768 times.
18688 const auto& globalPos = scvf.dofPosition();
110
111
2/2
✓ Branch 0 taken 8920 times.
✓ Branch 1 taken 9768 times.
18688 if (verticalFlow_)
112 {
113 // inflow
114 17840 if(onUpperBoundary_(globalPos))
115 {
116 2040 values.setDirichlet(Indices::velocityXIdx);
117 2040 values.setDirichlet(Indices::velocityYIdx);
118 }
119
120 // left/right wall
121 31552 if (onRightBoundary_(globalPos) || (onLeftBoundary_(globalPos)))
122 {
123 4128 values.setDirichlet(Indices::velocityXIdx);
124 4128 values.setDirichlet(Indices::velocityYIdx);
125 }
126 }
127 else // horizontal flow
128 {
129 // inlet / outlet
130 34160 if(onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
131 4912 values.setDirichlet(Indices::pressureIdx);
132 else // wall
133 {
134 4856 values.setDirichlet(Indices::velocityXIdx);
135 4856 values.setDirichlet(Indices::velocityYIdx);
136 }
137
138 }
139
140
2/2
✓ Branch 0 taken 5536 times.
✓ Branch 1 taken 13152 times.
18688 if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf))
141 {
142 5536 values.setCouplingNeumann(Indices::conti0EqIdx);
143 5536 values.setCouplingNeumann(Indices::momentumYBalanceIdx);
144 5536 values.setBeaversJoseph(Indices::momentumXBalanceIdx);
145 }
146
147 18688 return values;
148 }
149
150 /*!
151 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
152 */
153 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
154 {
155
1/10
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 7 taken 3152 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
5784 return initialAtPos(globalPos);
156 }
157
158 /*!
159 * \brief Evaluates the boundary conditions for a Neumann control volume.
160 *
161 * \param element The element for which the Neumann boundary condition is set
162 * \param fvGeometry The fvGeometry
163 * \param elemVolVars The element volume variables
164 * \param elemFaceVars The element face variables
165 * \param scvf The boundary sub control volume face
166 */
167 template<class ElementVolumeVariables, class ElementFaceVariables>
168 1816 NumEqVector neumann(const Element& element,
169 const FVElementGeometry& fvGeometry,
170 const ElementVolumeVariables& elemVolVars,
171 const ElementFaceVariables& elemFaceVars,
172 const SubControlVolumeFace& scvf) const
173 {
174 1816 NumEqVector values(0.0);
175
176
1/2
✓ Branch 0 taken 1816 times.
✗ Branch 1 not taken.
1816 if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf))
177 {
178 1816 values[Indices::conti0EqIdx] = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf);
179 1816 values[Indices::momentumYBalanceIdx] = couplingManager().couplingData().momentumCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf);
180 }
181 1816 return values;
182 }
183
184 // \}
185
186 //! Get the coupling manager
187 const CouplingManager& couplingManager() const
188 44640 { return *couplingManager_; }
189
190 /*!
191 * \name Volume terms
192 */
193 // \{
194
195 /*!
196 * \brief Evaluates the initial value for a control volume.
197 *
198 * \param globalPos The global position
199 */
200 81856 PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const
201 {
202 81856 PrimaryVariables values(0.0);
203
204
2/2
✓ Branch 0 taken 40788 times.
✓ Branch 1 taken 41068 times.
81856 if (verticalFlow_)
205 {
206
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 40787 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
40788 static const Scalar inletVelocity = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Velocity");
207 285516 values[Indices::velocityYIdx] = inletVelocity * globalPos[0] * (this->gridGeometry().bBoxMax()[0] - globalPos[0]);
208 }
209 else // horizontal flow
210 {
211
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 41067 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
41068 static const Scalar deltaP = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.PressureDifference");
212 82136 if(onLeftBoundary_(globalPos))
213 2664 values[Indices::pressureIdx] = deltaP;
214 }
215
216 81856 return values;
217 }
218
219 /*!
220 * \brief Returns the intrinsic permeability of required as input parameter
221 for the Beavers-Joseph-Saffman boundary condition
222 */
223 Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const
224 {
225 return couplingManager().couplingData().darcyPermeability(element, scvf);
226 }
227
228 /*!
229 * \brief Returns the alpha value required as input parameter for the
230 Beavers-Joseph-Saffman boundary condition.
231 */
232 Scalar alphaBJ(const SubControlVolumeFace& scvf) const
233 {
234 return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center());
235 }
236
237 // \}
238
239 private:
240 bool onLeftBoundary_(const GlobalPosition &globalPos) const
241
30/30
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 39736 times.
✓ Branch 2 taken 1332 times.
✓ Branch 3 taken 39736 times.
✓ Branch 4 taken 1332 times.
✓ Branch 5 taken 39736 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 39736 times.
✓ Branch 8 taken 1332 times.
✓ Branch 9 taken 39736 times.
✓ Branch 10 taken 2064 times.
✓ Branch 11 taken 4792 times.
✓ Branch 12 taken 2064 times.
✓ Branch 13 taken 4792 times.
✓ Branch 14 taken 2064 times.
✓ Branch 15 taken 4792 times.
✓ Branch 16 taken 2064 times.
✓ Branch 17 taken 4792 times.
✓ Branch 18 taken 2064 times.
✓ Branch 19 taken 4792 times.
✓ Branch 20 taken 7312 times.
✓ Branch 21 taken 2456 times.
✓ Branch 22 taken 7312 times.
✓ Branch 23 taken 2456 times.
✓ Branch 24 taken 7312 times.
✓ Branch 25 taken 2456 times.
✓ Branch 26 taken 7312 times.
✓ Branch 27 taken 2456 times.
✓ Branch 28 taken 7312 times.
✓ Branch 29 taken 2456 times.
288460 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
242
243 bool onRightBoundary_(const GlobalPosition &globalPos) const
244
20/20
✓ Branch 0 taken 6856 times.
✓ Branch 1 taken 2064 times.
✓ Branch 2 taken 6856 times.
✓ Branch 3 taken 2064 times.
✓ Branch 4 taken 6856 times.
✓ Branch 5 taken 2064 times.
✓ Branch 6 taken 6856 times.
✓ Branch 7 taken 2064 times.
✓ Branch 8 taken 6856 times.
✓ Branch 9 taken 2064 times.
✓ Branch 10 taken 4856 times.
✓ Branch 11 taken 2456 times.
✓ Branch 12 taken 4856 times.
✓ Branch 13 taken 2456 times.
✓ Branch 14 taken 4856 times.
✓ Branch 15 taken 2456 times.
✓ Branch 16 taken 4856 times.
✓ Branch 17 taken 2456 times.
✓ Branch 18 taken 4856 times.
✓ Branch 19 taken 2456 times.
81160 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
245
246 bool onLowerBoundary_(const GlobalPosition &globalPos) const
247 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
248
249 bool onUpperBoundary_(const GlobalPosition &globalPos) const
250
10/10
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 6880 times.
✓ Branch 2 taken 2040 times.
✓ Branch 3 taken 6880 times.
✓ Branch 4 taken 2040 times.
✓ Branch 5 taken 6880 times.
✓ Branch 6 taken 2040 times.
✓ Branch 7 taken 6880 times.
✓ Branch 8 taken 2040 times.
✓ Branch 9 taken 6880 times.
44600 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
251
252 Scalar eps_;
253 std::string problemName_;
254 bool verticalFlow_;
255
256 std::shared_ptr<CouplingManager> couplingManager_;
257 };
258 } // end namespace Dumux
259
260 #endif
261