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 DiamondDiscretization | ||
10 | * \copydoc Dumux::FaceCenteredDiamondFVGridGeometry | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_FV_GRID_GEOMETRY | ||
13 | #define DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_FV_GRID_GEOMETRY | ||
14 | |||
15 | #include <memory> | ||
16 | #include <unordered_map> | ||
17 | |||
18 | #include <dune/grid/common/mcmgmapper.hh> | ||
19 | #include <dune/geometry/type.hh> | ||
20 | |||
21 | #include <dumux/common/defaultmappertraits.hh> | ||
22 | #include <dumux/common/indextraits.hh> | ||
23 | #include <dumux/common/math.hh> | ||
24 | #include <dumux/geometry/volume.hh> | ||
25 | #include <dumux/geometry/center.hh> | ||
26 | #include <dumux/discretization/basegridgeometry.hh> | ||
27 | #include <dumux/discretization/checkoverlapsize.hh> | ||
28 | #include <dumux/discretization/method.hh> | ||
29 | #include <dumux/discretization/extrusion.hh> | ||
30 | #include <dumux/discretization/nonconformingfecache.hh> | ||
31 | |||
32 | #include <dumux/discretization/facecentered/diamond/subcontrolvolume.hh> | ||
33 | #include <dumux/discretization/facecentered/diamond/subcontrolvolumeface.hh> | ||
34 | #include <dumux/discretization/facecentered/diamond/fvelementgeometry.hh> | ||
35 | #include <dumux/discretization/facecentered/diamond/geometryhelper.hh> | ||
36 | |||
37 | namespace Dumux { | ||
38 | |||
39 | namespace Detail { | ||
40 | template<class GV, class T> | ||
41 | using FaceCenteredDiamondGeometryHelper_t = Dune::Std::detected_or_t< | ||
42 | Dumux::DiamondGeometryHelper<GV, typename T::SubControlVolume, typename T::SubControlVolumeFace>, | ||
43 | SpecifiesGeometryHelper, | ||
44 | T | ||
45 | >; | ||
46 | } // end namespace Detail | ||
47 | |||
48 | /*! | ||
49 | * \ingroup DiamondDiscretization | ||
50 | * \brief The default traits for the face-centered diamond finite volume grid geometry | ||
51 | * Defines the scv and scvf types and the mapper types | ||
52 | * \tparam GridView the grid view type | ||
53 | */ | ||
54 | template<class GridView> | ||
55 | struct FaceCenteredDiamondDefaultGridGeometryTraits : public DefaultMapperTraits<GridView> | ||
56 | { | ||
57 | using SubControlVolume = FaceCenteredDiamondSubControlVolume<GridView>; | ||
58 | using SubControlVolumeFace = FaceCenteredDiamondSubControlVolumeFace<GridView>; | ||
59 | using DofMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>; | ||
60 | |||
61 | template<class GridGeometry, bool enableCache> | ||
62 | using LocalView = FaceCenteredDiamondFVElementGeometry<GridGeometry, enableCache>; | ||
63 | }; | ||
64 | |||
65 | /*! | ||
66 | * \ingroup DiamondDiscretization | ||
67 | * \brief Grid geometry for the diamond discretization | ||
68 | */ | ||
69 | template<class GV, | ||
70 | bool enableCaching = true, | ||
71 | class Traits = FaceCenteredDiamondDefaultGridGeometryTraits<GV>> | ||
72 | class FaceCenteredDiamondFVGridGeometry | ||
73 | : public BaseGridGeometry<GV, Traits> | ||
74 | { | ||
75 | using ThisType = FaceCenteredDiamondFVGridGeometry<GV, enableCaching, Traits>; | ||
76 | using ParentType = BaseGridGeometry<GV, Traits>; | ||
77 | using GridIndexType = typename IndexTraits<GV>::GridIndex; | ||
78 | using LocalIndexType = typename IndexTraits<GV>::SmallLocalIndex; | ||
79 | using Element = typename GV::template Codim<0>::Entity; | ||
80 | |||
81 | using Scalar = typename GV::ctype; | ||
82 | |||
83 | static const int dim = GV::dimension; | ||
84 | static const int dimWorld = GV::dimensionworld; | ||
85 | |||
86 | static_assert(dim > 1, "Only implemented for dim > 1"); | ||
87 | |||
88 | public: | ||
89 | //! export discretization method | ||
90 | using DiscretizationMethod = DiscretizationMethods::FCDiamond; | ||
91 | static constexpr DiscretizationMethod discMethod = DiscretizationMethod{}; | ||
92 | static constexpr bool cachingEnabled = true; | ||
93 | |||
94 | //! export the type of the fv element geometry (the local view type) | ||
95 | using LocalView = typename Traits::template LocalView<ThisType, true>; | ||
96 | //! export the type of sub control volume | ||
97 | using SubControlVolume = typename Traits::SubControlVolume; | ||
98 | //! export the type of sub control volume | ||
99 | using SubControlVolumeFace = typename Traits::SubControlVolumeFace; | ||
100 | //! export the grid view type | ||
101 | using GridView = GV; | ||
102 | //! export the dof mapper type | ||
103 | using DofMapper = typename Traits::DofMapper; | ||
104 | //! export the type of extrusion | ||
105 | using Extrusion = Extrusion_t<Traits>; | ||
106 | //! export the finite element cache type | ||
107 | using FeCache = NonconformingFECache<Scalar, Scalar, dim>; | ||
108 | |||
109 | //! Constructor | ||
110 | 21 | FaceCenteredDiamondFVGridGeometry(const GridView& gridView, const std::string& paramGroup = "") | |
111 | : ParentType(gridView) | ||
112 | , dofMapper_(gridView, Dune::mcmgLayout(Dune::Codim<1>{})) | ||
113 |
6/16✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 21 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 21 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
63 | , cache_(*this) |
114 | { | ||
115 | 21 | update_(); | |
116 | 21 | } | |
117 | |||
118 | //! The total number of sub control volumes | ||
119 | std::size_t numScv() const | ||
120 | { return numScv_; } | ||
121 | |||
122 | //! The total number of sub control volume faces | ||
123 | std::size_t numScvf() const | ||
124 | { return numScvf_; } | ||
125 | |||
126 | //! The total number of boundary sub control volume faces | ||
127 | ✗ | std::size_t numBoundaryScvf() const | |
128 | ✗ | { return numBoundaryScvf_; } | |
129 | |||
130 | //! the total number of dofs | ||
131 | std::size_t numDofs() const | ||
132 |
14/25✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 13 times.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 3 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 3 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 30 taken 5 times.
✗ Branch 31 not taken.
✓ Branch 35 taken 2 times.
✗ Branch 36 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
|
233 | { return this->gridView().size(1); } |
133 | |||
134 | //! update all fvElementGeometries (call this after grid adaption) | ||
135 | void update(const GridView& gridView) | ||
136 | { | ||
137 | ParentType::update(gridView); | ||
138 | update_(); | ||
139 | } | ||
140 | |||
141 | //! update all fvElementGeometries (call this after grid adaption) | ||
142 | void update(GridView&& gridView) | ||
143 | { | ||
144 | ParentType::update(std::move(gridView)); | ||
145 | update_(); | ||
146 | } | ||
147 | |||
148 | //! The finite element cache for creating local FE bases | ||
149 | const FeCache& feCache() const | ||
150 |
0/2✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
36177620 | { return feCache_; } |
151 | |||
152 | //! If a face / d.o.f. is on the boundary | ||
153 | bool dofOnBoundary(GridIndexType dofIdx) const | ||
154 |
4/8✓ Branch 0 taken 30380 times.
✓ Branch 1 taken 1848852 times.
✓ Branch 2 taken 30380 times.
✓ Branch 3 taken 1848852 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3758464 | { return boundaryDofIndices_[dofIdx]; } |
155 | |||
156 | //! Return a reference to the dof mapper | ||
157 | const DofMapper& dofMapper() const | ||
158 |
3/7✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
59208354 | { return dofMapper_; } |
159 | |||
160 | //! If a d.o.f. is on a periodic boundary | ||
161 | bool dofOnPeriodicBoundary(GridIndexType dofIdx) const | ||
162 |
1/4✗ Branch 1 not taken.
✓ Branch 2 taken 27608 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
27608 | { return periodicFaceMap_.count(dofIdx); } |
163 | |||
164 | //! The index of the d.o.f. on the other side of the periodic boundary | ||
165 | GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const | ||
166 | ✗ | { return periodicFaceMap_.at(dofIdx); } | |
167 | |||
168 | //! Returns the map between dofs across periodic boundaries | ||
169 | const std::unordered_map<GridIndexType, GridIndexType>& periodicDofMap() const | ||
170 | 39 | { return periodicFaceMap_; } | |
171 | |||
172 | //! Returns the map between dofs across periodic boundaries | ||
173 | [[deprecated("Will be removed after release 3.9. Use periodicDofMap() instead.")]] | ||
174 | const std::unordered_map<GridIndexType, GridIndexType>& periodicVertexMap() const | ||
175 | { return periodicDofMap(); } | ||
176 | |||
177 | //! local view of this object (constructed with the internal cache) | ||
178 | friend inline LocalView localView(const FaceCenteredDiamondFVGridGeometry& gg) | ||
179 |
24/35✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 11 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 11 times.
✓ Branch 13 taken 42002 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 10278 times.
✓ Branch 16 taken 42002 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 10278 times.
✓ Branch 19 taken 603 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 30836 times.
✓ Branch 22 taken 603 times.
✓ Branch 23 taken 2 times.
✓ Branch 24 taken 30836 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 2 times.
✓ Branch 27 taken 22 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 22 times.
✗ Branch 31 not taken.
✓ Branch 39 taken 2 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 2 times.
✗ Branch 43 not taken.
|
1451300 | { return { gg.cache_ }; } |
180 | |||
181 | private: | ||
182 | |||
183 | class FCDiamondGridGeometryCache | ||
184 | { | ||
185 | friend class FaceCenteredDiamondFVGridGeometry; | ||
186 | public: | ||
187 | //! export the geometry helper type | ||
188 | using GeometryHelper = Detail::FaceCenteredDiamondGeometryHelper_t<GV, Traits>; | ||
189 | |||
190 | 21 | explicit FCDiamondGridGeometryCache(const FaceCenteredDiamondFVGridGeometry& gg) | |
191 |
4/8✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 21 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
84 | : gridGeometry_(&gg) |
192 | {} | ||
193 | |||
194 | ✗ | const FaceCenteredDiamondFVGridGeometry& gridGeometry() const | |
195 | ✗ | { return *gridGeometry_; } | |
196 | |||
197 | //! Get the global sub control volume indices of an element | ||
198 | const std::vector<SubControlVolume>& scvs(GridIndexType eIdx) const | ||
199 |
12/16✓ Branch 0 taken 5600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5603 times.
✓ Branch 3 taken 155224 times.
✓ Branch 4 taken 5603 times.
✓ Branch 5 taken 155224 times.
✓ Branch 6 taken 36608 times.
✓ Branch 7 taken 109330 times.
✓ Branch 8 taken 36608 times.
✓ Branch 9 taken 74416 times.
✓ Branch 10 taken 34914 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 30834 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 30834 times.
✗ Branch 17 not taken.
|
115410483 | { return scvs_[eIdx]; } |
200 | |||
201 | //! Get the global sub control volume face indices of an element | ||
202 | const std::vector<SubControlVolumeFace>& scvfs(GridIndexType eIdx) const | ||
203 |
2/4✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
|
8145385 | { return scvfs_[eIdx]; } |
204 | |||
205 | //! Returns whether one of the geometry's scvfs lies on a boundary | ||
206 | bool hasBoundaryScvf(GridIndexType eIdx) const | ||
207 |
4/8✓ Branch 0 taken 682 times.
✓ Branch 1 taken 28267 times.
✓ Branch 2 taken 682 times.
✓ Branch 3 taken 28267 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
57898 | { return hasBoundaryScvf_[eIdx]; } |
208 | |||
209 | private: | ||
210 | 21 | void clear_() | |
211 | { | ||
212 | 21 | scvs_.clear(); | |
213 | 21 | scvfs_.clear(); | |
214 | 42 | hasBoundaryScvf_.clear(); | |
215 | 21 | } | |
216 | |||
217 | std::vector<std::vector<SubControlVolume>> scvs_; | ||
218 | std::vector<std::vector<SubControlVolumeFace>> scvfs_; | ||
219 | std::vector<bool> hasBoundaryScvf_; | ||
220 | |||
221 | const FaceCenteredDiamondFVGridGeometry* gridGeometry_; | ||
222 | }; | ||
223 | |||
224 | public: | ||
225 | //! the cache type (only the caching implementation has this) | ||
226 | //! this alias should only be used by the local view implementation | ||
227 | using Cache = FCDiamondGridGeometryCache; | ||
228 | private: | ||
229 | using GeometryHelper = typename Cache::GeometryHelper; | ||
230 | |||
231 | //! update all fvElementGeometries | ||
232 | 21 | void update_() | |
233 | { | ||
234 | // clear containers (necessary after grid refinement) | ||
235 | 21 | cache_.clear_(); | |
236 | 42 | dofMapper_.update(this->gridView()); | |
237 | |||
238 | // determine size of containers | ||
239 | 42 | const auto numElements = this->gridView().size(0); | |
240 | 21 | cache_.scvs_.resize(numElements); | |
241 | 21 | cache_.scvfs_.resize(numElements); | |
242 | 21 | cache_.hasBoundaryScvf_.resize(numElements, false); | |
243 | |||
244 | 21 | boundaryDofIndices_.assign(numDofs(), false); | |
245 | |||
246 | 21 | numScv_ = 0; | |
247 | 21 | numScvf_ = 0; | |
248 | 21 | numBoundaryScvf_ = 0; | |
249 | |||
250 | // Build the scvs and scv faces | ||
251 |
10/12✓ Branch 2 taken 88293 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 67187 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10278 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 10278 times.
✓ Branch 11 taken 10 times.
✓ Branch 13 taken 10278 times.
✗ Branch 14 not taken.
|
197174 | for (const auto& element : elements(this->gridView())) |
252 | { | ||
253 |
2/4✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
|
197132 | const auto eIdx = this->elementMapper().index(element); |
254 | |||
255 |
2/4✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
|
108844 | const auto geometry = element.geometry(); |
256 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
98566 | GeometryHelper geometryHelper(geometry); |
257 | |||
258 | // build the scvs | ||
259 |
3/6✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10278 times.
✗ Branch 8 not taken.
|
197132 | cache_.scvs_[eIdx].reserve(geometryHelper.numScv()); |
260 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
98566 | numScv_ += geometryHelper.numScv(); |
261 |
4/4✓ Branch 1 taken 380908 times.
✓ Branch 2 taken 88288 times.
✓ Branch 3 taken 34274 times.
✓ Branch 4 taken 10278 times.
|
469196 | for (LocalIndexType localScvIdx = 0; localScvIdx < geometryHelper.numScv(); ++localScvIdx) |
262 | { | ||
263 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
370630 | const auto dofIndex = dofMapper().subIndex(element, localScvIdx, 1); |
264 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
370630 | const auto& corners = geometryHelper.getScvCorners(localScvIdx); |
265 |
1/2✓ Branch 1 taken 251950 times.
✗ Branch 2 not taken.
|
859940 | const auto volume = Dumux::convexPolytopeVolume<dim>( |
266 | SubControlVolume::Traits::geometryType(geometry.type()), | ||
267 | 3181456 | [&](unsigned int i){ return corners[i]; } | |
268 | ); | ||
269 | |||
270 |
2/4✓ Branch 2 taken 34274 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 34274 times.
✗ Branch 6 not taken.
|
370630 | cache_.scvs_[eIdx].emplace_back( |
271 | volume, | ||
272 | geometryHelper.facetCenter(localScvIdx), | ||
273 | 741260 | Dumux::center(corners), | |
274 | localScvIdx, | ||
275 | eIdx, | ||
276 | dofIndex | ||
277 | ); | ||
278 | } | ||
279 | |||
280 | // build interior scvfs | ||
281 | 98566 | LocalIndexType localScvfIdx = 0; | |
282 |
3/6✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10278 times.
✗ Branch 8 not taken.
|
197132 | cache_.scvfs_[eIdx].reserve(geometryHelper.numInteriorScvf()); |
283 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
98566 | numScvf_ += geometryHelper.numInteriorScvf(); |
284 |
4/4✓ Branch 1 taken 426188 times.
✓ Branch 2 taken 88288 times.
✓ Branch 3 taken 34274 times.
✓ Branch 4 taken 10278 times.
|
514476 | for (; localScvfIdx < geometryHelper.numInteriorScvf(); ++localScvfIdx) |
285 | { | ||
286 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
415910 | const auto& corners = geometryHelper.getScvfCorners(localScvfIdx); |
287 | 415910 | const auto& scvPair = geometryHelper.getInsideOutsideScvForScvf(localScvfIdx); | |
288 | 534596 | const auto area = Dumux::convexPolytopeVolume<dim-1>( | |
289 | SubControlVolumeFace::Traits::interiorGeometryType(geometry.type()), | ||
290 | 795072 | [&](unsigned int i){ return corners[i]; } | |
291 | ); | ||
292 | |||
293 |
3/6✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 34274 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 34274 times.
✗ Branch 8 not taken.
|
1247730 | cache_.scvfs_[eIdx].emplace_back( |
294 | 831820 | Dumux::center(corners), | |
295 | area, | ||
296 | geometryHelper.normal(corners, scvPair), | ||
297 | scvPair, | ||
298 | localScvfIdx | ||
299 | ); | ||
300 | } | ||
301 | |||
302 | // build boundary scvfs | ||
303 |
9/15✓ Branch 1 taken 10278 times.
✓ Branch 2 taken 21101 times.
✓ Branch 3 taken 151593 times.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 67187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 362093 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 14 taken 40144 times.
✓ Branch 15 taken 244484 times.
✓ Branch 17 taken 251950 times.
✗ Branch 18 not taken.
|
1026825 | for (const auto& intersection : intersections(this->gridView(), element)) |
304 | { | ||
305 |
3/3✓ Branch 0 taken 9052 times.
✓ Branch 1 taken 327944 times.
✓ Branch 2 taken 32038 times.
|
369034 | if (onDomainBoundary_(intersection)) |
306 | { | ||
307 | // store information that the face dof is on a boundary | ||
308 |
2/3✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 6698 times.
✗ Branch 2 not taken.
|
9692 | const LocalIndexType localFacetIndex = intersection.indexInInside(); |
309 |
1/2✓ Branch 1 taken 8106 times.
✗ Branch 2 not taken.
|
9692 | const auto dofIndex = dofMapper().subIndex(element, localFacetIndex, 1); |
310 |
2/4✓ Branch 1 taken 8106 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8106 times.
✗ Branch 5 not taken.
|
19384 | boundaryDofIndices_[dofIndex] = true; |
311 | |||
312 | // and that the element has a boundary face | ||
313 |
2/4✓ Branch 1 taken 8106 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8106 times.
✗ Branch 5 not taken.
|
19384 | cache_.hasBoundaryScvf_[eIdx] = true; |
314 | |||
315 | // add boundary scvf | ||
316 |
1/4✓ Branch 1 taken 8106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
17798 | const auto geo = intersection.geometry(); |
317 |
6/11✓ Branch 1 taken 7466 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 640 times.
✓ Branch 4 taken 7466 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8106 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 640 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7466 times.
✗ Branch 13 not taken.
|
24136 | cache_.scvfs_[eIdx].emplace_back( |
318 | geo.center(), | ||
319 | geo.volume(), | ||
320 | intersection.centerUnitOuterNormal(), | ||
321 | std::array<LocalIndexType, 2>{{localFacetIndex, localFacetIndex}}, | ||
322 | localScvfIdx, | ||
323 | typename SubControlVolumeFace::Traits::BoundaryFlag{ intersection } | ||
324 | ); | ||
325 | |||
326 | // increment local and global counters | ||
327 | 9692 | ++localScvfIdx; | |
328 | 9692 | ++numBoundaryScvf_; | |
329 |
1/2✓ Branch 0 taken 7466 times.
✗ Branch 1 not taken.
|
9692 | ++numScvf_; |
330 | } | ||
331 | |||
332 | // handle periodic boundaries | ||
333 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 336356 times.
✓ Branch 2 taken 32678 times.
|
369034 | if (onPeriodicBoundary_(intersection)) |
334 | { | ||
335 | ✗ | const LocalIndexType localFacetIndex = intersection.indexInInside(); | |
336 | ✗ | const auto dofIndex = dofMapper().subIndex(element, localFacetIndex, 1); | |
337 | |||
338 | ✗ | this->setPeriodic(); | |
339 | |||
340 | ✗ | const auto& otherElement = intersection.outside(); | |
341 | |||
342 | ✗ | LocalIndexType otherIntersectionLocalIdx = 0; | |
343 | ✗ | bool periodicFaceFound = false; | |
344 | |||
345 | ✗ | for (const auto& otherIntersection : intersections(this->gridView(), otherElement)) | |
346 | { | ||
347 | ✗ | if (periodicFaceFound) | |
348 | continue; | ||
349 | |||
350 | ✗ | if (Dune::FloatCmp::eq(intersection.centerUnitOuterNormal()*otherIntersection.centerUnitOuterNormal(), -1.0, 1e-7)) | |
351 | { | ||
352 | ✗ | const auto periodicDofIdx = dofMapper().subIndex(otherElement, otherIntersectionLocalIdx, 1); | |
353 | ✗ | periodicFaceMap_[dofIndex] = periodicDofIdx; | |
354 | ✗ | periodicFaceFound = true; | |
355 | } | ||
356 | |||
357 | ✗ | ++otherIntersectionLocalIdx; | |
358 | } | ||
359 | } | ||
360 | } | ||
361 | } | ||
362 | 21 | } | |
363 | |||
364 | 84406 | bool onDomainBoundary_(const typename GridView::Intersection& intersection) const | |
365 | { | ||
366 |
3/6✓ Branch 0 taken 83613 times.
✓ Branch 1 taken 793 times.
✓ Branch 2 taken 1586 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
85199 | return !intersection.neighbor() && intersection.boundary(); |
367 | } | ||
368 | |||
369 | bool onProcessorBoundary_(const typename GridView::Intersection& intersection) const | ||
370 | { | ||
371 | return !intersection.neighbor() && !intersection.boundary(); | ||
372 | } | ||
373 | |||
374 | 84406 | bool onPeriodicBoundary_(const typename GridView::Intersection& intersection) const | |
375 | { | ||
376 |
3/6✓ Branch 0 taken 84406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793 times.
✓ Branch 3 taken 793 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
85992 | return intersection.boundary() && intersection.neighbor(); |
377 | } | ||
378 | |||
379 | // faces on the boundary | ||
380 | std::vector<bool> boundaryDofIndices_; | ||
381 | |||
382 | DofMapper dofMapper_; | ||
383 | |||
384 | std::size_t numScv_; | ||
385 | std::size_t numScvf_; | ||
386 | std::size_t numBoundaryScvf_; | ||
387 | |||
388 | // a map for periodic boundary vertices | ||
389 | std::unordered_map<GridIndexType, GridIndexType> periodicFaceMap_; | ||
390 | |||
391 | const FeCache feCache_; | ||
392 | |||
393 | Cache cache_; | ||
394 | }; | ||
395 | |||
396 | } // end namespace Dumux | ||
397 | |||
398 | #endif | ||
399 |