GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/co2/spatialparams.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 29 39 74.4%
Functions: 10 35 28.6%
Branches: 35 78 44.9%

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 CO2Tests
10 * \brief Definition of the spatial parameters for the heterogeneous
11 * problem which uses the non-isothermal or isothermal CO2
12 * fully implicit model.
13 */
14
15 #ifndef DUMUX_HETEROGENEOUS_SPATIAL_PARAMS_HH
16 #define DUMUX_HETEROGENEOUS_SPATIAL_PARAMS_HH
17
18 #include <dumux/io/grid/griddata.hh>
19 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
20 #include <dumux/material/fluidmatrixinteractions/2p/brookscorey.hh>
21
22 #include <dumux/porousmediumflow/co2/model.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup CO2Tests
28 * \brief Definition of the spatial parameters for the heterogeneous
29 * problem which uses the non-isothermal or isothermal CO2
30 * fully implicit model.
31 */
32 template<class GridGeometry, class Scalar>
33 class HeterogeneousSpatialParams
34 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry,
35 Scalar,
36 HeterogeneousSpatialParams<GridGeometry, Scalar>>
37 {
38 using Grid = typename GridGeometry::Grid;
39 using GridView = typename GridGeometry::GridView;
40 using FVElementGeometry = typename GridGeometry::LocalView;
41 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
42 using Element = typename GridView::template Codim<0>::Entity;
43 using ParentType = FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, HeterogeneousSpatialParams<GridGeometry, Scalar>>;
44
45 using GlobalPosition = typename SubControlVolume::GlobalPosition;
46
47 using PcKrSwCurve = FluidMatrix::BrooksCoreyDefault<Scalar>;
48
49 static constexpr int dimWorld = GridView::dimensionworld;
50
51 public:
52 using PermeabilityType = Scalar;
53
54 14 HeterogeneousSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry,
55 std::shared_ptr<const GridData<Grid>> gridData)
56 : ParentType(gridGeometry)
57 , gridData_(gridData)
58
8/26
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 14 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 14 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 14 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 14 times.
✓ Branch 22 taken 14 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
28 , pcKrSwCurve_("SpatialParams")
59 {
60 // Set the permeability for the layers
61 14 barrierTopK_ = 1e-17; //sqm
62 14 barrierMiddleK_ = 1e-15; //sqm
63 14 reservoirK_ = 1e-14; //sqm
64
65 // Set the effective porosity of the layers
66 14 barrierTopPorosity_ = 0.001;
67 14 barrierMiddlePorosity_ = 0.05;
68 14 reservoirPorosity_ = 0.2;
69
70
1/2
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
14 depthBOR_ = getParam<Scalar>("Problem.DepthBOR");
71 14 }
72
73 /*!
74 * \brief Reads layer information from the grid
75 */
76 14 void getParamsFromGrid()
77 {
78 28 const auto& gridView = this->gridGeometry().gridView();
79 14 paramIdx_.resize(gridView.size(0));
80
81
7/10
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 37462 times.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 37462 times.
✓ Branch 10 taken 14 times.
✓ Branch 12 taken 37462 times.
✗ Branch 13 not taken.
74966 for (const auto& element : elements(gridView))
82 {
83
3/6
✓ Branch 1 taken 37462 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37462 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 37462 times.
✗ Branch 8 not taken.
112386 const auto eIdx = this->gridGeometry().elementMapper().index(element);
84
4/8
✓ Branch 1 taken 37462 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37462 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 37462 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 37462 times.
✗ Branch 11 not taken.
74924 paramIdx_[eIdx] = gridData_->parameters(element)[0];
85 }
86 14 }
87
88 /*!
89 * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$
90 * \note It is possibly solution dependent.
91 *
92 * \param element The current element
93 * \param scv The sub-control volume inside the element.
94 * \param elemSol The solution at the dofs connected to the element.
95 *
96 * \return The intrinsic permeability
97 */
98 template<class ElementSolution>
99 PermeabilityType permeability(const Element& element,
100 const SubControlVolume& scv,
101 const ElementSolution& elemSol) const
102 {
103 // Get the global index of the element
104 const auto eIdx = this->gridGeometry().elementMapper().index(element);
105 return permeability(eIdx);
106 }
107
108 /*!
109 * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$
110 * \note It is possibly solution dependent.
111 *
112 * \param eIdx The element index
113 */
114 PermeabilityType permeability(std::size_t eIdx) const
115 {
116
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3470 times.
✓ Branch 5 taken 33200 times.
✓ Branch 6 taken 3470 times.
✓ Branch 7 taken 33200 times.
73340 if (paramIdx_[eIdx] == barrierTop_)
117 3470 return barrierTopK_;
118
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6570 times.
✓ Branch 3 taken 26630 times.
33200 else if (paramIdx_[eIdx] == barrierMiddle_)
119 6570 return barrierMiddleK_;
120 else
121 26630 return reservoirK_;
122 }
123
124 /*!
125 * \brief Returns the volume fraction of the inert component with index compIdx \f$[-]\f$
126 *
127 * \param element The current element
128 * \param scv The sub-control volume inside the element.
129 * \param elemSol The element solution
130 * \param compIdx The solid component index
131 * \return The solid volume fraction
132 */
133 template<class SolidSystem, class ElementSolution>
134 Scalar inertVolumeFraction(const Element& element,
135 const SubControlVolume& scv,
136 const ElementSolution& elemSol,
137 int compIdx) const
138 {
139 // Get the global index of the element
140 const auto eIdx = this->gridGeometry().elementMapper().index(element);
141 return inertVolumeFraction(eIdx);
142 }
143
144 /*!
145 * \brief Returns the porosity \f$[-]\f$
146 *
147 * \param eIdx The element index
148 */
149 Scalar inertVolumeFraction(std::size_t eIdx) const
150 {
151
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3470 times.
✓ Branch 5 taken 33200 times.
36670 if (paramIdx_[eIdx] == barrierTop_)
152 3470 return 1- barrierTopPorosity_;
153
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6570 times.
✓ Branch 3 taken 26630 times.
33200 else if (paramIdx_[eIdx] == barrierMiddle_)
154 6570 return 1- barrierMiddlePorosity_;
155 else
156 26630 return 1- reservoirPorosity_;
157
158 }
159
160
161 /*!
162 * \brief Returns the fluid-matrix interaction law at a given location
163 *
164 * \param globalPos The global coordinates for the given location
165 */
166 auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const
167
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71506765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71506765 times.
286027060 { return makeFluidMatrixInteraction(pcKrSwCurve_); }
168
169 /*!
170 * \brief Function for defining which phase is to be considered as the wetting phase.
171 *
172 * \param globalPos The position of the center of the element
173 * \return The wetting phase index
174 */
175 template<class FluidSystem>
176 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
177 { return FluidSystem::BrineIdx; }
178
179 /*!
180 * \brief Returns the temperature within the domain.
181 *
182 * \param globalPos The global position
183 *
184 * This problem assumes a geothermal gradient with
185 * a surface temperature of 10 degrees Celsius.
186 */
187 Scalar temperatureAtPos(const GlobalPosition &globalPos) const
188 50300074 { return 283.0 + (depthBOR_ - globalPos[dimWorld-1])*0.03; }
189
190 private:
191
192 std::shared_ptr<const GridData<Grid>> gridData_;
193
194 int barrierTop_ = 1;
195 int barrierMiddle_ = 2;
196 int reservoir_ = 3;
197
198 Scalar barrierTopPorosity_;
199 Scalar barrierMiddlePorosity_;
200 Scalar reservoirPorosity_;
201
202 Scalar barrierTopK_;
203 Scalar barrierMiddleK_;
204 Scalar reservoirK_;
205
206 Scalar depthBOR_;
207
208 std::vector<int> paramIdx_;
209 const PcKrSwCurve pcKrSwCurve_;
210 };
211
212 } // end namespace Dumux
213
214 #endif
215