version 3.10-dev
facecentered/staggered/connectivitymap.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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
14
15#include <algorithm>
16#include <vector>
17#include <dune/grid/common/partitionset.hh>
18#include <dune/grid/common/gridenums.hh>
20
21namespace Dumux {
22
28template<class GridGeometry>
30{
31 using GridView = typename GridGeometry::GridView;
32 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
33 using Stencil = std::vector<GridIndexType>;
34 using Map = std::vector<Stencil>;
35
36public:
37
39 void update(const GridGeometry& gridGeometry)
40 {
41 map_.clear();
42 map_.resize(gridGeometry.numScv());
43
44 auto fvGeometry = localView(gridGeometry);
45 for (const auto& element : elements(gridGeometry.gridView()))
46 {
47 assert(element.partitionType() == Dune::OverlapEntity || element.partitionType() == Dune::InteriorEntity);
48
49 fvGeometry.bind(element);
50
51 // loop over sub control faces
52 for (const auto& scvf : scvfs(fvGeometry))
53 {
54 if(scvf.processorBoundary())
55 continue;
56
57 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
58 const auto ownDofIndex = ownScv.dofIndex();
59 const auto ownScvIndex = ownScv.index();
60
61 if (scvf.isFrontal())
62 {
63 if (!scvf.boundary()) // opposite dof
64 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
65 else
66 {
67 // treat frontal faces on boundaries
68 for (const auto& scv : scvs(fvGeometry))
69 {
70 const auto otherDofIndex = scv.dofIndex();
71 if (ownDofIndex != otherDofIndex)
72 map_[scv.index()].push_back(ownScvIndex);
73 }
74 }
75 }
76 else // lateral face
77 {
78 // the parallel DOF scv
79 // outsideScv insideScv
80 // ###y######|s|#####x####
81 // |c|
82 // |v|
83 // |f|
84 if (!scvf.boundary())
85 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
86
87
88 // the normal DOF scv
89 //
90 // outsideScv
91 //
92 // |s|orthogonalScvf
93 // |c|
94 // |v| insideScv
95 // |f|
96 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
97 assert(orthogonalScvf.isLateral());
98 map_[ownScvIndex].push_back(orthogonalScvf.insideScvIdx());
99 if (!orthogonalScvf.boundary())
100 map_[ownScvIndex].push_back(orthogonalScvf.outsideScvIdx());
101 }
102 }
103 }
104
105 // make stencils unique
106 for (auto& stencil : map_)
107 {
108 std::sort(stencil.begin(), stencil.end());
109 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
110 }
111 }
112
113 const Stencil& operator[] (const GridIndexType globalI) const
114 { return map_[globalI]; }
115
116private:
117 Map map_;
118};
119
120} // end namespace Dumux
121
122#endif
Stores the dof indices corresponding to the neighboring scvs that contribute to the derivative calcul...
Definition: facecentered/staggered/connectivitymap.hh:30
void update(const GridGeometry &gridGeometry)
Update the map and prepare the stencils.
Definition: facecentered/staggered/connectivitymap.hh:39
const Stencil & operator[](const GridIndexType globalI) const
Definition: facecentered/staggered/connectivitymap.hh:113
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
Defines the index types used for grid and local indices.
Definition: adapt.hh:17
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27