GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 20 23 87.0%
Functions: 4 7 57.1%
Branches: 20 34 58.8%

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) for
11 * the comparison of different diffusion laws.
12 */
13
14 #ifndef DUMUX_DARCY_SUBPROBLEM_DIFFUSION_COMPARISON_HH
15 #define DUMUX_DARCY_SUBPROBLEM_DIFFUSION_COMPARISON_HH
16
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/parameters.hh>
19 #include <dumux/common/boundarytypes.hh>
20 #include <dumux/common/numeqvector.hh>
21 #include <dumux/multidomain/boundary/stokesdarcy/couplingdata.hh>
22 #include <dumux/porousmediumflow/problem.hh>
23
24 namespace Dumux {
25
26 template <class TypeTag>
27 class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
28 {
29 using ParentType = PorousMediumFlowProblem<TypeTag>;
30 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
31 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
32 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
33 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
34 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
35 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
36 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
37 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
38 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
39 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
40 using DiffusionCoefficientAveragingType = typename StokesDarcyCouplingOptions::DiffusionCoefficientAveragingType;
41
42 // copy some indices for convenience
43 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
44 enum {
45 // grid and world dimension
46 dim = GridView::dimension,
47 dimworld = GridView::dimensionworld,
48
49 // primary variable indices
50 conti0EqIdx = Indices::conti0EqIdx,
51 pressureIdx = Indices::pressureIdx,
52 };
53
54 using Element = typename GridView::template Codim<0>::Entity;
55 using GlobalPosition = Dune::FieldVector<Scalar, dimworld>;
56
57 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
58
59 public:
60 2 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
61 std::shared_ptr<CouplingManager> couplingManager)
62
5/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
6 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
63 {
64
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
4 pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure");
65
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 initialMoleFraction_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialMoleFraction");
66 2 }
67
68 /*!
69 * \name Boundary conditions
70 */
71 // \{
72
73 /*!
74 * \brief Specifies which kind of boundary condition should be
75 * used for which equation on a given boundary control volume.
76 *
77 * \param element The element
78 * \param scvf The boundary sub control volume face
79 */
80 34400 BoundaryTypes boundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const
81 {
82 34400 BoundaryTypes values;
83 34400 values.setAllNeumann();
84
85
2/2
✓ Branch 0 taken 14400 times.
✓ Branch 1 taken 20000 times.
34400 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
86 values.setAllCouplingNeumann();
87
88 34400 return values;
89 }
90
91 /*!
92 * \brief Evaluates the boundary conditions for a Neumann control volume.
93 *
94 * \param element The element for which the Neumann boundary condition is set
95 * \param fvGeometry The fvGeometry
96 * \param elemVolVars The element volume variables
97 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
98 * \param scvf The boundary sub control volume face
99 *
100 * For this method, the \a values variable stores primary variables.
101 */
102 template<class ElementVolumeVariables, class ElementFluxVarsCache>
103 28000 NumEqVector neumann(const Element& element,
104 const FVElementGeometry& fvGeometry,
105 const ElementVolumeVariables& elemVolVars,
106 const ElementFluxVarsCache& elemFluxVarsCache,
107 const SubControlVolumeFace& scvf) const
108 {
109 28000 NumEqVector values(0.0);
110
111
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 15200 times.
28000 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
112 12800 values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, DiffusionCoefficientAveragingType::harmonic);
113
114 28000 return values;
115 }
116
117 // \}
118
119 /*!
120 * \name Volume terms
121 */
122 // \{
123 /*!
124 * \brief Evaluates the source term for all phases within a given
125 * sub control volume.
126 *
127 * \param element The element for which the source term is set
128 * \param fvGeometry The fvGeometry
129 * \param elemVolVars The element volume variables
130 * \param scv The sub control volume
131 */
132 template<class ElementVolumeVariables>
133 NumEqVector source(const Element &element,
134 const FVElementGeometry& fvGeometry,
135 const ElementVolumeVariables& elemVolVars,
136 const SubControlVolume &scv) const
137 208000 { return NumEqVector(0.0); }
138
139 // \}
140
141 /*!
142 * \brief Evaluates the initial value for a control volume.
143 *
144 * \param element The element
145 *
146 * For this method, the \a priVars parameter stores primary
147 * variables.
148 */
149 PrimaryVariables initial(const Element &element) const
150 {
151 800 PrimaryVariables values(0.0);
152 800 values[pressureIdx] = pressure_;
153 1600 values[conti0EqIdx + 1] = initialMoleFraction_;
154
155 return values;
156 }
157
158 // \}
159
160 //! Get the coupling manager
161 const CouplingManager& couplingManager() const
162
8/8
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 15200 times.
✓ Branch 2 taken 12800 times.
✓ Branch 3 taken 15200 times.
✓ Branch 6 taken 14400 times.
✓ Branch 7 taken 20000 times.
✓ Branch 8 taken 14400 times.
✓ Branch 9 taken 20000 times.
124800 { return *couplingManager_; }
163
164 private:
165 bool onLeftBoundary_(const GlobalPosition &globalPos) const
166 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
167
168 bool onRightBoundary_(const GlobalPosition &globalPos) const
169 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
170
171 bool onLowerBoundary_(const GlobalPosition &globalPos) const
172 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
173
174 bool onUpperBoundary_(const GlobalPosition &globalPos) const
175 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
176
177 Scalar eps_;
178 Scalar pressure_;
179 Scalar initialMoleFraction_;
180
181 std::shared_ptr<CouplingManager> couplingManager_;
182 };
183 } // end namespace Dumux
184
185 #endif
186