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 Navier-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 | #include <dumux/common/timeloop.hh> | ||
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 | * Horizontal flow from left to right with a parabolic velocity profile. | ||
30 | */ | ||
31 | template <class TypeTag> | ||
32 | class StokesSubProblem : public NavierStokesStaggeredProblem<TypeTag> | ||
33 | { | ||
34 | using ParentType = NavierStokesStaggeredProblem<TypeTag>; | ||
35 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
36 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
37 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
38 | using BoundaryTypes = Dumux::NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
39 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
40 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
41 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
42 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
43 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
44 | |||
45 | using Element = typename GridView::template Codim<0>::Entity; | ||
46 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
47 | |||
48 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
49 | using TimeLoopPtr = std::shared_ptr<TimeLoop<Scalar>>; | ||
50 | |||
51 | public: | ||
52 | 3 | StokesSubProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<CouplingManager> couplingManager) | |
53 |
6/20✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
✓ Branch 18 taken 3 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
9 | : ParentType(gridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) |
54 | { | ||
55 |
9/26✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 3 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.
|
6 | problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); |
56 | |||
57 | // determine whether to simulate a vertical or horizontal flow configuration | ||
58 | 3 | verticalFlow_ = problemName_.find("vertical") != std::string::npos; | |
59 | 3 | } | |
60 | |||
61 | /*! | ||
62 | * \name Problem parameters | ||
63 | */ | ||
64 | // \{ | ||
65 | |||
66 | /*! | ||
67 | * \brief The problem name. | ||
68 | */ | ||
69 | const std::string& name() const | ||
70 | { | ||
71 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | return problemName_; |
72 | } | ||
73 | |||
74 | /*! | ||
75 | * \brief Returns the sources within the domain. | ||
76 | * | ||
77 | * \param globalPos The global position | ||
78 | */ | ||
79 | ✗ | NumEqVector sourceAtPos(const GlobalPosition &globalPos) const | |
80 | 3870240 | { return NumEqVector(0.0); } | |
81 | // \} | ||
82 | |||
83 | /*! | ||
84 | * \name Boundary conditions | ||
85 | */ | ||
86 | // \{ | ||
87 | |||
88 | /*! | ||
89 | * \brief Specifies which kind of boundary condition should be | ||
90 | * used for which equation on a given boundary segment. | ||
91 | * | ||
92 | * \param element The finite element | ||
93 | * \param scvf The sub control volume face | ||
94 | */ | ||
95 | 939712 | BoundaryTypes boundaryTypes(const Element& element, | |
96 | const SubControlVolumeFace& scvf) const | ||
97 | { | ||
98 | 939712 | BoundaryTypes values; | |
99 | |||
100 |
2/2✓ Branch 0 taken 615312 times.
✓ Branch 1 taken 324400 times.
|
939712 | const auto& globalPos = scvf.dofPosition(); |
101 | |||
102 |
2/2✓ Branch 0 taken 615312 times.
✓ Branch 1 taken 324400 times.
|
939712 | if (verticalFlow_) |
103 | { | ||
104 | // inflow | ||
105 | 1230624 | if(onUpperBoundary_(globalPos)) | |
106 | { | ||
107 | 140212 | values.setDirichlet(Indices::velocityXIdx); | |
108 | 140212 | values.setDirichlet(Indices::velocityYIdx); | |
109 | 140212 | values.setDirichlet(Indices::conti0EqIdx + 1); | |
110 | } | ||
111 | |||
112 | // left/right wall | ||
113 | 2177328 | if (onRightBoundary_(globalPos) || (onLeftBoundary_(globalPos))) | |
114 | { | ||
115 | 283920 | values.setDirichlet(Indices::velocityXIdx); | |
116 | 283920 | values.setDirichlet(Indices::velocityYIdx); | |
117 | 283920 | values.setNeumann(Indices::conti0EqIdx); | |
118 | 283920 | values.setNeumann(Indices::conti0EqIdx + 1); | |
119 | } | ||
120 | |||
121 | } | ||
122 | else // horizontal flow | ||
123 | { | ||
124 | 648800 | if (onLeftBoundary_(globalPos)) | |
125 | { | ||
126 | 61840 | values.setDirichlet(Indices::conti0EqIdx + 1); | |
127 | 61840 | values.setDirichlet(Indices::velocityXIdx); | |
128 | 61840 | values.setDirichlet(Indices::velocityYIdx); | |
129 | } | ||
130 | 525120 | else if (onRightBoundary_(globalPos)) | |
131 | { | ||
132 | 92320 | values.setDirichlet(Indices::pressureIdx); | |
133 | 92320 | values.setOutflow(Indices::conti0EqIdx + 1); | |
134 | } | ||
135 | else | ||
136 | { | ||
137 | 170240 | values.setDirichlet(Indices::velocityXIdx); | |
138 | 170240 | values.setDirichlet(Indices::velocityYIdx); | |
139 | 170240 | values.setNeumann(Indices::conti0EqIdx); | |
140 | 170240 | values.setNeumann(Indices::conti0EqIdx + 1); | |
141 | } | ||
142 | } | ||
143 | |||
144 |
2/2✓ Branch 0 taken 299940 times.
✓ Branch 1 taken 639772 times.
|
939712 | if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) |
145 | { | ||
146 | 299940 | values.setCouplingNeumann(Indices::conti0EqIdx); | |
147 | 299940 | values.setCouplingNeumann(Indices::conti0EqIdx + 1); | |
148 | 299940 | values.setCouplingNeumann(Indices::momentumYBalanceIdx); | |
149 | 299940 | values.setBeaversJoseph(Indices::momentumXBalanceIdx); | |
150 | } | ||
151 | |||
152 | 939712 | return values; | |
153 | } | ||
154 | |||
155 | /*! | ||
156 | * \brief Evaluates the boundary conditions for a Dirichlet control volume. | ||
157 | */ | ||
158 | 315564 | PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const | |
159 | { | ||
160 | 315564 | PrimaryVariables values(0.0); | |
161 | 315564 | values = initialAtPos(globalPos); | |
162 | |||
163 |
2/2✓ Branch 0 taken 205164 times.
✓ Branch 1 taken 110400 times.
|
315564 | if (verticalFlow_) |
164 | { | ||
165 | // Check if this a pure diffusion problem. | ||
166 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 205162 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
205166 | static const bool isDiffusionProblem = problemName_.find("diffusion") != std::string::npos; |
167 | |||
168 | 205164 | Scalar topMoleFraction = 1e-3; | |
169 | |||
170 |
2/2✓ Branch 0 taken 20098 times.
✓ Branch 1 taken 185066 times.
|
205164 | if (isDiffusionProblem) |
171 | { | ||
172 | // For the diffusion problem, change the top mole fraction after some time | ||
173 | // in order to revert the concentration gradient. | ||
174 | 40196 | if (time() >= 1e10) | |
175 | 6706 | topMoleFraction = 0.0; | |
176 | } | ||
177 | else // advection problem | ||
178 | { | ||
179 | // reverse the flow direction after some time for the advection problem | ||
180 | 370132 | if (time() >= 3e5) | |
181 | 196176 | values[Indices::velocityYIdx] *= -1.0; | |
182 | } | ||
183 | |||
184 |
10/10✓ Branch 0 taken 69740 times.
✓ Branch 1 taken 135424 times.
✓ Branch 2 taken 69740 times.
✓ Branch 3 taken 135424 times.
✓ Branch 4 taken 69740 times.
✓ Branch 5 taken 135424 times.
✓ Branch 6 taken 69740 times.
✓ Branch 7 taken 135424 times.
✓ Branch 8 taken 69740 times.
✓ Branch 9 taken 135424 times.
|
1025820 | if(globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_) |
185 | 139480 | values[Indices::conti0EqIdx + 1] = topMoleFraction; | |
186 | } | ||
187 | else // horizontal flow | ||
188 | { | ||
189 |
5/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 110399 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.
|
110400 | static const Scalar inletMoleFraction = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InletMoleFraction"); |
190 |
10/10✓ Branch 0 taken 50760 times.
✓ Branch 1 taken 59640 times.
✓ Branch 2 taken 50760 times.
✓ Branch 3 taken 59640 times.
✓ Branch 4 taken 50760 times.
✓ Branch 5 taken 59640 times.
✓ Branch 6 taken 50760 times.
✓ Branch 7 taken 59640 times.
✓ Branch 8 taken 50760 times.
✓ Branch 9 taken 59640 times.
|
552000 | if(globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_) |
191 | 101520 | values[Indices::conti0EqIdx + 1] = inletMoleFraction; | |
192 | } | ||
193 | |||
194 | |||
195 | 315564 | return values; | |
196 | } | ||
197 | |||
198 | /*! | ||
199 | * \brief Evaluates the boundary conditions for a Neumann control volume. | ||
200 | * | ||
201 | * \param element The element for which the Neumann boundary condition is set | ||
202 | * \param fvGeometry The fvGeometry | ||
203 | * \param elemVolVars The element volume variables | ||
204 | * \param elemFaceVars The element face variables | ||
205 | * \param scvf The boundary sub control volume face | ||
206 | */ | ||
207 | template<class ElementVolumeVariables, class ElementFaceVariables> | ||
208 | 141056 | NumEqVector neumann(const Element& element, | |
209 | const FVElementGeometry& fvGeometry, | ||
210 | const ElementVolumeVariables& elemVolVars, | ||
211 | const ElementFaceVariables& elemFaceVars, | ||
212 | const SubControlVolumeFace& scvf) const | ||
213 | { | ||
214 | 141056 | NumEqVector values(0.0); | |
215 | |||
216 |
2/2✓ Branch 0 taken 83160 times.
✓ Branch 1 taken 57896 times.
|
141056 | if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) |
217 | { | ||
218 | 83160 | values[Indices::momentumYBalanceIdx] = couplingManager().couplingData().momentumCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf); | |
219 | |||
220 | 83160 | const auto tmp = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf); | |
221 | 166320 | values[Indices::conti0EqIdx] = tmp[0]; | |
222 | 249480 | values[Indices::conti0EqIdx + 1] = tmp[1]; | |
223 | } | ||
224 | 141056 | return values; | |
225 | } | ||
226 | |||
227 | // \} | ||
228 | |||
229 | //! Get the coupling manager | ||
230 | const CouplingManager& couplingManager() const | ||
231 | 2327856 | { return *couplingManager_; } | |
232 | |||
233 | /*! | ||
234 | * \name Volume terms | ||
235 | */ | ||
236 | // \{ | ||
237 | |||
238 | /*! | ||
239 | * \brief Evaluates the initial value for a control volume. | ||
240 | * | ||
241 | * \param globalPos The global position | ||
242 | */ | ||
243 | 3415900 | PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const | |
244 | { | ||
245 | 3415900 | PrimaryVariables values(0.0); | |
246 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3415897 times.
|
3415900 | values[Indices::pressureIdx] = 1e5; |
247 | |||
248 |
5/8✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3415897 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
|
3415900 | static const Scalar vMax = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Velocity", 0.0); |
249 | |||
250 | 3415900 | auto parabolicProfile = [&](const GlobalPosition& globalPos, int coord) | |
251 | { | ||
252 | 10247700 | return vMax * (globalPos[coord] - this->gridGeometry().bBoxMin()[coord]) | |
253 | 13663600 | * (this->gridGeometry().bBoxMax()[coord] - globalPos[coord]) | |
254 | 20495400 | / (0.25 * (this->gridGeometry().bBoxMax()[coord] - this->gridGeometry().bBoxMin()[coord]) | |
255 | 20495400 | * (this->gridGeometry().bBoxMax()[coord] - this->gridGeometry().bBoxMin()[coord])); | |
256 | }; | ||
257 | |||
258 |
2/2✓ Branch 0 taken 2351660 times.
✓ Branch 1 taken 1064240 times.
|
3415900 | if (verticalFlow_) |
259 | 7054980 | values[Indices::velocityYIdx] = parabolicProfile(globalPos, 0); | |
260 | else // horizontal flow | ||
261 | 3192720 | values[Indices::velocityXIdx] = parabolicProfile(globalPos, 1); | |
262 | |||
263 | 3415900 | return values; | |
264 | } | ||
265 | |||
266 | /*! | ||
267 | * \brief Returns the intrinsic permeability of required as input parameter | ||
268 | * for the Beavers-Joseph-Saffman boundary condition. | ||
269 | */ | ||
270 | Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const | ||
271 | { | ||
272 | ✗ | return couplingManager().couplingData().darcyPermeability(element, scvf); | |
273 | } | ||
274 | |||
275 | /*! | ||
276 | * \brief Returns the alpha value required as input parameter for the | ||
277 | * Beavers-Joseph-Saffman boundary condition. | ||
278 | */ | ||
279 | ✗ | Scalar alphaBJ(const SubControlVolumeFace& scvf) const | |
280 | { | ||
281 | ✗ | return 1.0; | |
282 | } | ||
283 | |||
284 | /*! | ||
285 | * \brief Sets the time loop pointer. | ||
286 | */ | ||
287 | void setTimeLoop(TimeLoopPtr timeLoop) | ||
288 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | { timeLoop_ = timeLoop; } |
289 | |||
290 | /*! | ||
291 | * \brief Returns the time. | ||
292 | */ | ||
293 | Scalar time() const | ||
294 |
12/12✓ Branch 0 taken 6706 times.
✓ Branch 1 taken 13392 times.
✓ Branch 2 taken 6706 times.
✓ Branch 3 taken 13392 times.
✓ Branch 4 taken 6706 times.
✓ Branch 5 taken 13392 times.
✓ Branch 6 taken 98088 times.
✓ Branch 7 taken 86978 times.
✓ Branch 8 taken 98088 times.
✓ Branch 9 taken 86978 times.
✓ Branch 10 taken 98088 times.
✓ Branch 11 taken 86978 times.
|
615492 | { return timeLoop_->time(); } |
295 | |||
296 | // \} | ||
297 | |||
298 | private: | ||
299 | bool onLeftBoundary_(const GlobalPosition &globalPos) const | ||
300 |
20/20✓ Branch 0 taken 141960 times.
✓ Branch 1 taken 331392 times.
✓ Branch 2 taken 141960 times.
✓ Branch 3 taken 331392 times.
✓ Branch 4 taken 141960 times.
✓ Branch 5 taken 331392 times.
✓ Branch 6 taken 141960 times.
✓ Branch 7 taken 331392 times.
✓ Branch 8 taken 141960 times.
✓ Branch 9 taken 331392 times.
✓ Branch 10 taken 61840 times.
✓ Branch 11 taken 262560 times.
✓ Branch 12 taken 61840 times.
✓ Branch 13 taken 262560 times.
✓ Branch 14 taken 61840 times.
✓ Branch 15 taken 262560 times.
✓ Branch 16 taken 61840 times.
✓ Branch 17 taken 262560 times.
✓ Branch 18 taken 61840 times.
✓ Branch 19 taken 262560 times.
|
3988760 | { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; } |
301 | |||
302 | bool onRightBoundary_(const GlobalPosition &globalPos) const | ||
303 |
20/20✓ Branch 0 taken 473352 times.
✓ Branch 1 taken 141960 times.
✓ Branch 2 taken 473352 times.
✓ Branch 3 taken 141960 times.
✓ Branch 4 taken 473352 times.
✓ Branch 5 taken 141960 times.
✓ Branch 6 taken 473352 times.
✓ Branch 7 taken 141960 times.
✓ Branch 8 taken 473352 times.
✓ Branch 9 taken 141960 times.
✓ Branch 10 taken 92320 times.
✓ Branch 11 taken 170240 times.
✓ Branch 12 taken 92320 times.
✓ Branch 13 taken 170240 times.
✓ Branch 14 taken 92320 times.
✓ Branch 15 taken 170240 times.
✓ Branch 16 taken 92320 times.
✓ Branch 17 taken 170240 times.
✓ Branch 18 taken 92320 times.
✓ Branch 19 taken 170240 times.
|
4389360 | { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; } |
304 | |||
305 | bool onLowerBoundary_(const GlobalPosition &globalPos) const | ||
306 | { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; } | ||
307 | |||
308 | bool onUpperBoundary_(const GlobalPosition &globalPos) const | ||
309 |
10/10✓ Branch 0 taken 140212 times.
✓ Branch 1 taken 475100 times.
✓ Branch 2 taken 140212 times.
✓ Branch 3 taken 475100 times.
✓ Branch 4 taken 140212 times.
✓ Branch 5 taken 475100 times.
✓ Branch 6 taken 140212 times.
✓ Branch 7 taken 475100 times.
✓ Branch 8 taken 140212 times.
✓ Branch 9 taken 475100 times.
|
3076560 | { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; } |
310 | |||
311 | Scalar eps_; | ||
312 | bool verticalFlow_; | ||
313 | std::string problemName_; | ||
314 | std::shared_ptr<CouplingManager> couplingManager_; | ||
315 | TimeLoopPtr timeLoop_; | ||
316 | }; | ||
317 | } // end namespace Dumux | ||
318 | |||
319 | #endif | ||
320 |