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-FileCopyrightText: 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 |
3/20✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 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 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
|
725 | 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 | 1238 | FVSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry) | |
46 | 1238 | : gridGeometry_(gridGeometry) | |
47 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
1238 | , gravity_(0.0) |
48 | { | ||
49 |
3/4✓ Branch 1 taken 840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 587 times.
|
1238 | if (getParam<bool>("Problem.EnableGravity")) |
50 | 291 | gravity_[dimWorld-1] = -9.81; | |
51 | 1238 | } | |
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 | 76622307 | Scalar extrusionFactor(const Element& element, | |
64 | const SubControlVolume& scv, | ||
65 | const ElementSolution& elemSol) const | ||
66 | { | ||
67 | // forward to generic interface | ||
68 |
17/21✓ Branch 1 taken 7340336 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 3478112 times.
✓ Branch 5 taken 644 times.
✓ Branch 7 taken 22032 times.
✓ Branch 8 taken 40896 times.
✓ Branch 10 taken 73500 times.
✓ Branch 11 taken 1319840 times.
✓ Branch 3 taken 7675 times.
✓ Branch 6 taken 534205 times.
✓ Branch 9 taken 5489 times.
✓ Branch 12 taken 80 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 20 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 105 times.
✗ Branch 19 not taken.
✓ Branch 14 taken 37180 times.
✗ Branch 20 not taken.
✓ Branch 17 taken 334400 times.
✓ Branch 0 taken 9003000 times.
|
570609768 | 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 | 218112521 | Scalar temperature(const Element& element, | |
86 | const SubControlVolume& scv, | ||
87 | const ElementSolution& elemSol) const | ||
88 | { | ||
89 | // forward to generic interface | ||
90 |
5/9✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 80 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 80 times.
✗ Branch 13 not taken.
✓ Branch 2 taken 3262 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 644 times.
|
219137889 | 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 | 215505088 | Scalar temperatureAtPos(const GlobalPosition& globalPos) const | |
98 | { | ||
99 |
4/4✓ Branch 0 taken 1307 times.
✓ Branch 1 taken 186509832 times.
✓ Branch 3 taken 440 times.
✓ Branch 4 taken 867 times.
|
215505948 | static const Scalar defaultTemperature = [] () |
100 | { | ||
101 | 440 | Scalar defaultTemp = 293.15; // 20°C | |
102 |
5/6✓ Branch 2 taken 224 times.
✓ Branch 3 taken 110 times.
✓ Branch 6 taken 71 times.
✓ Branch 7 taken 33 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
880 | if (!hasParam("SpatialParams.Temperature")) |
103 | { | ||
104 | 297 | 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 | 594 | << "Or provide the preferred domain temperature via the SpatialParams.Temperature parameter." | |
107 | 440 | << std::endl; | |
108 | } | ||
109 | 440 | const Scalar temperature = getParam<Scalar>("SpatialParams.Temperature", defaultTemp); | |
110 | 440 | return temperature; | |
111 |
1/2✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
|
650 | } (); |
112 | |||
113 | 215505088 | 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 | 43411836 | const GravityVector& gravity(const GlobalPosition& pos) const | |
127 |
8/11✓ Branch 1 taken 10808909 times.
✓ Branch 2 taken 1219510 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 91792 times.
✓ Branch 7 taken 696 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 0 taken 26331756 times.
✓ Branch 3 taken 39216 times.
✓ Branch 6 taken 116 times.
|
2199282722 | { return gravity_; } |
128 | |||
129 | //! The finite volume grid geometry | ||
130 | 444308321 | const GridGeometry& gridGeometry() const | |
131 |
18/28✓ Branch 1 taken 17619108 times.
✓ Branch 2 taken 1129728 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 83320 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2979476 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 2817816 times.
✓ Branch 16 taken 20618 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 939328 times.
✗ Branch 20 not taken.
✓ Branch 24 taken 939459 times.
✗ Branch 25 not taken.
✓ Branch 31 taken 77799 times.
✓ Branch 32 taken 861473 times.
✓ Branch 0 taken 67034088 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 12 taken 61644 times.
✓ Branch 21 taken 20652 times.
✗ Branch 22 not taken.
✓ Branch 28 taken 14658 times.
✓ Branch 29 taken 5890 times.
|
321240784 | { 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 |