GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/examples/2pinfiltration/spatialparams.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 3 3 100.0%
Branches: 37 50 74.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-FileCopyrightText: 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/2
✓ Branch 0 taken 1 times.
✗ Branch 1 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
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 , pcKrSwLens_("SpatialParams.Lens") // read params from input file
52
4/8
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
3 , 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/2
✓ Branch 1 taken 1 times.
✗ Branch 2 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 1 taken 2048519 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 257153 times.
✓ Branch 5 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 2048519 Scalar porosityAtPos(const GlobalPosition& globalPos) const
79 {
80
2/2
✓ Branch 0 taken 257153 times.
✓ Branch 1 taken 1791366 times.
2048519 if (isInLens_(globalPos))
81 257153 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 1 taken 4097038 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 514306 times.
✓ Branch 5 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 8194076 bool isInLens_(const GlobalPosition &globalPos) const
110 {
111
6/6
✓ Branch 0 taken 3165251 times.
✓ Branch 1 taken 257153 times.
✓ Branch 2 taken 3165251 times.
✓ Branch 3 taken 257153 times.
✓ Branch 4 taken 6330502 times.
✓ Branch 5 taken 514306 times.
13689616 for (int i = 0; i < dimWorld; ++i) {
112
12/12
✓ Branch 0 taken 2839790 times.
✓ Branch 1 taken 325461 times.
✓ Branch 2 taken 1373885 times.
✓ Branch 3 taken 1465905 times.
✓ Branch 4 taken 2839790 times.
✓ Branch 5 taken 325461 times.
✓ Branch 6 taken 1373885 times.
✓ Branch 7 taken 1465905 times.
✓ Branch 8 taken 5679580 times.
✓ Branch 9 taken 650922 times.
✓ Branch 10 taken 2747770 times.
✓ Branch 11 taken 2931810 times.
12661004 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