GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p2c_1p2c/problem_darcy.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 38 40 95.0%
Functions: 4 6 66.7%
Branches: 62 104 59.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-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 #include <dumux/common/timeloop.hh>
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 GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
30 using GridView = typename GridGeometry::GridView;
31 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
32 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
33 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
34 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
35 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
36 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
37 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
38 using Element = typename GridView::template Codim<0>::Entity;
39 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
40
41 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
42
43 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
44 using TimeLoopPtr = std::shared_ptr<TimeLoop<Scalar>>;
45
46 public:
47 3 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
48 std::shared_ptr<CouplingManager> couplingManager)
49
6/20
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
✓ Branch 18 taken 3 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
9 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
50 {
51
9/26
✓ 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 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 3 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
6 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
52
53 // determine whether to simulate a vertical or horizontal flow configuration
54 3 verticalFlow_ = problemName_.find("vertical") != std::string::npos;
55 3 }
56
57 /*!
58 * \brief The problem name.
59 */
60 const std::string& name() const
61 {
62
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 return problemName_;
63 }
64
65 /*!
66 * \name Boundary conditions
67 */
68 // \{
69
70 /*!
71 * \brief Specifies which kind of boundary condition should be
72 * used for which equation on a given boundary control volume.
73 *
74 * \param element The element
75 * \param scvf The boundary sub control volume face
76 */
77 70200 BoundaryTypes boundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const
78 {
79 70200 BoundaryTypes values;
80 70200 values.setAllNeumann();
81
82
2/2
✓ Branch 0 taken 27120 times.
✓ Branch 1 taken 43080 times.
70200 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
83 values.setAllCouplingNeumann();
84
85
2/2
✓ Branch 0 taken 47960 times.
✓ Branch 1 taken 22240 times.
70200 if (verticalFlow_)
86 {
87
2/2
✓ Branch 0 taken 9460 times.
✓ Branch 1 taken 38500 times.
47960 if (onLowerBoundary_(scvf.center()))
88 values.setAllDirichlet();
89 }
90
91 70200 return values;
92 }
93
94 /*!
95 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
96 *
97 * \param element The element for which the Dirichlet boundary condition is set
98 * \param scvf The boundary subcontrolvolumeface
99 *
100 */
101 2540 PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
102 {
103 2540 PrimaryVariables values(0.0);
104 5080 values = initial(element);
105
106 2540 if (verticalFlow_)
107 {
108 // Check if this a pure diffusion problem.
109
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2538 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2542 static const bool isDiffusionProblem = problemName_.find("diffusion") != std::string::npos;
110
111 2540 Scalar bottomMoleFraction = 0.0;
112
113
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 2280 times.
2540 if (isDiffusionProblem)
114 {
115 // For the diffusion problem, change the top mole fraction after some time
116 // in order to revert the concentration gradient.
117 520 if (time() >= 1e10)
118 100 bottomMoleFraction = 1e-3;
119 }
120
121
1/2
✓ Branch 0 taken 2540 times.
✗ Branch 1 not taken.
2540 if(onLowerBoundary_(scvf.center()))
122 5080 values[Indices::conti0EqIdx + 1] = bottomMoleFraction;
123 }
124
125 2540 return values;
126 }
127
128 /*!
129 * \brief Evaluates the boundary conditions for a Neumann control volume.
130 *
131 * \param element The element for which the Neumann boundary condition is set
132 * \param fvGeometry The fvGeometry
133 * \param elemVolVars The element volume variables
134 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
135 * \param scvf The boundary sub control volume face
136 *
137 * For this method, the \a values variable stores primary variables.
138 */
139 template<class ElementVolumeVariables, class ElementFluxVarsCache>
140 44460 NumEqVector neumann(const Element& element,
141 const FVElementGeometry& fvGeometry,
142 const ElementVolumeVariables& elemVolVars,
143 const ElementFluxVarsCache& elemFluxVarsCache,
144 const SubControlVolumeFace& scvf) const
145 {
146 44460 NumEqVector values(0.0);
147
148
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 22220 times.
44460 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
149 22240 values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf);
150
151 44460 return values;
152 }
153
154 // \}
155
156 /*!
157 * \name Volume terms
158 */
159 // \{
160 /*!
161 * \brief Evaluates the source term for all phases within a given
162 * sub control volume.
163 *
164 * \param element The element for which the source term is set
165 * \param fvGeometry The fvGeometry
166 * \param elemVolVars The element volume variables
167 * \param scv The sub control volume
168 */
169 template<class ElementVolumeVariables>
170 NumEqVector source(const Element &element,
171 const FVElementGeometry& fvGeometry,
172 const ElementVolumeVariables& elemVolVars,
173 const SubControlVolume &scv) const
174 343200 { return NumEqVector(0.0); }
175
176 // \}
177
178 /*!
179 * \brief Evaluates the initial value for a control volume.
180 *
181 * \param element The element
182 *
183 * For this method, the \a priVars parameter stores primary
184 * variables.
185 */
186 PrimaryVariables initial(const Element &element) const
187 {
188 3740 PrimaryVariables values(0.0);
189
1/2
✓ Branch 0 taken 2540 times.
✗ Branch 1 not taken.
3740 values[Indices::pressureIdx] = 1e5;
190
191
1/2
✓ Branch 0 taken 2540 times.
✗ Branch 1 not taken.
3740 return values;
192 }
193
194 // \}
195
196 //! Get the coupling manager
197 const CouplingManager& couplingManager() const
198
8/8
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 22220 times.
✓ Branch 2 taken 22240 times.
✓ Branch 3 taken 22220 times.
✓ Branch 6 taken 27120 times.
✓ Branch 7 taken 43080 times.
✓ Branch 8 taken 27120 times.
✓ Branch 9 taken 43080 times.
229320 { return *couplingManager_; }
199
200 /*!
201 * \brief Sets the time loop pointer.
202 */
203 void setTimeLoop(TimeLoopPtr timeLoop)
204
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 { timeLoop_ = timeLoop; }
205
206 /*!
207 * \brief Returns the time.
208 */
209 Scalar time() const
210
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 160 times.
780 { return timeLoop_->time(); }
211
212 private:
213 bool onLeftBoundary_(const GlobalPosition &globalPos) const
214 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
215
216 bool onRightBoundary_(const GlobalPosition &globalPos) const
217 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
218
219 bool onLowerBoundary_(const GlobalPosition &globalPos) const
220
15/20
✓ Branch 0 taken 2540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2540 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2540 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2540 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2540 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9460 times.
✓ Branch 11 taken 38500 times.
✓ Branch 12 taken 9460 times.
✓ Branch 13 taken 38500 times.
✓ Branch 14 taken 9460 times.
✓ Branch 15 taken 38500 times.
✓ Branch 16 taken 9460 times.
✓ Branch 17 taken 38500 times.
✓ Branch 18 taken 9460 times.
✓ Branch 19 taken 38500 times.
252500 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
221
222 bool onUpperBoundary_(const GlobalPosition &globalPos) const
223 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
224
225 Scalar eps_;
226 std::string problemName_;
227 bool verticalFlow_;
228 std::shared_ptr<CouplingManager> couplingManager_;
229 TimeLoopPtr timeLoop_;
230 };
231 } // end namespace Dumux
232
233 #endif
234