GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/facet/tracer_tracer/problem_tracer_lowdim.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 18 26 69.2%
Functions: 8 18 44.4%
Branches: 25 64 39.1%

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 lowdim domain of the tracer facet coupling test.
11 */
12
13 #ifndef DUMUX_TEST_TPFAFACETCOUPLING_TRACER_LOWDIM_PROBLEM_HH
14 #define DUMUX_TEST_TPFAFACETCOUPLING_TRACER_LOWDIM_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 TracerLowDimProblem : 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 FVElementGeometry = typename GridGeometry::LocalView;
39 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
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 TracerLowDimProblem(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
4/16
✓ 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 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
9 , couplingManagerPtr_(couplingManager)
61 {
62 // stating in the console whether mole or mass fractions are used
63
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");
64
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';
65
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;
66 3 }
67
68 //! The problem name.
69 const std::string& name() const
70
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 { return problemName_; }
71
72 /*!
73 * \brief Specifies which kind of boundary condition should be
74 * used for which equation on a given boundary segment.
75 *
76 * \param globalPos The position for which the bc type should be evaluated
77 */
78 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
79 {
80
3/4
✓ Branch 0 taken 4000 times.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8000 times.
20000 BoundaryTypes values;
81
3/4
✓ Branch 0 taken 4000 times.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8000 times.
20000 values.setAllNeumann();
82 return values;
83 }
84
85 /*!
86 * \brief Evaluates the initial value for a control volume.
87 *
88 * \param globalPos The position for which the initial condition should be evaluated
89 */
90 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
91 101 { return PrimaryVariables(0.0); }
92
93 /*!
94 * \brief Evaluates the Dirichlet boundary conditions for a control volume.
95 *
96 * \param globalPos The position for which the initial condition should be evaluated
97 */
98 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
99 { return initialAtPos(globalPos); }
100
101 //! Evaluates the source term at a given position
102 template<class ElementVolumeVariables, class SubControlVolume>
103 200000 NumEqVector source(const Element& element,
104 const FVElementGeometry& fvGeometry,
105 const ElementVolumeVariables& elemVolVars,
106 const SubControlVolume& scv) const
107 {
108 // evaluate sources from bulk domain
109 400000 auto source = couplingManagerPtr_->evalSourcesFromBulk(element, fvGeometry, elemVolVars, scv);
110 400000 source /= scv.volume()*elemVolVars[scv].extrusionFactor();
111 200000 return source;
112 }
113
114 /*!
115 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
116 *
117 * \param element The finite element
118 * \param fvGeometry The finite-volume geometry
119 * \param elemVolVars All volume variables for the element
120 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
121 * \param scvf The sub control volume face
122 *
123 * Negative values mean influx.
124 * E.g. for the mass balance that would the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$.
125 */
126 template<class ElementVolumeVariables, class ElementFluxVarsCache>
127 8000 NumEqVector neumann(const Element& element,
128 const FVElementGeometry& fvGeometry,
129 const ElementVolumeVariables& elemVolVars,
130 const ElementFluxVarsCache& elemFluxVarsCache,
131 const SubControlVolumeFace& scvf) const
132 {
133 // get the volume flux on this segment
134
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8000 times.
16000 const auto flux = this->spatialParams().volumeFlux(element, fvGeometry, elemVolVars, scvf);
135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if (flux > 0.0)
136 {
137 const auto& insideVolVars = elemVolVars[fvGeometry.scv(scvf.insideScvIdx())];
138 const auto tracerFlux = insideVolVars.massFraction(/*phaseIdx*/0, /*compIdx*/0)*flux;
139 return NumEqVector(tracerFlux);
140 }
141
142 8000 return NumEqVector(0.0);
143 }
144
145 //! Returns reference to the coupling manager.
146 const CouplingManager& couplingManager() const
147 { return *couplingManagerPtr_; }
148
149 private:
150 std::shared_ptr<CouplingManager> couplingManagerPtr_;
151 std::string problemName_;
152 };
153
154 } // end namespace Dumux
155
156 #endif
157