GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/darcydarcy/1p_1p/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 20 24 83.3%
Functions: 12 16 75.0%
Branches: 43 68 63.2%

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 BoundaryTests
10 * \brief The properties for the incompressible test.
11 */
12
13 #ifndef DUMUX_ONEP_SUB_TEST_PROBLEM_HH
14 #define DUMUX_ONEP_SUB_TEST_PROBLEM_HH
15
16 #include <dune/common/indices.hh>
17
18 #include <dumux/common/boundarytypes.hh>
19 #include <dumux/common/properties.hh>
20 #include <dumux/common/parameters.hh>
21 #include <dumux/common/numeqvector.hh>
22
23 #include <dumux/porousmediumflow/problem.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup BoundaryTests
29 * \brief Multidomain test problem for the incompressible one-phase model.
30 *
31 * Two possibilities to divide the model domain are given:
32 * half: a horizontal interface splits the domain in two equally sized subdomains
33 * lens: one subdomain is defined as a central lens, surrounded by the other subdomain
34 */
35 template<class TypeTag, std::size_t tag>
36 class OnePTestProblem
37 : public PorousMediumFlowProblem<TypeTag>
38 {
39 using ParentType = PorousMediumFlowProblem<TypeTag>;
40 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
41 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
44 using GridView = typename GridGeometry::GridView;
45 using Element = typename GridView::template Codim<0>::Entity;
46 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
47 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
48 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
49 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
50 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
51 static constexpr int dimWorld = GridView::dimensionworld;
52 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
53 static constexpr auto domainIdx = Dune::index_constant<tag>{};
54
55 public:
56 8 OnePTestProblem(std::shared_ptr<const GridGeometry> gridGeometry,
57 std::shared_ptr<CouplingManager> couplingManager,
58 const std::string& paramGroup = "")
59 : ParentType(gridGeometry, paramGroup)
60
3/10
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
16 , couplingManager_(couplingManager)
61 {
62 // set a default name for the problem
63
8/24
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
8 problemName_ = getParam<std::string>("Vtk.OutputName")+ "_" + getParamFromGroup<std::string>(paramGroup, "Problem.Name");
64 8 }
65
66 /*!
67 * \brief The problem name.
68 */
69 const std::string& name() const
70 {
71
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
4 return problemName_;
72 }
73
74 /*!
75 * \brief Specifies which kind of boundary condition should be
76 * used for which equation on a given boundary segment.
77 *
78 * \param element The finite element
79 * \param scvf The sub control volume face
80 */
81 5880 BoundaryTypes boundaryTypes(const Element &element,
82 const SubControlVolumeFace &scvf) const
83 {
84
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 636 times.
5880 BoundaryTypes values;
85
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 636 times.
5880 const auto& globalPos = scvf.ipGlobal();
86
87
8/8
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 636 times.
✓ Branch 2 taken 2304 times.
✓ Branch 3 taken 636 times.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 636 times.
✓ Branch 6 taken 2304 times.
✓ Branch 7 taken 636 times.
23520 if (globalPos[dimWorld-1] < this->gridGeometry().bBoxMin()[dimWorld-1] + eps_
88
12/12
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 636 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 1668 times.
✓ Branch 4 taken 636 times.
✓ Branch 5 taken 1668 times.
✓ Branch 6 taken 636 times.
✓ Branch 7 taken 1668 times.
✓ Branch 8 taken 636 times.
✓ Branch 9 taken 1668 times.
✓ Branch 10 taken 636 times.
✓ Branch 11 taken 1668 times.
5880 || globalPos[dimWorld-1] > this->gridGeometry().bBoxMax()[dimWorld-1] - eps_)
89 values.setAllDirichlet();
90 else
91 values.setAllNeumann();
92
93
2/2
✓ Branch 2 taken 1932 times.
✓ Branch 3 taken 1008 times.
11760 if (couplingManager_->isCoupled(domainIdx, scvf))
94 values.setAllCouplingNeumann();
95
96 5880 return values;
97 }
98
99 /*!
100 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
101 *
102 * This is the method for the case where the Neumann condition is
103 * potentially solution dependent.
104 *
105 * \param element The finite element
106 * \param fvGeometry The finite-volume geometry
107 * \param elemVolVars All volume variables for the element
108 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
109 * \param scvf The sub control volume face
110 *
111 * Negative values mean influx.
112 * E.g. for the mass balance that would the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$.
113 */
114 template<class ElementVolumeVariables, class ElementFluxVarsCache>
115 2256 NumEqVector neumann(const Element& element,
116 const FVElementGeometry& fvGeometry,
117 const ElementVolumeVariables& elemVolVars,
118 const ElementFluxVarsCache& elemFluxVarsCache,
119 const SubControlVolumeFace& scvf) const
120 {
121 2256 NumEqVector values(0.0);
122 2256 const auto bcTypes = boundaryTypes(element, scvf);
123
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 264 times.
✓ Branch 2 taken 864 times.
✓ Branch 3 taken 264 times.
4512 if (bcTypes.hasCouplingNeumann())
124 3456 values[Indices::conti0EqIdx] = couplingManager_->advectiveFluxCoupling(domainIdx, element, fvGeometry, elemVolVars, scvf);
125
126 2256 return values;
127 }
128
129 /*!
130 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
131 *
132 * \param globalPos The center of the finite volume which ought to be set.
133 *
134 * For this method, the \a values parameter stores primary variables.
135 */
136 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
137 {
138 120 PrimaryVariables values(0.0);
139 240 values[0] = 1.0e+5*(2.0 - globalPos[dimWorld-1]);
140 return values;
141 }
142
143 /*!
144 * \brief Evaluates the initial value for a control volume.
145 *
146 * \param globalPos The global position
147 */
148 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
149 { return dirichletAtPos(globalPos); }
150
151
152 private:
153 std::shared_ptr<CouplingManager> couplingManager_;
154 static constexpr Scalar eps_ = 1e-7;
155 std::string problemName_;
156
157 };
158
159 } // end namespace Dumux
160
161 #endif
162