GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/solidenergy/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 29 36 80.6%
Functions: 3 6 50.0%
Branches: 19 38 50.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 /**
8 * \file
9 * \ingroup SolidEnergyTests
10 * \brief A piece of stone heated by a network of channels
11 */
12 #ifndef DUMUX_TEST_SOLIDENERGY_PROBLEM_HH
13 #define DUMUX_TEST_SOLIDENERGY_PROBLEM_HH
14
15 #include <string>
16 #include <cmath>
17
18 #include <dumux/common/boundarytypes.hh>
19 #include <dumux/common/parameters.hh>
20 #include <dumux/common/properties.hh>
21 #include <dumux/common/numeqvector.hh>
22 #include <dumux/porousmediumflow/problem.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup SolidEnergyTests
28 * \brief A piece of stone heated by a network of channels
29 */
30 template <class TypeTag>
31 class SolidEnergyProblem : public PorousMediumFlowProblem<TypeTag>
32 {
33 using ParentType = PorousMediumFlowProblem<TypeTag>;
34 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
35 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
36 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
37 using NeumannValues = Dumux::NumEqVector<PrimaryVariables>;
38 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
39 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
40 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
41 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
42
43 using Element = typename GridView::template Codim<0>::Entity;
44 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
45 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
46 using FVElementGeometry = typename GridGeometry::LocalView;
47 using SubControlVolume = typename GridGeometry::SubControlVolume;
48 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
49 using PointSource = GetPropType<TypeTag, Properties::PointSource>;
50
51 public:
52 1 SolidEnergyProblem(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
53
3/10
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
2 : ParentType(gridGeometry, paramGroup)
54 {
55
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 name_ = getParam<std::string>("Problem.Name");
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 temperatureHigh_ = getParam<Scalar>("Problem.TemperatureHigh");
57
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 temperatureInit_ = getParam<Scalar>("Problem.TemperatureInit");
58
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 lambdaSolid_ = getParam<Scalar>("Component.SolidThermalConductivity");
59 1 }
60
61 /*!
62 * \name Problem parameters
63 */
64 // \{
65
66 /*!
67 * \brief The problem name.
68 *
69 * This is used as a prefix for files generated by the simulation.
70 */
71 const std::string& name() const
72 {
73
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 return name_;
74 }
75 // \}
76
77 /*!
78 * \name Boundary conditions
79 */
80 // \{
81
82 /*!
83 * \brief Specifies which kind of boundary condition should be
84 * used for which equation on a given boundary segment.
85 *
86 * \param globalPos The position for which the bc type should be evaluated
87 */
88 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
89 {
90
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16000 times.
24000 BoundaryTypes bcTypes;
91
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16000 times.
24000 bcTypes.setAllNeumann();
92 return bcTypes;
93 }
94
95 /*!
96 * \brief Evaluate the boundary conditions for a neumann
97 * boundary segment.
98 *
99 * This is the method for the case where the Neumann condition is
100 * potentially solution dependent
101 *
102 * \param element The finite element
103 * \param fvGeometry The finite-volume geometry
104 * \param elemVolVars All volume variables for the element
105 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
106 * \param scvf The sub control volume face
107 *
108 * Negative values mean influx.
109 * E.g. for the mass balance that would the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$.
110 */
111 NeumannValues neumann(const Element& element,
112 const FVElementGeometry& fvGeometry,
113 const ElementVolumeVariables& elemVolVars,
114 const ElementFluxVariablesCache& elemFluxVarsCache,
115 const SubControlVolumeFace& scvf) const
116 {
117 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
118 const Scalar value = 0.02*(volVars.temperatureSolid() - temperatureInit_)/0.002;
119 return NeumannValues(value);
120 }
121
122
123
124 // \}
125
126 /*!
127 * \name Volume terms
128 */
129 // \{
130
131 /*!
132 * \brief Evaluate the initial value for a control volume.
133 *
134 * \param globalPos The position for which the initial condition should be evaluated
135 *
136 * For this method, the \a values parameter stores primary
137 * variables.
138 */
139 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
140 {
141 20000 return PrimaryVariables(temperatureInit_);
142 }
143
144 /*!
145 * \brief Applies a vector of point sources. The point sources
146 * are possibly solution dependent.
147 *
148 * \param pointSources A vector of PointSource s that contain
149 source values for all phases and space positions.
150 *
151 * For this method, the values method of the point source
152 * has to return the absolute rate values in units
153 * \f$ [ \textnormal{unit of conserved quantity} / s ] \f$.
154 * Positive values mean that the conserved quantity is created, negative ones mean that it vanishes.
155 * E.g. for the mass balance that would be a mass rate in \f$ [ kg / s ] \f$.
156 */
157 1 void addPointSources(std::vector<PointSource>& pointSources) const
158 {
159 // add point sources along a sinus
160 1 const auto& gg = this->gridGeometry();
161 4 const auto ampl = (gg.bBoxMax()[1] - gg.bBoxMin()[1])/3.0;
162 4 const auto len = (gg.bBoxMax()[0] - gg.bBoxMin()[0]);
163 1 const auto freq = 1.0/len;
164
165
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1 times.
101 for (int i = 0; i < 100; ++i)
166 {
167 100 const auto posx = double(i)/99.0*len;
168 100 const auto posy = ampl*std::sin(2*M_PI*freq*posx) + ampl*3.0/2.0;
169 300 pointSources.emplace_back(GlobalPosition({posx, posy}), typename PointSource::Values({len/100.0}));
170 }
171 1 }
172
173 /*!
174 * \brief Evaluate the point sources (added by addPointSources)
175 * for all phases within a given sub-control-volume.
176 *
177 * This is the method for the case where the point source is
178 * solution dependent
179 *
180 * \param source A single point source
181 * \param element The finite element
182 * \param fvGeometry The finite-volume geometry
183 * \param elemVolVars All volume variables for the element
184 * \param scv The sub control volume
185 *
186 * For this method, the values() method of the point sources returns
187 * the absolute conserved quantity rate generated or annihilate in
188 * units \f$ [ \textnormal{unit of conserved quantity} / s ] \f$.
189 * Positive values mean that the conserved quantity is created, negative ones mean that it vanishes.
190 * E.g. for the mass balance that would be a mass rate in \f$ [ kg / s ] \f$.
191 */
192 4080 void pointSource(PointSource& source,
193 const Element &element,
194 const FVElementGeometry& fvGeometry,
195 const ElementVolumeVariables& elemVolVars,
196 const SubControlVolume &scv) const
197 {
198 4080 const auto& volVars = elemVolVars[scv];
199 4080 const Scalar charLen = 0.1;
200
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4079 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
4080 static const Scalar nusselt = getParam<Scalar>("Problem.NusseltNumber");
201 4080 const Scalar interfacialArea = 2*M_PI*0.001;
202 4080 const Scalar lambdaSolidFluidTransfer = lambdaSolid_;
203 8160 source *= -nusselt*interfacialArea*lambdaSolidFluidTransfer*(volVars.temperatureSolid() - temperatureHigh_)/charLen;
204 4080 }
205
206 // \}
207
208 private:
209 Scalar temperatureHigh_, temperatureInit_, lambdaSolid_;
210 static constexpr Scalar eps_ = 1e-6;
211 std::string name_;
212 };
213
214 } //end namespace Dumux
215
216 #endif
217