GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/tracer/multiphase/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 24 25 96.0%
Functions: 8 8 100.0%
Branches: 22 28 78.6%

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 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
3/6
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 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 1 taken 2 times.
✗ Branch 2 not taken.
2 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
2/2
✓ Branch 0 taken 13949040 times.
✓ Branch 1 taken 6974520 times.
20923560 BoundaryTypes values;
70 6974520 values.setAllNeumann();
71
72 // tracer is only present in water
73
4/4
✓ Branch 0 taken 1407760 times.
✓ Branch 1 taken 5566760 times.
✓ Branch 2 taken 703880 times.
✓ Branch 3 taken 703880 times.
6974520 if (this->spatialParams().isWater(globalPos) && globalPos[0] < eps_)
74 6974520 values.setAllDirichlet();
75
76 6974520 return values;
77 }
78
79 /*!
80 * \brief The Dirichlet values
81 */
82
1/2
✓ Branch 0 taken 421680 times.
✗ Branch 1 not taken.
421680 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
83 {
84
1/2
✓ Branch 0 taken 421680 times.
✗ Branch 1 not taken.
421680 if (globalPos[0] < eps_)
85 421680 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
2/2
✓ Branch 0 taken 300000 times.
✓ Branch 1 taken 780000 times.
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
2/2
✓ Branch 0 taken 300000 times.
✓ Branch 1 taken 780000 times.
1080000 if (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
116 {
117 300000 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
118
2/2
✓ Branch 1 taken 120000 times.
✓ Branch 2 taken 180000 times.
300000 values = NumEqVector({volVars.massFraction(0,0), volVars.massFraction(0,1)});
119
2/2
✓ Branch 0 taken 120000 times.
✓ Branch 1 taken 180000 times.
1020000 values *= volVars.density()*(this->spatialParams().velocity(scvf)*scvf.unitOuterNormal());
120 }
121 1080000 return values;
122 }
123
124 /*!
125 * \brief The initial values
126 */
127 5000 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
128 {
129 5000 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