GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/3p/infiltration/spatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 42 50 84.0%
Functions: 4 16 25.0%
Branches: 115 290 39.7%

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 * \ingroup ThreePTests
10 * \brief Definition of the spatial parameters for the kuevette problem.
11 */
12
13 #ifndef DUMUX_INFILTRATION_THREEP_SPATIAL_PARAMS_HH
14 #define DUMUX_INFILTRATION_THREEP_SPATIAL_PARAMS_HH
15
16 #include <dumux/porousmediumflow/properties.hh>
17 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
18 #include <dumux/material/fluidmatrixinteractions/3p/parkervangenuchten.hh>
19 #include <dumux/io/gnuplotinterface.hh>
20 #include <dumux/common/enumerate.hh>
21
22 namespace Dumux {
23 /*!
24 * \ingroup ThreePTests
25 * \brief Definition of the spatial parameters for the infiltration problem
26 */
27 template<class GridGeometry, class Scalar>
28
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 class InfiltrationThreePSpatialParams
29 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar,
30 InfiltrationThreePSpatialParams<GridGeometry, Scalar>>
31 {
32 using GridView = typename GridGeometry::GridView;
33 using FVElementGeometry = typename GridGeometry::LocalView;
34 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
35 using Element = typename GridView::template Codim<0>::Entity;
36 using ParentType = FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar,
37 InfiltrationThreePSpatialParams<GridGeometry, Scalar>>;
38
39 using GlobalPosition = typename SubControlVolume::GlobalPosition;
40
41 using ThreePhasePcKrSw = FluidMatrix::ParkerVanGenuchten3PDefault<Scalar>;
42
43 public:
44 //! Export permeability type
45 using PermeabilityType = Scalar;
46
47 2 InfiltrationThreePSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
48 : ParentType(gridGeometry)
49
7/20
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 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 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
6 , pcKrSwCurve_("SpatialParams")
50 {
51 // intrinsic permeabilities
52
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 fineK_ = getParam<Scalar>("SpatialParams.permeability");
53
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 coarseK_ = getParam<Scalar>("SpatialParams.permeability");
54
55 // porosities
56
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 porosity_ = getParam<Scalar>("SpatialParams.porosity");
57
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 plotFluidMatrixInteractions_ = getParam<bool>("Output.PlotFluidMatrixInteractions");
58 2 }
59
60 /*!
61 * \brief This is called from the problem and creates a gnuplot output
62 * of e.g the pc-Sw curve
63 */
64 2 void plotMaterialLaw()
65 {
66 2 GnuplotInterface<Scalar> gnuplot(plotFluidMatrixInteractions_);
67
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 gnuplot.setOpenPlotWindow(plotFluidMatrixInteractions_);
68
69 2 const Scalar sg = 0.2; // assume a fixed gas saturation
70
1/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 auto swRange = linspace(0.2, 1.0, 1000);
71
72 // assume fixed sn = 0.2 for pcgw curve
73
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
4 auto pcgw = swRange;
74 2008 std::transform(swRange.begin(), swRange.end(), pcgw.begin(), [&](auto x){ return this->pcKrSwCurve_.pcgw(x, 0.2); });
75
76
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 gnuplot.resetAll();
77
5/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
4 gnuplot.setXlabel("Sw");
78
5/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
4 gnuplot.setYlabel("pcgw");
79
9/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
4 gnuplot.addDataSetToPlot(swRange, pcgw, "pcgw", "w l");
80
5/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
4 gnuplot.plot("pcgw-sw");
81
82 // plot kr
83
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 swRange = linspace(0.2, 0.8, 1000);
84
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
4 auto krw = swRange;
85
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
4 auto krn = swRange;
86
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
4 auto krg = swRange;
87
4/4
✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2000 times.
✓ Branch 3 taken 2 times.
4008 for (const auto [i, sw] : enumerate(swRange))
88 {
89 2000 const Scalar sn = 1.0 - sg - sw;
90 2000 krw[i] = pcKrSwCurve_.krw(sw, sn);
91 2000 krn[i] = pcKrSwCurve_.krn(sw, sn);
92 2000 krg[i] = pcKrSwCurve_.krg(sw, sn);
93 }
94
95
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 gnuplot.resetAll();
96
5/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
4 gnuplot.setXlabel("Sw");
97
5/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
4 gnuplot.setYlabel("kr");
98
9/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
4 gnuplot.addDataSetToPlot(swRange, krw, "krw", "w l");
99
9/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
4 gnuplot.addDataSetToPlot(swRange, krn, "krn", "w l");
100
9/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
4 gnuplot.addDataSetToPlot(swRange, krg, "krg", "w l");
101
6/14
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
4 gnuplot.plot("kr-sw");
102 2 }
103
104 /*!
105 * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$.
106 *
107 * \param element The element
108 * \param scv The sub-control volume
109 * \param elemSol The element solution vector
110 * \return The intrinsic permeability
111 */
112 template<class ElementSolution>
113 PermeabilityType permeability(const Element& element,
114 const SubControlVolume& scv,
115 const ElementSolution& elemSol) const
116 {
117
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 219274 times.
✓ Branch 3 taken 33626 times.
252900 if (isFineMaterial_(scv.dofPosition()))
118 return fineK_;
119 251882 return coarseK_;
120 }
121
122 /*!
123 * \brief Returns the porosity \f$[-]\f$
124 *
125 * \param globalPos The global position
126 */
127 Scalar porosityAtPos(const GlobalPosition& globalPos) const
128 {
129 return porosity_;
130 }
131
132 /*!
133 * \brief Returns the fluid-matrix interaction law at a given location
134 *
135 * \param globalPos The global coordinates for the given location
136 */
137 auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const
138 {
139 1013768 return makeFluidMatrixInteraction(pcKrSwCurve_);
140 }
141
142 /*!
143 * \brief Returns the temperature at a given location
144 *
145 * \param globalPos The global coordinates for the given location
146 */
147 Scalar temperatureAtPos(const GlobalPosition &globalPos) const
148 {
149 return 273.15 + 10.0; // -> 10 degrees Celsius
150 }
151
152 private:
153 bool isFineMaterial_(const GlobalPosition &globalPos) const
154 {
155
6/18
✗ 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 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 219274 times.
✓ Branch 13 taken 33626 times.
✓ Branch 14 taken 10116 times.
✓ Branch 15 taken 209158 times.
✓ Branch 16 taken 10116 times.
✓ Branch 17 taken 209158 times.
252900 return 70. - eps_ <= globalPos[0] && globalPos[0] <= 85. + eps_ &&
156
10/30
✗ 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 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ 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 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 219274 times.
✓ Branch 21 taken 33626 times.
✓ Branch 22 taken 3378 times.
✓ Branch 23 taken 6738 times.
✓ Branch 24 taken 3378 times.
✓ Branch 25 taken 6738 times.
✓ Branch 26 taken 2360 times.
✓ Branch 27 taken 1018 times.
✓ Branch 28 taken 2360 times.
✓ Branch 29 taken 1018 times.
273132 7.0 - eps_ <= globalPos[1] && globalPos[1] <= 7.50 + eps_;
157 }
158
159 Scalar fineK_;
160 Scalar coarseK_;
161 Scalar porosity_;
162 const ThreePhasePcKrSw pcKrSwCurve_;
163
164 bool plotFluidMatrixInteractions_;
165
166 static constexpr Scalar eps_ = 1e-6;
167 };
168
169 } // end namespace Dumux
170
171 #endif
172