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-FileCopyrightText: 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 Pore-network sub-problem for the coupled 1p_1p free-flow/pore-network-model test | ||
11 | */ | ||
12 | |||
13 | #ifndef DUMUX_TEST_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORE_NETWORK_PROBLEM_PNM_HH | ||
14 | #define DUMUX_TEST_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORE_NETWORK_PROBLEM_PNM_HH | ||
15 | |||
16 | #include <dumux/common/boundarytypes.hh> | ||
17 | #include <dumux/common/numeqvector.hh> | ||
18 | #include <dumux/common/properties.hh> | ||
19 | #include <dumux/common/parameters.hh> | ||
20 | #include <dumux/porousmediumflow/problem.hh> | ||
21 | |||
22 | namespace Dumux { | ||
23 | |||
24 | /*! | ||
25 | * \ingroup BoundaryTests | ||
26 | * \brief Pore-network sub-problem for the coupled 1p_1p free-flow/pore-network-model test | ||
27 | * A two-dimensional pore-network region coupled to a free-flow model. | ||
28 | */ | ||
29 | template <class TypeTag> | ||
30 | class PNMOnePProblem : public PorousMediumFlowProblem<TypeTag> | ||
31 | { | ||
32 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
33 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
34 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
35 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
36 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
37 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
38 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
39 | using GridView = typename GridGeometry::GridView; | ||
40 | using Element = typename GridView::template Codim<0>::Entity; | ||
41 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
42 | |||
43 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
44 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
45 | |||
46 | public: | ||
47 | template<class SpatialParams> | ||
48 | 3 | PNMOnePProblem(std::shared_ptr<const GridGeometry> gridGeometry, | |
49 | std::shared_ptr<SpatialParams> spatialParams, | ||
50 | std::shared_ptr<CouplingManager> couplingManager) | ||
51 |
3/8✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
12 | : ParentType(gridGeometry, spatialParams, "PNM"), couplingManager_(couplingManager) |
52 | { | ||
53 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | verticalFlow_ = getParamFromGroup<bool>(this->paramGroup(), "Problem.VerticalFlow", true); |
54 | |||
55 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | initialPressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialPressure", 1e5); |
56 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | inletPressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InletPressure", 1.01e5); |
57 | |||
58 | #if !ISOTHERMAL | ||
59 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | initialTemperature_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialTemperature", 273.15 + 20); |
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | inletTemperature_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InletTemperature", 273.15 + 20); |
61 | #endif | ||
62 | 3 | } | |
63 | |||
64 | /*! | ||
65 | * \name Simulation steering | ||
66 | */ | ||
67 | // \{ | ||
68 | |||
69 | /*! | ||
70 | * \name Problem parameters | ||
71 | */ | ||
72 | // \{ | ||
73 | |||
74 | 3 | const std::string& name() const | |
75 | { | ||
76 |
5/10✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ 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.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
|
6 | static const std::string problemName = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); |
77 | 3 | return problemName; | |
78 | } | ||
79 | |||
80 | // \} | ||
81 | |||
82 | /*! | ||
83 | * \name Boundary conditions | ||
84 | */ | ||
85 | // \{ | ||
86 | |||
87 | /*! | ||
88 | * \brief Specifies which kind of boundary condition should be used for | ||
89 | * which equation for a finite volume on the boundary. | ||
90 | */ | ||
91 |
2/2✓ Branch 0 taken 46 times.
✓ Branch 1 taken 18 times.
|
108 | BoundaryTypes boundaryTypes(const Element& element, const SubControlVolume& scv) const |
92 | { | ||
93 | 108 | BoundaryTypes bcTypes; | |
94 |
2/2✓ Branch 0 taken 68 times.
✓ Branch 1 taken 40 times.
|
108 | if (couplingManager().isCoupled(CouplingManager::poreNetworkIndex, CouplingManager::freeFlowMassIndex, scv)) |
95 | 44 | bcTypes.setAllCouplingNeumann(); | |
96 | else | ||
97 | { | ||
98 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
|
68 | if(onInlet_(scv)) |
99 | 44 | bcTypes.setAllDirichlet(); //pressure (and Temperature) fixed for inflow from bottom | |
100 | else | ||
101 | 44 | bcTypes.setAllNeumann(); | |
102 | } | ||
103 | 108 | return bcTypes; | |
104 | } | ||
105 | |||
106 | /*! | ||
107 | * \brief Evaluate the boundary conditions for a dirichlet | ||
108 | * control volume. | ||
109 | */ | ||
110 |
1/4✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
47 | PrimaryVariables dirichlet(const Element& element, |
111 | const SubControlVolume& scv) const | ||
112 | { | ||
113 | 47 | PrimaryVariables priVars = initialAtPos(scv.dofPosition()); | |
114 |
1/4✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
47 | if(onInlet_(scv)) |
115 | { | ||
116 | 47 | priVars[Indices::pressureIdx] = inletPressure_; | |
117 | #if !ISOTHERMAL | ||
118 | 22 | priVars[Indices::temperatureIdx] = inletTemperature_; | |
119 | #endif | ||
120 | } | ||
121 | return priVars; | ||
122 | } | ||
123 | |||
124 | // \} | ||
125 | |||
126 | /*! | ||
127 | * \name Volume terms | ||
128 | */ | ||
129 | // \{ | ||
130 | |||
131 | /*! | ||
132 | * \brief Evaluate the source term for all phases within a given | ||
133 | * sub-control-volume. | ||
134 | * | ||
135 | * This is the method for the case where the source term is | ||
136 | * potentially solution dependent and requires some quantities that | ||
137 | * are specific to the fully-implicit method. | ||
138 | * | ||
139 | * \param element The finite element | ||
140 | * \param fvGeometry The finite-volume geometry | ||
141 | * \param elemVolVars All volume variables for the element | ||
142 | * \param scv The sub control volume | ||
143 | * | ||
144 | * For this method, the return parameter stores the conserved quantity rate | ||
145 | * generated or annihilate per volume unit. Positive values mean | ||
146 | * that the conserved quantity is created, negative ones mean that it vanishes. | ||
147 | * E.g. for the mass balance that would be a mass rate in \f$ [ kg / (m^3 \cdot s)] \f$. | ||
148 | */ | ||
149 | template<class ElementVolumeVariables> | ||
150 | 1928 | PrimaryVariables source(const Element &element, | |
151 | const FVElementGeometry& fvGeometry, | ||
152 | const ElementVolumeVariables& elemVolVars, | ||
153 | const SubControlVolume &scv) const | ||
154 | { | ||
155 | 1928 | PrimaryVariables values(0.0); | |
156 | |||
157 |
2/2✓ Branch 0 taken 896 times.
✓ Branch 1 taken 1032 times.
|
1928 | if (couplingManager().isCoupled(CouplingManager::poreNetworkIndex, CouplingManager::freeFlowMassIndex, scv)) |
158 | { | ||
159 | 896 | values[Indices::conti0EqIdx] = couplingManager().massCouplingCondition( | |
160 | CouplingManager::poreNetworkIndex, | ||
161 | CouplingManager::freeFlowMassIndex, fvGeometry, | ||
162 | scv, | ||
163 | elemVolVars); | ||
164 | #if !ISOTHERMAL | ||
165 | 660 | values[Indices::energyEqIdx] = couplingManager().energyCouplingCondition( | |
166 | CouplingManager::poreNetworkIndex, | ||
167 | CouplingManager::freeFlowMassIndex, fvGeometry, | ||
168 | scv, | ||
169 | elemVolVars); | ||
170 | #endif | ||
171 | } | ||
172 | 1928 | values /= this->gridGeometry().poreVolume(scv.dofIndex()); | |
173 | |||
174 | 1928 | return values; | |
175 | } | ||
176 | |||
177 | /*! | ||
178 | * \brief Evaluate the initial value for a given global position. | ||
179 | * | ||
180 | * For this method, the \a priVars parameter stores primary | ||
181 | * variables. | ||
182 | */ | ||
183 | 49 | PrimaryVariables initialAtPos(const GlobalPosition& pos) const | |
184 | { | ||
185 | 49 | PrimaryVariables values(0.0); | |
186 |
1/4✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
49 | values[Indices::pressureIdx] = initialPressure_; |
187 | #if !ISOTHERMAL | ||
188 | 2 | values[Indices::temperatureIdx] = initialTemperature_; | |
189 | #endif | ||
190 | return values; | ||
191 | } | ||
192 | |||
193 | // \} | ||
194 | |||
195 | //! Set the coupling manager | ||
196 | void setCouplingManager(std::shared_ptr<CouplingManager> cm) | ||
197 | { couplingManager_ = cm; } | ||
198 | |||
199 | //! Get the coupling manager | ||
200 | 2696 | const CouplingManager& couplingManager() const | |
201 |
5/5✓ Branch 0 taken 896 times.
✓ Branch 1 taken 1032 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 22 times.
✓ Branch 3 taken 46 times.
|
2036 | { return *couplingManager_; } |
202 | |||
203 | private: | ||
204 | 115 | bool onInlet_(const SubControlVolume& scv) const | |
205 | { | ||
206 |
3/6✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
|
115 | if (verticalFlow_) |
207 | 115 | return onLowerBoundary_(scv); | |
208 | else | ||
209 | ✗ | return onLeftBoundary_(scv); | |
210 | } | ||
211 | |||
212 | bool onOutlet_(const SubControlVolume& scv) const | ||
213 | { | ||
214 | if (verticalFlow_) | ||
215 | return 0; | ||
216 | else | ||
217 | return onRightBoundary_(scv); | ||
218 | } | ||
219 | |||
220 | ✗ | bool onLeftBoundary_(const SubControlVolume& scv) const | |
221 | ✗ | { return this->gridGeometry().poreLabel(scv.dofIndex()) == 0; } | |
222 | |||
223 | bool onRightBoundary_(const SubControlVolume& scv) const | ||
224 | { return this->gridGeometry().poreLabel(scv.dofIndex()) == 1; } | ||
225 | |||
226 | 115 | bool onLowerBoundary_(const SubControlVolume& scv) const | |
227 | 115 | { return this->gridGeometry().poreLabel(scv.dofIndex()) == 2; } | |
228 | |||
229 | bool onUpperBoundary_(const SubControlVolume& scv) const | ||
230 | { return this->gridGeometry().poreLabel(scv.dofIndex()) == 3; } | ||
231 | |||
232 | |||
233 | std::shared_ptr<CouplingManager> couplingManager_; | ||
234 | Scalar initialPressure_; | ||
235 | Scalar inletPressure_; | ||
236 | bool verticalFlow_; | ||
237 | #if !ISOTHERMAL | ||
238 | Scalar initialTemperature_; | ||
239 | Scalar inletTemperature_; | ||
240 | #endif | ||
241 | |||
242 | }; | ||
243 | |||
244 | } // end namespace Dumux | ||
245 | |||
246 | #endif | ||
247 |