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 | * | ||
10 | * \brief A test problem for the two-phase n-components pore network model. | ||
11 | */ | ||
12 | #ifndef DUMUX_PNM_2P_NC_PROBLEM_HH | ||
13 | #define DUMUX_PNM_2P_NC_PROBLEM_HH | ||
14 | |||
15 | #include <dumux/common/boundarytypes.hh> | ||
16 | #include <dumux/common/parameters.hh> | ||
17 | #include <dumux/porousmediumflow/problem.hh> | ||
18 | #include <dumux/material/components/air.hh> | ||
19 | |||
20 | namespace Dumux { | ||
21 | |||
22 | template <class TypeTag> | ||
23 | 2 | class DrainageProblem : public PorousMediumFlowProblem<TypeTag> | |
24 | { | ||
25 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
26 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
27 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
28 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
29 | using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView; | ||
30 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
31 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
32 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
33 | using GridView = typename GridGeometry::GridView; | ||
34 | using GridVariables = GetPropType<TypeTag, Properties::GridVariables>; | ||
35 | |||
36 | // copy some indices for convenience | ||
37 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
38 | using Labels = GetPropType<TypeTag, Properties::Labels>; | ||
39 | using Element = typename GridView::template Codim<0>::Entity; | ||
40 | using Vertex = typename GridView::template Codim<GridView::dimension>::Entity; | ||
41 | |||
42 | public: | ||
43 | template<class SpatialParams> | ||
44 | 2 | DrainageProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<SpatialParams> spatialParams) | |
45 |
7/20✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 18 taken 2 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.
✗ Branch 25 not taken.
|
8 | : ParentType(gridGeometry, spatialParams) |
46 | { | ||
47 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | vtpOutputFrequency_ = getParam<int>("Problem.VtpOutputFrequency"); |
48 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | inletPressure_ = getParam<Scalar>("Problem.InletPressure", 1.1e5); |
49 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | outletPressure_ = getParam<Scalar>("Problem.OutletPressure", 1e5); |
50 | #if !ISOTHERMAL | ||
51 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | inletTemperature_ = getParam<Scalar>("Problem.InletTemperature", 288.15); |
52 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | outletTemperature_ = getParam<Scalar>("Problem.OutletTemperature", 283.15); |
53 | #endif | ||
54 | 2 | } | |
55 | |||
56 | /*! | ||
57 | * \name Problem parameters | ||
58 | */ | ||
59 | // \{ | ||
60 | |||
61 | ✗ | bool shouldWriteOutput(const int timeStepIndex, const GridVariables& gridVariables) const | |
62 | { | ||
63 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 206 times.
✗ Branch 3 not taken.
|
206 | if (vtpOutputFrequency_ < 0) |
64 | ✗ | return true; | |
65 | |||
66 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 206 times.
|
206 | if (vtpOutputFrequency_ == 0) |
67 | ✗ | return (timeStepIndex == 0 || gridVariables.gridFluxVarsCache().invasionState().hasChanged()); | |
68 | else | ||
69 |
8/16✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 186 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 179 times.
✓ Branch 12 taken 7 times.
✓ Branch 13 taken 179 times.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 179 times.
|
206 | return (timeStepIndex % vtpOutputFrequency_ == 0 || gridVariables.gridFluxVarsCache().invasionState().hasChanged()); |
70 | } | ||
71 | |||
72 | // \} | ||
73 | |||
74 | /*! | ||
75 | * \name Boundary conditions | ||
76 | */ | ||
77 | // \{ | ||
78 | //! Specifies which kind of boundary condition should be used for | ||
79 | //! which equation for a sub control volume on the boundary. | ||
80 | 3430 | BoundaryTypes boundaryTypes(const Element& element, const SubControlVolume& scv) const | |
81 | { | ||
82 | 3430 | BoundaryTypes bcTypes; | |
83 | |||
84 | // Use Dirichlet BCs for both inlet and outlet | ||
85 | 10282 | if (isInletPore_(scv) || isOutletPore_(scv)) | |
86 | bcTypes.setAllDirichlet(); | ||
87 | #if !ISOTHERMAL | ||
88 | 2976 | bcTypes.setDirichlet(Indices::temperatureIdx); | |
89 | #endif | ||
90 | 3430 | return bcTypes; | |
91 | } | ||
92 | |||
93 | |||
94 | //! Evaluate the boundary conditions for a Dirichlet control volume. | ||
95 | ✗ | PrimaryVariables dirichlet(const Element& element, | |
96 | const SubControlVolume& scv) const | ||
97 | { | ||
98 | 1962 | PrimaryVariables values(0.0); | |
99 | |||
100 | 3924 | if (isInletPore_(scv)) | |
101 | { | ||
102 | 981 | values.setState(Indices::bothPhases); | |
103 | 981 | values[Indices::pressureIdx] = inletPressure_; | |
104 | 1962 | values[Indices::switchIdx] = 1.0; | |
105 | } | ||
106 | else | ||
107 | { | ||
108 | 981 | values.setState(Indices::bothPhases); | |
109 | 981 | values[Indices::pressureIdx] = outletPressure_; | |
110 | 1962 | values[Indices::switchIdx] = 0.0; | |
111 | } | ||
112 | |||
113 | #if !ISOTHERMAL | ||
114 | 1744 | if (isInletPore_(scv)) | |
115 | 872 | values[Indices::temperatureIdx] = inletTemperature_; | |
116 | else | ||
117 | 872 | values[Indices::temperatureIdx] = outletTemperature_; | |
118 | #endif | ||
119 | ✗ | return values; | |
120 | } | ||
121 | |||
122 | // \} | ||
123 | |||
124 | /*! | ||
125 | * \name Volume terms | ||
126 | */ | ||
127 | // \{ | ||
128 | |||
129 | //! Evaluate the source term for all phases within a given sub-control-volume. | ||
130 | ✗ | PrimaryVariables source(const Element& element, | |
131 | const FVElementGeometry& fvGeometry, | ||
132 | const ElementVolumeVariables& elemVolVars, | ||
133 | const SubControlVolume& scv) const | ||
134 | { | ||
135 | 69584 | PrimaryVariables values(0.0); | |
136 | ✗ | return values; | |
137 | } | ||
138 | // \} | ||
139 | |||
140 | //! Evaluate the initial value for a control volume. | ||
141 | 10 | PrimaryVariables initial(const Vertex& vertex) const | |
142 | { | ||
143 | 10 | PrimaryVariables values(0.0); | |
144 | |||
145 | 10 | values.setState(Indices::bothPhases); | |
146 | 10 | values[Indices::pressureIdx] = outletPressure_; | |
147 | 10 | values[Indices::switchIdx] = 0.0; | |
148 | |||
149 | #if !ISOTHERMAL | ||
150 | 5 | values[Indices::temperatureIdx] = outletTemperature_; | |
151 | #endif | ||
152 | |||
153 | 30 | const auto dofIdxGlobal = this->gridGeometry().vertexMapper().index(vertex); | |
154 | 20 | if (isInletPore_(dofIdxGlobal)) | |
155 | { | ||
156 | 2 | values.setState(Indices::bothPhases); | |
157 | 2 | values[Indices::pressureIdx] = inletPressure_; | |
158 | 3 | values[Indices::switchIdx] = 1.0; | |
159 | #if !ISOTHERMAL | ||
160 | 2 | values[Indices::temperatureIdx] = inletTemperature_; | |
161 | #endif | ||
162 | } | ||
163 | |||
164 | 10 | return values; | |
165 | } | ||
166 | |||
167 | //! Evaluate the initial invasion state of a pore throat | ||
168 | ✗ | bool initialInvasionState(const Element& element) const | |
169 | ✗ | { return false; } | |
170 | |||
171 | // \} | ||
172 | |||
173 | private: | ||
174 | |||
175 | bool isInletPore_(const SubControlVolume& scv) const | ||
176 | { | ||
177 | 12528 | return isInletPore_(scv.dofIndex()); | |
178 | } | ||
179 | |||
180 | bool isInletPore_(const std::size_t dofIdxGlobal) const | ||
181 | { | ||
182 |
42/48✓ Branch 0 taken 743 times.
✓ Branch 1 taken 743 times.
✓ Branch 2 taken 743 times.
✓ Branch 3 taken 743 times.
✓ Branch 4 taken 743 times.
✓ Branch 5 taken 743 times.
✓ Branch 6 taken 317 times.
✓ Branch 7 taken 317 times.
✓ Branch 8 taken 317 times.
✓ Branch 9 taken 317 times.
✓ Branch 10 taken 317 times.
✓ Branch 11 taken 317 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 971 times.
✓ Branch 19 taken 971 times.
✓ Branch 20 taken 971 times.
✓ Branch 21 taken 971 times.
✓ Branch 22 taken 971 times.
✓ Branch 23 taken 971 times.
✓ Branch 24 taken 859 times.
✓ Branch 25 taken 867 times.
✓ Branch 26 taken 859 times.
✓ Branch 27 taken 867 times.
✓ Branch 28 taken 859 times.
✓ Branch 29 taken 867 times.
✓ Branch 30 taken 120 times.
✓ Branch 31 taken 123 times.
✓ Branch 32 taken 120 times.
✓ Branch 33 taken 123 times.
✓ Branch 34 taken 120 times.
✓ Branch 35 taken 123 times.
✓ Branch 36 taken 119 times.
✓ Branch 37 taken 119 times.
✓ Branch 38 taken 119 times.
✓ Branch 39 taken 119 times.
✓ Branch 40 taken 119 times.
✓ Branch 41 taken 119 times.
✓ Branch 42 taken 1 times.
✓ Branch 43 taken 4 times.
✓ Branch 44 taken 1 times.
✓ Branch 45 taken 4 times.
✓ Branch 46 taken 1 times.
✓ Branch 47 taken 4 times.
|
18822 | return this->gridGeometry().poreLabel(dofIdxGlobal) == Labels::inlet; |
183 | } | ||
184 | |||
185 | bool isOutletPore_(const SubControlVolume& scv) const | ||
186 | { | ||
187 |
3/6✓ Branch 0 taken 1711 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1711 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1711 times.
✗ Branch 5 not taken.
|
5133 | return this->gridGeometry().poreLabel(scv.dofIndex()) == Labels::outlet; |
188 | } | ||
189 | |||
190 | int vtpOutputFrequency_; | ||
191 | Scalar inletPressure_; | ||
192 | Scalar outletPressure_; | ||
193 | #if !ISOTHERMAL | ||
194 | Scalar inletTemperature_; | ||
195 | Scalar outletTemperature_; | ||
196 | #endif | ||
197 | }; | ||
198 | } //end namespace Dumux | ||
199 | |||
200 | #endif | ||
201 |