GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p2c/waterair/spatialparams.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 32 36 88.9%
Functions: 4 10 40.0%
Branches: 84 210 40.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 * \ingroup TwoPTwoCTests
10 * \brief Definition of the spatial parameters for the non-isothermal gas injection problem where a gas (e.g. air) is injected into a fully water saturated medium.
11 */
12 #ifndef DUMUX_WATER_AIR_SPATIAL_PARAMS_HH
13 #define DUMUX_WATER_AIR_SPATIAL_PARAMS_HH
14
15 #include <dumux/common/math.hh>
16 #include <dumux/io/gnuplotinterface.hh>
17 #include <dumux/io/ploteffectivediffusivitymodel.hh>
18 #include <dumux/io/plotpckrsw.hh>
19 #include <dumux/io/plotthermalconductivitymodel.hh>
20 #include <dumux/porousmediumflow/properties.hh>
21 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
22 #include <dumux/material/fluidmatrixinteractions/2p/brookscorey.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup TwoPTwoCModel
28 * \brief Definition of the spatial parameters for the water-air problem.
29 */
30 template<class GridGeometry, class Scalar>
31
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 class WaterAirSpatialParams
32 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar,
33 WaterAirSpatialParams<GridGeometry, Scalar>>
34 {
35 using ThisType = WaterAirSpatialParams<GridGeometry, Scalar>;
36 using ParentType = FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, ThisType>;
37 using GridView = typename GridGeometry::GridView;
38 using FVElementGeometry = typename GridGeometry::LocalView;
39 using Element = typename GridView::template Codim<0>::Entity;
40 static constexpr int dimWorld = GridView::dimensionworld;
41 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
42
43 using PcKrSwCurve = FluidMatrix::BrooksCoreyDefault<Scalar>;
44
45 public:
46 //! Export the type used for the permeability
47 using PermeabilityType = Scalar;
48
49
50 3 WaterAirSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
51 : ParentType(gridGeometry)
52
7/20
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 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 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
9 , pcKrSwCurve_("SpatialParams")
53 {
54 3 layerBottom_ = 22.0;
55
56 // intrinsic permeabilities
57 3 fineK_ = 1e-13;
58 3 coarseK_ = 1e-12;
59
60 // porosities
61 3 finePorosity_ = 0.3;
62 3 coarsePorosity_ = 0.3;
63
64
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 plotFluidMatrixInteractions_ = getParam<bool>("Output.PlotFluidMatrixInteractions");
65 3 }
66
67 /*!
68 * \brief This is called from the problem and creates a gnuplot output
69 * of e.g the pc-Sw curve
70 */
71 3 void plotMaterialLaw()
72 {
73 3 GnuplotInterface<Scalar> gnuplot(plotFluidMatrixInteractions_);
74
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 gnuplot.setOpenPlotWindow(plotFluidMatrixInteractions_);
75
76
1/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 const auto sw = linspace(0.2, 1.0, 1000);
77
78
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 const auto pc = samplePcSw(pcKrSwCurve_, sw);
79
17/42
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 3 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 3 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 3 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 3 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 3 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 3 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 3 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 3 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 3 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
15 Gnuplot::addPcSw(gnuplot, sw, pc, "pc-Sw", "w lp");
80
5/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
9 gnuplot.setOption("set xrange [0:1]");
81
5/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
9 gnuplot.setOption("set label \"residual\\nsaturation\" at 0.1,100000 center");
82
5/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
6 gnuplot.plot("pc-Sw");
83
84
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 gnuplot.resetAll();
85
86
5/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
9 const auto [krw, krn] = sampleRelPerms(makeFluidMatrixInteraction(pcKrSwCurve_), sw); // test wrapped law
87
17/42
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 3 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 3 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 3 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 3 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 3 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 3 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 3 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 3 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 3 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
15 Gnuplot::addRelPerms(gnuplot, sw, krw, krn, "kr-Sw", "w lp");
88
4/10
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
6 gnuplot.plot("kr");
89 3 }
90
91 /*!
92 * \brief Applies the intrinsic permeability tensor to a pressure
93 * potential gradient.
94 *
95 * \param globalPos The global position
96 */
97 Scalar permeabilityAtPos(const GlobalPosition& globalPos) const
98 {
99 23044246 if (isFineMaterial_(globalPos))
100 5217129 return fineK_;
101 6304994 return coarseK_;
102 }
103
104 /*!
105 * \brief Defines the porosity \f$[-]\f$ of the spatial parameters
106 *
107 * \param globalPos The global position
108 */
109 Scalar porosityAtPos(const GlobalPosition& globalPos) const
110 {
111 23044246 if (isFineMaterial_(globalPos))
112 5217129 return finePorosity_;
113 else
114 6304994 return coarsePorosity_;
115 }
116
117 /*!
118 * \brief Returns the fluid-matrix interaction law at a given location
119 * \param globalPos The global coordinates for the given location
120 */
121 auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const
122 {
123
4/4
✓ Branch 0 taken 11407043 times.
✓ Branch 1 taken 115080 times.
✓ Branch 2 taken 11407043 times.
✓ Branch 3 taken 115080 times.
46158064 return makeFluidMatrixInteraction(pcKrSwCurve_);
124 }
125
126 /*!
127 * \brief Function for defining which phase is to be considered as the wetting phase.
128 *
129 * \param globalPos The position of the center of the element
130 * \return The wetting phase index
131 */
132 template<class FluidSystem>
133 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
134 { return FluidSystem::H2OIdx; }
135
136 private:
137 bool isFineMaterial_(const GlobalPosition &globalPos) const
138
8/24
✗ 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 5217129 times.
✓ Branch 13 taken 6304994 times.
✓ Branch 14 taken 5217129 times.
✓ Branch 15 taken 6304994 times.
✓ Branch 16 taken 5217129 times.
✓ Branch 17 taken 6304994 times.
✓ Branch 18 taken 5217129 times.
✓ Branch 19 taken 6304994 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
46088492 { return globalPos[dimWorld-1] > layerBottom_; }
139
140 Scalar fineK_;
141 Scalar coarseK_;
142 Scalar layerBottom_;
143
144 Scalar finePorosity_;
145 Scalar coarsePorosity_;
146
147 const PcKrSwCurve pcKrSwCurve_;
148
149 bool plotFluidMatrixInteractions_;
150 };
151
152 } // end namespace Dumux
153
154 #endif
155