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 The free-flow sub-problem of coupled FreeFlow/Darcy convergence test | ||
11 | */ | ||
12 | |||
13 | #ifndef DUMUX_FREEFLOW_SUBPROBLEM_HH | ||
14 | #define DUMUX_FREEFLOW_SUBPROBLEM_HH | ||
15 | |||
16 | #include <dune/common/fvector.hh> | ||
17 | #include <dumux/common/numeqvector.hh> | ||
18 | #include <dune/grid/yaspgrid.hh> | ||
19 | |||
20 | #include <dumux/discretization/staggered/freeflow/properties.hh> | ||
21 | |||
22 | #include <dumux/freeflow/navierstokes/boundarytypes.hh> | ||
23 | #include <dumux/freeflow/navierstokes/model.hh> | ||
24 | #include <dumux/freeflow/navierstokes/staggered/problem.hh> | ||
25 | |||
26 | #include <dumux/material/fluidsystems/1pliquid.hh> | ||
27 | #include <dumux/material/components/constant.hh> | ||
28 | |||
29 | #include "testcase.hh" | ||
30 | |||
31 | namespace Dumux { | ||
32 | template <class TypeTag> | ||
33 | class FreeFlowSubProblem; | ||
34 | |||
35 | /*! | ||
36 | * \ingroup BoundaryTests | ||
37 | * \brief The Stokes sub-problem of coupled Stokes-Darcy convergence test | ||
38 | */ | ||
39 | template <class TypeTag> | ||
40 | class FreeFlowSubProblem : public NavierStokesStaggeredProblem<TypeTag> | ||
41 | { | ||
42 | using ParentType = NavierStokesStaggeredProblem<TypeTag>; | ||
43 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
44 | using BoundaryTypes = Dumux::NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
45 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
46 | using GridView = typename GridGeometry::GridView; | ||
47 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
48 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
49 | using Element = typename GridView::template Codim<0>::Entity; | ||
50 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
51 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
52 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
53 | using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; | ||
54 | |||
55 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
56 | |||
57 | public: | ||
58 | //! export the Indices | ||
59 | using Indices = typename ModelTraits::Indices; | ||
60 | |||
61 | 6 | FreeFlowSubProblem(std::shared_ptr<const GridGeometry> gridGeometry, | |
62 | std::shared_ptr<CouplingManager> couplingManager, | ||
63 | const TestCase testCase, | ||
64 | const std::string& name) | ||
65 | : ParentType(gridGeometry, "FreeFlow") | ||
66 | , couplingManager_(couplingManager) | ||
67 |
5/16✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 6 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.
|
18 | , testCase_(testCase) |
68 | { | ||
69 |
7/20✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
12 | problemName_ = name + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); |
70 | 6 | } | |
71 | |||
72 | /*! | ||
73 | * \name Problem parameters | ||
74 | */ | ||
75 | // \{ | ||
76 | |||
77 | /*! | ||
78 | * \brief The problem name. | ||
79 | */ | ||
80 | const std::string& name() const | ||
81 | { | ||
82 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
12 | return problemName_; |
83 | } | ||
84 | |||
85 | /*! | ||
86 | * \brief Returns the sources within the domain. | ||
87 | * | ||
88 | * \param globalPos The global position | ||
89 | */ | ||
90 | 13594560 | NumEqVector sourceAtPos(const GlobalPosition &globalPos) const | |
91 | { | ||
92 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 3884160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9710400 times.
✗ Branch 4 not taken.
|
13594560 | switch (testCase_) |
93 | { | ||
94 | ✗ | case TestCase::ShiueExampleOne: | |
95 | ✗ | return rhsShiueEtAlExampleOne_(globalPos); | |
96 | case TestCase::ShiueExampleTwo: | ||
97 | 3884160 | return rhsShiueEtAlExampleTwo_(globalPos); | |
98 | ✗ | case TestCase::Rybak: | |
99 | ✗ | return rhsRybak_(globalPos); | |
100 | 9710400 | case TestCase::Schneider: | |
101 | 9710400 | return rhsSchneiderEtAl_(globalPos); | |
102 | ✗ | default: | |
103 | ✗ | DUNE_THROW(Dune::InvalidStateException, "Invalid test case"); | |
104 | } | ||
105 | } | ||
106 | |||
107 | // \} | ||
108 | |||
109 | /*! | ||
110 | * \name Boundary conditions | ||
111 | */ | ||
112 | // \{ | ||
113 | |||
114 | /*! | ||
115 | * \brief Specifies which kind of boundary condition should be | ||
116 | * used for which equation on a given boundary segment. | ||
117 | * | ||
118 | * \param element The finite element | ||
119 | * \param scvf The sub control volume face | ||
120 | */ | ||
121 | 473220 | BoundaryTypes boundaryTypes(const Element& element, | |
122 | const SubControlVolumeFace& scvf) const | ||
123 | { | ||
124 | 473220 | BoundaryTypes values; | |
125 | |||
126 | 473220 | values.setDirichlet(Indices::velocityXIdx); | |
127 | 473220 | values.setDirichlet(Indices::velocityYIdx); | |
128 | |||
129 |
2/2✓ Branch 0 taken 169686 times.
✓ Branch 1 taken 303534 times.
|
473220 | if (couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) |
130 | { | ||
131 | 169686 | values.setCouplingNeumann(Indices::conti0EqIdx); | |
132 | 169686 | values.setCouplingNeumann(Indices::momentumYBalanceIdx); | |
133 | 169686 | values.setBeaversJoseph(Indices::momentumXBalanceIdx); | |
134 | } | ||
135 | |||
136 | 473220 | return values; | |
137 | } | ||
138 | |||
139 | /*! | ||
140 | * \brief Evaluates the boundary conditions for a Dirichlet control volume. | ||
141 | */ | ||
142 | PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const | ||
143 | { | ||
144 |
2/10✓ Branch 1 taken 83400 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 7 taken 116880 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
258828 | return analyticalSolution(globalPos); |
145 | } | ||
146 | |||
147 | /*! | ||
148 | * \brief Evaluates the boundary conditions for a Neumann control volume. | ||
149 | * | ||
150 | * \param element The element for which the Neumann boundary condition is set | ||
151 | * \param fvGeometry The fvGeometry | ||
152 | * \param elemVolVars The element volume variables | ||
153 | * \param elemFaceVars The element face variables | ||
154 | * \param scvf The boundary sub control volume face | ||
155 | */ | ||
156 | template<class ElementVolumeVariables, class ElementFaceVariables> | ||
157 | 44954 | NumEqVector neumann(const Element& element, | |
158 | const FVElementGeometry& fvGeometry, | ||
159 | const ElementVolumeVariables& elemVolVars, | ||
160 | const ElementFaceVariables& elemFaceVars, | ||
161 | const SubControlVolumeFace& scvf) const | ||
162 | { | ||
163 | 44954 | NumEqVector values(0.0); | |
164 | |||
165 |
1/2✓ Branch 0 taken 44954 times.
✗ Branch 1 not taken.
|
44954 | if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) |
166 | { | ||
167 | 44954 | values[Indices::conti0EqIdx] = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf); | |
168 | 44954 | values[Indices::momentumYBalanceIdx] = couplingManager().couplingData().momentumCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf); | |
169 | } | ||
170 | 44954 | return values; | |
171 | } | ||
172 | |||
173 | // \} | ||
174 | |||
175 | //! Get the coupling manager | ||
176 | const CouplingManager& couplingManager() const | ||
177 | 1126256 | { return *couplingManager_; } | |
178 | |||
179 | /*! | ||
180 | * \name Volume terms | ||
181 | */ | ||
182 | // \{ | ||
183 | |||
184 | /*! | ||
185 | * \brief Evaluates the initial value for a control volume. | ||
186 | * | ||
187 | * \param globalPos The global position | ||
188 | */ | ||
189 | ✗ | PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const | |
190 | { | ||
191 | 22420818 | return PrimaryVariables(0.0); | |
192 | } | ||
193 | |||
194 | /*! | ||
195 | * \brief Returns the intrinsic permeability of required as input parameter | ||
196 | for the Beavers-Joseph-Saffman boundary condition | ||
197 | */ | ||
198 | auto permeability(const Element& element, const SubControlVolumeFace& scvf) const | ||
199 | { | ||
200 | 440496 | return couplingManager().couplingData().darcyPermeability(element, scvf); | |
201 | } | ||
202 | |||
203 | /*! | ||
204 | * \brief Returns the alpha value required as input parameter for the | ||
205 | Beavers-Joseph-Saffman boundary condition. | ||
206 | */ | ||
207 | ✗ | Scalar alphaBJ(const SubControlVolumeFace& scvf) const | |
208 | { | ||
209 | ✗ | return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); | |
210 | } | ||
211 | |||
212 | /*! | ||
213 | * \brief Returns the analytical solution of the problem at a given position. | ||
214 | * | ||
215 | * \param globalPos The global position | ||
216 | * \param time A parameter for consistent signatures. It is ignored here as this is a stationary test | ||
217 | */ | ||
218 | 1065228 | PrimaryVariables analyticalSolution(const GlobalPosition& globalPos, Scalar time = 0.0) const | |
219 | { | ||
220 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 453408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 611820 times.
✗ Branch 4 not taken.
|
1065228 | switch (testCase_) |
221 | { | ||
222 | ✗ | case TestCase::ShiueExampleOne: | |
223 | ✗ | return analyticalSolutionShiueEtAlExampleOne_(globalPos); | |
224 | 453408 | case TestCase::ShiueExampleTwo: | |
225 | 453408 | return analyticalSolutionShiueEtAlExampleTwo_(globalPos); | |
226 | ✗ | case TestCase::Rybak: | |
227 | ✗ | return analyticalSolutionRybak_(globalPos); | |
228 | 611820 | case TestCase::Schneider: | |
229 | 611820 | return analyticalSolutionSchneiderEtAl_(globalPos); | |
230 | ✗ | default: | |
231 | ✗ | DUNE_THROW(Dune::InvalidStateException, "Invalid test case"); | |
232 | } | ||
233 | } | ||
234 | |||
235 | // \} | ||
236 | |||
237 | private: | ||
238 | |||
239 | // see Rybak et al., 2015: "Multirate time integration for coupled saturated/unsaturated porous medium and free flow systems" | ||
240 | ✗ | PrimaryVariables analyticalSolutionRybak_(const GlobalPosition& globalPos) const | |
241 | { | ||
242 | ✗ | PrimaryVariables sol(0.0); | |
243 | ✗ | const Scalar x = globalPos[0]; | |
244 | ✗ | const Scalar y = globalPos[1]; | |
245 | |||
246 | using std::sin; using std::cos; | ||
247 | ✗ | sol[Indices::velocityXIdx] = -cos(M_PI*x)*sin(M_PI*y); | |
248 | ✗ | sol[Indices::velocityYIdx] = sin(M_PI*x)*cos(M_PI*y); | |
249 | ✗ | sol[Indices::pressureIdx] = 0.5*y*sin(M_PI*x); | |
250 | ✗ | return sol; | |
251 | } | ||
252 | |||
253 | // see Rybak et al., 2015: "Multirate time integration for coupled saturated/unsaturated porous medium and free flow systems" | ||
254 | ✗ | NumEqVector rhsRybak_(const GlobalPosition& globalPos) const | |
255 | { | ||
256 | ✗ | const Scalar x = globalPos[0]; | |
257 | ✗ | const Scalar y = globalPos[1]; | |
258 | ✗ | NumEqVector source(0.0); | |
259 | using std::sin; using std::cos; | ||
260 | ✗ | source[Indices::momentumXBalanceIdx] = 0.5*M_PI*y*cos(M_PI*x) - 2*M_PI*M_PI*cos(M_PI*x)*sin(M_PI*y); | |
261 | ✗ | source[Indices::momentumYBalanceIdx] = 0.5*sin(M_PI*x) + 2*M_PI*M_PI*sin(M_PI*x)*cos(M_PI*y); | |
262 | ✗ | return source; | |
263 | } | ||
264 | |||
265 | // see Shiue et al., 2018: "Convergence of the MAC Scheme for the Stokes/Darcy Coupling Problem" | ||
266 | ✗ | PrimaryVariables analyticalSolutionShiueEtAlExampleOne_(const GlobalPosition& globalPos) const | |
267 | { | ||
268 | ✗ | PrimaryVariables sol(0.0); | |
269 | ✗ | const Scalar x = globalPos[0]; | |
270 | ✗ | const Scalar y = globalPos[1]; | |
271 | |||
272 | using std::exp; using std::sin; using std::cos; | ||
273 | ✗ | sol[Indices::velocityXIdx] = -1/M_PI * exp(y) * sin(M_PI*x); | |
274 | ✗ | sol[Indices::velocityYIdx] = (exp(y) - exp(1)) * cos(M_PI*x); | |
275 | ✗ | sol[Indices::pressureIdx] = 2*exp(y) * cos(M_PI*x); | |
276 | ✗ | return sol; | |
277 | } | ||
278 | |||
279 | // see Shiue et al., 2018: "Convergence of the MAC Scheme for the Stokes/Darcy Coupling Problem" | ||
280 | ✗ | NumEqVector rhsShiueEtAlExampleOne_(const GlobalPosition& globalPos) const | |
281 | { | ||
282 | ✗ | const Scalar x = globalPos[0]; | |
283 | ✗ | const Scalar y = globalPos[1]; | |
284 | using std::exp; using std::sin; using std::cos; | ||
285 | ✗ | NumEqVector source(0.0); | |
286 | ✗ | source[Indices::momentumXBalanceIdx] = exp(y)*sin(M_PI*x) * (1/M_PI -3*M_PI); | |
287 | ✗ | source[Indices::momentumYBalanceIdx] = cos(M_PI*x) * (M_PI*M_PI*(exp(y)- exp(1)) + exp(y)); | |
288 | ✗ | return source; | |
289 | } | ||
290 | |||
291 | // see Shiue et al., 2018: "Convergence of the MAC Scheme for the Stokes/Darcy Coupling Problem" | ||
292 | 453408 | PrimaryVariables analyticalSolutionShiueEtAlExampleTwo_(const GlobalPosition& globalPos) const | |
293 | { | ||
294 | 453408 | PrimaryVariables sol(0.0); | |
295 | 906816 | const Scalar x = globalPos[0]; | |
296 | 906816 | const Scalar y = globalPos[1]; | |
297 | |||
298 | 906816 | sol[Indices::velocityXIdx] = (y-1.0)*(y-1.0) + x*(y-1.0) + 3.0*x - 1.0; | |
299 | 906816 | sol[Indices::velocityYIdx] = x*(x-1.0) - 0.5*(y-1.0)*(y-1.0) - 3.0*y + 1.0; | |
300 | 906816 | sol[Indices::pressureIdx] = 2.0*x + y - 1.0; | |
301 | 453408 | return sol; | |
302 | } | ||
303 | |||
304 | // see Shiue et al., 2018: "Convergence of the MAC Scheme for the Stokes/Darcy Coupling Problem" | ||
305 | ✗ | NumEqVector rhsShiueEtAlExampleTwo_(const GlobalPosition& globalPos) const | |
306 | 3884160 | { return NumEqVector(0.0); } | |
307 | |||
308 | // see Schneider et al., 2019: "Coupling staggered-grid and MPFA finite volume methods for | ||
309 | // free flow/porous-medium flow problems" | ||
310 | ✗ | PrimaryVariables analyticalSolutionSchneiderEtAl_(const GlobalPosition& globalPos) const | |
311 | { | ||
312 | ✗ | PrimaryVariables sol(0.0); | |
313 | ✗ | const Scalar x = globalPos[0]; | |
314 | ✗ | const Scalar y = globalPos[1]; | |
315 | using std::sin; | ||
316 | static constexpr Scalar omega = M_PI; | ||
317 | ✗ | const Scalar sinOmegaX = sin(omega*x); | |
318 | |||
319 | ✗ | sol[Indices::velocityXIdx] = y; | |
320 | ✗ | sol[Indices::velocityYIdx] = -y*sinOmegaX; | |
321 | ✗ | sol[Indices::pressureIdx] = -y*y*sinOmegaX*sinOmegaX; | |
322 | ✗ | return sol; | |
323 | } | ||
324 | |||
325 | // see Schneider et al., 2019: "Coupling staggered-grid and MPFA finite volume methods for | ||
326 | // free flow/porous-medium flow problems" | ||
327 | 9710400 | NumEqVector rhsSchneiderEtAl_(const GlobalPosition& globalPos) const | |
328 | { | ||
329 | 9710400 | const Scalar x = globalPos[0]; | |
330 | 9710400 | const Scalar y = globalPos[1]; | |
331 | using std::exp; using std::sin; using std::cos; | ||
332 | static constexpr Scalar omega = M_PI; | ||
333 | 9710400 | const Scalar sinOmegaX = sin(omega*x); | |
334 | 9710400 | const Scalar cosOmegaX = cos(omega*x); | |
335 | |||
336 | 9710400 | NumEqVector source(0.0); | |
337 | 19420800 | source[Indices::conti0EqIdx] = -sinOmegaX; | |
338 | 29131200 | source[Indices::momentumXBalanceIdx] = -2*omega*y*y*sinOmegaX*cosOmegaX | |
339 | 9710400 | -2*y*sinOmegaX + omega*cosOmegaX; | |
340 | 19420800 | source[Indices::momentumYBalanceIdx] = -omega*y*y*cosOmegaX - omega*omega*y*sinOmegaX; | |
341 | 9710400 | return source; | |
342 | } | ||
343 | |||
344 | static constexpr Scalar eps_ = 1e-7; | ||
345 | std::string problemName_; | ||
346 | std::shared_ptr<CouplingManager> couplingManager_; | ||
347 | TestCase testCase_; | ||
348 | }; | ||
349 | } // end namespace Dumux | ||
350 | |||
351 | #endif | ||
352 |