GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/examples/2pinfiltration/spatialparams.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 19 21 90.5%
Functions: 3 4 75.0%
Branches: 69 150 46.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 #ifndef DUMUX_TWOP_INCOMPRESSIBLE_EXAMPLE_SPATIAL_PARAMS_HH
9 #define DUMUX_TWOP_INCOMPRESSIBLE_EXAMPLE_SPATIAL_PARAMS_HH
10
11 // ## The file `spatialparams.hh`
12 // [[content]]
13 //
14 // ### Includes
15 // We include the basic spatial parameters for finite volumes file from which we will inherit
16 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
17
18 // We include all laws which are needed to define the interaction between the solid matrix and the fluids, e.g. laws for capillary pressure saturation relationships.
19 #include <dumux/material/fluidmatrixinteractions/2p/vangenuchten.hh>
20
21 // ### The spatial parameters class
22 // In the TwoPTestSpatialParams class we define all functions needed to describe the porous matrix, e.g. porosity and permeability. We inherit from the `FVPorousMediumFlowSpatialParamsMP` class, which is the base class for multiphase porous medium flow applications.
23 // [[codeblock]]
24 namespace Dumux {
25
26 template<class GridGeometry, class Scalar>
27
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 class TwoPTestSpatialParams
28 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, TwoPTestSpatialParams<GridGeometry, Scalar>>
29 {
30 //we introduce using declarations that are derived from the property system which we need in this class
31 using GridView = typename GridGeometry::GridView;
32 using Element = typename GridView::template Codim<0>::Entity;
33 using FVElementGeometry = typename GridGeometry::LocalView;
34 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
35 using ThisType = TwoPTestSpatialParams<GridGeometry, Scalar>;
36 using ParentType = FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, ThisType>;
37
38 static constexpr int dimWorld = GridView::dimensionworld;
39 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
40
41 using PcKrSwCurve = FluidMatrix::VanGenuchtenDefault<Scalar>;
42
43 public:
44 using PermeabilityType = Scalar;
45 // [[/codeblock]]
46
47 //Here, we get parameters for the position of the lens and porosity and permeability from the input file. Additionally, we set the parameters for the Van-Genuchten relationship.
48 // [[codeblock]]
49 1 TwoPTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
50 : ParentType(gridGeometry)
51 , pcKrSwLens_("SpatialParams.Lens") // read params from input file
52
14/34
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 1 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 1 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
9 , pcKrSwOuter_("SpatialParams.Outer") // read params from input file
53 {
54 // We get the position of the lens from the params.input file.
55 // The lens is defined by the position of the lower left and the upper right corner
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
57
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 lensUpperRight_ = getParam<GlobalPosition>("SpatialParams.LensUpperRight");
58
59 // Here, we get the permeabilities from the params.input file.
60 // In case that no parameter is set, the default parameters (9.05e-12 and 4.6e-10) are used
61
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 lensK_ = getParam<Scalar>("SpatialParams.Lens.Permeability", 9.05e-12);
62
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 outerK_ = getParam<Scalar>("SpatialParams.Outer.Permeability", 4.6e-10);
63 1 }
64 // [[/codeblock]]
65
66 // We define the (intrinsic) permeability $`[m^2]`$. In this test, we use element-wise distributed permeabilities.
67 template<class ElementSolution>
68 2048519 PermeabilityType permeability(const Element& element,
69 const SubControlVolume& scv,
70 const ElementSolution& elemSol) const
71 {
72
3/4
✓ Branch 2 taken 2048519 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 257153 times.
✓ Branch 6 taken 1791366 times.
4097038 if (isInLens_(element.geometry().center()))
73 257153 return lensK_;
74 1791366 return outerK_;
75 }
76
77 // We set the porosity $`[-]`$ depending on the position
78 Scalar porosityAtPos(const GlobalPosition& globalPos) const
79 {
80
2/8
✗ 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 taken 257153 times.
✓ Branch 7 taken 1791366 times.
2048519 if (isInLens_(globalPos))
81 return 0.2;
82 return 0.4;
83 }
84
85 // We set the parameter object for the Van Genuchten material law.
86 template<class ElementSolution>
87 4097038 auto fluidMatrixInteraction(const Element& element,
88 const SubControlVolume& scv,
89 const ElementSolution& elemSol) const
90 {
91
3/4
✓ Branch 2 taken 4097038 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 514306 times.
✓ Branch 6 taken 3582732 times.
8194076 if (isInLens_(element.geometry().center()))
92 514306 return makeFluidMatrixInteraction(pcKrSwLens_);
93 3582732 return makeFluidMatrixInteraction(pcKrSwOuter_);
94 }
95
96
97 // Here we can define which phase is to be considered as the wetting phase. We choose the first phase
98 // in the fluid system, which is water in our case (see definition of `FluidSystem` property).
99 template<class FluidSystem>
100 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
101 { return FluidSystem::phase0Idx; }
102
103 // The remainder of this class contains a convenient function to determine if
104 // a position is inside the lens and defines the data members.
105 // [[details]] private data members and member functions
106 // [[codeblock]]
107 private:
108 // we have a convenience definition of the position of the lens
109 bool isInLens_(const GlobalPosition &globalPos) const
110 {
111
6/12
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3165251 times.
✓ Branch 5 taken 257153 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 3165251 times.
✓ Branch 9 taken 257153 times.
✓ Branch 10 taken 6330502 times.
✓ Branch 11 taken 514306 times.
13689616 for (int i = 0; i < dimWorld; ++i) {
112
36/72
✗ 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 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 2839790 times.
✓ Branch 25 taken 325461 times.
✓ Branch 26 taken 2839790 times.
✓ Branch 27 taken 325461 times.
✓ Branch 28 taken 2839790 times.
✓ Branch 29 taken 325461 times.
✓ Branch 30 taken 1373885 times.
✓ Branch 31 taken 1465905 times.
✓ Branch 32 taken 1373885 times.
✓ Branch 33 taken 1465905 times.
✓ Branch 34 taken 1373885 times.
✓ Branch 35 taken 1465905 times.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 48 taken 2839790 times.
✓ Branch 49 taken 325461 times.
✓ Branch 50 taken 2839790 times.
✓ Branch 51 taken 325461 times.
✓ Branch 52 taken 2839790 times.
✓ Branch 53 taken 325461 times.
✓ Branch 54 taken 1373885 times.
✓ Branch 55 taken 1465905 times.
✓ Branch 56 taken 1373885 times.
✓ Branch 57 taken 1465905 times.
✓ Branch 58 taken 1373885 times.
✓ Branch 59 taken 1465905 times.
✓ Branch 60 taken 5679580 times.
✓ Branch 61 taken 650922 times.
✓ Branch 62 taken 5679580 times.
✓ Branch 63 taken 650922 times.
✓ Branch 64 taken 5679580 times.
✓ Branch 65 taken 650922 times.
✓ Branch 66 taken 2747770 times.
✓ Branch 67 taken 2931810 times.
✓ Branch 68 taken 2747770 times.
✓ Branch 69 taken 2931810 times.
✓ Branch 70 taken 2747770 times.
✓ Branch 71 taken 2931810 times.
37983012 if (globalPos[i] < lensLowerLeft_[i] + eps_ || globalPos[i] > lensUpperRight_[i] - eps_)
113 return false;
114 }
115 return true;
116 }
117
118 GlobalPosition lensLowerLeft_;
119 GlobalPosition lensUpperRight_;
120
121 Scalar lensK_;
122 Scalar outerK_;
123
124 const PcKrSwCurve pcKrSwLens_;
125 const PcKrSwCurve pcKrSwOuter_;
126
127 static constexpr Scalar eps_ = 1.5e-7;
128 };
129
130 } // end namespace Dumux
131 // [[/codeblock]]
132 // [[/details]]
133 // [[/content]]
134 #endif
135