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-FileCopyrightInfo: 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 Discretization | ||
10 | * \copydoc Dumux::WallDistance | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_WALL_DISTANCE_HH | ||
13 | #define DUMUX_DISCRETIZATION_WALL_DISTANCE_HH | ||
14 | |||
15 | #include <vector> | ||
16 | |||
17 | #include <dune/common/parallel/mpihelper.hh> | ||
18 | #include <dune/common/shared_ptr.hh> | ||
19 | #include <dune/common/reservedvector.hh> | ||
20 | #include <dune/grid/common/partitionset.hh> | ||
21 | |||
22 | #include <dumux/common/tag.hh> | ||
23 | #include <dumux/common/indextraits.hh> | ||
24 | #include <dumux/parallel/parallel_for.hh> | ||
25 | #include <dumux/geometry/distancefield.hh> | ||
26 | |||
27 | namespace Dumux { | ||
28 | |||
29 | /*! | ||
30 | * \ingroup Discretization | ||
31 | * \brief Class to calculate the wall distance at every element or vertex of a grid | ||
32 | * \tparam GridGeometry The grid geometry. | ||
33 | * \tparam DistanceField The type of distance field to use (parameterized with the geometry type) | ||
34 | */ | ||
35 | template<class GridGeometry, template<class> class DistanceField = AABBDistanceField> | ||
36 | class WallDistance | ||
37 | { | ||
38 | using GridView = typename GridGeometry::GridView; | ||
39 | using GridIndexType = typename IndexTraits<GridView>::GridIndex; | ||
40 | using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; | ||
41 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
42 | using Element = typename GridGeometry::GridView::template Codim<0>::Entity; | ||
43 | using Scalar = typename GridView::Grid::ctype; | ||
44 | using GlobalPosition = typename SubControlVolumeFace::GlobalPosition; | ||
45 | |||
46 | static constexpr int dim = GridView::dimension; | ||
47 | static constexpr int dimWorld = GridView::dimensionworld; | ||
48 | static_assert(dim == dimWorld, "Wall distances cannot be computed for embedded surface or network domains."); | ||
49 | |||
50 | using CornerStorage = Dune::ReservedVector<GlobalPosition, (1<<(GridView::dimension-1))>; | ||
51 | |||
52 | // We use a simplified geometry type here which allows much easier MPI communication | ||
53 | // for parallel runs compared to the Dune geometry types (due to fixed-size storage). | ||
54 | // This type only implements a minimal part of the Geometry interface. | ||
55 | struct SimpleGeometry | ||
56 | { | ||
57 | 19200 | SimpleGeometry() = default; | |
58 | 42578 | SimpleGeometry(CornerStorage&& corners) | |
59 | 42578 | : corners_(std::move(corners)) | |
60 | 42578 | , center_(0.0) | |
61 | { | ||
62 |
2/2✓ Branch 0 taken 81248 times.
✓ Branch 1 taken 21554 times.
|
204014 | for (int i = 0; i < corners_.size(); ++i) |
63 | 484308 | center_ += corners_[i]; | |
64 | 42578 | center_ /= corners_.size(); | |
65 | 42578 | } | |
66 | |||
67 | using GlobalCoordinate = GlobalPosition; | ||
68 | using ctype = typename GlobalCoordinate::value_type; | ||
69 | static constexpr int coorddimension = GridView::dimensionworld; | ||
70 | static constexpr int mydimension = GridView::dimension-1; | ||
71 | |||
72 | std::size_t corners() const | ||
73 |
22/44✓ Branch 0 taken 530 times.
✓ Branch 1 taken 530 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 213155 times.
✓ Branch 8 taken 96 times.
✓ Branch 9 taken 96 times.
✓ Branch 10 taken 48 times.
✓ Branch 11 taken 48 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14064 times.
✓ Branch 14 taken 14064 times.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 23040 times.
✓ Branch 20 taken 7680 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 9744 times.
✓ Branch 23 taken 9744 times.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5760 times.
✓ Branch 29 taken 1920 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 290679 times.
✓ Branch 32 taken 290679 times.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 37 taken 32580 times.
✓ Branch 38 taken 10860 times.
✓ Branch 39 taken 213155 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✓ Branch 46 taken 7240 times.
✓ Branch 47 taken 3620 times.
|
834845 | { return corners_.size(); } |
74 | |||
75 | const auto& corner(int i) const | ||
76 | 4010570 | { return corners_[i]; } | |
77 | |||
78 | const auto& center() const | ||
79 | { return center_; } | ||
80 | |||
81 | private: | ||
82 | CornerStorage corners_; | ||
83 | GlobalCoordinate center_; | ||
84 | }; | ||
85 | |||
86 | 79536 | struct WallDataImpl | |
87 | { | ||
88 | GridIndexType eIdx; | ||
89 | GridIndexType scvfIdx; | ||
90 | GlobalPosition scvfOuterNormal; | ||
91 | int rank; // for parallel runs | ||
92 | }; | ||
93 | |||
94 | struct ElementCenters {}; | ||
95 | struct VertexCenters {}; | ||
96 | |||
97 | public: | ||
98 | static constexpr auto atElementCenters = Utility::Tag<ElementCenters>{}; | ||
99 | static constexpr auto atVertexCenters = Utility::Tag<VertexCenters>{}; | ||
100 | using WallData = WallDataImpl; | ||
101 | |||
102 | /*! | ||
103 | * \brief Constructs a new wall distance object | ||
104 | * \param gridGeometry the grid geometry of the grid | ||
105 | * \param tag the policy (either WallDistance::atElementCenters or WallDistance::atVertexCenters) | ||
106 | * \param select a selection functor taking an scvf and returning bool signifying whether the scvfs is part of the wall | ||
107 | */ | ||
108 | template<class LocationTag, class ScvfSelectionFunctor> | ||
109 | 69 | WallDistance(std::shared_ptr<const GridGeometry> gridGeometry, LocationTag tag, const ScvfSelectionFunctor& select) | |
110 |
0/6✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
207 | : gridGeometry_(gridGeometry) |
111 | { | ||
112 |
1/2✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
|
69 | initializeWallDistance_(select, tag); |
113 | 69 | } | |
114 | |||
115 | /*! | ||
116 | * \brief Constructs a new wall distance object | ||
117 | * \param gridGeometry the grid geometry of the grid | ||
118 | * \param tag the policy (either WallDistance::atElementCenters or WallDistance::atVertexCenters) | ||
119 | * \note selects all boundary scvfs as wall faces | ||
120 | */ | ||
121 | template<class LocationTag> | ||
122 | 20 | WallDistance(std::shared_ptr<const GridGeometry> gridGeometry, LocationTag tag) | |
123 |
2/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
40 | : WallDistance(gridGeometry, tag, [](const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvf) { return true; }) {} |
124 | |||
125 | //! caller has to make sure the lifetime of grid geometry exceeds the lifetime of wall distance | ||
126 | template<class LocationTag, class ScvfSelectionFunctor> | ||
127 | 49 | WallDistance(const GridGeometry& gridGeometry, LocationTag tag, const ScvfSelectionFunctor& select) | |
128 |
2/6✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
98 | : WallDistance(Dune::stackobject_to_shared_ptr(gridGeometry), tag, select) {} |
129 | |||
130 | //! caller has to make sure the lifetime of grid geometry exceeds the lifetime of wall distance | ||
131 | template<class LocationTag> | ||
132 | 20 | WallDistance(const GridGeometry& gridGeometry, LocationTag tag) | |
133 |
2/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
40 | : WallDistance(Dune::stackobject_to_shared_ptr(gridGeometry), tag) {} |
134 | |||
135 | /*! | ||
136 | * \brief Returns a vector storing the distance from each DOF location to the nearest wall. | ||
137 | * For the atElementCenter policy, this is the distance from the element center to the nearest wall. | ||
138 | * For the atVertexCenter policy, this is the distance from the vertex to the nearest wall. | ||
139 | */ | ||
140 | const std::vector<Scalar>& wallDistance() const | ||
141 | { return distance_; } | ||
142 | |||
143 | /*! | ||
144 | * \brief Returns a vector storing additional information about the nearest scvf on the wall (element index and scvf index). | ||
145 | * For the atElementCenter policy, this information is given for each element | ||
146 | * For the atVertexCenter policy, this information is given for each vertex. | ||
147 | */ | ||
148 | const std::vector<WallData>& wallData() const | ||
149 | { return wallData_; } | ||
150 | |||
151 | private: | ||
152 | /*! | ||
153 | * \brief Perform the actual calculation of wall distances. | ||
154 | * \param considerFace Function object (e.g. a lambda) that determines whether a certain scvf shall be considered | ||
155 | * for the calculation of wall distances. | ||
156 | * \param loc Location a which the distance to the wall shall be calculated (elementCenter or vertex) | ||
157 | */ | ||
158 | template<class ConsiderFaceFunction, class LocationTag> | ||
159 | 69 | void initializeWallDistance_(const ConsiderFaceFunction& considerFace, LocationTag loc) | |
160 | { | ||
161 | 69 | const std::size_t numSamplingPoints = (loc == atElementCenters) | |
162 | 187 | ? gridGeometry_->gridView().size(0) | |
163 | 60 | : gridGeometry_->gridView().size(dim); | |
164 | // Reset the containers. | ||
165 | 69 | wallData_.resize(numSamplingPoints); | |
166 | 69 | distance_.resize(numSamplingPoints, std::numeric_limits<Scalar>::max()); | |
167 | |||
168 |
1/4✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
69 | std::vector<SimpleGeometry> wallGeometries; |
169 |
3/6✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 29 times.
✗ Branch 8 not taken.
|
167 | wallGeometries.reserve(gridGeometry_->numBoundaryScvf()); |
170 | |||
171 |
2/6✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
138 | std::vector<WallData> tempWallData; |
172 |
3/6✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 29 times.
✗ Branch 8 not taken.
|
167 | tempWallData.reserve(gridGeometry_->numBoundaryScvf()); |
173 | |||
174 | // Loop over all elements: find all wall scvfs. | ||
175 |
3/8✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
146 | auto fvGeometry = localView(*gridGeometry_); |
176 |
12/20✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 49 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 10733 times.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 34328 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 34328 times.
✓ Branch 18 taken 4 times.
✓ Branch 20 taken 34328 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 34328 times.
✗ Branch 24 not taken.
|
98943 | for (const auto& element : elements(gridGeometry_->gridView(), Dune::Partitions::interior)) |
177 | { | ||
178 |
1/2✓ Branch 1 taken 34328 times.
✗ Branch 2 not taken.
|
83696 | fvGeometry.bindElement(element); |
179 |
4/4✓ Branch 0 taken 11390 times.
✓ Branch 1 taken 33626 times.
✓ Branch 2 taken 11390 times.
✓ Branch 3 taken 33626 times.
|
167392 | if (!fvGeometry.hasBoundaryScvf()) |
180 | continue; | ||
181 | |||
182 |
3/6✓ Branch 1 taken 7216 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7216 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7216 times.
✗ Branch 8 not taken.
|
63258 | const auto eIdx = gridGeometry_->elementMapper().index(element); |
183 | |||
184 |
6/6✓ Branch 0 taken 81748 times.
✓ Branch 1 taken 11390 times.
✓ Branch 2 taken 81748 times.
✓ Branch 3 taken 11390 times.
✓ Branch 4 taken 7030 times.
✓ Branch 5 taken 21506 times.
|
198892 | for (const auto& scvf : scvfs(fvGeometry)) |
185 | { | ||
186 |
5/5✓ Branch 0 taken 24162 times.
✓ Branch 1 taken 57586 times.
✓ Branch 2 taken 10512 times.
✓ Branch 3 taken 1194 times.
✓ Branch 4 taken 1280 times.
|
156720 | if (scvf.boundary() && considerFace(fvGeometry, scvf)) |
187 | { | ||
188 |
1/2✓ Branch 1 taken 21554 times.
✗ Branch 2 not taken.
|
49818 | const auto& geo = fvGeometry.geometry(scvf); |
189 | 42578 | CornerStorage corners; | |
190 |
4/4✓ Branch 0 taken 81248 times.
✓ Branch 1 taken 21554 times.
✓ Branch 2 taken 81248 times.
✓ Branch 3 taken 21554 times.
|
365450 | for (int i = 0; i < geo.corners(); ++i) |
191 | 181916 | corners.push_back(geo.corner(i)); | |
192 | |||
193 |
1/2✓ Branch 1 taken 21554 times.
✗ Branch 2 not taken.
|
42578 | wallGeometries.emplace_back(std::move(corners)); |
194 |
1/4✓ Branch 1 taken 21554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
42578 | tempWallData.push_back(WallData{ |
195 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 7074 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7074 times.
✓ Branch 4 taken 14480 times.
✓ Branch 5 taken 7074 times.
✓ Branch 7 taken 7074 times.
✗ Branch 8 not taken.
|
127734 | eIdx, scvf.index(), scvf.unitOuterNormal(), gridGeometry_->gridView().comm().rank() |
196 | }); | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | |||
201 | #if HAVE_MPI | ||
202 | // Handle parallel runs. We need to prepare a global vector of wall geometries, | ||
203 | // containing the wall geometries of each process in order to get a correct distance field. | ||
204 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 45 times.
✓ Branch 7 taken 45 times.
✗ Branch 8 not taken.
|
207 | const bool isParallel = gridGeometry_->gridView().comm().size() > 1; |
205 |
2/6✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
138 | std::vector<SimpleGeometry> globalWallGeometries; |
206 |
3/4✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 41 times.
|
138 | std::vector<WallData> globalTempWallData; |
207 |
3/6✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
158 | const auto distanceField = [&] |
208 | { | ||
209 | 49 | if (isParallel) | |
210 | { | ||
211 |
0/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
16 | const auto& communication = gridGeometry_->gridView().comm(); |
212 | 16 | const int totalNumberOfBoundaryGeometries = communication.sum(wallGeometries.size()); | |
213 | 8 | globalWallGeometries.resize(totalNumberOfBoundaryGeometries); | |
214 | 8 | globalTempWallData.resize(totalNumberOfBoundaryGeometries); | |
215 | |||
216 | // prepare a displacement vector | ||
217 | 32 | std::vector<int> numGeosPerProcLocal{static_cast<int>(wallGeometries.size())}; | |
218 |
0/10✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
32 | std::vector<int> numGeosPerProcGlobal(communication.size()); |
219 |
0/6✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
24 | communication.allgather(numGeosPerProcLocal.data(), 1, numGeosPerProcGlobal.data()); |
220 | |||
221 |
0/14✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
40 | std::vector<int> disp(communication.size(), 0); |
222 | 8 | disp[1] = numGeosPerProcGlobal[0]; | |
223 |
0/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | for (int i = 2; i < numGeosPerProcGlobal.size(); ++i) |
224 | ✗ | disp[i] = disp[i-1] + numGeosPerProcGlobal[i-1]; | |
225 | |||
226 | // concatenate the wall geometries and temp scvf data of each process into a global vector | ||
227 |
0/12✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
48 | communication.allgatherv( |
228 | wallGeometries.data(), | ||
229 | wallGeometries.size(), | ||
230 | globalWallGeometries.data(), | ||
231 | numGeosPerProcGlobal.data(), | ||
232 | disp.data() | ||
233 | ); | ||
234 | |||
235 |
0/10✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
40 | communication.allgatherv( |
236 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
8 | tempWallData.data(), |
237 | tempWallData.size(), | ||
238 | globalTempWallData.data(), | ||
239 | numGeosPerProcGlobal.data(), | ||
240 | disp.data() | ||
241 | ); | ||
242 | |||
243 | // pass the global vector of wall geometries to the distance field | ||
244 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
8 | return DistanceField<SimpleGeometry>(globalWallGeometries); |
245 | } | ||
246 | else | ||
247 | 41 | return DistanceField<SimpleGeometry>(wallGeometries); | |
248 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
49 | }(); |
249 | #else | ||
250 | const DistanceField<SimpleGeometry> distanceField(wallGeometries); | ||
251 | #endif | ||
252 | |||
253 | // compute sampling points | ||
254 |
3/8✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
276 | std::vector<GlobalPosition> points(numSamplingPoints); |
255 | if (loc == atElementCenters) | ||
256 |
11/17✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 39 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8805 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 17164 times.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 17164 times.
✓ Branch 18 taken 2 times.
✓ Branch 20 taken 17164 times.
✗ Branch 21 not taken.
|
91203 | for (const auto& element : elements(gridGeometry_->gridView())) |
257 |
6/12✓ Branch 1 taken 17164 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17164 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 17164 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 17164 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 17164 times.
✗ Branch 14 not taken.
✓ Branch 18 taken 17164 times.
✗ Branch 19 not taken.
|
79128 | points[gridGeometry_->elementMapper().index(element)] = element.geometry().center(); |
258 | else | ||
259 |
8/13✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3572 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 3872 times.
|
22064 | for (const auto& vertex : vertices(gridGeometry_->gridView())) |
260 |
1/2✓ Branch 8 taken 3872 times.
✗ Branch 9 not taken.
|
14872 | points[gridGeometry_->vertexMapper().index(vertex)] = vertex.geometry().corner(0); |
261 | |||
262 | // get the actual distances (this is the most expensive part) | ||
263 | if (loc == atElementCenters) | ||
264 | { | ||
265 | 103777 | const auto kernel = [&](std::size_t eIdx){ | |
266 |
16/80✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6400 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 64 times.
✓ Branch 14 taken 640 times.
✓ Branch 15 taken 512 times.
✓ Branch 16 taken 640 times.
✓ Branch 17 taken 512 times.
✓ Branch 20 taken 640 times.
✓ Branch 21 taken 512 times.
✓ Branch 22 taken 640 times.
✓ Branch 23 taken 512 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 8582 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 8582 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 8582 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 8582 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
|
51864 | const auto [d, idx] = distanceField.distanceAndIndex(points[eIdx]); |
267 |
8/40✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 640 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 512 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8582 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 8582 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ 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.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
|
25932 | distance_[eIdx] = d; |
268 | #if HAVE_MPI | ||
269 |
8/40✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 640 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 512 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8582 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 8582 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ 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.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
|
25932 | wallData_[eIdx] = isParallel ? globalTempWallData[idx] : tempWallData[idx]; |
270 | #else | ||
271 | wallData_[eIdx] = tempWallData[idx]; | ||
272 | #endif | ||
273 | }; | ||
274 | |||
275 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
49 | runKernel_(numSamplingPoints, kernel); |
276 | } | ||
277 | else | ||
278 | { | ||
279 | 29764 | const auto kernel = [&](std::size_t vIdx){ | |
280 |
16/24✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 81 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 81 times.
✓ Branch 14 taken 972 times.
✓ Branch 15 taken 729 times.
✓ Branch 16 taken 972 times.
✓ Branch 17 taken 729 times.
✓ Branch 20 taken 972 times.
✓ Branch 21 taken 729 times.
✓ Branch 22 taken 972 times.
✓ Branch 23 taken 729 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 1936 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 1936 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 1936 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 1936 times.
|
14872 | const auto [d, idx] = distanceField.distanceAndIndex(points[vIdx]); |
281 |
8/12✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
✓ Branch 4 taken 972 times.
✓ Branch 5 taken 729 times.
✓ Branch 6 taken 972 times.
✓ Branch 7 taken 729 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1936 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1936 times.
|
7436 | distance_[vIdx] = d; |
282 | #if HAVE_MPI | ||
283 |
8/12✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
✓ Branch 4 taken 972 times.
✓ Branch 5 taken 729 times.
✓ Branch 6 taken 972 times.
✓ Branch 7 taken 729 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1936 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1936 times.
|
7436 | wallData_[vIdx] = isParallel ? globalTempWallData[idx] : tempWallData[idx]; |
284 | #else | ||
285 | wallData_[vIdx] = tempWallData[idx]; | ||
286 | #endif | ||
287 | }; | ||
288 | |||
289 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
20 | runKernel_(numSamplingPoints, kernel); |
290 | } | ||
291 | 69 | } | |
292 | |||
293 | template<class Kernel> | ||
294 | ✗ | void runKernel_(std::size_t size, const Kernel& kernel) | |
295 | { | ||
296 | // parallelize, if we have enough work (enough evaluation points) | ||
297 | ✗ | if (size > 10000) | |
298 | ✗ | Dumux::parallelFor(size, [&](const std::size_t i){ kernel(i); }); | |
299 | else | ||
300 | ✗ | for (std::size_t i = 0; i < size; ++i) kernel(i); | |
301 | ✗ | } | |
302 | |||
303 | std::vector<Scalar> distance_; | ||
304 | std::vector<WallData> wallData_; | ||
305 | std::shared_ptr<const GridGeometry> gridGeometry_; | ||
306 | }; | ||
307 | |||
308 | } // end namespace Dumux | ||
309 | |||
310 | #endif | ||
311 |