GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/tracer/2ptracer/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 3 3 100.0%
Branches: 45 50 90.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 * \file
9 * \ingroup TracerTests
10 * \brief Multiple tracer bands are diluted by diffusion and two-phase flow.
11 */
12 #ifndef DUMUX_TWOP_TRACER_TEST_PROBLEM_HH
13 #define DUMUX_TWOP_TRACER_TEST_PROBLEM_HH
14
15 #include <dumux/common/boundarytypes.hh>
16
17 #include <dumux/porousmediumflow/problem.hh>
18
19 namespace Dumux {
20 /*!
21 * \ingroup TracerTests
22 *
23 * \brief Definition of the tracer problem:
24 * Multiple tracer bands are diluted by diffusion and two-phase flow.
25 *
26 * This problem uses the \ref TracerModel model.
27 */
28 template <class TypeTag>
29 1 class TwoPTracerTestProblem : public PorousMediumFlowProblem<TypeTag>
30 {
31 using ParentType = PorousMediumFlowProblem<TypeTag>;
32
33 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
34 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
35 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
38 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
39 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
40 using SpatialParams = GetPropType<TypeTag, Properties::SpatialParams>;
41
42 //! property that defines whether mole or mass fractions are used
43 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
44
45 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
46 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
47
48 public:
49 1 TwoPTracerTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
50
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
3 : ParentType(gridGeometry)
51 {
52 // stating in the console whether mole or mass fractions are used
53 if(useMoles)
54 std::cout<<"problem uses mole fractions" << '\n';
55 else
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::cout<<"problem uses mass fractions" << '\n';
57
58
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 stripeWidth_ = getParam<Scalar>("Problem.StripeWidth", 0.125);
59 1 }
60
61 /*!
62 * \name Boundary conditions
63 */
64 // \{
65
66 /*!
67 * \brief Specifies which kind of boundary condition should be
68 * used for which equation on a given boundary segment.
69 *
70 * \param globalPos The position for which the bc type should be evaluated
71 */
72
2/2
✓ Branch 0 taken 32384 times.
✓ Branch 1 taken 8096 times.
40480 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
73 {
74 40480 BoundaryTypes values;
75
6/6
✓ Branch 0 taken 32384 times.
✓ Branch 1 taken 8096 times.
✓ Branch 2 taken 8096 times.
✓ Branch 3 taken 24288 times.
✓ Branch 4 taken 16192 times.
✓ Branch 5 taken 24288 times.
56672 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
76 values.setAllDirichlet();
77 else
78 values.setAllNeumann();
79 40480 return values;
80 }
81 // \}
82
83 /*!
84 * \name Volume terms
85 */
86 // \{
87
88 /*!
89 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
90 *
91 * \param globalPos The global position
92 */
93 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
94 {
95 PrimaryVariables initialValues(0.0);
96 return initialValues;
97 }
98
99 /*!
100 * \brief Evaluates the initial value for a control volume.
101 *
102 * \param globalPos The position for which the initial condition should be evaluated
103 *
104 * For this method, the \a values parameter stores primary
105 * variables.
106 */
107 1536 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
108 {
109 1536 PrimaryVariables initialValues(0.0);
110
111 4512 if (onStripe1_(globalPos) || onStripe2_(globalPos) || onStripe3_(globalPos))
112 {
113 if (useMoles)
114 initialValues = 1e-9;
115 else
116 1536 initialValues = 1e-9*FluidSystem::molarMass(0)/this->spatialParams().fluidMolarMass(globalPos);
117 }
118 1536 return initialValues;
119 }
120
121 private:
122 static constexpr Scalar eps_ = 1e-6;
123 Scalar stripeWidth_;
124
125 bool onUpperBoundary_(const GlobalPosition &globalPos) const
126 {
127 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - 0.1 - eps_;
128 }
129
130
2/2
✓ Branch 0 taken 32384 times.
✓ Branch 1 taken 8096 times.
40480 bool onLeftBoundary_(const GlobalPosition &globalPos) const
131 {
132
2/2
✓ Branch 0 taken 32384 times.
✓ Branch 1 taken 8096 times.
40480 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
133 }
134
135
2/2
✓ Branch 0 taken 8096 times.
✓ Branch 1 taken 24288 times.
32384 bool onRightBoundary_(const GlobalPosition &globalPos) const
136 {
137
2/2
✓ Branch 0 taken 8096 times.
✓ Branch 1 taken 24288 times.
32384 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
138 }
139
140 1536 bool onStripe1_(const GlobalPosition &globalPos) const
141 {
142
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 352 times.
1536 const auto xMax = this->gridGeometry().bBoxMax()[0];
143 return (
144
4/4
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 1152 times.
✓ Branch 3 taken 32 times.
1536 ( (xMax /4.0 - stripeWidth_*0.5) < globalPos[0] + eps_ ) &&
145
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 32 times.
1184 ( (xMax/4.0 + stripeWidth_*0.5) > globalPos[0] + eps_ )
146 );
147 }
148
149 1504 bool onStripe2_(const GlobalPosition &globalPos) const
150 {
151
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 704 times.
1504 const auto xMax = this->gridGeometry().bBoxMax()[0];
152 return (
153
4/4
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 704 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 32 times.
1504 ( (2.0 * xMax /4.0 - stripeWidth_*0.5) < globalPos[0] + eps_ ) &&
154
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 32 times.
800 ( (2.0 * xMax/4.0 + stripeWidth_*0.5) > globalPos[0] + eps_ )
155 );
156 }
157
158 1472 bool onStripe3_(const GlobalPosition &globalPos) const
159 {
160
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 416 times.
1472 const auto xMax = this->gridGeometry().bBoxMax()[0];
161 return (
162
4/4
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 416 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 32 times.
1472 ( (3.0 * xMax /4.0 - stripeWidth_*0.5) < globalPos[0] + eps_ ) &&
163
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 32 times.
416 ( (3.0 * xMax/4.0 + stripeWidth_*0.5) > globalPos[0] + eps_ )
164 );
165 }
166
167 };
168
169 } //end namespace Dumux
170
171 #endif
172