GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/facet/tracer_tracer/problem_tracer_bulk.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 23 28 82.1%
Functions: 5 14 35.7%
Branches: 67 122 54.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 FacetTests
10 * \brief The problem for the bulk domain of the tracer facet coupling test.
11 */
12
13 #ifndef DUMUX_TEST_TPFAFACETCOUPLING_TRACER_BULK_PROBLEM_HH
14 #define DUMUX_TEST_TPFAFACETCOUPLING_TRACER_BULK_PROBLEM_HH
15
16 #include <dumux/common/boundarytypes.hh>
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/parameters.hh>
19 #include <dumux/common/numeqvector.hh>
20
21 #include <dumux/porousmediumflow/problem.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup FacetTests
27 * \brief The problem for the bulk domain of the tracer facet coupling test.
28 */
29 template <class TypeTag>
30 class TracerBulkProblem : public PorousMediumFlowProblem<TypeTag>
31 {
32 using ParentType = PorousMediumFlowProblem<TypeTag>;
33
34 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
35 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
36 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
37 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
38 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
39 using FVElementGeometry = typename GridGeometry::LocalView;
40 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
41 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
42 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
43 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
44 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
45
46 //! property that defines whether mole or mass fractions are used
47 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
48
49 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
50 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
51
52 public:
53 using typename ParentType::SpatialParams;
54
55 3 TracerBulkProblem(std::shared_ptr<const GridGeometry> gridGeometry,
56 std::shared_ptr<SpatialParams> spatialParams,
57 std::shared_ptr<CouplingManager> couplingManager,
58 const std::string& paramGroup = "")
59 : ParentType(gridGeometry, spatialParams, paramGroup)
60 , couplingManagerPtr_(couplingManager)
61
5/18
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
9 , initialMassFraction_(getParamFromGroup<Scalar>(paramGroup, "Problem.ContaminationMassFraction"))
62 {
63 // stating in the console whether mole or mass fractions are used
64
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
6 const auto problemName = getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
65
2/4
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
15 std::cout<< "problem " << problemName << " uses " << (useMoles ? "mole" : "mass") << " fractions" << '\n';
66
7/20
✓ 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 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
3 problemName_ = getParamFromGroup<std::string>(this->paramGroup(), "Vtk.OutputName") + "_" + problemName;
67 3 }
68
69 //! The problem name.
70 const std::string& name() const
71
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 { return problemName_; }
72
73 /*!
74 * \brief Specifies which kind of boundary condition should be
75 * used for which equation on a given boundary segment.
76 *
77 * \param globalPos The position for which the bc type should be evaluated
78 */
79 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
80 {
81
5/8
✓ Branch 0 taken 114000 times.
✓ Branch 1 taken 102000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 343000 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 224000 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 70000 times.
853000 BoundaryTypes values;
82
5/8
✓ Branch 0 taken 114000 times.
✓ Branch 1 taken 102000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 343000 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 224000 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 70000 times.
853000 values.setAllNeumann();
83 return values;
84 }
85
86 //! Specifies the type of interior boundary condition at a given position.
87 BoundaryTypes interiorBoundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const
88 {
89
2/2
✓ Branch 0 taken 304000 times.
✓ Branch 1 taken 829000 times.
1133000 BoundaryTypes values;
90
2/2
✓ Branch 0 taken 304000 times.
✓ Branch 1 taken 829000 times.
1133000 values.setAllNeumann();
91 return values;
92 }
93
94 /*!
95 * \brief Evaluates the initial value for a control volume.
96 *
97 * \param globalPos The position for which the initial condition should be evaluated
98 */
99 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
100 {
101 4970 if (isInContaminatedRegion_(globalPos))
102 26 return PrimaryVariables(initialMassFraction_);
103 return PrimaryVariables(0.0);
104 }
105
106 /*!
107 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
108 *
109 * \param element The finite element
110 * \param fvGeometry The finite-volume geometry
111 * \param elemVolVars All volume variables for the element
112 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
113 * \param scvf The sub control volume face
114 *
115 * Negative values mean influx.
116 * E.g. for the mass balance that would the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$.
117 */
118 template<class ElementVolumeVariables, class ElementFluxVarsCache>
119 102000 NumEqVector neumann(const Element& element,
120 const FVElementGeometry& fvGeometry,
121 const ElementVolumeVariables& elemVolVars,
122 const ElementFluxVarsCache& elemFluxVarsCache,
123 const SubControlVolumeFace& scvf) const
124 {
125 // get the volume flux on this segment
126
4/4
✓ Branch 0 taken 15000 times.
✓ Branch 1 taken 87000 times.
✓ Branch 2 taken 15000 times.
✓ Branch 3 taken 87000 times.
204000 const auto flux = this->spatialParams().volumeFlux(element, fvGeometry, elemVolVars, scvf);
127
2/2
✓ Branch 0 taken 15000 times.
✓ Branch 1 taken 87000 times.
102000 if (flux > 0.0)
128 {
129
2/4
✓ Branch 0 taken 15000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5000 times.
✗ Branch 3 not taken.
35000 const auto& insideVolVars = elemVolVars[fvGeometry.scv(scvf.insideScvIdx())];
130 15000 const auto tracerFlux = insideVolVars.massFraction(/*phaseIdx*/0, /*compIdx*/0)*flux;
131 15000 return NumEqVector(tracerFlux);
132 }
133
134 87000 return NumEqVector(0.0);
135 }
136
137 //! Returns reference to the coupling manager.
138 const CouplingManager& couplingManager() const
139
12/12
✓ Branch 0 taken 600000 times.
✓ Branch 1 taken 8274000 times.
✓ Branch 2 taken 600000 times.
✓ Branch 3 taken 8274000 times.
✓ Branch 4 taken 600000 times.
✓ Branch 5 taken 8376000 times.
✓ Branch 6 taken 600000 times.
✓ Branch 7 taken 8376000 times.
✓ Branch 8 taken 829000 times.
✓ Branch 9 taken 17504000 times.
✓ Branch 10 taken 829000 times.
✓ Branch 11 taken 17504000 times.
73166000 { return *couplingManagerPtr_; }
140
141 private:
142 bool isInContaminatedRegion_(const GlobalPosition& globalPos) const
143 {
144
6/12
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4686 times.
✓ Branch 7 taken 271 times.
✓ Branch 8 taken 181 times.
✓ Branch 9 taken 4505 times.
✓ Branch 10 taken 181 times.
✓ Branch 11 taken 4505 times.
4957 return globalPos[0] > 0.75 && globalPos[0] < 1.3
145
10/20
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 4686 times.
✓ Branch 11 taken 271 times.
✓ Branch 12 taken 115 times.
✓ Branch 13 taken 66 times.
✓ Branch 14 taken 115 times.
✓ Branch 15 taken 66 times.
✓ Branch 16 taken 13 times.
✓ Branch 17 taken 102 times.
✓ Branch 18 taken 13 times.
✓ Branch 19 taken 102 times.
5319 && globalPos[1] > 5.3 && globalPos[1] < 5.8;
146 }
147
148 std::shared_ptr<CouplingManager> couplingManagerPtr_;
149 Scalar initialMassFraction_;
150 std::string problemName_;
151 };
152
153 } // end namespace Dumux
154
155 #endif
156