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 BoxDiscretization | ||
10 | * \brief Base class for the finite volume geometry vector for box models | ||
11 | * This builds up the sub control volumes and sub control volume faces | ||
12 | * for each element of the grid partition. | ||
13 | */ | ||
14 | #ifndef DUMUX_DISCRETIZATION_BOX_GRID_FVGEOMETRY_HH | ||
15 | #define DUMUX_DISCRETIZATION_BOX_GRID_FVGEOMETRY_HH | ||
16 | |||
17 | #include <utility> | ||
18 | #include <unordered_map> | ||
19 | #include <array> | ||
20 | #include <vector> | ||
21 | |||
22 | #include <dune/localfunctions/lagrange/lagrangelfecache.hh> | ||
23 | |||
24 | #include <dumux/discretization/method.hh> | ||
25 | #include <dumux/common/indextraits.hh> | ||
26 | #include <dumux/common/defaultmappertraits.hh> | ||
27 | #include <dumux/discretization/basegridgeometry.hh> | ||
28 | #include <dumux/discretization/box/boxgeometryhelper.hh> | ||
29 | #include <dumux/discretization/box/fvelementgeometry.hh> | ||
30 | #include <dumux/discretization/box/subcontrolvolume.hh> | ||
31 | #include <dumux/discretization/box/subcontrolvolumeface.hh> | ||
32 | #include <dumux/discretization/extrusion.hh> | ||
33 | |||
34 | namespace Dumux { | ||
35 | |||
36 | namespace Detail { | ||
37 | template<class GV, class T> | ||
38 | using BoxGeometryHelper_t = Dune::Std::detected_or_t< | ||
39 | Dumux::BoxGeometryHelper<GV, GV::dimension, typename T::SubControlVolume, typename T::SubControlVolumeFace>, | ||
40 | SpecifiesGeometryHelper, | ||
41 | T | ||
42 | >; | ||
43 | } // end namespace Detail | ||
44 | |||
45 | /*! | ||
46 | * \ingroup BoxDiscretization | ||
47 | * \brief The default traits for the box finite volume grid geometry | ||
48 | * Defines the scv and scvf types and the mapper types | ||
49 | * \tparam the grid view type | ||
50 | */ | ||
51 | template<class GridView, class MapperTraits = DefaultMapperTraits<GridView>> | ||
52 | struct BoxDefaultGridGeometryTraits | ||
53 | : public MapperTraits | ||
54 | { | ||
55 | using SubControlVolume = BoxSubControlVolume<GridView>; | ||
56 | using SubControlVolumeFace = BoxSubControlVolumeFace<GridView>; | ||
57 | |||
58 | template<class GridGeometry, bool enableCache> | ||
59 | using LocalView = BoxFVElementGeometry<GridGeometry, enableCache>; | ||
60 | }; | ||
61 | |||
62 | /*! | ||
63 | * \ingroup BoxDiscretization | ||
64 | * \brief Base class for the finite volume geometry vector for box schemes | ||
65 | * This builds up the sub control volumes and sub control volume faces | ||
66 | * \note This class is specialized for versions with and without caching the fv geometries on the grid view | ||
67 | */ | ||
68 | template<class Scalar, | ||
69 | class GridView, | ||
70 | bool enableGridGeometryCache = false, | ||
71 | class Traits = BoxDefaultGridGeometryTraits<GridView> > | ||
72 | class BoxFVGridGeometry; | ||
73 | |||
74 | /*! | ||
75 | * \ingroup BoxDiscretization | ||
76 | * \brief Base class for the finite volume geometry vector for box schemes | ||
77 | * This builds up the sub control volumes and sub control volume faces | ||
78 | * \note For caching enabled we store the fv geometries for the whole grid view which is memory intensive but faster | ||
79 | */ | ||
80 | template<class Scalar, class GV, class Traits> | ||
81 | class BoxFVGridGeometry<Scalar, GV, true, Traits> | ||
82 | : public BaseGridGeometry<GV, Traits> | ||
83 | { | ||
84 | using ThisType = BoxFVGridGeometry<Scalar, GV, true, Traits>; | ||
85 | using ParentType = BaseGridGeometry<GV, Traits>; | ||
86 | using GridIndexType = typename IndexTraits<GV>::GridIndex; | ||
87 | using LocalIndexType = typename IndexTraits<GV>::LocalIndex; | ||
88 | |||
89 | using Element = typename GV::template Codim<0>::Entity; | ||
90 | using CoordScalar = typename GV::ctype; | ||
91 | static const int dim = GV::dimension; | ||
92 | static const int dimWorld = GV::dimensionworld; | ||
93 | |||
94 | public: | ||
95 | //! export the discretization method this geometry belongs to | ||
96 | using DiscretizationMethod = DiscretizationMethods::Box; | ||
97 | static constexpr DiscretizationMethod discMethod{}; | ||
98 | |||
99 | //! export basic grid geometry type for the alternative constructor | ||
100 | using BasicGridGeometry = BasicGridGeometry_t<GV, Traits>; | ||
101 | //! export the type of the fv element geometry (the local view type) | ||
102 | using LocalView = typename Traits::template LocalView<ThisType, true>; | ||
103 | //! export the type of sub control volume | ||
104 | using SubControlVolume = typename Traits::SubControlVolume; | ||
105 | //! export the type of sub control volume | ||
106 | using SubControlVolumeFace = typename Traits::SubControlVolumeFace; | ||
107 | //! export the type of extrusion | ||
108 | using Extrusion = Extrusion_t<Traits>; | ||
109 | //! export dof mapper type | ||
110 | using DofMapper = typename Traits::VertexMapper; | ||
111 | //! export the finite element cache type | ||
112 | using FeCache = Dune::LagrangeLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>; | ||
113 | //! export the grid view type | ||
114 | using GridView = GV; | ||
115 | |||
116 | //! Constructor with basic grid geometry used to share state with another grid geometry on the same grid view | ||
117 | 57 | BoxFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg) | |
118 | 57 | : ParentType(std::move(gg)) | |
119 |
6/14✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 50 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 50 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 50 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 50 times.
✗ Branch 17 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
228 | , cache_(*this) |
120 | { | ||
121 | 57 | update_(); | |
122 | 57 | } | |
123 | |||
124 | //! Constructor | ||
125 | 55 | BoxFVGridGeometry(const GridView& gridView) | |
126 |
2/6✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
55 | : BoxFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView)) |
127 | 55 | {} | |
128 | |||
129 | //! the vertex mapper is the dofMapper | ||
130 | //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... | ||
131 | const DofMapper& dofMapper() const | ||
132 |
19/39✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 700 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 700 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 4184 times.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4184 times.
✓ Branch 13 taken 189 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 189 times.
✗ 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 taken 3 times.
✓ Branch 24 taken 2 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 5 times.
✓ Branch 27 taken 14 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 14 times.
✓ Branch 31 taken 10 times.
✓ Branch 32 taken 2 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 10 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
|
193276166 | { return this->vertexMapper(); } |
133 | |||
134 | //! The total number of sub control volumes | ||
135 | std::size_t numScv() const | ||
136 | { return numScv_; } | ||
137 | |||
138 | //! The total number of sun control volume faces | ||
139 | std::size_t numScvf() const | ||
140 | { return numScvf_; } | ||
141 | |||
142 | //! The total number of boundary sub control volume faces | ||
143 | //! For compatibility reasons with cc methods | ||
144 | ✗ | std::size_t numBoundaryScvf() const | |
145 | ✗ | { return numBoundaryScvf_; } | |
146 | |||
147 | //! The total number of degrees of freedom | ||
148 | std::size_t numDofs() const | ||
149 |
54/75✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 11 times.
✓ Branch 13 taken 10 times.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 10 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 2 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 4 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 3 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 3 times.
✓ Branch 30 taken 1 times.
✓ Branch 31 taken 1 times.
✓ Branch 32 taken 2 times.
✓ Branch 33 taken 1 times.
✓ Branch 34 taken 1 times.
✓ Branch 35 taken 4 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 1 times.
✓ Branch 38 taken 2 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 1 times.
✓ Branch 44 taken 1 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 1 times.
✓ Branch 47 taken 1 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 2 times.
✓ Branch 50 taken 1 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 2 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 2 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 2 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
|
555 | { return this->vertexMapper().size(); } |
150 | |||
151 | |||
152 | //! update all fvElementGeometries (call this after grid adaption) | ||
153 | void update(const GridView& gridView) | ||
154 | { | ||
155 | ParentType::update(gridView); | ||
156 | update_(); | ||
157 | } | ||
158 | |||
159 | //! update all fvElementGeometries (call this after grid adaption) | ||
160 | void update(GridView&& gridView) | ||
161 | { | ||
162 | ParentType::update(std::move(gridView)); | ||
163 | update_(); | ||
164 | } | ||
165 | |||
166 | //! The finite element cache for creating local FE bases | ||
167 | const FeCache& feCache() const | ||
168 |
6/16✓ Branch 1 taken 4887560 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2430 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 56184 times.
✓ Branch 9 taken 22120 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9920 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 9920 times.
✗ Branch 17 not taken.
|
54224533 | { return feCache_; } |
169 | |||
170 | //! If a vertex / d.o.f. is on the boundary | ||
171 | bool dofOnBoundary(GridIndexType dofIdx) const | ||
172 |
12/12✓ Branch 0 taken 2148140 times.
✓ Branch 1 taken 18103418 times.
✓ Branch 2 taken 2148140 times.
✓ Branch 3 taken 18103418 times.
✓ Branch 4 taken 159198 times.
✓ Branch 5 taken 127898 times.
✓ Branch 6 taken 159198 times.
✓ Branch 7 taken 127898 times.
✓ Branch 8 taken 49375 times.
✓ Branch 9 taken 91648 times.
✓ Branch 10 taken 49375 times.
✓ Branch 11 taken 91648 times.
|
41359354 | { return boundaryDofIndices_[dofIdx]; } |
173 | |||
174 | //! If a vertex / d.o.f. is on a periodic boundary | ||
175 | bool dofOnPeriodicBoundary(GridIndexType dofIdx) const | ||
176 |
3/8✗ Branch 1 not taken.
✓ Branch 2 taken 339247 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5328 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 944 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
345519 | { return periodicVertexMap_.count(dofIdx); } |
177 | |||
178 | //! The index of the vertex / d.o.f. on the other side of the periodic boundary | ||
179 | GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const | ||
180 | ✗ | { return periodicVertexMap_.at(dofIdx); } | |
181 | |||
182 | //! Returns the map between dofs across periodic boundaries | ||
183 | const std::unordered_map<GridIndexType, GridIndexType>& periodicDofMap() const | ||
184 | 3285 | { return periodicVertexMap_; } | |
185 | |||
186 | //! Returns the map between dofs across periodic boundaries | ||
187 | [[deprecated("Will be removed after release 3.9. Use periodicDofMap() instead.")]] | ||
188 | const std::unordered_map<GridIndexType, GridIndexType>& periodicVertexMap() const | ||
189 | { return periodicDofMap(); } | ||
190 | |||
191 | //! local view of this object (constructed with the internal cache) | ||
192 | friend inline LocalView localView(const BoxFVGridGeometry& gg) | ||
193 |
62/86✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 926074 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 706 times.
✓ Branch 8 taken 926074 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 706 times.
✓ Branch 11 taken 20 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 30 times.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 30 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 1182335 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 766 times.
✓ Branch 22 taken 1182335 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 766 times.
✓ Branch 25 taken 444392 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 397608 times.
✓ Branch 28 taken 444392 times.
✓ Branch 29 taken 2091 times.
✓ Branch 30 taken 397608 times.
✓ Branch 31 taken 471 times.
✓ Branch 32 taken 2091 times.
✓ Branch 33 taken 673344 times.
✓ Branch 34 taken 471 times.
✓ Branch 35 taken 78 times.
✓ Branch 36 taken 673344 times.
✓ Branch 37 taken 210896 times.
✓ Branch 38 taken 78 times.
✓ Branch 39 taken 23854 times.
✓ Branch 40 taken 210896 times.
✓ Branch 41 taken 21 times.
✓ Branch 42 taken 23854 times.
✓ Branch 43 taken 3 times.
✓ Branch 44 taken 21 times.
✓ Branch 45 taken 7 times.
✓ Branch 46 taken 3 times.
✓ Branch 47 taken 2 times.
✓ Branch 48 taken 7 times.
✓ Branch 49 taken 1189858 times.
✓ Branch 50 taken 2 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 1189858 times.
✓ Branch 53 taken 2 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 3 times.
✓ Branch 56 taken 2 times.
✓ Branch 57 taken 76 times.
✓ Branch 58 taken 3 times.
✓ Branch 59 taken 2 times.
✓ Branch 60 taken 76 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 2 times.
✗ Branch 63 not taken.
✓ Branch 65 taken 1 times.
✗ Branch 66 not taken.
✓ Branch 68 taken 1 times.
✗ Branch 69 not taken.
✓ Branch 71 taken 1 times.
✗ Branch 72 not taken.
✓ Branch 74 taken 1 times.
✗ Branch 75 not taken.
✓ Branch 77 taken 3200 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 3200 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 9600 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 9600 times.
✗ Branch 87 not taken.
✓ Branch 89 taken 3200 times.
✗ Branch 90 not taken.
✓ Branch 92 taken 3200 times.
✗ Branch 93 not taken.
✓ Branch 95 taken 9600 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 9600 times.
✗ Branch 99 not taken.
|
19400050 | { return { gg.cache_ }; } |
194 | |||
195 | private: | ||
196 | |||
197 | class BoxGridGeometryCache | ||
198 | { | ||
199 | friend class BoxFVGridGeometry; | ||
200 | public: | ||
201 | //! export the geometry helper type | ||
202 | using GeometryHelper = Detail::BoxGeometryHelper_t<GV, Traits>; | ||
203 | |||
204 | 50 | explicit BoxGridGeometryCache(const BoxFVGridGeometry& gg) | |
205 |
15/30✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 45 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 45 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 4 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 4 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
|
250 | : gridGeometry_(&gg) |
206 | {} | ||
207 | |||
208 | ✗ | const BoxFVGridGeometry& gridGeometry() const | |
209 | ✗ | { return *gridGeometry_; } | |
210 | |||
211 | //! Get the global sub control volume indices of an element | ||
212 | const std::vector<SubControlVolume>& scvs(GridIndexType eIdx) const | ||
213 |
30/38✗ Branch 0 not taken.
✓ Branch 1 taken 34130964 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 106937615 times.
✓ Branch 4 taken 34130966 times.
✓ Branch 5 taken 72887970 times.
✓ Branch 6 taken 71904073 times.
✓ Branch 7 taken 83663507 times.
✓ Branch 8 taken 62124 times.
✓ Branch 9 taken 148284126 times.
✓ Branch 10 taken 83644312 times.
✓ Branch 11 taken 64681418 times.
✓ Branch 12 taken 64590528 times.
✓ Branch 13 taken 22430 times.
✓ Branch 14 taken 117984 times.
✓ Branch 15 taken 4887560 times.
✓ Branch 16 taken 2431 times.
✓ Branch 17 taken 58967 times.
✓ Branch 18 taken 4983945 times.
✓ Branch 19 taken 402085 times.
✓ Branch 20 taken 152568 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 399303 times.
✓ Branch 23 taken 666200 times.
✓ Branch 24 taken 1 times.
✓ Branch 25 taken 1199834 times.
✓ Branch 26 taken 666144 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1199778 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 9600 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 9600 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 9600 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 9600 times.
✗ Branch 41 not taken.
|
2490565067 | { return scvs_[eIdx]; } |
214 | |||
215 | //! Get the global sub control volume face indices of an element | ||
216 | const std::vector<SubControlVolumeFace>& scvfs(GridIndexType eIdx) const | ||
217 |
4/8✓ Branch 1 taken 19386 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19386 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3200 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3200 times.
✗ Branch 11 not taken.
|
76148897 | { return scvfs_[eIdx]; } |
218 | |||
219 | //! Returns whether one of the geometry's scvfs lies on a boundary | ||
220 | bool hasBoundaryScvf(GridIndexType eIdx) const | ||
221 |
24/24✓ Branch 0 taken 214184 times.
✓ Branch 1 taken 1733951 times.
✓ Branch 2 taken 214184 times.
✓ Branch 3 taken 1733951 times.
✓ Branch 4 taken 205916 times.
✓ Branch 5 taken 119476 times.
✓ Branch 6 taken 205916 times.
✓ Branch 7 taken 119476 times.
✓ Branch 8 taken 1804 times.
✓ Branch 9 taken 6778 times.
✓ Branch 10 taken 1804 times.
✓ Branch 11 taken 6778 times.
✓ Branch 12 taken 28 times.
✓ Branch 13 taken 36 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 36 times.
✓ Branch 16 taken 592 times.
✓ Branch 17 taken 432 times.
✓ Branch 18 taken 592 times.
✓ Branch 19 taken 432 times.
✓ Branch 20 taken 1804 times.
✓ Branch 21 taken 6778 times.
✓ Branch 22 taken 1804 times.
✓ Branch 23 taken 6778 times.
|
4583558 | { return hasBoundaryScvf_[eIdx]; } |
222 | |||
223 | //! Returns local mappings for constructing boundary scvf geometries | ||
224 | const std::vector<std::array<LocalIndexType, 2>>& scvfBoundaryGeometryKeys(GridIndexType eIdx) const | ||
225 |
2/4✓ Branch 5 taken 10860 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 10860 times.
✗ Branch 9 not taken.
|
73556 | { return scvfBoundaryGeometryKeys_.at(eIdx); } |
226 | |||
227 | private: | ||
228 | 57 | void clear_() | |
229 | { | ||
230 | 57 | scvs_.clear(); | |
231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
|
57 | scvfs_.clear(); |
232 | 57 | hasBoundaryScvf_.clear(); | |
233 | 57 | scvfBoundaryGeometryKeys_.clear(); | |
234 | 57 | } | |
235 | |||
236 | std::vector<std::vector<SubControlVolume>> scvs_; | ||
237 | std::vector<std::vector<SubControlVolumeFace>> scvfs_; | ||
238 | std::vector<bool> hasBoundaryScvf_; | ||
239 | std::unordered_map<GridIndexType, std::vector<std::array<LocalIndexType, 2>>> scvfBoundaryGeometryKeys_; | ||
240 | |||
241 | const BoxFVGridGeometry* gridGeometry_; | ||
242 | }; | ||
243 | |||
244 | public: | ||
245 | //! the cache type (only the caching implementation has this) | ||
246 | //! this alias should only be used by the local view implementation | ||
247 | using Cache = BoxGridGeometryCache; | ||
248 | |||
249 | private: | ||
250 | using GeometryHelper = typename Cache::GeometryHelper; | ||
251 | |||
252 | 57 | void update_() | |
253 | { | ||
254 | 57 | cache_.clear_(); | |
255 | |||
256 | 114 | const auto numElements = this->gridView().size(0); | |
257 | 57 | cache_.scvs_.resize(numElements); | |
258 | 57 | cache_.scvfs_.resize(numElements); | |
259 | 57 | cache_.hasBoundaryScvf_.resize(numElements, false); | |
260 | |||
261 | 114 | boundaryDofIndices_.assign(numDofs(), false); | |
262 | |||
263 | 57 | numScv_ = 0; | |
264 | 57 | numScvf_ = 0; | |
265 | 57 | numBoundaryScvf_ = 0; | |
266 | // Build the SCV and SCV faces | ||
267 |
10/12✓ Branch 2 taken 96917 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 54398 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39459 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 39459 times.
✓ Branch 11 taken 10 times.
✓ Branch 13 taken 39459 times.
✗ Branch 14 not taken.
|
306172 | for (const auto& element : elements(this->gridView())) |
268 | { | ||
269 | // fill the element map with seeds | ||
270 |
2/4✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39459 times.
✗ Branch 5 not taken.
|
306058 | const auto eIdx = this->elementMapper().index(element); |
271 | |||
272 | // count | ||
273 |
1/2✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
|
153029 | numScv_ += element.subEntities(dim); |
274 |
1/2✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
|
153029 | numScvf_ += element.subEntities(dim-1); |
275 | |||
276 | // get the element geometry | ||
277 |
2/4✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39459 times.
✗ Branch 5 not taken.
|
201070 | auto elementGeometry = element.geometry(); |
278 |
1/2✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
|
153029 | const auto refElement = referenceElement(elementGeometry); |
279 | |||
280 | // instantiate the geometry helper | ||
281 |
1/2✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
|
153029 | GeometryHelper geometryHelper(elementGeometry); |
282 | |||
283 | // construct the sub control volumes | ||
284 |
3/6✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39459 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 39459 times.
✗ Branch 8 not taken.
|
459087 | cache_.scvs_[eIdx].resize(elementGeometry.corners()); |
285 |
4/4✓ Branch 0 taken 586012 times.
✓ Branch 1 taken 136352 times.
✓ Branch 2 taken 586012 times.
✓ Branch 3 taken 136352 times.
|
1675506 | for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx) |
286 | { | ||
287 |
2/4✓ Branch 1 taken 143474 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 143474 times.
✗ Branch 5 not taken.
|
1369448 | const auto dofIdxGlobal = this->vertexMapper().subIndex(element, scvLocalIdx, dim); |
288 | |||
289 |
1/2✓ Branch 1 taken 143474 times.
✗ Branch 2 not taken.
|
684724 | cache_.scvs_[eIdx][scvLocalIdx] = SubControlVolume( |
290 | geometryHelper.getScvCorners(scvLocalIdx), | ||
291 | scvLocalIdx, | ||
292 | eIdx, | ||
293 | dofIdxGlobal | ||
294 | ); | ||
295 | } | ||
296 | |||
297 | // construct the sub control volume faces | ||
298 | 153029 | LocalIndexType scvfLocalIdx = 0; | |
299 |
3/6✓ Branch 1 taken 39459 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39459 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 39459 times.
✗ Branch 8 not taken.
|
363666 | cache_.scvfs_[eIdx].resize(element.subEntities(dim-1)); |
300 |
5/5✓ Branch 0 taken 372898 times.
✓ Branch 1 taken 436972 times.
✓ Branch 2 taken 420278 times.
✓ Branch 3 taken 228117 times.
✓ Branch 4 taken 39459 times.
|
1548741 | for (; scvfLocalIdx < element.subEntities(dim-1); ++scvfLocalIdx) |
301 | { | ||
302 | // find the global and local scv indices this scvf is belonging to | ||
303 |
1/4✓ Branch 3 taken 720898 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
3475192 | std::vector<LocalIndexType> localScvIndices({static_cast<LocalIndexType>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)), |
304 |
1/2✓ Branch 2 taken 178604 times.
✗ Branch 3 not taken.
|
868798 | static_cast<LocalIndexType>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))}); |
305 | |||
306 |
1/2✓ Branch 1 taken 720898 times.
✗ Branch 2 not taken.
|
868798 | const auto& corners = geometryHelper.getScvfCorners(scvfLocalIdx); |
307 |
2/4✗ Branch 4 not taken.
✓ Branch 5 taken 720898 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 720898 times.
|
868798 | cache_.scvfs_[eIdx][scvfLocalIdx] = SubControlVolumeFace( |
308 | corners, | ||
309 | geometryHelper.normal(corners, localScvIndices), | ||
310 | element, | ||
311 | elementGeometry, | ||
312 | scvfLocalIdx, | ||
313 |
1/2✓ Branch 1 taken 169396 times.
✗ Branch 2 not taken.
|
868798 | std::move(localScvIndices), |
314 | false | ||
315 | ); | ||
316 | } | ||
317 | |||
318 | // construct the sub control volume faces on the domain boundary | ||
319 |
12/16✓ Branch 1 taken 39459 times.
✓ Branch 2 taken 42495 times.
✓ Branch 3 taken 262846 times.
✓ Branch 4 taken 68057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47380 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 390291 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 638 times.
✓ Branch 11 taken 20942 times.
✓ Branch 13 taken 21580 times.
✓ Branch 14 taken 158150 times.
✓ Branch 15 taken 145302 times.
✓ Branch 17 taken 160572 times.
✗ Branch 18 not taken.
|
1558210 | for (const auto& intersection : intersections(this->gridView(), element)) |
320 | { | ||
321 |
6/8✓ Branch 0 taken 231374 times.
✓ Branch 1 taken 171898 times.
✓ Branch 2 taken 142765 times.
✓ Branch 3 taken 30281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10730 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 638 times.
|
666516 | if (intersection.boundary() && !intersection.neighbor()) |
322 | { | ||
323 |
2/4✓ Branch 1 taken 10730 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4438 times.
✗ Branch 4 not taken.
|
41714 | const auto isGeometry = intersection.geometry(); |
324 | 50748 | cache_.hasBoundaryScvf_[eIdx] = true; | |
325 | |||
326 | // count | ||
327 | 25374 | numScvf_ += isGeometry.corners(); | |
328 | 25374 | numBoundaryScvf_ += isGeometry.corners(); | |
329 | |||
330 |
4/4✓ Branch 0 taken 64236 times.
✓ Branch 1 taken 20532 times.
✓ Branch 2 taken 64236 times.
✓ Branch 3 taken 20532 times.
|
188822 | for (unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx) |
331 | { | ||
332 | // find the scvs this scvf is belonging to | ||
333 |
2/3✓ Branch 0 taken 2484 times.
✓ Branch 1 taken 18442 times.
✗ Branch 2 not taken.
|
140938 | const LocalIndexType insideScvIdx = static_cast<LocalIndexType>(refElement.subEntity(intersection.indexInInside(), 1, isScvfLocalIdx, dim)); |
334 |
2/6✓ Branch 1 taken 28468 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28468 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
245172 | std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx}; |
335 | |||
336 |
7/11✓ Branch 1 taken 64236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2484 times.
✓ Branch 4 taken 61752 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5120 times.
✓ Branch 7 taken 59116 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5116 times.
✓ Branch 10 taken 23348 times.
✗ Branch 11 not taken.
|
181226 | cache_.scvfs_[eIdx].emplace_back( |
337 | geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), isScvfLocalIdx), | ||
338 | intersection.centerUnitOuterNormal(), | ||
339 | intersection, | ||
340 | isGeometry, | ||
341 | isScvfLocalIdx, | ||
342 | scvfLocalIdx, | ||
343 | 81724 | std::move(localScvIndices), | |
344 |
1/2✓ Branch 1 taken 28468 times.
✗ Branch 2 not taken.
|
81724 | true |
345 | ); | ||
346 | |||
347 |
2/7✓ Branch 1 taken 64236 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 35768 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
81724 | cache_.scvfBoundaryGeometryKeys_[eIdx].emplace_back(std::array<LocalIndexType, 2>{{ |
348 |
7/9✓ Branch 0 taken 2484 times.
✓ Branch 1 taken 61752 times.
✓ Branch 2 taken 2484 times.
✓ Branch 3 taken 2636 times.
✓ Branch 4 taken 59116 times.
✓ Branch 5 taken 5120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 23348 times.
✗ Branch 8 not taken.
|
174838 | static_cast<LocalIndexType>(intersection.indexInInside()), |
349 | static_cast<LocalIndexType>(isScvfLocalIdx) | ||
350 | }}); | ||
351 | |||
352 | // increment local counter | ||
353 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 64236 times.
|
81724 | scvfLocalIdx++; |
354 | } | ||
355 | |||
356 | // add all vertices on the intersection to the set of | ||
357 | // boundary vertices | ||
358 |
2/3✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 6974 times.
✗ Branch 2 not taken.
|
25374 | const auto fIdx = intersection.indexInInside(); |
359 | 25374 | const auto numFaceVerts = refElement.size(fIdx, 1, dim); | |
360 |
2/2✓ Branch 1 taken 64236 times.
✓ Branch 2 taken 20532 times.
|
107098 | for (int localVIdx = 0; localVIdx < numFaceVerts; ++localVIdx) |
361 | { | ||
362 | 81724 | const auto vIdx = refElement.subEntity(fIdx, 1, localVIdx, dim); | |
363 |
2/4✓ Branch 1 taken 28468 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28468 times.
✗ Branch 5 not taken.
|
163448 | const auto vIdxGlobal = this->vertexMapper().subIndex(element, vIdx, dim); |
364 | 245172 | boundaryDofIndices_[vIdxGlobal] = true; | |
365 | } | ||
366 | } | ||
367 | |||
368 | // inform the grid geometry if we have periodic boundaries | ||
369 |
3/8✓ Branch 0 taken 216496 times.
✓ Branch 1 taken 303470 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20942 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
618794 | else if (intersection.boundary() && intersection.neighbor()) |
370 | { | ||
371 | ✗ | this->setPeriodic(); | |
372 | |||
373 | // find the mapped periodic vertex of all vertices on periodic boundaries | ||
374 | ✗ | const auto fIdx = intersection.indexInInside(); | |
375 | ✗ | const auto numFaceVerts = refElement.size(fIdx, 1, dim); | |
376 | ✗ | const auto eps = 1e-7*(elementGeometry.corner(1) - elementGeometry.corner(0)).two_norm(); | |
377 | ✗ | for (int localVIdx = 0; localVIdx < numFaceVerts; ++localVIdx) | |
378 | { | ||
379 | ✗ | const auto vIdx = refElement.subEntity(fIdx, 1, localVIdx, dim); | |
380 | ✗ | const auto vIdxGlobal = this->vertexMapper().subIndex(element, vIdx, dim); | |
381 | ✗ | const auto vPos = elementGeometry.corner(vIdx); | |
382 | |||
383 | ✗ | const auto& outside = intersection.outside(); | |
384 | ✗ | const auto outsideGeometry = outside.geometry(); | |
385 | ✗ | for (const auto& isOutside : intersections(this->gridView(), outside)) | |
386 | { | ||
387 | // only check periodic vertices of the periodic neighbor | ||
388 | ✗ | if (isOutside.boundary() && isOutside.neighbor()) | |
389 | { | ||
390 | ✗ | const auto fIdxOutside = isOutside.indexInInside(); | |
391 | ✗ | const auto numFaceVertsOutside = refElement.size(fIdxOutside, 1, dim); | |
392 | ✗ | for (int localVIdxOutside = 0; localVIdxOutside < numFaceVertsOutside; ++localVIdxOutside) | |
393 | { | ||
394 | ✗ | const auto vIdxOutside = refElement.subEntity(fIdxOutside, 1, localVIdxOutside, dim); | |
395 | ✗ | const auto vPosOutside = outsideGeometry.corner(vIdxOutside); | |
396 | ✗ | const auto shift = std::abs((this->bBoxMax()-this->bBoxMin())*intersection.centerUnitOuterNormal()); | |
397 | ✗ | if (std::abs((vPosOutside-vPos).two_norm() - shift) < eps) | |
398 | ✗ | periodicVertexMap_[vIdxGlobal] = this->vertexMapper().subIndex(outside, vIdxOutside, dim); | |
399 | } | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | } | ||
406 | |||
407 | // error check: periodic boundaries currently don't work for box in parallel | ||
408 |
1/10✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
57 | if (this->isPeriodic() && this->gridView().comm().size() > 1) |
409 | ✗ | DUNE_THROW(Dune::NotImplemented, "Periodic boundaries for box method for parallel simulations!"); | |
410 | 57 | } | |
411 | |||
412 | const FeCache feCache_; | ||
413 | |||
414 | std::size_t numScv_; | ||
415 | std::size_t numScvf_; | ||
416 | std::size_t numBoundaryScvf_; | ||
417 | |||
418 | // vertices on the boundary | ||
419 | std::vector<bool> boundaryDofIndices_; | ||
420 | |||
421 | // a map for periodic boundary vertices | ||
422 | std::unordered_map<GridIndexType, GridIndexType> periodicVertexMap_; | ||
423 | |||
424 | Cache cache_; | ||
425 | }; | ||
426 | |||
427 | /*! | ||
428 | * \ingroup BoxDiscretization | ||
429 | * \brief Base class for the finite volume geometry vector for box schemes | ||
430 | * This builds up the sub control volumes and sub control volume faces | ||
431 | * \note For caching disabled we store only some essential index maps to build up local systems on-demand in | ||
432 | * the corresponding FVElementGeometry | ||
433 | */ | ||
434 | template<class Scalar, class GV, class Traits> | ||
435 | class BoxFVGridGeometry<Scalar, GV, false, Traits> | ||
436 | : public BaseGridGeometry<GV, Traits> | ||
437 | { | ||
438 | using ThisType = BoxFVGridGeometry<Scalar, GV, false, Traits>; | ||
439 | using ParentType = BaseGridGeometry<GV, Traits>; | ||
440 | using GridIndexType = typename IndexTraits<GV>::GridIndex; | ||
441 | |||
442 | static const int dim = GV::dimension; | ||
443 | static const int dimWorld = GV::dimensionworld; | ||
444 | |||
445 | using Element = typename GV::template Codim<0>::Entity; | ||
446 | using CoordScalar = typename GV::ctype; | ||
447 | |||
448 | public: | ||
449 | //! export the discretization method this geometry belongs to | ||
450 | using DiscretizationMethod = DiscretizationMethods::Box; | ||
451 | static constexpr DiscretizationMethod discMethod{}; | ||
452 | |||
453 | //! export basic grid geometry type for the alternative constructor | ||
454 | using BasicGridGeometry = BasicGridGeometry_t<GV, Traits>; | ||
455 | //! export the type of the fv element geometry (the local view type) | ||
456 | using LocalView = typename Traits::template LocalView<ThisType, false>; | ||
457 | //! export the type of sub control volume | ||
458 | using SubControlVolume = typename Traits::SubControlVolume; | ||
459 | //! export the type of sub control volume | ||
460 | using SubControlVolumeFace = typename Traits::SubControlVolumeFace; | ||
461 | //! export the type of extrusion | ||
462 | using Extrusion = Extrusion_t<Traits>; | ||
463 | //! export dof mapper type | ||
464 | using DofMapper = typename Traits::VertexMapper; | ||
465 | //! export the finite element cache type | ||
466 | using FeCache = Dune::LagrangeLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>; | ||
467 | //! export the grid view type | ||
468 | using GridView = GV; | ||
469 | |||
470 | //! Constructor with basic grid geometry used to share state with another grid geometry on the same grid view | ||
471 | 125 | BoxFVGridGeometry(std::shared_ptr<BasicGridGeometry> gg) | |
472 | 125 | : ParentType(std::move(gg)) | |
473 |
6/14✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 125 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 125 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 125 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 125 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 125 times.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
500 | , cache_(*this) |
474 | { | ||
475 | 125 | update_(); | |
476 | 125 | } | |
477 | |||
478 | //! Constructor | ||
479 | 125 | BoxFVGridGeometry(const GridView& gridView) | |
480 |
2/6✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 125 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
125 | : BoxFVGridGeometry(std::make_shared<BasicGridGeometry>(gridView)) |
481 | 125 | {} | |
482 | |||
483 | //! the vertex mapper is the dofMapper | ||
484 | //! this is convenience to have better chance to have the same main files for box/tpfa/mpfa... | ||
485 | const DofMapper& dofMapper() const | ||
486 |
28/42✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1408 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 1408 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 21 times.
✓ Branch 9 taken 18861 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 12 times.
✓ Branch 12 taken 18861 times.
✓ Branch 13 taken 189 times.
✓ Branch 14 taken 12 times.
✓ Branch 15 taken 26 times.
✓ Branch 16 taken 189 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 26 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 11 times.
✓ Branch 25 taken 4039 times.
✓ Branch 26 taken 11 times.
✓ Branch 27 taken 57 times.
✓ Branch 28 taken 4039 times.
✓ Branch 29 taken 33 times.
✓ Branch 30 taken 57 times.
✓ Branch 31 taken 22 times.
✓ Branch 32 taken 33 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 22 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
|
206936206 | { return this->vertexMapper(); } |
487 | |||
488 | //! The total number of sub control volumes | ||
489 | std::size_t numScv() const | ||
490 | { return numScv_; } | ||
491 | |||
492 | //! The total number of sun control volume faces | ||
493 | std::size_t numScvf() const | ||
494 | { return numScvf_; } | ||
495 | |||
496 | //! The total number of boundary sub control volume faces | ||
497 | //! For compatibility reasons with cc methods | ||
498 | std::size_t numBoundaryScvf() const | ||
499 | { return numBoundaryScvf_; } | ||
500 | |||
501 | //! The total number of degrees of freedom | ||
502 | std::size_t numDofs() const | ||
503 |
36/49✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 1118 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 33 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 458 times.
✓ Branch 11 taken 38 times.
✓ Branch 12 taken 403 times.
✓ Branch 13 taken 62 times.
✓ Branch 14 taken 11488 times.
✓ Branch 15 taken 4 times.
✓ Branch 16 taken 11481 times.
✓ Branch 17 taken 32 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 24 times.
✓ Branch 20 taken 33 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 8 times.
✓ Branch 23 taken 11 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 8 times.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 2 times.
✓ Branch 29 taken 20 times.
✓ Branch 30 taken 1 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 20 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 20 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 2 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 1 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 1 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 1 times.
✗ Branch 51 not taken.
✓ Branch 53 taken 1 times.
✗ Branch 54 not taken.
|
27494 | { return this->vertexMapper().size(); } |
504 | |||
505 | |||
506 | //! update all fvElementGeometries (call this after grid adaption) | ||
507 | void update(const GridView& gridView) | ||
508 | { | ||
509 | ParentType::update(gridView); | ||
510 | update_(); | ||
511 | } | ||
512 | |||
513 | //! update all fvElementGeometries (call this after grid adaption) | ||
514 | void update(GridView&& gridView) | ||
515 | { | ||
516 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
10 | ParentType::update(std::move(gridView)); |
517 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
10 | update_(); |
518 | } | ||
519 | |||
520 | //! The finite element cache for creating local FE bases | ||
521 | const FeCache& feCache() const | ||
522 |
1/6✓ Branch 1 taken 5362908 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
67115750 | { return feCache_; } |
523 | |||
524 | //! If a vertex / d.o.f. is on the boundary | ||
525 | bool dofOnBoundary(GridIndexType dofIdx) const | ||
526 |
12/12✓ Branch 0 taken 1578782 times.
✓ Branch 1 taken 12639456 times.
✓ Branch 2 taken 1578782 times.
✓ Branch 3 taken 12639456 times.
✓ Branch 4 taken 314539 times.
✓ Branch 5 taken 178129 times.
✓ Branch 6 taken 314539 times.
✓ Branch 7 taken 178129 times.
✓ Branch 8 taken 106446 times.
✓ Branch 9 taken 107614 times.
✓ Branch 10 taken 106446 times.
✓ Branch 11 taken 107614 times.
|
29849932 | { return boundaryDofIndices_[dofIdx]; } |
527 | |||
528 | //! If a vertex / d.o.f. is on a periodic boundary | ||
529 | bool dofOnPeriodicBoundary(GridIndexType dofIdx) const | ||
530 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 2 taken 488983 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 158400 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
648987 | { return periodicVertexMap_.count(dofIdx); } |
531 | |||
532 | //! The index of the vertex / d.o.f. on the other side of the periodic boundary | ||
533 | GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const | ||
534 |
2/6✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1200 times.
✗ Branch 6 not taken.
|
1204 | { return periodicVertexMap_.at(dofIdx); } |
535 | |||
536 | //! Returns the map between dofs across periodic boundaries | ||
537 | const std::unordered_map<GridIndexType, GridIndexType>& periodicDofMap() const | ||
538 | 14582 | { return periodicVertexMap_; } | |
539 | |||
540 | //! Returns the map between dofs across periodic boundaries | ||
541 | [[deprecated("Will be removed after release 3.9. Use periodicDofMap() instead.")]] | ||
542 | const std::unordered_map<GridIndexType, GridIndexType>& periodicVertexMap() const | ||
543 | { return periodicDofMap(); } | ||
544 | |||
545 | //! local view of this object (constructed with the internal cache) | ||
546 | friend inline LocalView localView(const BoxFVGridGeometry& gg) | ||
547 |
31/46✗ Branch 0 not taken.
✓ Branch 1 taken 23167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 23165 times.
✓ Branch 5 taken 5541 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11269 times.
✓ Branch 8 taken 5541 times.
✓ Branch 9 taken 4466 times.
✓ Branch 10 taken 11269 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 4466 times.
✓ Branch 13 taken 2106802 times.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2106802 times.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1867370 times.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1867370 times.
✓ Branch 23 taken 30330 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 103138 times.
✓ Branch 26 taken 30330 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 103138 times.
✓ Branch 29 taken 1 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 376562 times.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 376562 times.
✓ Branch 35 taken 2 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 16705 times.
✓ Branch 38 taken 2 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 16705 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 604311 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 604311 times.
✗ Branch 47 not taken.
|
10626242 | { return { gg.cache_ }; } |
548 | |||
549 | private: | ||
550 | |||
551 | class BoxGridGeometryCache | ||
552 | { | ||
553 | friend class BoxFVGridGeometry; | ||
554 | public: | ||
555 | //! export the geometry helper type | ||
556 | using GeometryHelper = Detail::BoxGeometryHelper_t<GV, Traits>; | ||
557 | |||
558 | 125 | explicit BoxGridGeometryCache(const BoxFVGridGeometry& gg) | |
559 |
1/2✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
|
125 | : gridGeometry_(&gg) |
560 | {} | ||
561 | |||
562 | ✗ | const BoxFVGridGeometry& gridGeometry() const | |
563 | ✗ | { return *gridGeometry_; } | |
564 | |||
565 | private: | ||
566 | const BoxFVGridGeometry* gridGeometry_; | ||
567 | }; | ||
568 | |||
569 | public: | ||
570 | //! the cache type (only the caching implementation has this) | ||
571 | //! this alias should only be used by the local view implementation | ||
572 | using Cache = BoxGridGeometryCache; | ||
573 | |||
574 | private: | ||
575 | |||
576 | 135 | void update_() | |
577 | { | ||
578 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
270 | boundaryDofIndices_.assign(numDofs(), false); |
579 | |||
580 | // save global data on the grid's scvs and scvfs | ||
581 | // TODO do we need those information? | ||
582 | 135 | numScv_ = 0; | |
583 | 135 | numScvf_ = 0; | |
584 | 135 | numBoundaryScvf_ = 0; | |
585 |
10/12✓ Branch 2 taken 97340 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 39157 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8723 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 8723 times.
✓ Branch 11 taken 6 times.
✓ Branch 13 taken 8723 times.
✗ Branch 14 not taken.
|
212233 | for (const auto& element : elements(this->gridView())) |
586 | { | ||
587 |
1/2✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
|
105980 | numScv_ += element.subEntities(dim); |
588 |
1/2✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
|
105980 | numScvf_ += element.subEntities(dim-1); |
589 | |||
590 |
2/4✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8723 times.
✗ Branch 5 not taken.
|
114703 | const auto elementGeometry = element.geometry(); |
591 |
1/2✓ Branch 1 taken 8723 times.
✗ Branch 2 not taken.
|
105980 | const auto refElement = referenceElement(elementGeometry); |
592 | |||
593 | // store the sub control volume face indices on the domain boundary | ||
594 |
14/17✗ Branch 0 not taken.
✓ Branch 1 taken 8723 times.
✓ Branch 2 taken 68100 times.
✓ Branch 3 taken 282731 times.
✓ Branch 4 taken 57273 times.
✓ Branch 5 taken 26272 times.
✓ Branch 6 taken 26345 times.
✓ Branch 7 taken 40000 times.
✓ Branch 8 taken 178491 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 5660 times.
✓ Branch 13 taken 5738 times.
✓ Branch 14 taken 48144 times.
✓ Branch 15 taken 95279 times.
✓ Branch 17 taken 109269 times.
✗ Branch 18 not taken.
|
976152 | for (const auto& intersection : intersections(this->gridView(), element)) |
595 | { | ||
596 |
7/8✓ Branch 0 taken 230454 times.
✓ Branch 1 taken 102331 times.
✓ Branch 2 taken 76971 times.
✓ Branch 3 taken 13514 times.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 4993 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
|
426993 | if (intersection.boundary() && !intersection.neighbor()) |
597 | { | ||
598 |
2/6✓ Branch 1 taken 4793 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3723 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
21693 | const auto isGeometry = intersection.geometry(); |
599 |
2/3✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 1150 times.
✗ Branch 2 not taken.
|
13255 | numScvf_ += isGeometry.corners(); |
600 |
2/3✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 1150 times.
✗ Branch 2 not taken.
|
13255 | numBoundaryScvf_ += isGeometry.corners(); |
601 | |||
602 | // add all vertices on the intersection to the set of | ||
603 | // boundary vertices | ||
604 |
2/3✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 1150 times.
✗ Branch 2 not taken.
|
13255 | const auto fIdx = intersection.indexInInside(); |
605 | 13255 | const auto numFaceVerts = refElement.size(fIdx, 1, dim); | |
606 |
2/2✓ Branch 1 taken 28972 times.
✓ Branch 2 taken 13255 times.
|
42227 | for (int localVIdx = 0; localVIdx < numFaceVerts; ++localVIdx) |
607 | { | ||
608 | 28972 | const auto vIdx = refElement.subEntity(fIdx, 1, localVIdx, dim); | |
609 |
2/4✓ Branch 1 taken 11684 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11684 times.
✗ Branch 5 not taken.
|
57944 | const auto vIdxGlobal = this->vertexMapper().subIndex(element, vIdx, dim); |
610 | 86916 | boundaryDofIndices_[vIdxGlobal] = true; | |
611 | } | ||
612 | } | ||
613 | |||
614 | // inform the grid geometry if we have periodic boundaries | ||
615 |
3/8✓ Branch 0 taken 218591 times.
✓ Branch 1 taken 173701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5860 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
397952 | else if (intersection.boundary() && intersection.neighbor()) |
616 | { | ||
617 |
0/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
200 | this->setPeriodic(); |
618 | |||
619 | // find the mapped periodic vertex of all vertices on periodic boundaries | ||
620 |
0/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
200 | const auto fIdx = intersection.indexInInside(); |
621 | 200 | const auto numFaceVerts = refElement.size(fIdx, 1, dim); | |
622 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
400 | const auto eps = 1e-7*(elementGeometry.corner(1) - elementGeometry.corner(0)).two_norm(); |
623 |
2/2✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
|
600 | for (int localVIdx = 0; localVIdx < numFaceVerts; ++localVIdx) |
624 | { | ||
625 | 400 | const auto vIdx = refElement.subEntity(fIdx, 1, localVIdx, dim); | |
626 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
800 | const auto vIdxGlobal = this->vertexMapper().subIndex(element, vIdx, dim); |
627 |
0/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
400 | const auto vPos = elementGeometry.corner(vIdx); |
628 | |||
629 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
400 | const auto& outside = intersection.outside(); |
630 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
400 | const auto outsideGeometry = outside.geometry(); |
631 |
5/19✗ Branch 1 not taken.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 1600 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 400 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1600 times.
✗ 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.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5200 | for (const auto& isOutside : intersections(this->gridView(), outside)) |
632 | { | ||
633 | // only check periodic vertices of the periodic neighbor | ||
634 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✓ Branch 2 taken 1192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1600 | if (isOutside.boundary() && isOutside.neighbor()) |
635 | { | ||
636 |
0/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
400 | const auto fIdxOutside = isOutside.indexInInside(); |
637 | 400 | const auto numFaceVertsOutside = refElement.size(fIdxOutside, 1, dim); | |
638 |
2/2✓ Branch 1 taken 800 times.
✓ Branch 2 taken 400 times.
|
1200 | for (int localVIdxOutside = 0; localVIdxOutside < numFaceVertsOutside; ++localVIdxOutside) |
639 | { | ||
640 | 800 | const auto vIdxOutside = refElement.subEntity(fIdxOutside, 1, localVIdxOutside, dim); | |
641 |
0/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
800 | const auto vPosOutside = outsideGeometry.corner(vIdxOutside); |
642 |
0/12✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
4800 | const auto shift = std::abs((this->bBoxMax()-this->bBoxMin())*intersection.centerUnitOuterNormal()); |
643 |
4/8✓ Branch 0 taken 400 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3200 | if (std::abs((vPosOutside-vPos).two_norm() - shift) < eps) |
644 |
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.
|
800 | periodicVertexMap_[vIdxGlobal] = this->vertexMapper().subIndex(outside, vIdxOutside, dim); |
645 | } | ||
646 | } | ||
647 | } | ||
648 | } | ||
649 | } | ||
650 | } | ||
651 | } | ||
652 | |||
653 | // error check: periodic boundaries currently don't work for box in parallel | ||
654 |
6/10✓ Branch 0 taken 1 times.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
135 | if (this->isPeriodic() && this->gridView().comm().size() > 1) |
655 | ✗ | DUNE_THROW(Dune::NotImplemented, "Periodic boundaries for box method for parallel simulations!"); | |
656 | 135 | } | |
657 | |||
658 | const FeCache feCache_; | ||
659 | |||
660 | // Information on the global number of geometries | ||
661 | // TODO do we need those information? | ||
662 | std::size_t numScv_; | ||
663 | std::size_t numScvf_; | ||
664 | std::size_t numBoundaryScvf_; | ||
665 | |||
666 | // vertices on the boundary | ||
667 | std::vector<bool> boundaryDofIndices_; | ||
668 | |||
669 | // a map for periodic boundary vertices | ||
670 | std::unordered_map<GridIndexType, GridIndexType> periodicVertexMap_; | ||
671 | |||
672 | Cache cache_; | ||
673 | }; | ||
674 | |||
675 | } // end namespace Dumux | ||
676 | |||
677 | #endif | ||
678 |