GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p_2p/problem_darcy.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 26 31 83.9%
Functions: 3 6 50.0%
Branches: 41 72 56.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 BoundaryTests
10 * \brief A simple Darcy test problem (cell-centered finite volume method).
11 */
12
13 #ifndef DUMUX_DARCY_SUBPROBLEM_HH
14 #define DUMUX_DARCY_SUBPROBLEM_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 template <class TypeTag>
26 class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
27 {
28 using ParentType = PorousMediumFlowProblem<TypeTag>;
29 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
30 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
31 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
32 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
33 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
34 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
35 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
36 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
37 using VolumeVariables = typename GridVariables::GridVolumeVariables::VolumeVariables;
38
39 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
40 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
41 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
42 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
43
44 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
45
46 // copy some indices for convenience
47 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
48 enum {
49 // primary variable indices
50 conti0EqIdx = Indices::conti0EqIdx,
51 pressureIdx = Indices::pressureIdx,
52 saturationIdx = Indices::saturationIdx,
53 };
54
55 using Element = typename GridView::template Codim<0>::Entity;
56 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
57
58 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
59
60 public:
61 1 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
62 std::shared_ptr<CouplingManager> couplingManager)
63
5/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
3 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
64 {
65
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure");
66
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 saturation_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Saturation");
67
8/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 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.
1 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
68 1 }
69
70 /*!
71 * \brief The problem name.
72 */
73 const std::string& name() const
74 {
75
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 return problemName_;
76 }
77
78 /*!
79 * \name Boundary conditions
80 */
81 // \{
82
83 /*!
84 * \brief Specifies which kind of boundary condition should be
85 * used for which equation on a given boundary segment.
86 *
87 * \param element The finite element
88 * \param scvf The sub control volume face
89 */
90 42232 BoundaryTypes boundaryTypes(const Element& element,
91 const SubControlVolumeFace& scvf) const
92 {
93 42232 BoundaryTypes values;
94
95 42232 values.setAllNeumann(); // left/right wall
96
97
2/2
✓ Branch 0 taken 8820 times.
✓ Branch 1 taken 33412 times.
42232 if(onLowerBoundary_(scvf.center()))
98 values.setAllDirichlet();
99
100
2/2
✓ Branch 0 taken 15140 times.
✓ Branch 1 taken 27092 times.
42232 if(couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
101 values.setAllCouplingNeumann();
102
103 42232 return values;
104 }
105
106 /*!
107 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
108 *
109 * \param element The element for which the Dirichlet boundary condition is set
110 * \param scvf The boundary sub control volume face
111 *
112 * For this method, the \a values parameter stores primary variables.
113 */
114 PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
115 {
116 2080 PrimaryVariables values(0.0);
117 4160 values = initial(element);
118
119 return values;
120 }
121
122 /*!
123 * \brief Evaluates the boundary conditions for a Neumann control volume.
124 *
125 * \param element The element for which the Neumann boundary condition is set
126 * \param fvGeometry The fvGeometry
127 * \param elemVolVars The element volume variables
128 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
129 * \param scvf The boundary sub control volume face
130 *
131 * For this method, the \a values variable stores primary variables.
132 */
133 24172 NumEqVector neumann(const Element& element,
134 const FVElementGeometry& fvGeometry,
135 const ElementVolumeVariables& elemVolVars,
136 const ElementFluxVariablesCache& elemFluxVarsCache,
137 const SubControlVolumeFace& scvf) const
138 {
139 24172 NumEqVector values(0.0);
140
141
2/2
✓ Branch 0 taken 12060 times.
✓ Branch 1 taken 12112 times.
24172 if(couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
142 12060 values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf);
143
144 24172 return values;
145 }
146
147 // \}
148
149 /*!
150 * \name Volume terms
151 */
152 // \{
153 /*!
154 * \brief Evaluates the source term for all phases within a given
155 * sub control volume.
156 *
157 * \param element The element for which the source term is set
158 * \param fvGeometry The fvGeometry
159 * \param elemVolVars The element volume variables
160 * \param scv The sub control volume
161 *
162 * For this method, the \a values variable stores the rate mass
163 * of a component is generated or annihilated per volume
164 * unit. Positive values mean that mass is created, negative ones
165 * mean that it vanishes.
166 */
167 NumEqVector source(const Element &element,
168 const FVElementGeometry& fvGeometry,
169 const ElementVolumeVariables& elemVolVars,
170 const SubControlVolume &scv) const
171 202240 { return NumEqVector(0.0); }
172
173 // \}
174
175 /*!
176 * \brief Evaluates the initial value for a control volume.
177 *
178 * \param element The element
179 *
180 * For this method, the \a priVars parameter stores primary
181 * variables.
182 */
183 PrimaryVariables initial(const Element &element) const
184 {
185 2480 PrimaryVariables values(0.0);
186 2480 values[pressureIdx] = pressure_;
187 4960 values[saturationIdx] = saturation_;
188
189 return values;
190 }
191
192 // \}
193
194 /*!
195 * \brief Get the coupling manager
196 */
197 const CouplingManager& couplingManager() const
198
8/8
✓ Branch 0 taken 12060 times.
✓ Branch 1 taken 12112 times.
✓ Branch 2 taken 12060 times.
✓ Branch 3 taken 12112 times.
✓ Branch 6 taken 15140 times.
✓ Branch 7 taken 27092 times.
✓ Branch 8 taken 15140 times.
✓ Branch 9 taken 27092 times.
132808 { return *couplingManager_; }
199
200 private:
201 bool onLeftBoundary_(const GlobalPosition &globalPos) const
202 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
203
204 bool onRightBoundary_(const GlobalPosition &globalPos) const
205 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
206
207 bool onLowerBoundary_(const GlobalPosition &globalPos) const
208
10/10
✓ Branch 0 taken 8820 times.
✓ Branch 1 taken 33412 times.
✓ Branch 2 taken 8820 times.
✓ Branch 3 taken 33412 times.
✓ Branch 4 taken 8820 times.
✓ Branch 5 taken 33412 times.
✓ Branch 6 taken 8820 times.
✓ Branch 7 taken 33412 times.
✓ Branch 8 taken 8820 times.
✓ Branch 9 taken 33412 times.
211160 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
209
210 bool onUpperBoundary_(const GlobalPosition &globalPos) const
211 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
212
213 Scalar eps_;
214 Scalar pressure_;
215 Scalar saturation_;
216 std::string problemName_;
217 std::shared_ptr<CouplingManager> couplingManager_;
218 };
219 } // end namespace Dumux
220
221 #endif
222