GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porenetwork/2pnc/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 52 53 98.1%
Functions: 3 3 100.0%
Branches: 49 72 68.1%

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 *
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
3/8
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 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 206 bool shouldWriteOutput(const int timeStepIndex, const GridVariables& gridVariables) const
63 {
64
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if (vtpOutputFrequency_ < 0)
65 return true;
66
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if (vtpOutputFrequency_ == 0)
68 return (timeStepIndex == 0 || gridVariables.gridFluxVarsCache().invasionState().hasChanged());
69 else
70
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 20 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
3/4
✓ Branch 0 taken 1711 times.
✓ Branch 1 taken 1719 times.
✓ Branch 2 taken 1711 times.
✗ Branch 3 not taken.
3430 if (isInletPore_(scv) || isOutletPore_(scv))
87 3430 bcTypes.setAllDirichlet();
88 #if !ISOTHERMAL
89 1488 bcTypes.setDirichlet(Indices::temperatureIdx);
90 #endif
91 3430 return bcTypes;
92 }
93
94
95 //! Evaluate the boundary conditions for a Dirichlet control volume.
96 1962 PrimaryVariables dirichlet(const Element& element,
97 const SubControlVolume& scv) const
98 {
99 1962 PrimaryVariables values(0.0);
100
101
4/6
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 238 times.
✓ Branch 5 taken 238 times.
1962 if (isInletPore_(scv))
102 {
103 981 values.setState(Indices::bothPhases);
104 981 values[Indices::pressureIdx] = inletPressure_;
105 981 values[Indices::switchIdx] = 1.0;
106 }
107 else
108 {
109 981 values.setState(Indices::bothPhases);
110 981 values[Indices::pressureIdx] = outletPressure_;
111 981 values[Indices::switchIdx] = 0.0;
112 }
113
114 #if !ISOTHERMAL
115
4/6
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 119 times.
872 if (isInletPore_(scv))
116 436 values[Indices::temperatureIdx] = inletTemperature_;
117 else
118 436 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 34792 PrimaryVariables source(const Element& element,
132 const FVElementGeometry& fvGeometry,
133 const ElementVolumeVariables& elemVolVars,
134 const SubControlVolume& scv) const
135 {
136
2/2
✓ Branch 0 taken 87336 times.
✓ Branch 1 taken 34792 times.
156920 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 20 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 10 const auto dofIdxGlobal = this->gridGeometry().vertexMapper().index(vertex);
155 10 if (isInletPore_(dofIdxGlobal))
156 {
157 2 values.setState(Indices::bothPhases);
158 2 values[Indices::pressureIdx] = inletPressure_;
159 2 values[Indices::switchIdx] = 1.0;
160 #if !ISOTHERMAL
161 1 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
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 bool initialInvasionState(const Element& element) const
170 { return false; }
171
172 // \}
173
174 private:
175
176
6/8
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1711 times.
✓ Branch 5 taken 1719 times.
✓ Branch 6 taken 238 times.
✓ Branch 7 taken 238 times.
5392 bool isInletPore_(const SubControlVolume& scv) const
177 {
178 5392 return isInletPore_(scv.dofIndex());
179 }
180
181 5402 bool isInletPore_(const std::size_t dofIdxGlobal) const
182 {
183
16/16
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 743 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 317 times.
✓ Branch 4 taken 971 times.
✓ Branch 5 taken 971 times.
✓ Branch 6 taken 119 times.
✓ Branch 7 taken 119 times.
✓ Branch 8 taken 741 times.
✓ Branch 9 taken 752 times.
✓ Branch 10 taken 119 times.
✓ Branch 11 taken 119 times.
✓ Branch 12 taken 119 times.
✓ Branch 13 taken 119 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 4 times.
6274 return this->gridGeometry().poreLabel(dofIdxGlobal) == Labels::inlet;
184 }
185
186 bool isOutletPore_(const SubControlVolume& scv) const
187 {
188
1/2
✓ Branch 0 taken 1711 times.
✗ Branch 1 not taken.
1711 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