GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/fvspatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 18 26 69.2%
Functions: 300 1195 25.1%
Branches: 113 235 48.1%

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 Core
10 * \ingroup SpatialParameters
11 * \brief Basic spatial parameters to be used with finite-volume schemes.
12 */
13 #ifndef DUMUX_COMMON_FV_SPATIAL_PARAMS_HH
14 #define DUMUX_COMMON_FV_SPATIAL_PARAMS_HH
15
16 #include <memory>
17
18 #include <dune/common/fvector.hh>
19 #include <dune/common/exceptions.hh>
20
21 #include <dumux/common/parameters.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup Core
27 * \ingroup SpatialParameters
28 * \brief The base class for spatial parameters used with finite-volume schemes.
29 */
30 template<class GridGeometry,
31 class Scalar,
32 class Implementation>
33
6/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 329 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 139 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 18 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ 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 29 not taken.
661 class FVSpatialParams
34 {
35 using GridView = typename GridGeometry::GridView;
36 using Element = typename GridView::template Codim<0>::Entity;
37 using SubControlVolume = typename GridGeometry::SubControlVolume;
38
39 static constexpr int dimWorld = GridView::dimensionworld;
40
41 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
42 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
43
44 public:
45 1112 FVSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
46 : gridGeometry_(gridGeometry)
47
1/5
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1112 , gravity_(0.0)
48 {
49
3/4
✓ Branch 1 taken 749 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203 times.
✓ Branch 4 taken 546 times.
1112 if (getParam<bool>("Problem.EnableGravity"))
50 455 gravity_[dimWorld-1] = -9.81;
51 1112 }
52
53 /*!
54 * \brief Return how much the domain is extruded at a given sub-control volume.
55 *
56 * This means the factor by which a lower-dimensional (1D or 2D)
57 * entity needs to be expanded to get a full dimensional cell. The
58 * default is 1.0 which means that 1D problems are actually
59 * thought as pipes with a cross section of 1 m^2 and 2D problems
60 * are assumed to extend 1 m to the back.
61 */
62 template<class ElementSolution>
63 Scalar extrusionFactor(const Element& element,
64 const SubControlVolume& scv,
65 const ElementSolution& elemSol) const
66 {
67 // forward to generic interface
68
44/59
✓ Branch 0 taken 9003000 times.
✓ Branch 1 taken 7352392 times.
✓ Branch 2 taken 9003000 times.
✓ Branch 3 taken 6426620 times.
✓ Branch 4 taken 928712 times.
✓ Branch 5 taken 792000 times.
✓ Branch 6 taken 2940 times.
✓ Branch 7 taken 393340 times.
✓ Branch 8 taken 792000 times.
✓ Branch 9 taken 6864 times.
✓ Branch 10 taken 393340 times.
✓ Branch 11 taken 40896 times.
✓ Branch 12 taken 6864 times.
✓ Branch 13 taken 106700 times.
✓ Branch 14 taken 40896 times.
✓ Branch 15 taken 3179720 times.
✓ Branch 16 taken 106700 times.
✓ Branch 17 taken 6768 times.
✓ Branch 18 taken 3179720 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 6768 times.
✓ Branch 21 taken 1395105 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 1056 times.
✓ Branch 24 taken 1395105 times.
✓ Branch 25 taken 9120 times.
✓ Branch 26 taken 1056 times.
✓ Branch 27 taken 37120 times.
✓ Branch 28 taken 9120 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 37120 times.
✓ Branch 31 taken 542815 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 542815 times.
✓ Branch 35 taken 334412 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 334412 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 477951 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 477951 times.
✓ Branch 45 taken 3310 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 48 times.
✓ Branch 48 taken 3310 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 48 times.
✗ Branch 51 not taken.
✓ Branch 53 taken 3384 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 3384 times.
✓ Branch 57 taken 21948 times.
✗ Branch 58 not taken.
✓ Branch 60 taken 21948 times.
✗ Branch 61 not taken.
✓ Branch 73 taken 528 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 528 times.
✗ Branch 77 not taken.
974237744 return asImp_().extrusionFactorAtPos(scv.center());
69 }
70
71 /*!
72 * \brief Return how much the domain is extruded at a given position.
73 */
74 Scalar extrusionFactorAtPos(const GlobalPosition& globalPos) const
75 {
76 // As a default, i.e. if the user's spatial parameters do not overload
77 // any extrusion factor method, return 1.0
78 return 1.0;
79 }
80
81 /*!
82 * \brief Return the temperature in the given sub-control volume.
83 */
84 template<class ElementSolution>
85 Scalar temperature(const Element& element,
86 const SubControlVolume& scv,
87 const ElementSolution& elemSol) const
88 {
89 // forward to generic interface
90
8/49
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2940 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2940 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 12160 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 12160 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 80 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 80 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 80 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 80 times.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
305540313 return asImp_().temperatureAtPos(scv.center());
91 }
92
93 /*!
94 * \brief Return the temperature in the domain at the given position
95 * \param globalPos The position in global coordinates where the temperature should be specified.
96 */
97 Scalar temperatureAtPos(const GlobalPosition& globalPos) const
98 {
99
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
186 static const Scalar defaultTemperature = [] ()
100 {
101 388 Scalar defaultTemp = 293.15; // 20°C
102
8/14
✓ Branch 1 taken 202 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 202 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 202 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 202 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 124 times.
✓ Branch 12 taken 78 times.
✓ Branch 13 taken 124 times.
✓ Branch 14 taken 78 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
1940 if (!hasParam("SpatialParams.Temperature"))
103 {
104 264 std::cout << " -- Using the default temperature of " << defaultTemp << " in the entire domain. "
105 << "Overload temperatureAtPos() in your spatial params class to define a custom temperature field."
106 792 << "Or provide the preferred domain temperature via the SpatialParams.Temperature parameter."
107 264 << std::endl;
108 }
109 388 const Scalar temperature = getParam<Scalar>("SpatialParams.Temperature", defaultTemp);
110 388 return temperature;
111 } ();
112
113 return defaultTemperature;
114 }
115
116 /*!
117 * \brief Returns the acceleration due to gravity \f$\mathrm{[m/s^2]}\f$.
118 *
119 * The default behaviour is a constant gravity vector;
120 * if the <tt>Problem.EnableGravity</tt> parameter is true,
121 * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$,
122 * else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$.
123 *
124 * \param pos the spatial position at which to evaluate the gravity vector
125 */
126 const GravityVector& gravity(const GlobalPosition& pos) const
127
5/6
✓ Branch 0 taken 22330032 times.
✓ Branch 1 taken 10764764 times.
✓ Branch 2 taken 1198420 times.
✓ Branch 3 taken 39216 times.
✓ Branch 4 taken 1344 times.
✗ Branch 5 not taken.
2061116432 { return gravity_; }
128
129 //! The finite volume grid geometry
130 const GridGeometry& gridGeometry() const
131
38/62
✓ Branch 0 taken 67034088 times.
✓ Branch 1 taken 17440094 times.
✓ Branch 2 taken 67034090 times.
✓ Branch 3 taken 17477552 times.
✓ Branch 4 taken 67034094 times.
✓ Branch 5 taken 17440090 times.
✓ Branch 6 taken 67071552 times.
✓ Branch 7 taken 17440094 times.
✓ Branch 8 taken 2522978 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2522980 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2522976 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2522976 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1092264 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1092264 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1175584 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1175584 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 1092264 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 4133384 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4133384 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 1092264 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 2817816 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 2817816 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✓ Branch 38 taken 20618 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 20618 times.
✗ Branch 41 not taken.
✓ Branch 44 taken 939328 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 939328 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 20652 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 20652 times.
✗ Branch 51 not taken.
✓ Branch 54 taken 939459 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 939459 times.
✗ Branch 57 not taken.
✓ Branch 66 taken 14658 times.
✓ Branch 67 taken 5890 times.
✓ Branch 68 taken 14658 times.
✓ Branch 69 taken 5890 times.
✓ Branch 72 taken 77799 times.
✓ Branch 73 taken 861473 times.
✓ Branch 74 taken 77799 times.
✓ Branch 75 taken 861473 times.
518937784 { return *gridGeometry_; }
132
133 protected:
134 //! Returns the implementation of the spatial parameters (static polymorphism)
135 Implementation &asImp_()
136 { return *static_cast<Implementation *>(this); }
137
138 //! \copydoc asImp_()
139 const Implementation &asImp_() const
140 { return *static_cast<const Implementation *>(this); }
141
142 private:
143 std::shared_ptr<const GridGeometry> gridGeometry_;
144 GravityVector gravity_;
145 };
146
147 } // namespace Dumux
148
149 #endif
150