GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p/adaptive/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 8 8 100.0%
Branches: 14 36 38.9%

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 Soil contamination problem where DNAPL infiltrates a fully
11 * water saturated medium.
12 */
13
14 #ifndef DUMUX_LENSPROBLEM_ADAPTIVE_HH
15 #define DUMUX_LENSPROBLEM_ADAPTIVE_HH
16
17 #include <dumux/io/container.hh>
18 #include "../incompressible/problem.hh"
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup TwoPTests
24 * \brief Soil contamination problem where DNAPL infiltrates a fully
25 * water saturated medium.
26 */
27 template <class TypeTag >
28 class TwoPTestProblemAdaptive : public TwoPTestProblem<TypeTag>
29 {
30 using ParentType = TwoPTestProblem<TypeTag>;
31 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
32 using Element = typename GridView::template Codim<0>::Entity;
33 using Vertex = typename GridView::template Codim<GridView::dimensionworld>::Entity;
34 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
35 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37
38 static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethods::box;
39
40 public:
41 4 TwoPTestProblemAdaptive(std::shared_ptr<const GridGeometry> gridGeometry)
42
3/10
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
8 : ParentType(gridGeometry)
43 {
44 if(!isBox)
45
5/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
9 initialValues_ = readFileToContainer<std::vector<PrimaryVariables>>("initialsolutioncc.txt");
46 else
47
5/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3 initialValues_ = readFileToContainer<std::vector<PrimaryVariables>>("initialsolutionbox.txt");
48 4 }
49
50 /*!
51 * \brief Evaluates the initial value for an element for cell-centered models.
52 */
53 18432 PrimaryVariables initial(const Element& element) const
54 {
55 18432 const auto delta = 0.0625;
56 55296 unsigned int cellsX = this->gridGeometry().bBoxMax()[0]/delta;
57
1/2
✓ Branch 2 taken 18432 times.
✗ Branch 3 not taken.
18432 const auto globalPos = element.geometry().center();
58
59 // the input data corresponds to a uniform grid with discretization length deltaX_
60 36864 unsigned int dataIdx = std::trunc(globalPos[1]/delta) * cellsX + std::trunc(globalPos[0]/delta);
61 36864 return initialValues_[dataIdx];
62 }
63
64 /*!
65 * \brief Evaluates the initial value for a vertex for vertex-centered models.
66 */
67 6305 PrimaryVariables initial(const Vertex& vertex) const
68 {
69 6305 const auto delta = 0.0625;
70 18915 unsigned int verticesX = this->gridGeometry().bBoxMax()[0]/delta + 1;
71 12610 const auto globalPos = vertex.geometry().center();
72
73 // the input data corresponds to a uniform grid with discretization length deltaX_
74 18915 unsigned int dataIdx = std::trunc(globalPos[1]/delta) * verticesX + std::trunc(globalPos[0]/delta);
75 12610 return initialValues_[dataIdx];
76 }
77
78 private:
79 std::vector<PrimaryVariables> initialValues_;
80 };
81
82 } // end namespace Dumux
83
84 #endif
85