3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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_CONNECTIVITY_MAP_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
26
27#include <algorithm>
28#include <vector>
29#include <dune/grid/common/partitionset.hh>
30#include <dune/grid/common/gridenums.hh>
32
33namespace Dumux {
34
40template<class GridGeometry>
42{
43 using GridView = typename GridGeometry::GridView;
44 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
45 using Stencil = std::vector<GridIndexType>;
46 using Map = std::vector<Stencil>;
47
48public:
49
51 void update(const GridGeometry& gridGeometry)
52 {
53 map_.clear();
54 map_.resize(gridGeometry.numScv());
55
56 auto fvGeometry = localView(gridGeometry);
57 for (const auto& element : elements(gridGeometry.gridView()))
58 {
59 if (element.partitionType() == Dune::InteriorEntity)
60 continue;
61
62 assert(element.partitionType() == Dune::OverlapEntity);
63
64 // restrict the FvGeometry locally and bind to the element
65 fvGeometry.bind(element);
66 // loop over sub control faces
67 for (const auto& scvf : scvfs(fvGeometry))
68 {
69 if (scvf.isFrontal() && !scvf.boundary() && !scvf.processorBoundary())
70 {
71 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
72 const auto& facet = element.template subEntity <1> (ownScv.indexInElement());
73 if (facet.partitionType() == Dune::BorderEntity)
74 map_[ownScv.index()].push_back(scvf.outsideScvIdx());
75 }
76 }
77 }
78
79 for (const auto& element : elements(gridGeometry.gridView(), Dune::Partitions::interior))
80 {
81 fvGeometry.bind(element);
82
83 // loop over sub control faces
84 for (const auto& scvf : scvfs(fvGeometry))
85 {
86 assert(!scvf.processorBoundary());
87 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
88 const auto ownDofIndex = ownScv.dofIndex();
89 const auto ownScvIndex = ownScv.index();
90
91 if (scvf.isFrontal())
92 {
93 if (!scvf.boundary()) // opposite dof
94 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
95 else
96 {
97 // treat frontal faces on boundaries
98 for (const auto& scv : scvs(fvGeometry))
99 {
100 const auto otherDofIndex = scv.dofIndex();
101 if (ownDofIndex != otherDofIndex)
102 map_[scv.index()].push_back(ownScvIndex);
103 }
104 }
105 }
106 else // lateral face
107 {
108 // the parallel DOF scv
109 // outsideScv insideScv
110 // ###y######|s|#####x####
111 // |c|
112 // |v|
113 // |f|
114 if (!scvf.boundary())
115 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
116
117
118 // the normal DOF scv
119 //
120 // outsideScv
121 //
122 // |s|orthogonalScvf
123 // |c|
124 // |v| insideScv
125 // |f|
126 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
127 assert(orthogonalScvf.isLateral());
128 map_[ownScvIndex].push_back(orthogonalScvf.insideScvIdx());
129 if (!orthogonalScvf.boundary())
130 map_[ownScvIndex].push_back(orthogonalScvf.outsideScvIdx());
131 }
132 }
133 }
134
135 // make stencils unique
136 for (auto& stencil : map_)
137 {
138 std::sort(stencil.begin(), stencil.end());
139 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
140 }
141 }
142
143 const Stencil& operator[] (const GridIndexType globalI) const
144 { return map_[globalI]; }
145
146private:
147 Map map_;
148};
149
150} // end namespace Dumux
151
152#endif
Defines the index types used for grid and local indices.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
Stores the dof indices corresponding to the neighboring scvs that contribute to the derivative calcul...
Definition: facecentered/staggered/connectivitymap.hh:42
void update(const GridGeometry &gridGeometry)
Update the map and prepare the stencils.
Definition: facecentered/staggered/connectivitymap.hh:51
const Stencil & operator[](const GridIndexType globalI) const
Definition: facecentered/staggered/connectivitymap.hh:143