GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p/incompressible/spatialparams.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 23 26 88.5%
Functions: 17 31 54.8%
Branches: 90 148 60.8%

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 TwoPTests
10 * \brief The spatial params for the incompressible 2p test.
11 */
12
13 #ifndef DUMUX_INCOMPRESSIBLE_TWOP_TEST_SPATIAL_PARAMS_HH
14 #define DUMUX_INCOMPRESSIBLE_TWOP_TEST_SPATIAL_PARAMS_HH
15
16 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
17 #include <dumux/material/fluidmatrixinteractions/2p/vangenuchten.hh>
18 #include <dumux/porousmediumflow/2p/boxmaterialinterfaces.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup TwoPTests
24 * \brief The spatial params for the incompressible 2p test.
25 */
26 template<class GridGeometry, class Scalar>
27 class TwoPTestSpatialParams
28 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, TwoPTestSpatialParams<GridGeometry, Scalar>>
29 {
30 using GridView = typename GridGeometry::GridView;
31 using Element = typename GridView::template Codim<0>::Entity;
32 using FVElementGeometry = typename GridGeometry::LocalView;
33 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
34 using ThisType = TwoPTestSpatialParams<GridGeometry, Scalar>;
35 using ParentType = FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, ThisType>;
36
37 static constexpr int dimWorld = GridView::dimensionworld;
38 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
39
40 using PcKrSw = FluidMatrix::VanGenuchtenDefault<Scalar>;
41 using MaterialInterfaces = BoxMaterialInterfaces<GridGeometry, PcKrSw>;
42
43 public:
44 using PermeabilityType = Scalar;
45
46 13 TwoPTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
47 : ParentType(gridGeometry)
48 , lensPcKrSw_("SpatialParams.Lens")
49
15/38
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 13 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 13 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 13 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 13 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 13 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 13 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 13 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 13 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 13 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 13 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 13 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 13 times.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 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.
130 , outerPcKrSw_("SpatialParams.Outer")
50 {
51
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 lensIsOilWet_ = getParam<bool>("SpatialParams.LensIsOilWet", false);
52
53
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
54
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 lensUpperRight_ = getParam<GlobalPosition>("SpatialParams.LensUpperRight");
55
56
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 lensK_ = getParam<Scalar>("SpatialParams.Lens.Permeability", 9.05e-12);
57
1/4
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 outerK_ = getParam<Scalar>("SpatialParams.Outer.Permeability", 4.6e-10);
58 13 }
59
60 /*!
61 * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$.
62 * In this test, we use element-wise distributed permeabilities.
63 *
64 * \param element The current element
65 * \param scv The sub-control volume inside the element.
66 * \param elemSol The solution at the dofs connected to the element.
67 * \return The permeability
68 */
69 template<class ElementSolution>
70 12898386 PermeabilityType permeability(const Element& element,
71 const SubControlVolume& scv,
72 const ElementSolution& elemSol) const
73 {
74
75 // do not use a less permeable lens in the test with inverted wettability
76
9/13
✓ Branch 1 taken 3683584 times.
✓ Branch 2 taken 9214802 times.
✓ Branch 3 taken 1294528 times.
✓ Branch 4 taken 2389056 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 297450 times.
✓ Branch 7 taken 2000812 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 297450 times.
✓ Branch 11 taken 297450 times.
✓ Branch 12 taken 2000812 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
38397708 if (isInLens_(element.geometry().center()) && !lensIsOilWet_)
77 1591978 return lensK_;
78 11306408 return outerK_;
79 }
80
81 /*!
82 * \brief Returns the porosity \f$[-]\f$
83 *
84 * \param globalPos The global position
85 */
86 Scalar porosityAtPos(const GlobalPosition& globalPos) const
87 { return 0.4; }
88
89 /*!
90 * \brief Returns the parameter object for the Brooks-Corey material law.
91 *
92 * In this test, we use element-wise distributed material parameters.
93 *
94 * \param element The current element
95 * \param scv The sub-control volume inside the element.
96 * \param elemSol The solution at the dofs connected to the element.
97 * \return The material parameters object
98 */
99 template<class ElementSolution>
100 27722106 auto fluidMatrixInteraction(const Element& element,
101 const SubControlVolume& scv,
102 const ElementSolution& elemSol) const
103 {
104 // do not use different parameters in the test with inverted wettability
105
9/13
✓ Branch 1 taken 7673168 times.
✓ Branch 2 taken 20048938 times.
✓ Branch 3 taken 2895056 times.
✓ Branch 4 taken 4778112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 594900 times.
✓ Branch 7 taken 4001624 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 594900 times.
✓ Branch 11 taken 594900 times.
✓ Branch 12 taken 4001624 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
82571418 if (isInLens_(element.geometry().center()) && !lensIsOilWet_)
106 3489956 return makeFluidMatrixInteraction(lensPcKrSw_);
107 24232150 return makeFluidMatrixInteraction(outerPcKrSw_);
108 }
109
110 /*!
111 * \brief Function for defining which phase is to be considered as the wetting phase.
112 *
113 * \param globalPos The global position
114 * \return The wetting phase index
115 */
116 template<class FluidSystem>
117 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
118 {
119
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1856973 times.
✓ Branch 5 taken 11706070 times.
✓ Branch 6 taken 90794 times.
✓ Branch 7 taken 1766179 times.
13563043 if (isInLens_(globalPos) && lensIsOilWet_)
120 return FluidSystem::phase1Idx;
121 return FluidSystem::phase0Idx;
122 }
123
124 //! Updates the map of which material parameters are associated with a nodal dof.
125 template<class SolutionVector>
126 1 void updateMaterialInterfaces(const SolutionVector& x)
127 {
128 if (GridGeometry::discMethod == DiscretizationMethods::box)
129
2/4
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
2 materialInterfaces_ = std::make_unique<MaterialInterfaces>(this->gridGeometry(), *this, x);
130 1 }
131
132 //! Returns the material parameters associated with a nodal dof
133 const MaterialInterfaces& materialInterfaces() const
134
4/4
✓ Branch 0 taken 175574 times.
✓ Branch 1 taken 3784274 times.
✓ Branch 2 taken 175574 times.
✓ Branch 3 taken 3784274 times.
7919696 { return *materialInterfaces_; }
135
136 //! Returns whether or not the lens is oil wet
137 bool lensIsOilWet() const { return lensIsOilWet_; }
138
139 private:
140 bool isInLens_(const GlobalPosition &globalPos) const
141 {
142
6/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 19535236 times.
✓ Branch 3 taken 1682772 times.
✓ Branch 4 taken 20681961 times.
✓ Branch 5 taken 1856973 times.
✓ Branch 6 taken 42023418 times.
✓ Branch 7 taken 3671544 times.
89451904 for (int i = 0; i < dimWorld; ++i) {
143
36/48
✗ 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 14862058 times.
✓ Branch 13 taken 4673178 times.
✓ Branch 14 taken 14862058 times.
✓ Branch 15 taken 4673178 times.
✓ Branch 16 taken 14862058 times.
✓ Branch 17 taken 4673178 times.
✓ Branch 18 taken 8319622 times.
✓ Branch 19 taken 6542436 times.
✓ Branch 20 taken 8319622 times.
✓ Branch 21 taken 6542436 times.
✓ Branch 22 taken 8319622 times.
✓ Branch 23 taken 6542436 times.
✓ Branch 24 taken 15888463 times.
✓ Branch 25 taken 4793498 times.
✓ Branch 26 taken 15888463 times.
✓ Branch 27 taken 4793498 times.
✓ Branch 28 taken 15888463 times.
✓ Branch 29 taken 4793498 times.
✓ Branch 30 taken 8975891 times.
✓ Branch 31 taken 6912572 times.
✓ Branch 32 taken 8975891 times.
✓ Branch 33 taken 6912572 times.
✓ Branch 34 taken 8975891 times.
✓ Branch 35 taken 6912572 times.
✓ Branch 36 taken 31904778 times.
✓ Branch 37 taken 10118640 times.
✓ Branch 38 taken 31904778 times.
✓ Branch 39 taken 10118640 times.
✓ Branch 40 taken 31904778 times.
✓ Branch 41 taken 10118640 times.
✓ Branch 42 taken 17972856 times.
✓ Branch 43 taken 13931922 times.
✓ Branch 44 taken 17972856 times.
✓ Branch 45 taken 13931922 times.
✓ Branch 46 taken 17972856 times.
✓ Branch 47 taken 13931922 times.
246721845 if (globalPos[i] < lensLowerLeft_[i] + eps_ || globalPos[i] > lensUpperRight_[i] - eps_)
144 return false;
145 }
146 return true;
147 }
148
149 bool lensIsOilWet_;
150 GlobalPosition lensLowerLeft_;
151 GlobalPosition lensUpperRight_;
152
153 Scalar lensK_;
154 Scalar outerK_;
155
156 const PcKrSw lensPcKrSw_;
157 const PcKrSw outerPcKrSw_;
158
159 std::unique_ptr<MaterialInterfaces> materialInterfaces_;
160
161 static constexpr Scalar eps_ = 1.5e-7;
162 };
163
164 } // end namespace Dumux
165
166 #endif
167