GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p/incompressible/spatialparams.hh
Date: 2024-09-21 20:52:54
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 12 TwoPTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
47 : ParentType(gridGeometry)
48 , lensPcKrSw_("SpatialParams.Lens")
49
15/38
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 12 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 12 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 12 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 12 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 12 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 12 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 12 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 12 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 12 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 12 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 12 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.
120 , outerPcKrSw_("SpatialParams.Outer")
50 {
51
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 lensIsOilWet_ = getParam<bool>("SpatialParams.LensIsOilWet", false);
52
53
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
54
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 lensUpperRight_ = getParam<GlobalPosition>("SpatialParams.LensUpperRight");
55
56
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 lensK_ = getParam<Scalar>("SpatialParams.Lens.Permeability", 9.05e-12);
57
1/4
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
12 outerK_ = getParam<Scalar>("SpatialParams.Outer.Permeability", 4.6e-10);
58 12 }
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 12726690 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 3661882 times.
✓ Branch 2 taken 9064808 times.
✓ Branch 3 taken 1272826 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.
37882620 if (isInLens_(element.geometry().center()) && !lensIsOilWet_)
77 1570276 return lensK_;
78 11156414 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 27378714 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 7629764 times.
✓ Branch 2 taken 19748950 times.
✓ Branch 3 taken 2851652 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.
81541242 if (isInLens_(element.geometry().center()) && !lensIsOilWet_)
106 3446552 return makeFluidMatrixInteraction(lensPcKrSw_);
107 23932162 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 1835271 times.
✓ Branch 5 taken 11556076 times.
✓ Branch 6 taken 90794 times.
✓ Branch 7 taken 1744477 times.
13391347 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 19277224 times.
✓ Branch 3 taken 1661070 times.
✓ Branch 4 taken 20423949 times.
✓ Branch 5 taken 1835271 times.
✓ Branch 6 taken 41507394 times.
✓ Branch 7 taken 3628140 times.
88333048 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 14674676 times.
✓ Branch 13 taken 4602548 times.
✓ Branch 14 taken 14674676 times.
✓ Branch 15 taken 4602548 times.
✓ Branch 16 taken 14674676 times.
✓ Branch 17 taken 4602548 times.
✓ Branch 18 taken 8211604 times.
✓ Branch 19 taken 6463072 times.
✓ Branch 20 taken 8211604 times.
✓ Branch 21 taken 6463072 times.
✓ Branch 22 taken 8211604 times.
✓ Branch 23 taken 6463072 times.
✓ Branch 24 taken 15701081 times.
✓ Branch 25 taken 4722868 times.
✓ Branch 26 taken 15701081 times.
✓ Branch 27 taken 4722868 times.
✓ Branch 28 taken 15701081 times.
✓ Branch 29 taken 4722868 times.
✓ Branch 30 taken 8867873 times.
✓ Branch 31 taken 6833208 times.
✓ Branch 32 taken 8867873 times.
✓ Branch 33 taken 6833208 times.
✓ Branch 34 taken 8867873 times.
✓ Branch 35 taken 6833208 times.
✓ Branch 36 taken 31530014 times.
✓ Branch 37 taken 9977380 times.
✓ Branch 38 taken 31530014 times.
✓ Branch 39 taken 9977380 times.
✓ Branch 40 taken 31530014 times.
✓ Branch 41 taken 9977380 times.
✓ Branch 42 taken 17756820 times.
✓ Branch 43 taken 13773194 times.
✓ Branch 44 taken 17756820 times.
✓ Branch 45 taken 13773194 times.
✓ Branch 46 taken 17756820 times.
✓ Branch 47 taken 13773194 times.
243625701 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