GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porenetwork/1pnc/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 31 32 96.9%
Functions: 3 4 75.0%
Branches: 33 60 55.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 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
7/20
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✓ Branch 18 taken 3 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.
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
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 outletMoleFraction_ = getParam<Scalar>("Problem.OutletMoleFraction");
69
70
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 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 13870 if (isInletPore_(scv) || isOutletPore_(scv))
83 bcTypes.setAllDirichlet();
84 #if !ISOTHERMAL
85 4088 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 2044 PrimaryVariables dirichlet(const Element& element,
100 const SubControlVolume& scv) const
101 {
102 5110 PrimaryVariables values(0.0);
103 10220 if(isInletPore_(scv))
104 {
105 3285 values[pressureIdx] = inletPressure_;
106 6570 values[transportEqIdx] = inletMoleFraction_;
107 }
108 else
109 {
110 1825 values[pressureIdx] = outletPressure_;
111 3650 values[transportEqIdx] = outletMoleFraction_;
112 }
113
114 #if !ISOTHERMAL
115 4088 if(isInletPore_(scv))
116 2628 values[temperatureIdx] = 273.15 +25;
117 else
118 1460 values[temperatureIdx] = 273.15 +20;
119 #endif
120 5110 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 PrimaryVariables initial(const Vertex& vertex) const
130 {
131 270 PrimaryVariables values(0.0);
132 270 values[pressureIdx] = 1e5;
133 #if !ISOTHERMAL
134 180 values[temperatureIdx] = 273.15 +20;
135 #endif
136 180 return values;
137 }
138
139 private:
140
141 bool isInletPore_(const SubControlVolume& scv) const
142 {
143
18/24
✓ Branch 0 taken 1314 times.
✓ Branch 1 taken 730 times.
✓ Branch 2 taken 1314 times.
✓ Branch 3 taken 730 times.
✓ Branch 4 taken 1314 times.
✓ Branch 5 taken 730 times.
✓ Branch 6 taken 2409 times.
✓ Branch 7 taken 2701 times.
✓ Branch 8 taken 2409 times.
✓ Branch 9 taken 2701 times.
✓ Branch 10 taken 2409 times.
✓ Branch 11 taken 2701 times.
✓ Branch 12 taken 2701 times.
✓ Branch 13 taken 2409 times.
✓ Branch 14 taken 2701 times.
✓ Branch 15 taken 2409 times.
✓ Branch 16 taken 2701 times.
✓ Branch 17 taken 2409 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
36792 return this->gridGeometry().poreLabel(scv.dofIndex()) == Labels::inlet;
144 }
145
146 bool isOutletPore_(const SubControlVolume& scv) const
147 {
148
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
5475 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