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 The base class for spatial parameters in porous medium problems. | ||
12 | */ | ||
13 | #ifndef DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH | ||
14 | #define DUMUX_POROUS_MEDIUM_FV_SPATIAL_PARAMS_HH | ||
15 | |||
16 | #include <dumux/common/fvspatialparams.hh> | ||
17 | #include <dumux/common/typetraits/isvalid.hh> | ||
18 | |||
19 | namespace Dumux { | ||
20 | |||
21 | #ifndef DOXYGEN | ||
22 | namespace Detail { | ||
23 | template<class GlobalPosition, class SolidSystem> | ||
24 | struct hasInertVolumeFractionAtPos | ||
25 | { | ||
26 | template<class SpatialParams> | ||
27 | auto operator()(const SpatialParams& a) | ||
28 | -> decltype(a.template inertVolumeFractionAtPos<SolidSystem>(std::declval<GlobalPosition>(), 0)) | ||
29 | {} | ||
30 | }; | ||
31 | |||
32 | template<class GlobalPosition> | ||
33 | struct hasPorosityAtPos | ||
34 | { | ||
35 | template<class SpatialParams> | ||
36 | auto operator()(const SpatialParams& a) | ||
37 | -> decltype(a.porosityAtPos(std::declval<GlobalPosition>())) | ||
38 | {} | ||
39 | }; | ||
40 | } // end namespace Detail | ||
41 | #endif | ||
42 | |||
43 | /*! | ||
44 | * \ingroup Core | ||
45 | * \ingroup SpatialParameters | ||
46 | * \brief The base class for spatial parameters of porous-medium problems. | ||
47 | */ | ||
48 | template<class GridGeometry, class Scalar, class Implementation> | ||
49 |
3/20✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 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.
|
459 | class FVPorousMediumSpatialParams |
50 | : public FVSpatialParams<GridGeometry, Scalar, Implementation> | ||
51 | { | ||
52 | using ParentType = FVSpatialParams<GridGeometry, Scalar, Implementation>; | ||
53 | using GridView = typename GridGeometry::GridView; | ||
54 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
55 | using SubControlVolume = typename GridGeometry::SubControlVolume; | ||
56 | using Element = typename GridView::template Codim<0>::Entity; | ||
57 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
58 | |||
59 | public: | ||
60 | 756 | FVPorousMediumSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry) | |
61 |
1/2✓ Branch 2 taken 567 times.
✗ Branch 3 not taken.
|
756 | : ParentType(gridGeometry) |
62 | 756 | {} | |
63 | |||
64 | /*! | ||
65 | * \brief Function for defining the porosity. | ||
66 | * That is possibly solution dependent. | ||
67 | * \note this can only be used for solids with one inert component | ||
68 | * (see inertVolumeFraction for the more general interface) | ||
69 | * \param element The current element | ||
70 | * \param scv The sub-control volume inside the element. | ||
71 | * \param elemSol The solution at the dofs connected to the element. | ||
72 | * \return the porosity | ||
73 | */ | ||
74 | template<class ElementSolution> | ||
75 | 143040869 | Scalar porosity(const Element& element, | |
76 | const SubControlVolume& scv, | ||
77 | const ElementSolution& elemSol) const | ||
78 | { | ||
79 | static_assert(decltype(isValid(Detail::hasPorosityAtPos<GlobalPosition>())(this->asImp_()))::value," \n\n" | ||
80 | " Your spatial params class has to either implement\n\n" | ||
81 | " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n" | ||
82 | " or overload this function\n\n" | ||
83 | " template<class ElementSolution>\n" | ||
84 | " Scalar porosity(const Element& element,\n" | ||
85 | " const SubControlVolume& scv,\n" | ||
86 | " const ElementSolution& elemSol) const\n\n"); | ||
87 | |||
88 |
1/2✓ Branch 1 taken 661 times.
✗ Branch 2 not taken.
|
256667972 | return this->asImp_().porosityAtPos(scv.center()); |
89 | } | ||
90 | |||
91 | /*! | ||
92 | * \brief Function for defining the solid volume fraction. | ||
93 | * That is possibly solution dependent. | ||
94 | * | ||
95 | * \param element The current element | ||
96 | * \param scv The sub-control volume inside the element. | ||
97 | * \param elemSol The solution at the dofs connected to the element. | ||
98 | * \param compIdx The solid component index | ||
99 | * \return the volume fraction of the inert solid component with index compIdx | ||
100 | * | ||
101 | * \note this overload is enable if there is only one inert solid component and the | ||
102 | * user didn't choose to implement a inertVolumeFractionAtPos overload. | ||
103 | * It then forwards to the simpler porosity interface. | ||
104 | * With more than one solid components or active solid components (i.e. dissolution) | ||
105 | * please overload the more general inertVolumeFraction/inertVolumeFractionAtPos interface. | ||
106 | */ | ||
107 | template<class SolidSystem, class ElementSolution, | ||
108 | typename std::enable_if_t<SolidSystem::isInert() | ||
109 | && SolidSystem::numInertComponents == 1 | ||
110 | && !decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(std::declval<Implementation>()))::value, | ||
111 | int> = 0> | ||
112 | 212321339 | Scalar inertVolumeFraction(const Element& element, | |
113 | const SubControlVolume& scv, | ||
114 | const ElementSolution& elemSol, | ||
115 | int compIdx) const | ||
116 | { | ||
117 |
6/7✓ Branch 1 taken 18975292 times.
✓ Branch 2 taken 31063599 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✓ Branch 3 taken 2322371 times.
✗ Branch 6 not taken.
✓ Branch 0 taken 43379345 times.
|
352595632 | return 1.0 - this->asImp_().porosity(element, scv, elemSol); |
118 | } | ||
119 | |||
120 | // specialization if there are no inert components at all | ||
121 | template<class SolidSystem, class ElementSolution, | ||
122 | typename std::enable_if_t<SolidSystem::numInertComponents == 0, int> = 0> | ||
123 | Scalar inertVolumeFraction(const Element& element, | ||
124 | const SubControlVolume& scv, | ||
125 | const ElementSolution& elemSol, | ||
126 | int compIdx) const | ||
127 | { | ||
128 | return 0.0; | ||
129 | } | ||
130 | |||
131 | // the more general interface forwarding to inertVolumeFractionAtPos | ||
132 | template<class SolidSystem, class ElementSolution, | ||
133 | typename std::enable_if_t<(SolidSystem::numInertComponents > 1) || | ||
134 | ( | ||
135 | (SolidSystem::numInertComponents > 0) && | ||
136 | ( | ||
137 | !SolidSystem::isInert() | ||
138 | || decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>()) | ||
139 | (std::declval<Implementation>()))::value | ||
140 | ) | ||
141 | ), | ||
142 | int> = 0> | ||
143 | 5107147 | Scalar inertVolumeFraction(const Element& element, | |
144 | const SubControlVolume& scv, | ||
145 | const ElementSolution& elemSol, | ||
146 | int compIdx) const | ||
147 | { | ||
148 | static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos<GlobalPosition, SolidSystem>())(this->asImp_()))::value," \n\n" | ||
149 | " Your spatial params class has to either implement\n\n" | ||
150 | " template<class SolidSystem>\n" | ||
151 | " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" | ||
152 | " or overload this function\n\n" | ||
153 | " template<class SolidSystem, class ElementSolution>\n" | ||
154 | " Scalar inertVolumeFraction(const Element& element,\n" | ||
155 | " const SubControlVolume& scv,\n" | ||
156 | " const ElementSolution& elemSol,\n" | ||
157 | " int compIdx) const\n\n"); | ||
158 | |||
159 | 5107147 | return this->asImp_().template inertVolumeFractionAtPos<SolidSystem>(scv.center(), compIdx); | |
160 | } | ||
161 | }; | ||
162 | |||
163 | } // namespace Dumux | ||
164 | |||
165 | #endif | ||
166 |