GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/1p/periodicbc/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 23 27 85.2%
Functions: 4 9 44.4%
Branches: 21 40 52.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-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 OnePTests
10 * \brief The properties for the incompressible test
11 */
12
13 #ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH
14 #define DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_HH
15
16
17
18 #ifndef FVGEOMCACHING
19 #define FVGEOMCACHING 0
20 #endif
21
22 #include <dumux/common/numeqvector.hh>
23 #include <dumux/porousmediumflow/problem.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup OnePTests
29 * \brief Test problem for the incompressible one-phase model.
30 */
31 template<class TypeTag>
32 5 class OnePTestProblem : public PorousMediumFlowProblem<TypeTag>
33 {
34 using ParentType = PorousMediumFlowProblem<TypeTag>;
35 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
36 using Element = typename GridView::template Codim<0>::Entity;
37 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
38 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
39 using SourceValues = Dumux::NumEqVector<PrimaryVariables>;
40 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
41 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
42 static constexpr int dimWorld = GridView::dimensionworld;
43 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
44
45 public:
46 5 OnePTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
47
8/20
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 5 times.
✓ Branch 15 taken 5 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 5 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
15 : ParentType(gridGeometry)
48 {
49
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 sourcePosition_ = getParam<GlobalPosition>("Source.Position");
50
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 sourceValues_ = getParam<SourceValues>("Source.Values");
51
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 sourceRadius_ = getParam<Scalar>("Source.Radius", 0.1);
52 5 }
53
54 /*!
55 * \brief Specifies which kind of boundary condition should be
56 * used for which equation on a given boundary control volume.
57 *
58 * \param globalPos The position of the center of the finite volume
59 */
60 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
61 {
62
4/6
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 608 times.
✗ Branch 5 not taken.
2224 BoundaryTypes values;
63
4/6
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 608 times.
✗ Branch 5 not taken.
2224 values.setAllDirichlet();
64 return values;
65 }
66
67 /*!
68 * \brief Applies a vector of point sources. The point sources
69 * are possibly solution dependent.
70 *
71 * \param pointSources A vector of PointSource s that contain
72 source values for all phases and space positions.
73 *
74 * For this method, the values method of the point source
75 * has to return the absolute rate values in units
76 * \f$ [ \textnormal{unit of conserved quantity} / s ] \f$.
77 * Positive values mean that the conserved quantity is created, negative ones mean that it vanishes.
78 * E.g. for the mass balance that would be a mass rate in \f$ [ kg / s ] \f$.
79 */
80 template<class PointSource>
81 5 void addPointSources(std::vector<PointSource>& pointSources) const
82 {
83 5 constexpr std::size_t numS = 20;
84 5 pointSources.reserve(numS);
85
2/2
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 5 times.
105 for (int i = 0; i < numS; ++i)
86 {
87 100 const double angle = double(i)/numS*M_PI*2.0;
88 100 const double weight = 1.0/double(numS);
89 100 auto values = sourceValues_;
90 100 values *= weight;
91 100 auto pos = sourcePosition_;
92 200 pos.axpy(sourceRadius_, GlobalPosition({std::cos(angle), std::sin(angle)}));
93 100 pointSources.emplace_back(pos, values);
94 }
95 5 }
96
97 /*!
98 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
99 *
100 * \param globalPos The center of the finite volume which ought to be set.
101 *
102 * For this method, the \a values parameter stores primary variables.
103 */
104 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
105 {
106 1008 PrimaryVariables values(0);
107 2016 values[0] = 1.0e+5*(2.0 - globalPos[dimWorld-1]);
108 return values;
109 }
110
111 private:
112 GlobalPosition sourcePosition_;
113 SourceValues sourceValues_;
114 Scalar sourceRadius_;
115 };
116
117 } // end namespace Dumux
118
119 #endif
120