GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porenetwork/2pnc/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 45 54 83.3%
Functions: 3 9 33.3%
Branches: 67 124 54.0%

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