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 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 | #include <dumux/io/grid/periodicgridtraits.hh> | ||
38 | |||
39 | namespace Dumux { | ||
40 | |||
41 | namespace Detail { | ||
42 | template<class GV, class T> | ||
43 | using FaceCenteredDiamondGeometryHelper_t = Dune::Std::detected_or_t< | ||
44 | Dumux::DiamondGeometryHelper<GV, typename T::SubControlVolume, typename T::SubControlVolumeFace>, | ||
45 | SpecifiesGeometryHelper, | ||
46 | T | ||
47 | >; | ||
48 | } // end namespace Detail | ||
49 | |||
50 | /*! | ||
51 | * \ingroup DiamondDiscretization | ||
52 | * \brief The default traits for the face-centered diamond finite volume grid geometry | ||
53 | * Defines the scv and scvf types and the mapper types | ||
54 | * \tparam GridView the grid view type | ||
55 | */ | ||
56 | template<class GridView> | ||
57 | struct FaceCenteredDiamondDefaultGridGeometryTraits : public DefaultMapperTraits<GridView> | ||
58 | { | ||
59 | using SubControlVolume = FaceCenteredDiamondSubControlVolume<GridView>; | ||
60 | using SubControlVolumeFace = FaceCenteredDiamondSubControlVolumeFace<GridView>; | ||
61 | using DofMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>; | ||
62 | |||
63 | template<class GridGeometry, bool enableCache> | ||
64 | using LocalView = FaceCenteredDiamondFVElementGeometry<GridGeometry, enableCache>; | ||
65 | }; | ||
66 | |||
67 | /*! | ||
68 | * \ingroup DiamondDiscretization | ||
69 | * \brief Grid geometry for the diamond discretization | ||
70 | */ | ||
71 | template<class GV, | ||
72 | bool enableCaching = true, | ||
73 | class Traits = FaceCenteredDiamondDefaultGridGeometryTraits<GV>> | ||
74 | class FaceCenteredDiamondFVGridGeometry | ||
75 | : public BaseGridGeometry<GV, Traits> | ||
76 | { | ||
77 | using ThisType = FaceCenteredDiamondFVGridGeometry<GV, enableCaching, Traits>; | ||
78 | using ParentType = BaseGridGeometry<GV, Traits>; | ||
79 | using GridIndexType = typename IndexTraits<GV>::GridIndex; | ||
80 | using LocalIndexType = typename IndexTraits<GV>::SmallLocalIndex; | ||
81 | using Element = typename GV::template Codim<0>::Entity; | ||
82 | |||
83 | using Scalar = typename GV::ctype; | ||
84 | |||
85 | static const int dim = GV::dimension; | ||
86 | static const int dimWorld = GV::dimensionworld; | ||
87 | |||
88 | static_assert(dim > 1, "Only implemented for dim > 1"); | ||
89 | |||
90 | public: | ||
91 | //! export discretization method | ||
92 | using DiscretizationMethod = DiscretizationMethods::FCDiamond; | ||
93 | static constexpr DiscretizationMethod discMethod = DiscretizationMethod{}; | ||
94 | static constexpr bool cachingEnabled = true; | ||
95 | |||
96 | //! export the type of the fv element geometry (the local view type) | ||
97 | using LocalView = typename Traits::template LocalView<ThisType, true>; | ||
98 | //! export the type of sub control volume | ||
99 | using SubControlVolume = typename Traits::SubControlVolume; | ||
100 | //! export the type of sub control volume | ||
101 | using SubControlVolumeFace = typename Traits::SubControlVolumeFace; | ||
102 | //! export the grid view type | ||
103 | using GridView = GV; | ||
104 | //! export the dof mapper type | ||
105 | using DofMapper = typename Traits::DofMapper; | ||
106 | //! export the type of extrusion | ||
107 | using Extrusion = Extrusion_t<Traits>; | ||
108 | //! export the finite element cache type | ||
109 | using FeCache = NonconformingFECache<Scalar, Scalar, dim>; | ||
110 | //! export whether the grid(geometry) supports periodicity | ||
111 | using SupportsPeriodicity = typename PeriodicGridTraits<typename GV::Grid>::SupportsPeriodicity; | ||
112 | |||
113 | //! Constructor | ||
114 | 23 | FaceCenteredDiamondFVGridGeometry(const GridView& gridView, const std::string& paramGroup = "") | |
115 | : ParentType(gridView) | ||
116 |
1/2✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
|
23 | , dofMapper_(gridView, Dune::mcmgLayout(Dune::Codim<1>{})) |
117 | 23 | , cache_(*this) | |
118 |
4/8✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 23 times.
✓ Branch 10 taken 23 times.
✗ Branch 11 not taken.
|
46 | , periodicGridTraits_(this->gridView().grid()) |
119 | { | ||
120 |
1/2✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
|
23 | update_(); |
121 | 23 | } | |
122 | |||
123 | //! The total number of sub control volumes | ||
124 | std::size_t numScv() const | ||
125 | { return numScv_; } | ||
126 | |||
127 | //! The total number of sub control volume faces | ||
128 | std::size_t numScvf() const | ||
129 | { return numScvf_; } | ||
130 | |||
131 | //! The total number of boundary sub control volume faces | ||
132 | 4 | std::size_t numBoundaryScvf() const | |
133 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | { return numBoundaryScvf_; } |
134 | |||
135 | //! the total number of dofs | ||
136 | 142 | std::size_t numDofs() const | |
137 |
20/36✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 8 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 10 times.
✓ Branch 4 taken 12 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 11 times.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 23 taken 2 times.
✓ Branch 26 taken 2 times.
✓ Branch 29 taken 2 times.
✓ Branch 32 taken 2 times.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 13 not taken.
✗ Branch 17 not taken.
|
121 | { return this->gridView().size(1); } |
138 | |||
139 | //! update all fvElementGeometries (call this after grid adaption) | ||
140 | void update(const GridView& gridView) | ||
141 | { | ||
142 | ParentType::update(gridView); | ||
143 | update_(); | ||
144 | } | ||
145 | |||
146 | //! update all fvElementGeometries (call this after grid adaption) | ||
147 | void update(GridView&& gridView) | ||
148 | { | ||
149 | ParentType::update(std::move(gridView)); | ||
150 | update_(); | ||
151 | } | ||
152 | |||
153 | //! The finite element cache for creating local FE bases | ||
154 | 38186155 | const FeCache& feCache() const | |
155 |
0/2✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
38186155 | { return feCache_; } |
156 | |||
157 | //! If a face / d.o.f. is on the boundary | ||
158 | 2162396 | bool dofOnBoundary(GridIndexType dofIdx) const | |
159 |
4/4✓ Branch 0 taken 36370 times.
✓ Branch 1 taken 2033524 times.
✓ Branch 2 taken 2224 times.
✓ Branch 3 taken 90278 times.
|
2162396 | { return boundaryDofIndices_[dofIdx]; } |
160 | |||
161 | //! Return a reference to the dof mapper | ||
162 | 59731114 | const DofMapper& dofMapper() const | |
163 |
3/7✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 0 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
|
59731128 | { return dofMapper_; } |
164 | |||
165 | //! If a d.o.f. is on a periodic boundary | ||
166 | 40608 | bool dofOnPeriodicBoundary(GridIndexType dofIdx) const | |
167 |
0/4✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
81216 | { return periodicFaceMap_.count(dofIdx); } |
168 | |||
169 | //! The index of the d.o.f. on the other side of the periodic boundary | ||
170 | ✗ | GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const | |
171 | ✗ | { return periodicFaceMap_.at(dofIdx); } | |
172 | |||
173 | //! Returns the map between dofs across periodic boundaries | ||
174 | const std::unordered_map<GridIndexType, GridIndexType>& periodicDofMap() const | ||
175 | 43 | { return periodicFaceMap_; } | |
176 | |||
177 | //! local view of this object (constructed with the internal cache) | ||
178 | 1383258 | friend inline LocalView localView(const FaceCenteredDiamondFVGridGeometry& gg) | |
179 |
15/19✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 42002 times.
✓ Branch 10 taken 606 times.
✓ Branch 11 taken 30838 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 20 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
✓ Branch 8 taken 10280 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
|
846167 | { 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 | 23 | explicit FCDiamondGridGeometryCache(const FaceCenteredDiamondFVGridGeometry& gg) | |
191 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | : gridGeometry_(&gg) |
192 | {} | ||
193 | |||
194 | 20176656 | const FaceCenteredDiamondFVGridGeometry& gridGeometry() const | |
195 |
14/23✓ Branch 2 taken 178520 times.
✓ Branch 3 taken 1198864 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 8 taken 55304 times.
✓ Branch 9 taken 10278 times.
✓ Branch 11 taken 10487 times.
✓ Branch 12 taken 20716 times.
✓ Branch 14 taken 10487 times.
✓ Branch 15 taken 480 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 24 taken 8208 times.
✓ Branch 25 taken 655440 times.
✓ Branch 33 taken 2 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 2 times.
✗ Branch 37 not taken.
✓ Branch 1 taken 82886 times.
✓ Branch 0 taken 1280 times.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
|
18096522 | { return *gridGeometry_; } |
196 | |||
197 | //! Get the global sub control volume indices of an element | ||
198 | 56251914 | const std::vector<SubControlVolume>& scvs(GridIndexType eIdx) const | |
199 |
6/8✓ Branch 1 taken 5 times.
✓ Branch 2 taken 186999 times.
✓ Branch 3 taken 36608 times.
✓ Branch 4 taken 109330 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 30834 times.
✗ Branch 8 not taken.
✓ Branch 0 taken 5600 times.
|
56114185 | { return scvs_[eIdx]; } |
200 | |||
201 | //! Get the global sub control volume face indices of an element | ||
202 | 4601328 | const std::vector<SubControlVolumeFace>& scvfs(GridIndexType eIdx) const | |
203 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
4451472 | { return scvfs_[eIdx]; } |
204 | |||
205 | //! Returns whether one of the geometry's scvfs lies on a boundary | ||
206 | 28949 | bool hasBoundaryScvf(GridIndexType eIdx) const | |
207 |
2/4✓ Branch 0 taken 682 times.
✓ Branch 1 taken 28267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
28949 | { return hasBoundaryScvf_[eIdx]; } |
208 | |||
209 | private: | ||
210 | 23 | void clear_() | |
211 | { | ||
212 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | scvs_.clear(); |
213 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | scvfs_.clear(); |
214 | 23 | hasBoundaryScvf_.clear(); | |
215 | 23 | } | |
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 | 23 | void update_() | |
233 | { | ||
234 | // clear containers (necessary after grid refinement) | ||
235 | 23 | cache_.clear_(); | |
236 | 23 | dofMapper_.update(this->gridView()); | |
237 | |||
238 | // determine size of containers | ||
239 | 23 | const auto numElements = this->gridView().size(0); | |
240 | 23 | cache_.scvs_.resize(numElements); | |
241 | 23 | cache_.scvfs_.resize(numElements); | |
242 | 23 | cache_.hasBoundaryScvf_.resize(numElements, false); | |
243 | |||
244 | 23 | boundaryDofIndices_.assign(numDofs(), false); | |
245 | |||
246 | 23 | numScv_ = 0; | |
247 | 23 | numScvf_ = 0; | |
248 | 23 | numBoundaryScvf_ = 0; | |
249 | |||
250 | // Build the scvs and scv faces | ||
251 |
6/9✓ Branch 2 taken 961 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 10278 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10278 times.
✓ Branch 11 taken 10 times.
✓ Branch 1 taken 117241 times.
|
161775 | 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.
|
128457 | const auto eIdx = this->elementMapper().index(element); |
254 | |||
255 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
128457 | const auto geometry = element.geometry(); |
256 | 128457 | GeometryHelper geometryHelper(geometry); | |
257 | |||
258 | // build the scvs | ||
259 |
2/4✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
|
128457 | cache_.scvs_[eIdx].reserve(geometryHelper.numScv()); |
260 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
128457 | numScv_ += geometryHelper.numScv(); |
261 |
4/4✓ Branch 1 taken 473410 times.
✓ Branch 2 taken 118179 times.
✓ Branch 3 taken 34274 times.
✓ Branch 4 taken 10278 times.
|
591589 | for (LocalIndexType localScvIdx = 0; localScvIdx < geometryHelper.numScv(); ++localScvIdx) |
262 | { | ||
263 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
463132 | const auto dofIndex = dofMapper().subIndex(element, localScvIdx, 1); |
264 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
463132 | const auto& corners = geometryHelper.getScvCorners(localScvIdx); |
265 |
2/3✓ Branch 0 taken 338794 times.
✓ Branch 1 taken 118674 times.
✗ Branch 2 not taken.
|
517230 | const auto volume = Dumux::convexPolytopeVolume<dim>( |
266 | SubControlVolume::Traits::geometryType(geometry.type()), | ||
267 |
1/2✓ Branch 1 taken 118674 times.
✗ Branch 2 not taken.
|
1449158 | [&](unsigned int i){ return corners[i]; } |
268 | ); | ||
269 | |||
270 |
2/4✓ Branch 1 taken 463132 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 463132 times.
✗ Branch 5 not taken.
|
463132 | cache_.scvs_[eIdx].emplace_back( |
271 | volume, | ||
272 | 926264 | geometryHelper.facetCenter(localScvIdx), | |
273 |
1/2✓ Branch 1 taken 463132 times.
✗ Branch 2 not taken.
|
926264 | Dumux::center(corners), |
274 | localScvIdx, | ||
275 | eIdx, | ||
276 | dofIndex | ||
277 | ); | ||
278 | } | ||
279 | |||
280 | // build interior scvfs | ||
281 | 128457 | LocalIndexType localScvfIdx = 0; | |
282 |
2/4✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10278 times.
✗ Branch 5 not taken.
|
128457 | cache_.scvfs_[eIdx].reserve(geometryHelper.numInteriorScvf()); |
283 |
1/2✓ Branch 1 taken 10278 times.
✗ Branch 2 not taken.
|
128457 | numScvf_ += geometryHelper.numInteriorScvf(); |
284 |
4/4✓ Branch 1 taken 524348 times.
✓ Branch 2 taken 118179 times.
✓ Branch 3 taken 34274 times.
✓ Branch 4 taken 10278 times.
|
642527 | for (; localScvfIdx < geometryHelper.numInteriorScvf(); ++localScvfIdx) |
285 | { | ||
286 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
514070 | const auto& corners = geometryHelper.getScvfCorners(localScvfIdx); |
287 | 514070 | const auto& scvPair = geometryHelper.getInsideOutsideScvForScvf(localScvfIdx); | |
288 | 609798 | const auto area = Dumux::convexPolytopeVolume<dim-1>( | |
289 | SubControlVolumeFace::Traits::interiorGeometryType(geometry.type()), | ||
290 | 1138840 | [&](unsigned int i){ return corners[i]; } | |
291 | ); | ||
292 | |||
293 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
514070 | cache_.scvfs_[eIdx].emplace_back( |
294 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
514070 | Dumux::center(corners), |
295 | area, | ||
296 |
1/2✓ Branch 1 taken 34274 times.
✗ Branch 2 not taken.
|
1028140 | geometryHelper.normal(corners, scvPair), |
297 | scvPair, | ||
298 | localScvfIdx | ||
299 | ); | ||
300 | } | ||
301 | |||
302 | // build boundary scvfs | ||
303 |
10/12✓ Branch 2 taken 181484 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 97078 times.
✓ Branch 6 taken 42956 times.
✓ Branch 7 taken 434929 times.
✓ Branch 8 taken 5658 times.
✓ Branch 13 taken 8148 times.
✓ Branch 14 taken 330646 times.
✓ Branch 1 taken 31379 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5658 times.
✓ Branch 11 taken 943 times.
|
1407370 | for (const auto& intersection : intersections(this->gridView(), element)) |
304 | { | ||
305 |
2/2✓ Branch 0 taken 9734 times.
✓ Branch 1 taken 413466 times.
|
463718 | if (onDomainBoundary_(intersection)) |
306 | { | ||
307 | // store information that the face dof is on a boundary | ||
308 | 11916 | const LocalIndexType localFacetIndex = intersection.indexInInside(); | |
309 |
1/2✓ Branch 1 taken 11916 times.
✗ Branch 2 not taken.
|
11916 | const auto dofIndex = dofMapper().subIndex(element, localFacetIndex, 1); |
310 |
1/2✓ Branch 1 taken 8788 times.
✗ Branch 2 not taken.
|
11916 | boundaryDofIndices_[dofIndex] = true; |
311 | |||
312 | // and that the element has a boundary face | ||
313 |
1/2✓ Branch 1 taken 8788 times.
✗ Branch 2 not taken.
|
11916 | cache_.hasBoundaryScvf_[eIdx] = true; |
314 | |||
315 | // add boundary scvf | ||
316 | 11916 | const auto geo = intersection.geometry(); | |
317 |
4/5✓ Branch 1 taken 9734 times.
✓ Branch 2 taken 640 times.
✓ Branch 4 taken 8941 times.
✗ Branch 5 not taken.
✓ Branch 3 taken 793 times.
|
11916 | cache_.scvfs_[eIdx].emplace_back( |
318 |
1/2✓ Branch 1 taken 11916 times.
✗ Branch 2 not taken.
|
11916 | geo.center(), |
319 |
1/2✓ Branch 1 taken 640 times.
✗ Branch 2 not taken.
|
11916 | geo.volume(), |
320 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
11916 | 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 | 11916 | ++localScvfIdx; | |
328 | 11916 | ++numBoundaryScvf_; | |
329 |
1/2✓ Branch 0 taken 8108 times.
✗ Branch 1 not taken.
|
11916 | ++numScvf_; |
330 | 8788 | } | |
331 | |||
332 | // handle periodic boundaries | ||
333 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5658 times.
|
5658 | 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 | 23 | } | |
363 | |||
364 |
2/2✓ Branch 0 taken 97419 times.
✓ Branch 1 taken 331439 times.
|
461536 | bool onDomainBoundary_(const typename GridView::Intersection& intersection) const |
365 | { | ||
366 |
3/4✓ Branch 0 taken 8788 times.
✓ Branch 1 taken 364226 times.
✓ Branch 2 taken 640 times.
✗ Branch 3 not taken.
|
375240 | 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 | 5658 | bool onPeriodicBoundary_(const typename GridView::Intersection& intersection) const | |
375 | { | ||
376 |
1/2✓ Branch 1 taken 371472 times.
✗ Branch 2 not taken.
|
461536 | return periodicGridTraits_.isPeriodic(intersection); |
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 | PeriodicGridTraits<typename GridView::Grid> periodicGridTraits_; | ||
396 | }; | ||
397 | |||
398 | } // end namespace Dumux | ||
399 | |||
400 | #endif | ||
401 |