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 | ||
11 | * (Navier-)Stokes model. | ||
12 | * | ||
13 | * This test uses the same set-up as the horizontal test but uses a harmonic | ||
14 | * averaging of the diffusion coefficients at the interface for Fick's law and | ||
15 | * compares the solution with the Maxwell-Stefan coupling. | ||
16 | */ | ||
17 | |||
18 | #ifndef DUMUX_STOKES_SUBPROBLEM_DIFFUSION_COMPARISON_HH | ||
19 | #define DUMUX_STOKES_SUBPROBLEM_DIFFUSION_COMPARISON_HH | ||
20 | |||
21 | #include <dumux/common/properties.hh> | ||
22 | #include <dumux/common/parameters.hh> | ||
23 | #include <dumux/common/numeqvector.hh> | ||
24 | |||
25 | #include <dumux/freeflow/navierstokes/boundarytypes.hh> | ||
26 | #include <dumux/freeflow/navierstokes/staggered/problem.hh> | ||
27 | |||
28 | // for StokesDarcyCouplingOptions | ||
29 | #include <dumux/multidomain/boundary/stokesdarcy/couplingdata.hh> | ||
30 | |||
31 | namespace Dumux { | ||
32 | |||
33 | /*! | ||
34 | * \ingroup BoundaryTests | ||
35 | * \brief Test problem for the 1pnc (Navier-) Stokes problem. | ||
36 | * | ||
37 | * Horizontal flow from left to right with a parabolic velocity profile. | ||
38 | */ | ||
39 | template <class TypeTag> | ||
40 | class StokesSubProblem : public NavierStokesStaggeredProblem<TypeTag> | ||
41 | { | ||
42 | using ParentType = NavierStokesStaggeredProblem<TypeTag>; | ||
43 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
44 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
45 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
46 | using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; | ||
47 | using BoundaryTypes = Dumux::NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
48 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
49 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
50 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
51 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
52 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
53 | |||
54 | using Element = typename GridView::template Codim<0>::Entity; | ||
55 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
56 | |||
57 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
58 | using DiffusionCoefficientAveragingType = typename StokesDarcyCouplingOptions::DiffusionCoefficientAveragingType; | ||
59 | |||
60 | public: | ||
61 | 2 | StokesSubProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<CouplingManager> couplingManager) | |
62 |
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 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
6 | : ParentType(gridGeometry, "Stokes"), eps_(1e-6), injectionState_(false), couplingManager_(couplingManager) |
63 | { | ||
64 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | inletVelocity_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Velocity"); |
65 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure"); |
66 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | inletMoleFraction_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InletMoleFraction"); |
67 | 2 | } | |
68 | |||
69 | /*! | ||
70 | * \name Problem parameters | ||
71 | */ | ||
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 | 2345600 | { return NumEqVector(0.0); } | |
81 | |||
82 | // \} | ||
83 | |||
84 | /*! | ||
85 | * \name Boundary conditions | ||
86 | */ | ||
87 | // \{ | ||
88 | |||
89 | /*! | ||
90 | * \brief Specifies which kind of boundary condition should be | ||
91 | * used for which equation on a given boundary segment. | ||
92 | * | ||
93 | * \param element The finite element | ||
94 | * \param scvf The sub control volume face | ||
95 | */ | ||
96 | 648800 | BoundaryTypes boundaryTypes(const Element& element, | |
97 | const SubControlVolumeFace& scvf) const | ||
98 | { | ||
99 | 648800 | BoundaryTypes values; | |
100 | |||
101 |
2/2✓ Branch 0 taken 123680 times.
✓ Branch 1 taken 525120 times.
|
648800 | const auto& globalPos = scvf.dofPosition(); |
102 | |||
103 | 1297600 | if(onLeftBoundary_(globalPos)) | |
104 | { | ||
105 | 123680 | values.setDirichlet(Indices::conti0EqIdx + 1); | |
106 | 123680 | values.setDirichlet(Indices::velocityXIdx); | |
107 | 123680 | values.setDirichlet(Indices::velocityYIdx); | |
108 | } | ||
109 | 1050240 | else if(onRightBoundary_(globalPos)) | |
110 | { | ||
111 | 184640 | values.setDirichlet(Indices::pressureIdx); | |
112 | 184640 | values.setOutflow(Indices::conti0EqIdx + 1); | |
113 | } | ||
114 | else | ||
115 | { | ||
116 | 340480 | values.setDirichlet(Indices::velocityXIdx); | |
117 | 340480 | values.setDirichlet(Indices::velocityYIdx); | |
118 | 340480 | values.setNeumann(Indices::conti0EqIdx); | |
119 | 340480 | values.setNeumann(Indices::conti0EqIdx + 1); | |
120 | } | ||
121 | |||
122 |
2/2✓ Branch 0 taken 217520 times.
✓ Branch 1 taken 431280 times.
|
648800 | if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) |
123 | { | ||
124 | 217520 | values.setCouplingNeumann(Indices::conti0EqIdx); | |
125 | 217520 | values.setCouplingNeumann(Indices::conti0EqIdx + 1); | |
126 | 217520 | values.setCouplingNeumann(Indices::momentumYBalanceIdx); | |
127 | 217520 | values.setBeaversJoseph(Indices::momentumXBalanceIdx); | |
128 | } | ||
129 | |||
130 | 648800 | return values; | |
131 | } | ||
132 | |||
133 | /*! | ||
134 | * \brief Evaluates the boundary conditions for a Dirichlet control volume. | ||
135 | */ | ||
136 | 220800 | PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const | |
137 | { | ||
138 | 220800 | PrimaryVariables values(0.0); | |
139 | 441600 | values = initialAtPos(globalPos); | |
140 | |||
141 | // start injecting after the velocity field had enough time to initialize | ||
142 |
10/10✓ Branch 0 taken 101520 times.
✓ Branch 1 taken 119280 times.
✓ Branch 2 taken 101520 times.
✓ Branch 3 taken 119280 times.
✓ Branch 4 taken 101520 times.
✓ Branch 5 taken 119280 times.
✓ Branch 6 taken 101520 times.
✓ Branch 7 taken 119280 times.
✓ Branch 8 taken 101440 times.
✓ Branch 9 taken 80 times.
|
883200 | if(globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_ && isInjectionPeriod()) |
143 | 202880 | values[Indices::conti0EqIdx + 1] = inletMoleFraction_; | |
144 | |||
145 | 220800 | return values; | |
146 | } | ||
147 | |||
148 | /*! | ||
149 | * \brief Evaluates the boundary conditions for a Neumann control volume. | ||
150 | * | ||
151 | * \param element The element for which the Neumann boundary condition is set | ||
152 | * \param fvGeometry The fvGeometry | ||
153 | * \param elemVolVars The element volume variables | ||
154 | * \param elemFaceVars The element face variables | ||
155 | * \param scvf The boundary sub control volume face | ||
156 | */ | ||
157 | template<class ElementVolumeVariables, class ElementFaceVariables> | ||
158 | 70880 | NumEqVector neumann(const Element& element, | |
159 | const FVElementGeometry& fvGeometry, | ||
160 | const ElementVolumeVariables& elemVolVars, | ||
161 | const ElementFaceVariables& elemFaceVars, | ||
162 | const SubControlVolumeFace& scvf) const | ||
163 | { | ||
164 | 70880 | NumEqVector values(0.0); | |
165 | |||
166 |
2/2✓ Branch 0 taken 50400 times.
✓ Branch 1 taken 20480 times.
|
70880 | if(couplingManager().isCoupledEntity(CouplingManager::stokesIdx, scvf)) |
167 | { | ||
168 | 50400 | values[Indices::momentumYBalanceIdx] = couplingManager().couplingData().momentumCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf); | |
169 | |||
170 | 50400 | const auto tmp = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf, DiffusionCoefficientAveragingType::harmonic); | |
171 | 100800 | values[Indices::conti0EqIdx] = tmp[0]; | |
172 | 151200 | values[Indices::conti0EqIdx + 1] = tmp[1]; | |
173 | } | ||
174 | 70880 | return values; | |
175 | } | ||
176 | |||
177 | // \} | ||
178 | |||
179 | //! Get the coupling manager | ||
180 | const CouplingManager& couplingManager() const | ||
181 | 1540160 | { return *couplingManager_; } | |
182 | |||
183 | /*! | ||
184 | * \name Volume terms | ||
185 | */ | ||
186 | // \{ | ||
187 | |||
188 | /*! | ||
189 | * \brief Evaluates the initial value for a control volume. | ||
190 | * | ||
191 | * \param globalPos The global position | ||
192 | */ | ||
193 | PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const | ||
194 | { | ||
195 | 2128480 | PrimaryVariables values(0.0); | |
196 |
2/2✓ Branch 0 taken 101520 times.
✓ Branch 1 taken 119280 times.
|
2057760 | values[Indices::pressureIdx] = pressure_; |
197 |
10/10✓ Branch 0 taken 101520 times.
✓ Branch 1 taken 119280 times.
✓ Branch 2 taken 101520 times.
✓ Branch 3 taken 119280 times.
✓ Branch 4 taken 101520 times.
✓ Branch 5 taken 119280 times.
✓ Branch 6 taken 101520 times.
✓ Branch 7 taken 119280 times.
✓ Branch 8 taken 101520 times.
✓ Branch 9 taken 119280 times.
|
10288800 | values[Indices::velocityXIdx] = inletVelocity_ * (globalPos[1] - this->gridGeometry().bBoxMin()[1]) |
198 |
8/8✓ Branch 0 taken 101520 times.
✓ Branch 1 taken 119280 times.
✓ Branch 2 taken 101520 times.
✓ Branch 3 taken 119280 times.
✓ Branch 4 taken 101520 times.
✓ Branch 5 taken 119280 times.
✓ Branch 6 taken 101520 times.
✓ Branch 7 taken 119280 times.
|
8231040 | * (this->gridGeometry().bBoxMax()[1] - globalPos[1]) |
199 |
12/12✓ Branch 0 taken 101520 times.
✓ Branch 1 taken 119280 times.
✓ Branch 2 taken 101520 times.
✓ Branch 3 taken 119280 times.
✓ Branch 4 taken 101520 times.
✓ Branch 5 taken 119280 times.
✓ Branch 6 taken 101520 times.
✓ Branch 7 taken 119280 times.
✓ Branch 8 taken 101520 times.
✓ Branch 9 taken 119280 times.
✓ Branch 10 taken 101520 times.
✓ Branch 11 taken 119280 times.
|
12346560 | / (0.25 * (this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1]) |
200 |
14/14✓ Branch 0 taken 101520 times.
✓ Branch 1 taken 119280 times.
✓ Branch 2 taken 101520 times.
✓ Branch 3 taken 119280 times.
✓ Branch 4 taken 101520 times.
✓ Branch 5 taken 119280 times.
✓ Branch 6 taken 101520 times.
✓ Branch 7 taken 119280 times.
✓ Branch 8 taken 101520 times.
✓ Branch 9 taken 119280 times.
✓ Branch 10 taken 101520 times.
✓ Branch 11 taken 119280 times.
✓ Branch 12 taken 101520 times.
✓ Branch 13 taken 119280 times.
|
14404320 | * (this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1])); |
201 | |||
202 | return values; | ||
203 | } | ||
204 | |||
205 | /*! | ||
206 | * \brief Returns the intrinsic permeability of required as input parameter | ||
207 | * for the Beavers-Joseph-Saffman boundary condition. | ||
208 | */ | ||
209 | Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const | ||
210 | { | ||
211 | ✗ | return couplingManager().couplingData().darcyPermeability(element, scvf); | |
212 | } | ||
213 | |||
214 | /*! | ||
215 | * \brief Returns the alpha value required as input parameter for the | ||
216 | * Beavers-Joseph-Saffman boundary condition. | ||
217 | */ | ||
218 | ✗ | Scalar alphaBJ(const SubControlVolumeFace& scvf) const | |
219 | { | ||
220 | ✗ | return 1.0; | |
221 | } | ||
222 | |||
223 | void setInjectionState(const bool yesNo) | ||
224 | { | ||
225 | 40 | injectionState_ = yesNo; | |
226 | } | ||
227 | |||
228 | ✗ | bool isInjectionPeriod() const | |
229 | { | ||
230 | ✗ | return injectionState_; | |
231 | } | ||
232 | |||
233 | // \} | ||
234 | |||
235 | private: | ||
236 | bool onLeftBoundary_(const GlobalPosition &globalPos) const | ||
237 |
10/10✓ Branch 0 taken 123680 times.
✓ Branch 1 taken 525120 times.
✓ Branch 2 taken 123680 times.
✓ Branch 3 taken 525120 times.
✓ Branch 4 taken 123680 times.
✓ Branch 5 taken 525120 times.
✓ Branch 6 taken 123680 times.
✓ Branch 7 taken 525120 times.
✓ Branch 8 taken 123680 times.
✓ Branch 9 taken 525120 times.
|
3244000 | { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; } |
238 | |||
239 | bool onRightBoundary_(const GlobalPosition &globalPos) const | ||
240 |
10/10✓ Branch 0 taken 184640 times.
✓ Branch 1 taken 340480 times.
✓ Branch 2 taken 184640 times.
✓ Branch 3 taken 340480 times.
✓ Branch 4 taken 184640 times.
✓ Branch 5 taken 340480 times.
✓ Branch 6 taken 184640 times.
✓ Branch 7 taken 340480 times.
✓ Branch 8 taken 184640 times.
✓ Branch 9 taken 340480 times.
|
2625600 | { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; } |
241 | |||
242 | bool onLowerBoundary_(const GlobalPosition &globalPos) const | ||
243 | { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; } | ||
244 | |||
245 | bool onUpperBoundary_(const GlobalPosition &globalPos) const | ||
246 | { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; } | ||
247 | |||
248 | Scalar eps_; | ||
249 | Scalar inletVelocity_; | ||
250 | Scalar pressure_; | ||
251 | Scalar inletMoleFraction_; | ||
252 | bool injectionState_; | ||
253 | |||
254 | std::shared_ptr<CouplingManager> couplingManager_; | ||
255 | }; | ||
256 | } // end namespace Dumux | ||
257 | |||
258 | #endif | ||
259 |