GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/tracer/multiphase/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 21 23 91.3%
Functions: 6 8 75.0%
Branches: 32 48 66.7%

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 TracerTests
10 * \brief Definition of a problem for the tracer problem:
11 * Two tracers are diluted by diffusion and constant two-phase saturation field.
12 */
13
14 #ifndef DUMUX_TRACER_MULTIPHASE_TEST_PROBLEM_HH
15 #define DUMUX_TRACER_MULTIPHASE_TEST_PROBLEM_HH
16
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/parameters.hh>
19
20 #include <dumux/common/boundarytypes.hh>
21 #include <dumux/common/numeqvector.hh>
22 #include <dumux/porousmediumflow/problem.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup TracerTests
28 * \brief A problem, where two tracers are diluted by diffusion and constant two-phase saturation field.
29 */
30 template <class TypeTag>
31 2 class TracerTest : public PorousMediumFlowProblem<TypeTag>
32 {
33 using ParentType = PorousMediumFlowProblem<TypeTag>;
34
35 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
36 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
37 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
38 using GridView = typename GridGeometry::GridView;
39 using FVElementGeometry = typename GridGeometry::LocalView;
40 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
41 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
42 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
43 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
44 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
45 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
46 using SpatialParams = GetPropType<TypeTag, Properties::SpatialParams>;
47
48 //! property that defines whether mole or mass fractions are used
49 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
50 using Element = typename GridView::template Codim<0>::Entity;
51 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
52
53 public:
54 2 TracerTest(std::shared_ptr<const GridGeometry> gg)
55
5/14
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
6 : ParentType(gg)
56 {
57 // stating in the console whether mole or mass fractions are used
58 if(useMoles)
59 std::cout<<"problem uses mole fractions" << '\n';
60 else
61
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
4 std::cout<<"problem uses mass fractions" << '\n';
62 2 }
63
64 /*!
65 * \brief The boundary types
66 */
67 6974520 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
68 {
69 6974520 BoundaryTypes values;
70 6974520 values.setAllNeumann();
71
72 // tracer is only present in water
73
8/8
✓ Branch 0 taken 1407760 times.
✓ Branch 1 taken 5566760 times.
✓ Branch 2 taken 1407760 times.
✓ Branch 3 taken 5566760 times.
✓ Branch 4 taken 703880 times.
✓ Branch 5 taken 703880 times.
✓ Branch 6 taken 703880 times.
✓ Branch 7 taken 703880 times.
13949040 if (this->spatialParams().isWater(globalPos) && globalPos[0] < eps_)
74 values.setAllDirichlet();
75
76 6974520 return values;
77 }
78
79 /*!
80 * \brief The Dirichlet values
81 */
82 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
83 {
84
6/12
✓ Branch 0 taken 240960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 240960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 120480 times.
✗ Branch 11 not taken.
843360 if (globalPos[0] < eps_)
85 843360 return PrimaryVariables({1e-8, 1e-8});
86 else
87 return PrimaryVariables({0.0, 0.0});
88 }
89
90 /*!
91 * \brief Evaluate the boundary conditions for a neumann
92 * boundary segment.
93 *
94 * This is the method for the case where the Neumann condition is
95 * potentially solution dependent
96 *
97 * \param element The finite element
98 * \param fvGeometry The finite-volume geometry
99 * \param elemVolVars All volume variables for the element
100 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
101 * \param scvf The sub control volume face
102 *
103 * Negative values mean influx.
104 * E.g. for the mass balance that would the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$.
105 */
106 template<class ElemFluxVarsCache>
107 1080000 NumEqVector neumann(const Element& element,
108 const FVElementGeometry& fvGeometry,
109 const ElementVolumeVariables& elemVolVars,
110 const ElemFluxVarsCache& elemFluxVarsCache,
111 const SubControlVolumeFace& scvf) const
112 {
113 1080000 NumEqVector values(0.0);
114
2/2
✓ Branch 0 taken 300000 times.
✓ Branch 1 taken 780000 times.
1080000 const auto& globalPos = scvf.ipGlobal();
115
10/10
✓ Branch 0 taken 300000 times.
✓ Branch 1 taken 780000 times.
✓ Branch 2 taken 300000 times.
✓ Branch 3 taken 780000 times.
✓ Branch 4 taken 300000 times.
✓ Branch 5 taken 780000 times.
✓ Branch 6 taken 300000 times.
✓ Branch 7 taken 780000 times.
✓ Branch 8 taken 300000 times.
✓ Branch 9 taken 780000 times.
5400000 if (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
116 {
117 400000 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
118 900000 values = NumEqVector({volVars.massFraction(0,0), volVars.massFraction(0,1)});
119 1500000 values *= volVars.density()*(this->spatialParams().velocity(scvf)*scvf.unitOuterNormal());
120 }
121 1080000 return values;
122 }
123
124 /*!
125 * \brief The initial values
126 */
127 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
128 {
129 10000 return PrimaryVariables({0.0, 0.0});
130 }
131 private:
132 static constexpr Scalar eps_ = 1e-7;
133 };
134
135 } // end namespace Dumux
136
137 #endif
138