Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
3 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
4 | // | ||
5 | /*! | ||
6 | * \file | ||
7 | * | ||
8 | * \brief Some tests for the grid creator | ||
9 | * \note This can/should be extended | ||
10 | */ | ||
11 | |||
12 | #ifndef DUMUX_TEST_IO_GRIDMANAGER_TESTS_HH | ||
13 | #define DUMUX_TEST_IO_GRIDMANAGER_TESTS_HH | ||
14 | |||
15 | #include <dune/grid/common/datahandleif.hh> | ||
16 | #include <dune/grid/common/mcmgmapper.hh> | ||
17 | #include <dune/grid/io/file/vtk.hh> | ||
18 | |||
19 | #include <dumux/io/grid/gridmanager.hh> | ||
20 | #include <dumux/discretization/method.hh> | ||
21 | #include <dumux/common/gridcapabilities.hh> | ||
22 | |||
23 | namespace Dumux { | ||
24 | |||
25 | /*! | ||
26 | * \brief data handle for parallel communication which takes | ||
27 | * the minimum non-zero values that are attached to vertices | ||
28 | */ | ||
29 | template <class GridView> | ||
30 | class VertexHandleNonZeroMin | ||
31 | : public Dune::CommDataHandleIF< VertexHandleNonZeroMin<GridView>, int > | ||
32 | { | ||
33 | using Container = std::vector<int>; | ||
34 | |||
35 | public: | ||
36 | 4 | VertexHandleNonZeroMin(Container &container, const GridView &gridView) | |
37 | : gridView_(gridView) | ||
38 | 8 | , container_(container) | |
39 | {} | ||
40 | |||
41 | ✗ | bool contains(int dim, int codim) const | |
42 | { | ||
43 | // only communicate vertices | ||
44 | ✗ | return codim == dim; | |
45 | } | ||
46 | |||
47 | ✗ | bool fixedSize(int dim, int codim) const | |
48 | { | ||
49 | // for each vertex we communicate a single field vector which | ||
50 | // has a fixed size | ||
51 | ✗ | return true; | |
52 | } | ||
53 | |||
54 | template<class EntityType> | ||
55 | ✗ | size_t size (const EntityType &e) const | |
56 | { | ||
57 | // communicate a field type per entity | ||
58 | ✗ | return 1; | |
59 | } | ||
60 | |||
61 | template<class MessageBufferImp, class EntityType> | ||
62 | 2868 | void gather(MessageBufferImp &buff, const EntityType &e) const | |
63 | { | ||
64 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
|
2868 | int vIdx = gridView_.indexSet().index(e); |
65 | 6228 | buff.write(container_[vIdx]); | |
66 | 2868 | } | |
67 | |||
68 | template<class MessageBufferImp, class EntityType> | ||
69 | 2868 | void scatter(MessageBufferImp &buff, const EntityType &e, size_t n) | |
70 | { | ||
71 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 158 times.
✓ Branch 3 taken 88 times.
|
2868 | int vIdx = gridView_.indexSet().index(e); |
72 | int tmp; | ||
73 |
2/2✓ Branch 0 taken 158 times.
✓ Branch 1 taken 88 times.
|
2868 | buff.read(tmp); |
74 | using std::min; | ||
75 |
2/2✓ Branch 0 taken 841 times.
✓ Branch 1 taken 593 times.
|
2868 | if (tmp > 0) |
76 | { | ||
77 |
4/4✓ Branch 0 taken 495 times.
✓ Branch 1 taken 346 times.
✓ Branch 2 taken 495 times.
✓ Branch 3 taken 346 times.
|
3364 | if (container_[vIdx] == 0) |
78 | 990 | container_[vIdx] = tmp; | |
79 | else | ||
80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 346 times.
|
692 | container_[vIdx] = min(container_[vIdx], tmp); |
81 | } | ||
82 | 2868 | } | |
83 | |||
84 | private: | ||
85 | const GridView gridView_; | ||
86 | Container &container_; | ||
87 | }; | ||
88 | |||
89 | template<class Grid> | ||
90 | class GridManagerTests | ||
91 | { | ||
92 | using GridView = typename Grid::LeafGridView; | ||
93 | using Scalar = double; | ||
94 | static const int dim = Grid::dimension; | ||
95 | using GridManager = typename Dumux::GridManager<Grid>; | ||
96 | |||
97 | public: | ||
98 | |||
99 | 6 | static void testBoundaryAndElementMarkers(const std::string& type = "gmsh", | |
100 | const std::string& vtkFileName = "test", | ||
101 | bool refine = true) | ||
102 | { | ||
103 | // make the grid manager and initialize the grid | ||
104 | 6 | GridManager gridManager; | |
105 |
5/12✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
12 | gridManager.init(); |
106 |
1/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12 | auto gridData = gridManager.getGridData(); |
107 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | const auto& leafGridView = gridManager.grid().leafGridView(); |
108 | |||
109 | // read the boundary and element markers as well as the rank | ||
110 |
6/18✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
|
36 | std::vector<int> boundaryMarker, elementMarker, rank; |
111 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | getBoundaryMarkers_(leafGridView, gridData, boundaryMarker); |
112 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | getElementMarkers_(leafGridView, gridData, elementMarker, type); |
113 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | getRank_(leafGridView, rank); |
114 | |||
115 | // construct a vtk output writer and attach the boundary markers | ||
116 |
9/18✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 6 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✓ Branch 20 taken 6 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 6 times.
✗ Branch 24 not taken.
|
30 | Dune::VTKSequenceWriter<typename Grid::LeafGridView> vtkWriter(leafGridView, vtkFileName, ".", ""); |
117 |
5/12✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
12 | vtkWriter.addVertexData(boundaryMarker, "boundaryMarker"); |
118 |
5/12✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
12 | vtkWriter.addCellData(elementMarker, "elementMarker"); |
119 |
5/12✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
12 | vtkWriter.addCellData(rank, "rank"); |
120 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | vtkWriter.write(0); |
121 | |||
122 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
|
6 | if (refine) |
123 | { | ||
124 | // refine grid once and write out the markers again | ||
125 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | gridManager.grid().globalRefine(1); |
126 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | getBoundaryMarkers_(leafGridView, gridData, boundaryMarker); |
127 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | getElementMarkers_(leafGridView, gridData, elementMarker, type); |
128 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | getRank_(leafGridView, rank); |
129 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | vtkWriter.write(1); |
130 | } | ||
131 | 6 | } | |
132 | |||
133 | template<class Marker = int> | ||
134 | 12 | static void testElementMarkers(const std::string& type = "gmsh", | |
135 | const std::string& vtkFileName = "test", | ||
136 | bool refine = true) | ||
137 | { | ||
138 | // make the grid manager and initialize the grid | ||
139 | 12 | GridManager gridManager; | |
140 |
5/12✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
24 | gridManager.init(); |
141 |
1/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
24 | auto gridData = gridManager.getGridData(); |
142 | |||
143 | // read the element markers and the rank | ||
144 |
2/6✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
24 | std::vector<Marker> elementMarker; |
145 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
|
24 | std::vector<int> rank; |
146 |
3/6✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
|
12 | getElementMarkers_(gridManager.grid().leafGridView(), gridData, elementMarker, type); |
147 |
3/8✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
12 | getRank_(gridManager.grid().leafGridView(), rank); |
148 | |||
149 | // construct a vtk output writer and attach the element markers | ||
150 |
12/26✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 12 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 12 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 12 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 12 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 12 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 12 times.
✓ Branch 28 taken 12 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 12 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
|
36 | Dune::VTKSequenceWriter<typename Grid::LeafGridView> vtkWriter(gridManager.grid().leafGridView(), vtkFileName, ".", ""); |
151 |
5/12✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
24 | vtkWriter.addCellData(elementMarker, "elementMarker"); |
152 |
5/12✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
24 | vtkWriter.addCellData(rank, "rank"); |
153 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | vtkWriter.write(0); |
154 | |||
155 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (refine) |
156 | { | ||
157 | // refine grid once and write out the markers again | ||
158 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
12 | gridManager.grid().globalRefine(1); |
159 |
3/6✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
|
12 | getElementMarkers_(gridManager.grid().leafGridView(), gridData, elementMarker, type); |
160 |
3/6✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
|
12 | getRank_(gridManager.grid().leafGridView(), rank); |
161 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | vtkWriter.write(1); |
162 | } | ||
163 | 12 | } | |
164 | |||
165 | template<class Marker = int> | ||
166 | 6 | static void testVertexMarkers(const std::string& type = "dgf", | |
167 | const std::string& vtkFileName = "test") | ||
168 | { | ||
169 | // make the grid manager and initialize the grid | ||
170 | 6 | GridManager gridManager; | |
171 |
5/12✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
12 | gridManager.init(); |
172 |
1/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12 | auto gridData = gridManager.getGridData(); |
173 | |||
174 | // read the element markers and the rank | ||
175 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
|
12 | std::vector<Marker> vertexMarker; |
176 |
3/8✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
6 | getVertexMarkers_(gridManager.grid().levelGridView(0), gridData, vertexMarker, type); |
177 | |||
178 | // construct a vtk output writer and attach the element markers | ||
179 |
12/26✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 6 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 6 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 6 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 6 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 6 times.
✓ Branch 28 taken 6 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 6 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
|
18 | Dune::VTKSequenceWriter<typename Grid::LevelGridView> vtkWriter(gridManager.grid().levelGridView(0), vtkFileName, ".", ""); |
180 |
5/12✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
12 | vtkWriter.addVertexData(vertexMarker, "vertexData"); |
181 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | vtkWriter.write(0); |
182 | 6 | } | |
183 | |||
184 | private: | ||
185 | |||
186 | 31 | static void getRank_(const GridView& gridView, std::vector<int>& rank) | |
187 | { | ||
188 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 18 times.
|
31 | rank.clear(); |
189 | 31 | rank.resize(gridView.size(0)); | |
190 | |||
191 |
11/12✓ Branch 1 taken 116932 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 116932 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 116932 times.
✓ Branch 7 taken 107588 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 107588 times.
✓ Branch 10 taken 15 times.
✓ Branch 12 taken 107588 times.
✗ Branch 13 not taken.
|
449071 | for(const auto& element : elements(gridView)) |
192 | { | ||
193 |
3/7✗ Branch 0 not taken.
✓ Branch 1 taken 224520 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 107588 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 107588 times.
✗ Branch 8 not taken.
|
332108 | auto eIdx = gridView.indexSet().index(element); |
194 |
3/6✓ Branch 2 taken 107588 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 107588 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 107588 times.
✗ Branch 9 not taken.
|
575316 | rank[eIdx] = gridView.comm().rank(); |
195 | } | ||
196 | 31 | } | |
197 | |||
198 | template<class GridData, class Marker> | ||
199 | 31 | static void getElementMarkers_(const GridView& gridView, | |
200 | const GridData& gridData, | ||
201 | std::vector<Marker>& elementMarker, | ||
202 | const std::string& type) | ||
203 | { | ||
204 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 18 times.
|
31 | elementMarker.clear(); |
205 | 31 | elementMarker.resize(gridView.size(0)); | |
206 | |||
207 |
12/14✓ Branch 1 taken 116932 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 116932 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 116932 times.
✓ Branch 7 taken 107588 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 107588 times.
✓ Branch 10 taken 15 times.
✓ Branch 12 taken 107588 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 107588 times.
✗ Branch 16 not taken.
|
224551 | for(const auto& element : elements(gridView)) |
208 | { | ||
209 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 224520 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 107588 times.
✗ Branch 5 not taken.
|
224520 | const auto eIdx = gridView.indexSet().index(element); |
210 |
2/2✓ Branch 1 taken 142912 times.
✓ Branch 2 taken 81608 times.
|
224520 | if (type == "gmsh") |
211 |
2/4✓ Branch 1 taken 62910 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 62910 times.
✗ Branch 5 not taken.
|
285824 | elementMarker[eIdx] = gridData->getElementDomainMarker(element); |
212 |
1/2✓ Branch 1 taken 81608 times.
✗ Branch 2 not taken.
|
81608 | else if (type == "dgf") |
213 |
2/4✓ Branch 1 taken 44678 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 44678 times.
✗ Branch 5 not taken.
|
163216 | elementMarker[eIdx] = gridData->parameters(element)[0]; |
214 | ✗ | else if (type == "vtu" || type == "vtk") | |
215 | ✗ | elementMarker[eIdx] = gridData->getParameter(element, "elementMarker"); | |
216 | else | ||
217 | ✗ | DUNE_THROW(Dune::InvalidStateException, "No parameters for type " << type); | |
218 | } | ||
219 | 31 | } | |
220 | |||
221 | template<class LevelGridView, class GridData, class Marker> | ||
222 | 6 | static void getVertexMarkers_(const LevelGridView& gridView, | |
223 | const GridData& gridData, | ||
224 | std::vector<Marker>& vertexMarker, | ||
225 | const std::string& type) | ||
226 | { | ||
227 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
|
6 | if (type == "gmsh") |
228 | ✗ | DUNE_THROW(Dune::InvalidStateException, "Vertex markers are not supported for gmsh grids."); | |
229 | |||
230 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | vertexMarker.clear(); |
231 | 6 | vertexMarker.resize(gridView.size(Grid::dimension)); | |
232 | |||
233 |
10/12✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 7723 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 7723 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 7723 times.
✓ Branch 11 taken 7711 times.
✓ Branch 17 taken 7711 times.
✗ Branch 18 not taken.
|
30889 | for (const auto& vertex : vertices(gridView.grid().levelGridView(0))) |
234 | { | ||
235 |
1/2✓ Branch 1 taken 7711 times.
✗ Branch 2 not taken.
|
15434 | const auto vIdx = gridView.indexSet().index(vertex); |
236 |
1/2✓ Branch 1 taken 15434 times.
✗ Branch 2 not taken.
|
15434 | if (type == "dgf") |
237 |
2/4✓ Branch 1 taken 7711 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7711 times.
✗ Branch 5 not taken.
|
30868 | vertexMarker[vIdx] = gridData->parameters(vertex)[0]; |
238 | ✗ | else if (type == "vtu" || type == "vtk") | |
239 | ✗ | vertexMarker[vIdx] = gridData->getParameter(vertex, "vertexData"); | |
240 | else | ||
241 | ✗ | DUNE_THROW(Dune::InvalidStateException, "No parameters for type " << type); | |
242 | } | ||
243 | 6 | } | |
244 | |||
245 | template<class GridData, class Marker> | ||
246 | 7 | static void getBoundaryMarkers_(const GridView& gridView, | |
247 | const GridData& gridData, | ||
248 | std::vector<Marker>& boundaryMarker) | ||
249 | { | ||
250 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
|
7 | boundaryMarker.clear(); |
251 | 7 | boundaryMarker.resize(gridView.size(dim), 0); | |
252 | |||
253 |
10/12✓ Branch 1 taken 22498 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 22498 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5178 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 5178 times.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 5178 times.
✗ Branch 13 not taken.
|
55359 | for(const auto& element : elements(gridView)) |
254 | { | ||
255 |
9/14✓ Branch 1 taken 5178 times.
✓ Branch 2 taken 22498 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 46222 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 112490 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 18546 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 19180 times.
✓ Branch 14 taken 70812 times.
✓ Branch 16 taken 89992 times.
✓ Branch 17 taken 5178 times.
✗ Branch 18 not taken.
|
229292 | for(const auto& intersection : intersections(gridView, element)) |
256 | { | ||
257 |
3/3✓ Branch 0 taken 19180 times.
✓ Branch 1 taken 72608 times.
✓ Branch 2 taken 16750 times.
|
108538 | if (!intersection.boundary()) |
258 | continue; | ||
259 | |||
260 |
2/4✓ Branch 1 taken 7234 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7234 times.
✗ Branch 5 not taken.
|
12672 | const auto refElement = referenceElement(element.geometry()); |
261 |
1/2✓ Branch 1 taken 1796 times.
✗ Branch 2 not taken.
|
12672 | const auto numVertices = refElement.size(intersection.indexInInside(), 1, dim); |
262 | // loop over vertices of the intersection facet | ||
263 |
2/2✓ Branch 1 taken 21702 times.
✓ Branch 2 taken 7234 times.
|
28936 | for(std::size_t vIdx = 0; vIdx < numVertices; vIdx++) |
264 | { | ||
265 | // get local vertex index with respect to the element | ||
266 |
1/2✓ Branch 1 taken 5388 times.
✗ Branch 2 not taken.
|
38016 | auto vIdxLocal = refElement.subEntity(intersection.indexInInside(), 1, vIdx, dim); |
267 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 21702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16314 times.
✓ Branch 4 taken 5388 times.
✗ Branch 5 not taken.
|
21702 | auto vIdxGlobal = gridView.indexSet().subIndex(element, vIdxLocal, dim); |
268 | |||
269 | // make sure we always take the lowest non-zero marker (problem dependent!) | ||
270 |
4/4✓ Branch 0 taken 3781 times.
✓ Branch 1 taken 17921 times.
✓ Branch 2 taken 3781 times.
✓ Branch 3 taken 17921 times.
|
43404 | if (boundaryMarker[vIdxGlobal] == 0) |
271 |
2/4✓ Branch 1 taken 3781 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3781 times.
✗ Branch 5 not taken.
|
15124 | boundaryMarker[vIdxGlobal] = gridData->getBoundaryDomainMarker(intersection); |
272 | else | ||
273 | { | ||
274 |
4/6✓ Branch 1 taken 17921 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17921 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84 times.
✓ Branch 7 taken 17837 times.
|
53763 | if (boundaryMarker[vIdxGlobal] > gridData->getBoundaryDomainMarker(intersection)) |
275 |
2/4✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
|
336 | boundaryMarker[vIdxGlobal] = gridData->getBoundaryDomainMarker(intersection); |
276 | } | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | // In a parallel setting, it is possible that not all boundary vertices | ||
282 | // will be reached on each process by the procedure above that loops | ||
283 | // over the boundary intersections and their vertices. This mandates the | ||
284 | // following synchronization. | ||
285 |
5/6✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 2 times.
|
7 | if (gridView.comm().size() > 1) |
286 | { | ||
287 | 4 | VertexHandleNonZeroMin<GridView> dataHandle(boundaryMarker, gridView); | |
288 | if constexpr (Detail::canCommunicate<typename GridView::Traits::Grid, GridView::dimension>) | ||
289 | 4 | gridView.communicate(dataHandle, | |
290 | Dune::InteriorBorder_All_Interface, | ||
291 | Dune::ForwardCommunication); | ||
292 | else | ||
293 | DUNE_THROW(Dune::InvalidStateException, "Cannot call getBoundaryMarkers_ on multiple processes for a grid that cannot communicate codim-" << GridView::dimension << "-entities"); | ||
294 | } | ||
295 | 7 | } | |
296 | }; | ||
297 | |||
298 | } // end namespace Dumux | ||
299 | |||
300 | #endif | ||
301 |