GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p3c_1p3c/problem_stokes.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 51 54 94.4%
Functions: 4 5 80.0%
Branches: 34 48 70.8%

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