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 FaceCenteredStaggeredDiscretization | ||
10 | * \copydoc Dumux::FaceCenteredStaggeredConnectivityMap | ||
11 | */ | ||
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> | ||
19 | #include <dumux/common/indextraits.hh> | ||
20 | |||
21 | namespace Dumux { | ||
22 | |||
23 | /*! | ||
24 | * \ingroup FaceCenteredStaggeredDiscretization | ||
25 | * \brief Stores the dof indices corresponding to the neighboring scvs | ||
26 | * that contribute to the derivative calculation. | ||
27 | */ | ||
28 | template<class GridGeometry> | ||
29 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
74 | class FaceCenteredStaggeredConnectivityMap |
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 | |||
36 | public: | ||
37 | |||
38 | //! Update the map and prepare the stencils | ||
39 | 74 | void update(const GridGeometry& gridGeometry) | |
40 | { | ||
41 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
|
74 | map_.clear(); |
42 | 74 | map_.resize(gridGeometry.numScv()); | |
43 | |||
44 | 74 | auto fvGeometry = localView(gridGeometry); | |
45 |
9/11✓ Branch 2 taken 343854 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 115 times.
✓ Branch 6 taken 121700 times.
✓ Branch 9 taken 3536 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3536 times.
✓ Branch 12 taken 6 times.
✓ Branch 4 taken 111 times.
✓ Branch 7 taken 121694 times.
✓ Branch 8 taken 4 times.
|
1407590 | for (const auto& element : elements(gridGeometry.gridView())) |
46 | { | ||
47 |
4/5✓ Branch 0 taken 125339 times.
✓ Branch 1 taken 343622 times.
✓ Branch 3 taken 468961 times.
✓ Branch 4 taken 164 times.
✗ Branch 2 not taken.
|
812747 | assert(element.partitionType() == Dune::OverlapEntity || element.partitionType() == Dune::InteriorEntity); |
48 | |||
49 | 469125 | fvGeometry.bind(element); | |
50 | |||
51 | // loop over sub control faces | ||
52 |
4/4✓ Branch 0 taken 336 times.
✓ Branch 1 taken 5713170 times.
✓ Branch 2 taken 5713506 times.
✓ Branch 3 taken 469125 times.
|
11859515 | for (const auto& scvf : scvfs(fvGeometry)) |
53 | { | ||
54 |
2/2✓ Branch 0 taken 336 times.
✓ Branch 1 taken 5713170 times.
|
5713506 | if(scvf.processorBoundary()) |
55 | 336 | continue; | |
56 | |||
57 |
4/4✓ Branch 0 taken 1376614 times.
✓ Branch 1 taken 4312412 times.
✓ Branch 2 taken 565814 times.
✓ Branch 3 taken 1033176 times.
|
5713170 | const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx()); |
58 |
2/2✓ Branch 0 taken 1930762 times.
✓ Branch 1 taken 3782408 times.
|
5713170 | const auto ownDofIndex = ownScv.dofIndex(); |
59 |
2/2✓ Branch 0 taken 1930762 times.
✓ Branch 1 taken 3782408 times.
|
5713170 | const auto ownScvIndex = ownScv.index(); |
60 | |||
61 |
2/2✓ Branch 0 taken 1930762 times.
✓ Branch 1 taken 3782408 times.
|
5713170 | if (scvf.isFrontal()) |
62 | { | ||
63 |
2/2✓ Branch 0 taken 1880186 times.
✓ Branch 1 taken 50576 times.
|
1930762 | if (!scvf.boundary()) // opposite dof |
64 |
1/2✓ Branch 1 taken 1880186 times.
✗ Branch 2 not taken.
|
1880186 | map_[ownScvIndex].push_back(scvf.outsideScvIdx()); |
65 | else | ||
66 | { | ||
67 | // treat frontal faces on boundaries | ||
68 |
5/5✓ Branch 1 taken 156220 times.
✓ Branch 2 taken 51794 times.
✓ Branch 3 taken 206390 times.
✓ Branch 4 taken 50170 times.
✓ Branch 0 taken 1218 times.
|
258184 | for (const auto& scv : scvs(fvGeometry)) |
69 | { | ||
70 | 207608 | const auto otherDofIndex = scv.dofIndex(); | |
71 |
2/2✓ Branch 0 taken 157032 times.
✓ Branch 1 taken 50576 times.
|
207608 | if (ownDofIndex != otherDofIndex) |
72 |
1/2✓ Branch 1 taken 157032 times.
✗ Branch 2 not taken.
|
157032 | 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 |
2/2✓ Branch 0 taken 3675952 times.
✓ Branch 1 taken 106456 times.
|
3782408 | if (!scvf.boundary()) |
85 |
1/2✓ Branch 1 taken 3675952 times.
✗ Branch 2 not taken.
|
3675952 | 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 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3782408 times.
|
3782408 | const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf); |
97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3782408 times.
|
3782408 | assert(orthogonalScvf.isLateral()); |
98 |
3/4✓ Branch 1 taken 3782408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3675960 times.
✓ Branch 4 taken 106448 times.
|
3782408 | map_[ownScvIndex].push_back(orthogonalScvf.insideScvIdx()); |
99 |
2/2✓ Branch 0 taken 3675960 times.
✓ Branch 1 taken 106448 times.
|
3782408 | if (!orthogonalScvf.boundary()) |
100 |
1/2✓ Branch 1 taken 3675960 times.
✗ Branch 2 not taken.
|
3675960 | map_[ownScvIndex].push_back(orthogonalScvf.outsideScvIdx()); |
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | // make stencils unique | ||
106 |
2/2✓ Branch 1 taken 1880186 times.
✓ Branch 2 taken 74 times.
|
1880260 | for (auto& stencil : map_) |
107 | { | ||
108 | 1880186 | std::sort(stencil.begin(), stencil.end()); | |
109 | 1880186 | stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end()); | |
110 | } | ||
111 | 74 | } | |
112 | |||
113 | 9917940 | const Stencil& operator[] (const GridIndexType globalI) const | |
114 | 9917940 | { return map_[globalI]; } | |
115 | |||
116 | private: | ||
117 | Map map_; | ||
118 | }; | ||
119 | |||
120 | } // end namespace Dumux | ||
121 | |||
122 | #endif | ||
123 |