GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/2p/incompressible/spatialparams.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 28 28 100.0%
Functions: 19 19 100.0%
Branches: 59 80 73.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-FileCopyrightText: 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
2/4
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 , lensPcKrSw_("SpatialParams.Lens")
49
5/10
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 13 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 13 times.
✗ Branch 15 not taken.
52 , 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/2
✓ Branch 1 taken 13 times.
✗ Branch 2 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 13562963 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
10/14
✓ Branch 1 taken 11687201 times.
✓ Branch 2 taken 1784968 times.
✓ Branch 4 taken 2298262 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.
✓ Branch 3 taken 264995 times.
✓ Branch 0 taken 1385306 times.
29126738 if (isInLens_(element.geometry().center()) && !lensIsOilWet_)
77 1766163 return lensK_;
78 11796800 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 29051268 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
10/14
✓ Branch 1 taken 24993736 times.
✓ Branch 2 taken 3875944 times.
✓ Branch 4 taken 4596524 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.
✓ Branch 3 taken 529990 times.
✓ Branch 0 taken 3076620 times.
62104160 if (isInLens_(element.geometry().center()) && !lensIsOilWet_)
106 3838334 return makeFluidMatrixInteraction(lensPcKrSw_);
107 25212934 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 11264701 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
118 {
119
4/4
✓ Branch 0 taken 11706006 times.
✓ Branch 1 taken 1856957 times.
✓ Branch 2 taken 1766163 times.
✓ Branch 3 taken 90794 times.
13562963 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
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 materialInterfaces_ = std::make_unique<MaterialInterfaces>(this->gridGeometry(), *this, x);
130 1 }
131
132 //! Returns the material parameters associated with a nodal dof
133 3959768 const MaterialInterfaces& materialInterfaces() const
134
2/2
✓ Branch 0 taken 3784186 times.
✓ Branch 1 taken 175582 times.
3959768 { return *materialInterfaces_; }
135
136 //! Returns whether or not the lens is oil wet
137
2/2
✓ Branch 0 taken 13598 times.
✓ Branch 1 taken 431489 times.
445087 bool lensIsOilWet() const { return lensIsOilWet_; }
138
139 private:
140 53878932 bool isInLens_(const GlobalPosition &globalPos) const
141 {
142
6/6
✓ Branch 0 taken 20681825 times.
✓ Branch 1 taken 1856957 times.
✓ Branch 2 taken 20681825 times.
✓ Branch 3 taken 1856957 times.
✓ Branch 4 taken 44316612 times.
✓ Branch 5 taken 4019922 times.
93414098 for (int i = 0; i < dimWorld; ++i) {
143
12/12
✓ Branch 0 taken 15888391 times.
✓ Branch 1 taken 4793434 times.
✓ Branch 2 taken 8975819 times.
✓ Branch 3 taken 6912572 times.
✓ Branch 4 taken 15888391 times.
✓ Branch 5 taken 4793434 times.
✓ Branch 6 taken 8975819 times.
✓ Branch 7 taken 6912572 times.
✓ Branch 8 taken 33957460 times.
✓ Branch 9 taken 10359152 times.
✓ Branch 10 taken 19285266 times.
✓ Branch 11 taken 14672194 times.
85680262 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