GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux-testing/systemtest/porousmediumflow/1p/spatialparams.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 18 33 54.5%
Functions: 6 9 66.7%
Branches: 22 62 35.5%

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 #ifndef DUMUX_1P_TEST_SPATIALPARAMS_HH
8 #define DUMUX_1P_TEST_SPATIALPARAMS_HH
9
10 #include <dumux/porousmediumflow/properties.hh>
11 #include <dumux/porousmediumflow/fvspatialparams1p.hh>
12 #include <dumux/material/gstatrandomfield.hh>
13
14 namespace Dumux {
15
16 template<class GridGeometry, class Scalar>
17 class OnePTestSpatialParams
18 : public FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar, OnePTestSpatialParams<GridGeometry, Scalar>>
19 {
20 using GridView = typename GridGeometry::GridView;
21 using FVElementGeometry = typename GridGeometry::LocalView;
22 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
23 using IndexSet = typename GridView::IndexSet;
24
25 using ThisType = OnePTestSpatialParams<GridGeometry, Scalar>;
26 using ParentType = FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar, ThisType>;
27
28 static constexpr int dim = GridView::dimension;
29 static constexpr int dimWorld = GridView::dimensionworld;
30
31 using Element = typename GridView::template Codim<0>::Entity;
32 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
33
34 public:
35 // export permeability type
36 using PermeabilityType = Scalar;
37 // using PermeabilityType = PERMEABILITYTYPE;
38
39 24 OnePTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
40 : ParentType(gridGeometry)
41
3/7
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24 times.
✗ Branch 8 not taken.
24 , randomPermeability_(gridGeometry->gridView().size(dim), 0.0)
42
4/9
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 24 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 24 times.
✗ Branch 11 not taken.
72 , indexSet_(gridGeometry->gridView().indexSet())
43 {
44
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 randomField_ = getParam<bool>("SpatialParams.RandomField", false);
45
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 permeability_ = getParam<Scalar>("SpatialParams.Permeability");
46
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!randomField_)
47
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 permeabilityLens_ = getParam<Scalar>("SpatialParams.PermeabilityLens");
48 else
49 initRandomField(*gridGeometry);
50
51
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
52
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 lensUpperRight_ = getParam<GlobalPosition>("SpatialParams.LensUpperRight");
53 24 }
54
55 /*!
56 * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$.
57 */
58 template<class ElementSolution>
59 35040 PermeabilityType permeability(const Element& element,
60 const SubControlVolume& scv,
61 const ElementSolution& elemSol) const
62 {
63
2/2
✓ Branch 0 taken 12960 times.
✓ Branch 1 taken 22080 times.
35040 if (isInLens_(scv.dofPosition()))
64 {
65
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12960 times.
12960 if(randomField_)
66 return randomPermeability_[indexSet_.index(element)];
67 else
68 12960 return permeabilityLens_;
69 }
70 else
71 22080 return permeability_;
72 }
73
74 /*! \brief Define the porosity in [-].
75 */
76 Scalar porosityAtPos(const GlobalPosition& globalPos) const
77 { return 0.4; }
78
79 /*!
80 * \brief This method allows the generation of a statistical field
81 */
82 void initRandomField(const GridGeometry& gg)
83 {
84 const auto& gridView = gg.gridView();
85 const auto& elementMapper = gg.elementMapper();
86 const auto gStatControlFile = getParam<std::string>("Gstat.ControlFile");
87 const auto gStatInputFile = getParam<std::string>("Gstat.InputFile");
88 const auto outputFilePrefix = getParam<std::string>("Gstat.OutputFilePrefix");
89
90 // create random permeability object
91 using RandomField = GstatRandomField<GridView, Scalar>;
92 RandomField randomPermeabilityField(gridView, elementMapper);
93 randomPermeabilityField.create(gStatControlFile,
94 gStatInputFile,
95 outputFilePrefix + ".dat",
96 RandomField::FieldType::log10,
97 true);
98 randomPermeability_.resize(gridView.size(dim), 0.0);
99
100 // copy vector from the temporary gstat object
101 randomPermeability_ = randomPermeabilityField.data();
102 }
103
104 //! get the permeability field for output
105 const std::vector<Scalar>& getPermField() const
106 { return randomPermeability_; }
107
108 private:
109 35040 bool isInLens_(const GlobalPosition &globalPos) const
110 {
111
2/2
✓ Branch 0 taken 56640 times.
✓ Branch 1 taken 12960 times.
69600 for (int i = 0; i < dimWorld; ++i) {
112
4/4
✓ Branch 0 taken 45600 times.
✓ Branch 1 taken 11040 times.
✓ Branch 2 taken 34560 times.
✓ Branch 3 taken 11040 times.
56640 if (globalPos[i] < lensLowerLeft_[i] + eps_ || globalPos[i] > lensUpperRight_[i] - eps_)
113 return false;
114 }
115 return true;
116 }
117
118 bool randomField_;
119 GlobalPosition lensLowerLeft_;
120 GlobalPosition lensUpperRight_;
121
122 Scalar permeability_, permeabilityLens_;
123 std::vector<Scalar> randomPermeability_;
124
125 const IndexSet& indexSet_;
126 static constexpr Scalar eps_ = 1.5e-7;
127 };
128
129 } // end namespace Dumux
130
131 #endif
132