GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/dualnetwork/problem_solid.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 58 72 80.6%
Functions: 5 7 71.4%
Branches: 97 202 48.0%

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 #ifndef DUMUX_TEST_MULTIDOMAIN_DUALNETWORK_PROBLEM_SOLID_HH
8 #define DUMUX_TEST_MULTIDOMAIN_DUALNETWORK_PROBLEM_SOLID_HH
9
10 #include <dumux/common/properties.hh>
11 #include <dumux/common/parameters.hh>
12 #include <dumux/porousmediumflow/problem.hh>
13 #include <dumux/common/boundarytypes.hh>
14 #include <dumux/common/numeqvector.hh>
15
16 namespace Dumux {
17
18 /*!
19 * \brief Heat problem with multiple solid spheres
20 */
21 template <class TypeTag>
22 class SolidSubProblem : public PorousMediumFlowProblem<TypeTag>
23 {
24 using ParentType = PorousMediumFlowProblem<TypeTag>;
25 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
26 using GridView = typename GridGeometry::GridView;
27 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
28 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
29 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
30 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
31 using FVElementGeometry = typename GridGeometry::LocalView;
32 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
33 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
34
35 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
36
37 using Element = typename GridView::template Codim<0>::Entity;
38 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
39
40 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
41
42 enum class SourceMode {conduction, convection, max};
43
44 public:
45 template<class SpatialParams>
46 1 SolidSubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
47 std::shared_ptr<SpatialParams> spatialParams,
48 std::shared_ptr<const CouplingManager> couplingManager)
49
8/26
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 1 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 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
4 : ParentType(gridGeometry, spatialParams, "Solid"), couplingManager_(couplingManager)
50 {
51
9/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 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 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.
2 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
52
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 initialTemperature_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialTemperature");
53
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 temperatureBottom_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.BottomTemperature");
54
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 temperatureIn_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InletTemperature");
55
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 enableCoupling_ = getParamFromGroup<bool>(this->paramGroup(), "Problem.EnableCoupling", true);
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 heatingOn_ = getParamFromGroup<bool>(this->paramGroup(), "Problem.EnableHeating", true);
57
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 useRobinInlet_ = getParamFromGroup<bool>(this->paramGroup(), "Problem.UseRobinInlet", true);
58
59
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 inletIndex_ = getParamFromGroup<int>(this->paramGroup(), "Problem.InletIndex");
60
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 heaterIndex_ = getParamFromGroup<int>(this->paramGroup(), "Problem.HeaterIndex");
61
62
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 const auto mode = getParamFromGroup<std::string>(this->paramGroup(), "Problem.DualNetworkSourceMode", "max");
63
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (mode == "conduction")
64 sourceMode_ = SourceMode::conduction;
65
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 else if (mode == "convection")
66 1 sourceMode_ = SourceMode::convection;
67 else
68 sourceMode_ = SourceMode::max;
69 1 }
70
71 const std::string& name() const
72
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 { return problemName_; }
73
74 16926 BoundaryTypes boundaryTypes(const Element &element, const SubControlVolume& scv) const
75 {
76
2/2
✓ Branch 0 taken 7254 times.
✓ Branch 1 taken 9672 times.
16926 BoundaryTypes values;
77 16926 values.setAllNeumann();
78
79
3/4
✓ Branch 0 taken 7254 times.
✓ Branch 1 taken 9672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2303 times.
19229 if ((!useRobinInlet_ && onInletBoundary_(scv)) || (onHeaterBoundary_(scv) && heatingOn_))
80 values.setAllDirichlet();
81
82 16926 return values;
83 }
84
85 template<class ElementVolumeVariables>
86 807711 NumEqVector source(const Element& element,
87 const FVElementGeometry& fvGeometry,
88 const ElementVolumeVariables& elemVolVars,
89 const SubControlVolume& scv) const
90 {
91
1/2
✓ Branch 0 taken 807711 times.
✗ Branch 1 not taken.
807711 NumEqVector value = 0.0;
92
93
3/4
✓ Branch 0 taken 807711 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 807237 times.
✓ Branch 5 taken 474 times.
807711 if (enableCoupling_ && couplingManager_->isCoupledPore(CouplingManager::solidDomainIdx, scv.dofIndex()))
94 {
95
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 807237 times.
807237 if (sourceMode_ == SourceMode::conduction)
96 {
97 value[Indices::energyEqIdx] = couplingManager_->conductionSource(CouplingManager::solidDomainIdx,
98 element, fvGeometry, elemVolVars, scv);
99 }
100
1/2
✓ Branch 0 taken 807237 times.
✗ Branch 1 not taken.
807237 else if (sourceMode_ == SourceMode::convection)
101 {
102 1614474 value[Indices::energyEqIdx] = couplingManager_->convectionSource(CouplingManager::solidDomainIdx,
103 element, fvGeometry, elemVolVars, scv);
104 }
105 else
106 {
107 const Scalar condSource = couplingManager_->conductionSource(CouplingManager::solidDomainIdx,
108 element, fvGeometry, elemVolVars, scv);
109 const Scalar convSource = couplingManager_->convectionSource(CouplingManager::solidDomainIdx,
110 element, fvGeometry, elemVolVars, scv);
111
112 using std::abs;
113 if (abs(condSource) > abs(convSource))
114 value[Indices::energyEqIdx] = condSource;
115 else
116 value[Indices::energyEqIdx] = convSource;
117 }
118 }
119
120 807711 value[Indices::energyEqIdx] += robinInletHeatFlux(element, fvGeometry, elemVolVars, scv);
121
122 807711 return value;
123 }
124
125 template<class ElementVolumeVariables>
126 812079 Scalar robinInletHeatFlux(const Element& element,
127 const FVElementGeometry& fvGeometry,
128 const ElementVolumeVariables& elemVolVars,
129 const SubControlVolume& scv) const
130 {
131 812079 Scalar flux = 0.0;
132
133
2/2
✓ Branch 0 taken 798480 times.
✓ Branch 1 taken 13599 times.
812079 if (useRobinInlet_ && onInletBoundary_(scv))
134 {
135
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82759 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 82759 times.
165520 const Scalar r = this->spatialParams().poreExtendedRadius(scv.dofIndex());
136
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82759 times.
82760 const auto& volVars = elemVolVars[scv];
137
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82759 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
82760 static const Scalar lambdaSolid = getParam<Scalar>("1.Component.SolidThermalConductivity");
138
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82759 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
82760 static const Scalar lambdaFluid = getParam<Scalar>("2.Component.LiquidThermalConductivity");
139
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82759 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
82760 static const Scalar dPadding = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.PaddingThickness");
140
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82759 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
82760 static const Scalar robinShapeFactor = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.RobinShapeFactor", 1.0);
141
142 82760 const Scalar lambdaHarmonic = (r + dPadding)/(r/lambdaSolid + dPadding/lambdaFluid);
143 82760 const Scalar A = M_PI * r*r * robinShapeFactor;
144
145 82760 flux = (temperatureIn_ - volVars.temperature())
146 248280 * A * lambdaHarmonic / (r + dPadding) / (scv.volume() * fvGeometry.gridGeometry().coordinationNumber()[scv.dofIndex()]);
147 }
148
149 812079 return flux;
150 }
151
152 PrimaryVariables dirichlet(const Element& element, const SubControlVolume& scv) const
153 {
154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1316 auto values = initialAtPos(scv.dofPosition());
155
156 2632 if (onInletBoundary_(scv))
157 {
158 values = temperatureIn_;
159
160 if (!dirichletValuesForOutput_.empty())
161 values = dirichletValuesForOutput_[scv.dofIndex()];
162 }
163 2632 else if (onHeaterBoundary_(scv))
164 1316 values = temperatureBottom_;
165
166 return values;
167 }
168
169 template<class ElementVolumeVariables, class ElementFluxVariablesCache>
170 NumEqVector neumann(const Element& element,
171 const FVElementGeometry& fvGeometry,
172 const ElementVolumeVariables& elemVolVars,
173 const ElementFluxVariablesCache& elemFluxVarsCache,
174 const SubControlVolumeFace& scvf) const
175 {
176 return NumEqVector(0.0);
177 }
178
179 PrimaryVariables initialAtPos(const GlobalPosition& pos) const
180 {
181
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2436 PrimaryVariables values(initialTemperature_);
182 return values;
183 }
184
185 template<class Sol>
186 1 void setInletToDirichletForOutput(const Sol& sol)
187 {
188 1 useRobinInlet_ = false;
189 1 dirichletValuesForOutput_.resize(sol.size());
190
191
4/4
✓ Branch 3 taken 560 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 560 times.
✓ Branch 6 taken 1 times.
1123 for (const auto& vertex : vertices(this->gridGeometry().gridView()))
192 {
193 1680 const auto vIdx = this->gridGeometry().vertexMapper().index(vertex);
194 1680 dirichletValuesForOutput_[vIdx] = sol[vIdx][Indices::temperatureIdx];
195 }
196 1 }
197
198 private:
199
200 bool onInletBoundary_(const SubControlVolume& scv) const
201
15/24
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1316 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1316 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 5754 times.
✓ Branch 13 taken 1500 times.
✓ Branch 14 taken 5754 times.
✓ Branch 15 taken 1500 times.
✓ Branch 16 taken 5754 times.
✓ Branch 17 taken 1500 times.
✓ Branch 18 taken 82760 times.
✓ Branch 19 taken 715720 times.
✓ Branch 20 taken 82760 times.
✓ Branch 21 taken 715720 times.
✓ Branch 22 taken 82760 times.
✓ Branch 23 taken 715720 times.
2421150 { return this->gridGeometry().poreLabel(scv.dofIndex()) == inletIndex_; }
202
203 bool onHeaterBoundary_(const SubControlVolume& scv) const
204
9/18
✓ Branch 0 taken 1316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1316 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1316 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2303 times.
✓ Branch 13 taken 13123 times.
✓ Branch 14 taken 2303 times.
✓ Branch 15 taken 13123 times.
✓ Branch 16 taken 2303 times.
✓ Branch 17 taken 13123 times.
50226 { return this->gridGeometry().poreLabel(scv.dofIndex()) == heaterIndex_; }
205
206 std::shared_ptr<const CouplingManager> couplingManager_;
207
208 std::string problemName_;
209 Scalar initialTemperature_;
210 Scalar temperatureIn_;
211 Scalar temperatureBottom_;
212 bool heatingOn_;
213 bool enableCoupling_;
214 int inletIndex_;
215 int heaterIndex_;
216 SourceMode sourceMode_;
217 bool useRobinInlet_;
218 std::vector<Scalar> dirichletValuesForOutput_;
219 };
220 } // end namespace Dumux
221
222 #endif
223