3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/facecentered/staggered/fvgridgeometry.hh
Go to the documentation of this file.
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_FV_GRID_GEOMETRY
26
27#include <memory>
28
29#include <dune/common/rangeutilities.hh>
30#include <dune/grid/common/scsgmapper.hh>
31
35#include <dumux/common/math.hh>
36
41
49
50namespace Dumux {
51
58template<class GridView>
60{
66
67 template<class GridGeometry>
69
70 template<class GridGeometry, bool enableCache>
72
74 {
75 static constexpr auto dim = GridView::Grid::dimension;
76 static constexpr auto numFacesPerElement = dim * 2;
77 static constexpr auto numScvsPerElement = numFacesPerElement;
78 static constexpr auto numLateralScvfsPerScv = 2 * (dim - 1);
80 static constexpr auto minNumScvfsPerElement = numLateralScvfsPerElement // number of lateral faces
81 + numFacesPerElement; // number of central frontal faces
83 + numFacesPerElement; // number of potential frontal faces on boundary
84 };
85};
86
93template<class GridView,
94 bool cachingEnabled = false,
97
104template<class GV, class Traits>
106: public BaseGridGeometry<GV, Traits>
107{
110 using GridIndexType = typename IndexTraits<GV>::GridIndex;
111 using LocalIndexType = typename IndexTraits<GV>::LocalIndex;
112 using SmallLocalIndexType = typename IndexTraits<GV>::SmallLocalIndex;
113 using Element = typename GV::template Codim<0>::Entity;
114
115 using IntersectionMapper = typename Traits::IntersectionMapper;
116 using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>;
117
118 using Scalar = typename GV::ctype;
119
120 static constexpr auto dim = Traits::StaticInfo::dim;
121 static constexpr auto numScvsPerElement = Traits::StaticInfo::numScvsPerElement;
122 static constexpr auto numLateralScvfsPerScv = Traits::StaticInfo::numLateralScvfsPerScv;
123 static constexpr auto numLateralScvfsPerElement = Traits::StaticInfo::numLateralScvfsPerElement;
124 static constexpr auto minNumScvfsPerElement = Traits::StaticInfo::minNumScvfsPerElement;
125 static constexpr auto maxNumScvfsPerElement = Traits::StaticInfo::maxNumScvfsPerElement;
126
127 using ScvfCornerStorage = typename Traits::SubControlVolumeFace::Traits::CornerStorage;
128 using ScvCornerStorage = typename Traits::SubControlVolume::Traits::CornerStorage;
129
130public:
133 static constexpr DiscretizationMethod discMethod{};
134
135 static constexpr bool cachingEnabled = true;
136
140 using LocalView = typename Traits::template LocalView<ThisType, true>;
142 using SubControlVolume = typename Traits::SubControlVolume;
144 using SubControlVolumeFace = typename Traits::SubControlVolumeFace;
146 using GridView = GV;
148 using GeometryHelper = typename Traits::GeometryHelper;
150 using LocalIntersectionMapper = typename Traits::LocalIntersectionMapper;
152 using StaticInformation = typename Traits::StaticInfo;
155
157 FaceCenteredStaggeredFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg, const std::string& paramGroup = "")
158 : ParentType(std::move(gg))
159 , intersectionMapper_(this->gridView())
160 {
161 // Check if the overlap size is what we expect
163 DUNE_THROW(Dune::InvalidStateException, "The staggered discretization method needs at least an overlap of 1 for parallel computations. "
164 << " Set the parameter \"Grid.Overlap\" in the input file.");
165
166 update_();
167 }
168
170 FaceCenteredStaggeredFVGridGeometry(const GridView& gridView, const std::string& paramGroup = "")
171 : FaceCenteredStaggeredFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView), paramGroup)
172 {}
173
175 std::size_t numScv() const
176 { return scvs_.size(); }
177
179 std::size_t numScvf() const
180 { return scvfs_.size(); }
181
183 std::size_t numBoundaryScv() const
184 { return numBoundaryScv_; }
185
187 std::size_t numBoundaryScvf() const
188 { return numBoundaryScvf_; }
189
191 std::size_t numIntersections() const
192 { return intersectionMapper_.numIntersections(); }
193
195 std::size_t numDofs() const
196 { return this->gridView().size(1); }
197
199 void update(const GridView& gridView)
200 {
201 ParentType::update(gridView);
202 update_();
203 }
204
206 void update(GridView&& gridView)
207 {
208 ParentType::update(std::move(gridView));
209 update_();
210 }
211
213 const SubControlVolume& scv(GridIndexType scvIdx) const
214 { return scvs_[scvIdx]; }
215
218 auto scvs(const LocalView& fvGeometry) const
219 {
220 auto begin = scvs_.cbegin() + numScvsPerElement*fvGeometry.elementIndex();
221 const auto end = begin + numScvsPerElement;
222 return Dune::IteratorRange<std::decay_t<decltype(begin)>>(begin, end);
223 }
224
226 const SubControlVolumeFace& scvf(GridIndexType scvfIdx) const
227 { return scvfs_[scvfIdx]; }
228
230 const std::vector<GridIndexType>& scvfIndicesOfElement(GridIndexType eIdx) const
231 { return scvfIndicesOfElement_[eIdx]; }
232
237 const ConnectivityMap& connectivityMap() const
238 { return connectivityMap_; }
239
241 bool hasBoundaryScvf(GridIndexType eIdx) const
242 { return hasBoundaryScvf_[eIdx]; }
243
245 const IntersectionMapper& intersectionMapper() const
246 { return intersectionMapper_; }
247
249 bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
250 { return periodicFaceMap_.count(dofIdx); }
251
253 GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
254 { return periodicFaceMap_.at(dofIdx); }
255
257 const std::unordered_map<GridIndexType, GridIndexType>& periodicVertexMap() const
258 { return periodicFaceMap_; }
259
260private:
261
262 void update_()
263 {
264 // clear containers (necessary after grid refinement)
265 scvs_.clear();
266 scvfs_.clear();
267 scvfIndicesOfElement_.clear();
268 intersectionMapper_.update(this->gridView());
269
270 // determine size of containers
271 const auto numElements = this->gridView().size(0);
272 scvfIndicesOfElement_.resize(numElements);
273 hasBoundaryScvf_.resize(numElements, false);
274
275 outSideBoundaryVolVarIdx_ = 0;
276 numBoundaryScv_ = 0;
277 numBoundaryScvf_ = 0;
278
279 GeometryHelper geometryHelper(this->gridView());
280
281 // get the global scvf indices first
282 GridIndexType numScvfs = 0;
283 for (const auto& element : elements(this->gridView()))
284 {
285 assert(numScvsPerElement == element.subEntities(1));
286
287 for (const auto& intersection : intersections(this->gridView(), element))
288 {
289 // frontal scvf in element center
290 ++numScvfs;
291
292 // lateral scvfs
293 numScvfs += numLateralScvfsPerScv;
294
295 // handle physical domain boundary
296 if (onDomainBoundary_(intersection))
297 {
298 ++numBoundaryScv_; // frontal face
299 numBoundaryScv_ += numLateralScvfsPerScv; // boundary scvs for lateral faces
300
301 // frontal scvf at boundary
302 ++numScvfs;
303 }
304 }
305 }
306
307 // allocate memory
308 const auto numScvs = numElements*numScvsPerElement;
309 scvs_.resize(numScvs);
310 scvfs_.reserve(numScvfs);
311
312 // Build the scvs and scv faces
313 std::size_t globalScvfIdx = 0;
314 for (const auto& element : elements(this->gridView()))
315 {
316 const auto eIdx = this->elementMapper().index(element);
317 auto& globalScvfIndices = scvfIndicesOfElement_[eIdx];
318 globalScvfIndices.resize(minNumScvfsPerElement);
319 globalScvfIndices.reserve(maxNumScvfsPerElement);
320
321 auto getGlobalScvIdx = [&](const auto elementIdx, const auto localScvIdx)
322 { return numScvsPerElement*elementIdx + localScvIdx; };
323
324 LocalIntersectionMapper localIsMapper;
325 localIsMapper.update(this->gridView(), element);
326
327 for (const auto& intersection : intersections(this->gridView(), element))
328 {
329 const auto& intersectionUnitOuterNormal = intersection.centerUnitOuterNormal();
330 const auto localScvIdx = localIsMapper.realToRefIdx(intersection.indexInInside());
331 auto localScvfIdx = localScvIdx*(1 + numLateralScvfsPerScv);
332
333 const auto globalScvIdx = getGlobalScvIdx(eIdx, localScvIdx);
334 const auto dofIndex = intersectionMapper().globalIntersectionIndex(element, intersection.indexInInside());
335 const auto localOppositeScvIdx = geometryHelper.localOppositeIdx(localScvIdx);
336 const auto& intersectionGeometry = intersection.geometry();
337 const auto& elementGeometry = element.geometry();
338
339 assert(localIsMapper.refToRealIdx(localScvIdx) == intersection.indexInInside());
340
341 // handle periodic boundaries
342 if (onPeriodicBoundary_(intersection))
343 {
344 this->setPeriodic();
345
346 const auto& otherElement = intersection.outside();
347
348 SmallLocalIndexType otherIntersectionLocalIdx = 0;
349 bool periodicFaceFound = false;
350
351 for (const auto& otherIntersection : intersections(this->gridView(), otherElement))
352 {
353 if (periodicFaceFound)
354 continue;
355
356 if (Dune::FloatCmp::eq(intersectionUnitOuterNormal*otherIntersection.centerUnitOuterNormal(), -1.0, 1e-7))
357 {
358 const auto periodicDofIdx = intersectionMapper().globalIntersectionIndex(otherElement, otherIntersectionLocalIdx);
359 periodicFaceMap_[dofIndex] = periodicDofIdx;
360 periodicFaceFound = true;
361 }
362
363 ++otherIntersectionLocalIdx;
364 }
365 }
366
367 // the sub control volume
368 scvs_[globalScvIdx] = SubControlVolume(
369 elementGeometry,
370 intersectionGeometry,
371 globalScvIdx,
372 localScvIdx,
373 dofIndex,
374 Dumux::normalAxis(intersectionUnitOuterNormal),
375 this->elementMapper().index(element),
376 onDomainBoundary_(intersection)
377 );
378
379 // the frontal sub control volume face at the element center
380 scvfs_.emplace_back(elementGeometry,
381 intersectionGeometry,
382 std::array{globalScvIdx, getGlobalScvIdx(eIdx, localOppositeScvIdx)},
383 localScvfIdx,
384 globalScvfIdx,
385 intersectionUnitOuterNormal,
386 SubControlVolumeFace::FaceType::frontal,
387 SubControlVolumeFace::BoundaryType::interior
388 );
389
390 globalScvfIndices[localScvfIdx] = globalScvfIdx++;
391 ++localScvfIdx;
392
393 // the lateral sub control volume faces
394 for (const auto lateralFacetIndex : Dune::transformedRangeView(geometryHelper.localLaterFaceIndices(localScvIdx),
395 [&](auto&& idx) { return localIsMapper.refToRealIdx(idx) ;})
396 )
397 {
398 const auto& lateralIntersection = geometryHelper.intersection(lateralFacetIndex, element);
399
400 // helper lambda to get the lateral scvf's global inside and outside scv indices
401 const auto globalScvIndicesForLateralFace = [&]
402 {
403 const auto globalOutsideScvIdx = [&]
404 {
405 if (lateralIntersection.neighbor())
406 {
407 const auto parallelElemIdx = this->elementMapper().index(lateralIntersection.outside());
408 return getGlobalScvIdx(parallelElemIdx, localScvIdx);
409 }
410 else if (onDomainBoundary_(lateralIntersection))
411 return numScvs + outSideBoundaryVolVarIdx_++;
412 else
413 return globalScvIdx; // fallback for parallel, won't be used anyway
414 }();
415
416 return std::array{globalScvIdx, globalOutsideScvIdx};
417 }();
418
419 const auto boundaryType = [&]
420 {
421 if (onProcessorBoundary_(lateralIntersection))
422 return SubControlVolumeFace::BoundaryType::processorBoundary;
423 else if (onDomainBoundary_(lateralIntersection))
424 return SubControlVolumeFace::BoundaryType::physicalBoundary;
425 else
426 return SubControlVolumeFace::BoundaryType::interior;
427 }();
428
429 scvfs_.emplace_back(
430 elementGeometry,
431 intersectionGeometry,
432 geometryHelper.facet(lateralFacetIndex, element).geometry(),
433 globalScvIndicesForLateralFace, // TODO higher order
434 localScvfIdx,
435 globalScvfIdx,
436 lateralIntersection.centerUnitOuterNormal(),
437 SubControlVolumeFace::FaceType::lateral,
438 boundaryType
439 );
440
441 globalScvfIndices[localScvfIdx] = globalScvfIdx++;
442 ++localScvfIdx;
443
444 if (onDomainBoundary_(lateralIntersection))
445 {
446 ++numBoundaryScvf_;
447 hasBoundaryScvf_[eIdx] = true;
448 }
449 } // end loop over lateral facets
450
451 } // end first loop over intersections
452
453 // do a second loop over all intersections to add frontal boundary faces
454 int localScvfIdx = minNumScvfsPerElement;
455 for (const auto& intersection : intersections(this->gridView(), element))
456 {
457 // the frontal sub control volume face at a domain boundary (coincides with element face)
458 if (onDomainBoundary_(intersection))
459 {
460 const auto localScvIdx = localIsMapper.realToRefIdx(intersection.indexInInside());
461 const auto globalScvIdx = getGlobalScvIdx(eIdx, localScvIdx);
462 ++numBoundaryScvf_;
463
464 // the frontal sub control volume face at the boundary
465 scvfs_.emplace_back(
466 element.geometry(),
467 intersection.geometry(),
468 std::array{globalScvIdx, globalScvIdx}, // TODO outside boundary, periodic, parallel?
469 localScvfIdx,
470 globalScvfIdx,
471 intersection.centerUnitOuterNormal(),
472 SubControlVolumeFace::FaceType::frontal,
473 SubControlVolumeFace::BoundaryType::physicalBoundary
474 );
475
476 globalScvfIndices.push_back(globalScvfIdx);
477 ++globalScvfIdx;
478 ++localScvfIdx;
479 hasBoundaryScvf_[eIdx] = true;
480 }
481 }
482 }
483
484 connectivityMap_.update(*this);
485 }
486
487 bool onDomainBoundary_(const typename GridView::Intersection& intersection) const
488 {
489 return !intersection.neighbor() && intersection.boundary();
490 }
491
492 bool onProcessorBoundary_(const typename GridView::Intersection& intersection) const
493 {
494 return !intersection.neighbor() && !intersection.boundary();
495 }
496
497 bool onPeriodicBoundary_(const typename GridView::Intersection& intersection) const
498 {
499 return intersection.boundary() && intersection.neighbor();
500 }
501
502 // mappers
503 ConnectivityMap connectivityMap_;
504 IntersectionMapper intersectionMapper_;
505
506 std::vector<SubControlVolume> scvs_;
507 std::vector<SubControlVolumeFace> scvfs_;
508 GridIndexType numBoundaryScv_;
509 GridIndexType numBoundaryScvf_;
510 GridIndexType outSideBoundaryVolVarIdx_;
511 std::vector<bool> hasBoundaryScvf_;
512
513 std::vector<std::vector<GridIndexType>> scvfIndicesOfElement_;
514
515 // a map for periodic boundary vertices
516 std::unordered_map<GridIndexType, GridIndexType> periodicFaceMap_;
517};
518
525template<class GV, class Traits>
527: public BaseGridGeometry<GV, Traits>
528{
531 using GridIndexType = typename IndexTraits<GV>::GridIndex;
532 using LocalIndexType = typename IndexTraits<GV>::LocalIndex;
533 using SmallLocalIndexType = typename IndexTraits<GV>::SmallLocalIndex;
534 using Element = typename GV::template Codim<0>::Entity;
535
536 using IntersectionMapper = typename Traits::IntersectionMapper;
537 using ConnectivityMap = typename Traits::template ConnectivityMap<ThisType>;
538
539 static constexpr auto dim = Traits::StaticInfo::dim;
540 static constexpr auto numScvsPerElement = Traits::StaticInfo::numScvsPerElement;
541 static constexpr auto numLateralScvfsPerScv = Traits::StaticInfo::numLateralScvfsPerScv;
542 static constexpr auto numLateralScvfsPerElement = Traits::StaticInfo::numLateralScvfsPerElement;
543 static constexpr auto minNumScvfsPerElement = Traits::StaticInfo::minNumScvfsPerElement;
544 static constexpr auto maxNumScvfsPerElement = Traits::StaticInfo::maxNumScvfsPerElement;
545
546public:
549 static constexpr DiscretizationMethod discMethod{};
550
551 static constexpr bool cachingEnabled = false;
552
556 using LocalView = typename Traits::template LocalView<ThisType, false>;
558 using SubControlVolume = typename Traits::SubControlVolume;
560 using SubControlVolumeFace = typename Traits::SubControlVolumeFace;
562 using GridView = GV;
564 using GeometryHelper = typename Traits::GeometryHelper;
566 using LocalIntersectionMapper = typename Traits::LocalIntersectionMapper;
568 using StaticInformation = typename Traits::StaticInfo;
571
573 FaceCenteredStaggeredFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg, const std::string& paramGroup = "")
574 : ParentType(std::move(gg))
575 , intersectionMapper_(this->gridView())
576 {
577 // Check if the overlap size is what we expect
579 DUNE_THROW(Dune::InvalidStateException, "The staggered discretization method needs at least an overlap of 1 for parallel computations. "
580 << " Set the parameter \"Grid.Overlap\" in the input file.");
581
582 update_();
583 }
584
586 FaceCenteredStaggeredFVGridGeometry(const GridView& gridView, const std::string& paramGroup = "")
587 : FaceCenteredStaggeredFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView), paramGroup)
588 {}
589
591 std::size_t numScv() const
592 { return numScvs_; }
593
595 std::size_t numScvf() const
596 { return numScvf_; }
597
599 std::size_t numBoundaryScv() const
600 { return numBoundaryScv_; }
601
603 std::size_t numBoundaryScvf() const
604 { return numBoundaryScvf_; }
605
607 std::size_t numIntersections() const
608 { return intersectionMapper_.numIntersections(); }
609
611 std::size_t numDofs() const
612 { return this->gridView().size(1); }
613
618 const ConnectivityMap& connectivityMap() const
619 { return connectivityMap_; }
620
622 bool hasBoundaryScvf(GridIndexType eIdx) const
623 { return hasBoundaryScvf_[eIdx]; }
624
626 const IntersectionMapper& intersectionMapper() const
627 { return intersectionMapper_; }
628
630 const std::vector<GridIndexType>& scvfIndicesOfElement(GridIndexType eIdx) const
631 { return scvfIndicesOfElement_[eIdx]; }
632
634 GridIndexType outsideVolVarIndex(GridIndexType scvfIdx) const
635 { return outsideVolVarIndices_.at(scvfIdx); }
636
638 void update(const GridView& gridView)
639 {
640 ParentType::update(gridView);
641 update_();
642 }
643
645 void update(GridView&& gridView)
646 {
647 ParentType::update(std::move(gridView));
648 update_();
649 }
650
652 bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
653 { return periodicFaceMap_.count(dofIdx); }
654
656 GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
657 { return periodicFaceMap_.at(dofIdx); }
658
660 const std::unordered_map<GridIndexType, GridIndexType>& periodicVertexMap() const
661 { return periodicFaceMap_; }
662
663private:
664
665 void update_()
666 {
667 intersectionMapper_.update(this->gridView());
668
669 // clear local data
670 numScvf_ = 0;
671 numBoundaryScv_ = 0;
672 numBoundaryScvf_ = 0;
673 hasBoundaryScvf_.clear();
674 scvfIndicesOfElement_.clear();
675 outsideVolVarIndices_.clear();
676
677 // determine size of containers
678 const auto numElements = this->gridView().size(0);
679 scvfIndicesOfElement_.resize(numElements);
680 hasBoundaryScvf_.resize(numElements, false);
681 numScvs_ = numElements*numScvsPerElement;
682
683 GeometryHelper geometryHelper(this->gridView());
684
685 // get the global scv indices first
686 GridIndexType scvfIdx = 0;
687
688 GridIndexType neighborVolVarIdx = numScvs_;
689
690 for (const auto& element : elements(this->gridView()))
691 {
692 const auto eIdx = this->elementMapper().index(element);
693 assert(numScvsPerElement == element.subEntities(1));
694
695 // the element-wise index sets for finite volume geometry
696 auto& globalScvfIndices = scvfIndicesOfElement_[eIdx];
697 globalScvfIndices.reserve(maxNumScvfsPerElement);
698 globalScvfIndices.resize(minNumScvfsPerElement);
699
700 // keep track of frontal boundary scvfs
701 std::size_t numFrontalBoundaryScvfs = 0;
702
703 using LocalIntersectionIndexMapper = FaceCenteredStaggeredLocalIntersectionIndexMapper<GridView>;
704 LocalIntersectionIndexMapper localIsMapper;
705 localIsMapper.update(this->gridView(), element);
706
707 for (const auto& intersection : intersections(this->gridView(), element))
708 {
709 const auto localScvIdx = localIsMapper.realToRefIdx(intersection.indexInInside());
710 auto localScvfIdx = localScvIdx*(1 + numLateralScvfsPerScv);
711
712 assert(localIsMapper.refToRealIdx(localScvIdx) == intersection.indexInInside());
713 // the frontal sub control volume face at the element center
714 globalScvfIndices[localScvfIdx] = scvfIdx++;
715 ++localScvfIdx;
716
717 if constexpr(dim > 1)
718 {
719 // the lateral sub control volume faces
720 for (const auto lateralFacetIndex : Dune::transformedRangeView(geometryHelper.localLaterFaceIndices(localScvIdx),
721 [&](auto idx) { return localIsMapper.refToRealIdx(idx) ;})
722 )
723 {
724 if (onDomainBoundary_(geometryHelper.intersection(lateralFacetIndex, element)))
725 {
726 outsideVolVarIndices_[scvfIdx] = neighborVolVarIdx++;
727 ++numBoundaryScvf_;
728 hasBoundaryScvf_[eIdx] = true;
729 }
730
731 globalScvfIndices[localScvfIdx] = scvfIdx++;
732 ++localScvfIdx;
733 }
734 }
735
736 // handle physical domain boundary
737 if (onDomainBoundary_(intersection))
738 {
739 ++numBoundaryScv_; // frontal face
740 numBoundaryScv_ += numLateralScvfsPerScv; // boundary scvs for lateral faces
741 ++numFrontalBoundaryScvfs;
742 ++numBoundaryScvf_;
743 hasBoundaryScvf_[eIdx] = true;
744 }
745
746 // handle periodic boundaries
747 if (onPeriodicBoundary_(intersection))
748 {
749 this->setPeriodic();
750
751 const auto& otherElement = intersection.outside();
752
753 SmallLocalIndexType otherIntersectionLocalIdx = 0;
754 bool periodicFaceFound = false;
755
756 for (const auto& otherIntersection : intersections(this->gridView(), otherElement))
757 {
758 if (periodicFaceFound)
759 continue;
760
761 if (Dune::FloatCmp::eq(intersection.centerUnitOuterNormal()*otherIntersection.centerUnitOuterNormal(), -1.0, 1e-7))
762 {
763 const auto periodicDofIdx = intersectionMapper().globalIntersectionIndex(otherElement, otherIntersectionLocalIdx);
764 const auto dofIndex = intersectionMapper().globalIntersectionIndex(element, localScvIdx);
765 periodicFaceMap_[dofIndex] = periodicDofIdx;
766 periodicFaceFound = true;
767 }
768
769 ++otherIntersectionLocalIdx;
770 }
771 }
772 }
773
774 // add global indices of frontal boundary scvfs last
775 for (std::size_t i = 0; i < numFrontalBoundaryScvfs; ++i)
776 globalScvfIndices.push_back(scvfIdx++);
777 }
778
779 // set number of subcontrolvolume faces
780 numScvf_ = scvfIdx;
781
782 connectivityMap_.update(*this);
783 }
784
785 bool onDomainBoundary_(const typename GridView::Intersection& intersection) const
786 {
787 return !intersection.neighbor() && intersection.boundary();
788 }
789
790 bool onProcessorBoundary_(const typename GridView::Intersection& intersection) const
791 {
792 return !intersection.neighbor() && !intersection.boundary();
793 }
794
795 bool onPeriodicBoundary_(const typename GridView::Intersection& intersection) const
796 {
797 return intersection.boundary() && intersection.neighbor();
798 }
799
800 // mappers
801 ConnectivityMap connectivityMap_;
802 IntersectionMapper intersectionMapper_;
803
805 std::size_t numScvs_;
806 std::size_t numScvf_;
807 std::size_t numBoundaryScv_;
808 std::size_t numBoundaryScvf_;
809 std::vector<bool> hasBoundaryScvf_;
810
811 std::vector<std::vector<GridIndexType>> scvfIndicesOfElement_;
812
813 // a map for periodic boundary vertices
814 std::unordered_map<GridIndexType, GridIndexType> periodicFaceMap_;
815 std::unordered_map<GridIndexType, GridIndexType> outsideVolVarIndices_;
816};
817
818} // end namespace Dumux
819
820#endif
Defines the default element and vertex mapper types.
defines intersection mappers.
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Check the overlap size for different discretization methods.
Base class for grid geometries.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
Dune::Std::detected_or_t< Dumux::BasicGridGeometry< GV, typename T::ElementMapper, typename T::VertexMapper >, Detail::SpecifiesBaseGridGeometry, T > BasicGridGeometry_t
Type of the basic grid geometry implementation used as backend.
Definition: basegridgeometry.hh:51
static std::size_t normalAxis(const Vector &v)
Returns the normal axis index of a unit vector (0 = x, 1 = y, 2 = z)
Definition: normalaxis.hh:38
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
Definition: defaultmappertraits.hh:35
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:38
defines a standard intersection mapper for mapping of global DOFs assigned to faces....
Definition: intersectionmapper.hh:41
Base class for all grid geometries.
Definition: basegridgeometry.hh:61
typename BaseImplementation::GridView GridView
export the grid view type
Definition: basegridgeometry.hh:69
Check if the overlap size is valid for a given discretization method.
Definition: checkoverlapsize.hh:40
Stores the dof indices corresponding to the neighboring scvs that contribute to the derivative calcul...
Definition: facecentered/staggered/connectivitymap.hh:42
Definition: discretization/facecentered/staggered/fvelementgeometry.hh:42
The default traits for the face-center staggered finite volume grid geometry Defines the scv and scvf...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:60
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:74
static constexpr auto numLateralScvfsPerElement
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:79
static constexpr auto maxNumScvfsPerElement
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:82
static constexpr auto numScvsPerElement
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:77
static constexpr auto numFacesPerElement
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:76
static constexpr auto dim
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:75
static constexpr auto numLateralScvfsPerScv
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:78
static constexpr auto minNumScvfsPerElement
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:80
Base class for the finite volume geometry vector for face-centered staggered models This builds up th...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:96
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:107
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:237
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:179
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:245
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:241
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:199
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:144
typename Traits::LocalIntersectionMapper LocalIntersectionMapper
export the local intersection mapper
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:150
typename Traits::GeometryHelper GeometryHelper
export the geometry helper type
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:148
const std::vector< GridIndexType > & scvfIndicesOfElement(GridIndexType eIdx) const
Get the global sub control volume face indices of an element.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:230
FaceCenteredStaggeredFVGridGeometry(std::shared_ptr< BasicGridGeometry > gg, const std::string &paramGroup="")
Constructor with basic grid geometry used to share state with another grid geometry on the same grid ...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:157
typename Traits::StaticInfo StaticInformation
export static information
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:152
std::size_t numDofs() const
the total number of dofs
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:195
const std::unordered_map< GridIndexType, GridIndexType > & periodicVertexMap() const
Returns the map between dofs across periodic boundaries // TODO rename to periodic dof map in fvassem...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:257
std::size_t numBoundaryScv() const
The total number of boundary sub control volumes.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:183
FaceCenteredStaggeredFVGridGeometry(const GridView &gridView, const std::string &paramGroup="")
Constructor from gridView.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:170
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the d.o.f. on the other side of the periodic boundary.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:253
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:213
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:142
typename Traits::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:140
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:206
BasicGridGeometry_t< GV, Traits > BasicGridGeometry
export basic grid geometry type for the alternative constructor
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:138
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:154
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:187
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:191
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:226
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
If a d.o.f. is on a periodic boundary.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:249
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:175
auto scvs(const LocalView &fvGeometry) const
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:218
Base class for the finite volume geometry vector for face-centered staggered models This builds up th...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:528
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:560
typename Traits::GeometryHelper GeometryHelper
export the geometry helper type
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:564
FaceCenteredStaggeredFVGridGeometry(std::shared_ptr< BasicGridGeometry > gg, const std::string &paramGroup="")
Constructor with basic grid geometry used to share state with another grid geometry on the same grid ...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:573
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:558
std::size_t numDofs() const
the total number of dofs
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:611
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the d.o.f. on the other side of the periodic boundary.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:656
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:618
std::size_t numBoundaryScv() const
The total number of boundary sub control volumes.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:599
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:626
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:645
FaceCenteredStaggeredFVGridGeometry(const GridView &gridView, const std::string &paramGroup="")
Constructor from gridView.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:586
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
If a d.o.f. is on a periodic boundary.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:652
typename Traits::StaticInfo StaticInformation
export static information
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:568
const std::vector< GridIndexType > & scvfIndicesOfElement(GridIndexType eIdx) const
Get the global sub control volume face indices of an element.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:630
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:622
const std::unordered_map< GridIndexType, GridIndexType > & periodicVertexMap() const
Returns the map between dofs across periodic boundaries // TODO rename to periodic dof map in fvassem...
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:660
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:595
BasicGridGeometry_t< GV, Traits > BasicGridGeometry
export basic grid geometry type for the alternative constructor
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:554
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:603
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:591
typename Traits::LocalIntersectionMapper LocalIntersectionMapper
export the local intersection mapper
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:566
GridIndexType outsideVolVarIndex(GridIndexType scvfIdx) const
Get the global sub control volume face indices of an element.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:634
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:638
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:607
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:570
typename Traits::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/facecentered/staggered/fvgridgeometry.hh:556
Face centered staggered geometry helper.
Definition: discretization/facecentered/staggered/geometryhelper.hh:40
Definition: localintersectionindexmapper.hh:41
Face centered staggered sub control volume.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:64
Face centered staggered sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:67
Geometry helper for face-centered staggered scheme.