GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porenetwork/1pnc/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 29 29 100.0%
Functions: 2 2 100.0%
Branches: 22 42 52.4%

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 one-phase two-component pore network model.
11 */
12 #ifndef DUMUX_PNM1P2C_PROBLEM_HH
13 #define DUMUX_PNM1P2C_PROBLEM_HH
14
15 // base problem
16 #include <dumux/porousmediumflow/problem.hh>
17 // Pore network model
18 #include <dumux/porenetwork/1pnc/model.hh>
19
20 #include <dumux/common/boundarytypes.hh>
21
22 namespace Dumux
23 {
24 template <class TypeTag>
25 class PNMOnePTwoCProblem;
26
27 template <class TypeTag>
28 3 class PNMOnePTwoCProblem : public PorousMediumFlowProblem<TypeTag>
29 {
30 using ParentType = PorousMediumFlowProblem<TypeTag>;
31 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
32 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
33 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
34 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
35 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using GridView = typename GridGeometry::GridView;
38 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
39
40 // copy some indices for convenience
41 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
42 using Labels = GetPropType<TypeTag, Properties::Labels>;
43 enum {
44 // primary variable indices
45 conti0EqIdx = Indices::conti0EqIdx,
46 pressureIdx = Indices::pressureIdx,
47 transportEqIdx = 1,
48
49 #if !ISOTHERMAL
50 temperatureIdx = Indices::temperatureIdx,
51 energyEqIdx = Indices::energyEqIdx,
52 #endif
53
54 };
55
56 using Element = typename GridView::template Codim<0>::Entity;
57 using Vertex = typename GridView::template Codim<GridView::dimension>::Entity;
58
59 public:
60 template<class SpatialParams>
61 3 PNMOnePTwoCProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<SpatialParams> spatialParams)
62
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 10 not taken.
✗ Branch 11 not taken.
12 : ParentType(gridGeometry, spatialParams)
63 {
64 // get some parameters from the input file
65
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 inletPressure_ = getParam<Scalar>("Problem.InletPressure");
66
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 outletPressure_ = getParam<Scalar>("Problem.OutletPressure");
67
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 inletMoleFraction_ = getParam<Scalar>("Problem.InletMoleFraction");
68
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 outletMoleFraction_ = getParam<Scalar>("Problem.OutletMoleFraction");
69
70 FluidSystem::init();
71 3 }
72
73 /*!
74 * \name Boundary conditions
75 */
76 // \{
77 //! Specifies which kind of boundary condition should be used for
78 //! which equation for a finite volume on the boundary.
79 5110 BoundaryTypes boundaryTypes(const Element& element, const SubControlVolume& scv) const
80 {
81 5110 BoundaryTypes bcTypes;
82
3/4
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 3285 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
5110 if (isInletPore_(scv) || isOutletPore_(scv))
83 5110 bcTypes.setAllDirichlet();
84 #if !ISOTHERMAL
85 2044 bcTypes.setDirichlet(temperatureIdx);
86 #endif
87 5110 return bcTypes;
88 }
89
90 /*!
91 * \brief Evaluate the boundary conditions for a Dirichlet
92 * control volume.
93 *
94 * \param values The Dirichlet values for the primary variables
95 * \param vertex The vertex (pore body) for which the condition is evaluated
96 *
97 * For this method, the \a values parameter stores primary variables.
98 */
99 5110 PrimaryVariables dirichlet(const Element& element,
100 const SubControlVolume& scv) const
101 {
102 5110 PrimaryVariables values(0.0);
103
2/4
✓ Branch 0 taken 3285 times.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5110 if(isInletPore_(scv))
104 {
105 3285 values[pressureIdx] = inletPressure_;
106 3285 values[transportEqIdx] = inletMoleFraction_;
107 }
108 else
109 {
110 1825 values[pressureIdx] = outletPressure_;
111 1825 values[transportEqIdx] = outletMoleFraction_;
112 }
113
114 #if !ISOTHERMAL
115
2/4
✓ Branch 0 taken 1314 times.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2044 if(isInletPore_(scv))
116 1314 values[temperatureIdx] = 273.15 +25;
117 else
118 730 values[temperatureIdx] = 273.15 +20;
119 #endif
120 return values;
121 }
122
123 /*!
124 * \brief Evaluate the initial value for a control volume.
125 *
126 * For this method, the \a priVars parameter stores primary
127 * variables.
128 */
129 90 PrimaryVariables initial(const Vertex& vertex) const
130 {
131 90 PrimaryVariables values(0.0);
132 values[pressureIdx] = 1e5;
133 #if !ISOTHERMAL
134 values[temperatureIdx] = 273.15 +20;
135 #endif
136 return values;
137 }
138
139 private:
140
141 10220 bool isInletPore_(const SubControlVolume& scv) const
142 {
143
6/10
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 3285 times.
✓ Branch 2 taken 3285 times.
✓ Branch 3 taken 1825 times.
✓ Branch 4 taken 1314 times.
✓ Branch 5 taken 730 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12264 return this->gridGeometry().poreLabel(scv.dofIndex()) == Labels::inlet;
144 }
145
146 bool isOutletPore_(const SubControlVolume& scv) const
147 {
148
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 return this->gridGeometry().poreLabel(scv.dofIndex()) == Labels::outlet;
149 }
150
151 Scalar inletPressure_;
152 Scalar outletPressure_;
153 Scalar inletMoleFraction_;
154 Scalar outletMoleFraction_;
155 };
156 } //end namespace Dumux
157
158 #endif
159