GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porenetwork/solidenergy/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 19 25 76.0%
Functions: 1 4 25.0%
Branches: 38 90 42.2%

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_PORENETWORK_SOLID_ENERGY_PROBLEM_HH
8 #define DUMUX_TEST_PORENETWORK_SOLID_ENERGY_PROBLEM_HH
9
10 #include <dumux/common/properties.hh>
11 #include <dumux/common/parameters.hh>
12 #include <dumux/common/boundarytypes.hh>
13 #include <dumux/common/numeqvector.hh>
14 #include <dumux/porousmediumflow/problem.hh>
15
16 namespace Dumux {
17
18 /*!
19 * \brief Heat conduction problem with multiple solid spheres
20 */
21 template <class TypeTag>
22 class SolidProblem : 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 public:
41 template<class SpatialParams>
42 2 SolidProblem(std::shared_ptr<const GridGeometry> gridGeometry,
43 std::shared_ptr<SpatialParams> spatialParams)
44
8/24
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 2 times.
✗ 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.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
8 : ParentType(gridGeometry, spatialParams)
45 {
46
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 problemName_ = getParam<std::string>("Problem.Name");
47
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 initialTemperature_ = getParam<Scalar>("Problem.InitialTemperature");
48
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 temperatureLeft_ = getParam<Scalar>("Problem.LeftTemperature");
49
50
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 leftIndex_ = getParam<int>("Problem.LeftIndex");
51
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 rightIndex_ = getParam<int>("Problem.RightIndex");
52 2 }
53
54 const std::string& name() const
55
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 { return problemName_; }
56
57 BoundaryTypes boundaryTypes(const Element &element, const SubControlVolume& scv) const
58 {
59
2/2
✓ Branch 0 taken 14720 times.
✓ Branch 1 taken 14720 times.
29440 BoundaryTypes values;
60 29440 values.setAllNeumann();
61
62 88320 if (onLeftBoundary_(scv) || onRightBoundary_(scv))
63 values.setAllDirichlet();
64
65 return values;
66 }
67
68 template<class ElementVolumeVariables>
69 NumEqVector source(const Element& element,
70 const FVElementGeometry& fvGeometry,
71 const ElementVolumeVariables& elemVolVars,
72 const SubControlVolume& scv) const
73 {
74
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 224640 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 224640 times.
449280 NumEqVector value = 0.0; //isolating boundary condition
75 return value;
76 }
77
78 PrimaryVariables dirichlet(const Element& element, const SubControlVolume& scv) const
79 {
80
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 14720 times.
✓ Branch 3 taken 14720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29440 auto values = initialAtPos(scv.dofPosition()); //onRightBoundary_(scv)
81
82 58880 if (onLeftBoundary_(scv))
83 {
84 14720 values = temperatureLeft_;
85 }
86
87 return values;
88 }
89
90 PrimaryVariables initialAtPos(const GlobalPosition& pos) const
91 {
92
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 14720 times.
✓ Branch 3 taken 14720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29696 PrimaryVariables values(initialTemperature_); //uniform initial temperature
93 return values;
94 }
95
96 private:
97
98 bool onLeftBoundary_(const SubControlVolume& scv) const
99
12/24
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 14720 times.
✓ Branch 7 taken 14720 times.
✓ Branch 8 taken 14720 times.
✓ Branch 9 taken 14720 times.
✓ Branch 10 taken 14720 times.
✓ Branch 11 taken 14720 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 14720 times.
✓ Branch 19 taken 14720 times.
✓ Branch 20 taken 14720 times.
✓ Branch 21 taken 14720 times.
✓ Branch 22 taken 14720 times.
✓ Branch 23 taken 14720 times.
176640 { return this->gridGeometry().poreLabel(scv.dofIndex()) == leftIndex_; }
100
101 bool onRightBoundary_(const SubControlVolume& scv) const
102
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14720 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14720 times.
44160 { return this->gridGeometry().poreLabel(scv.dofIndex()) == rightIndex_; }
103
104 std::string problemName_;
105
106 Scalar initialTemperature_;
107 Scalar temperatureLeft_;
108
109 int leftIndex_;
110 int rightIndex_;
111 };
112
113 } // end namespace Dumux
114
115 #endif
116