Loading [MathJax]/extensions/tex2jax.js

DUNE MultiDomainGrid (2.8)

entity.hh
1#ifndef DUNE_MULTIDOMAINGRID_SUBDOMAINGRID_ENTITY_HH
2#define DUNE_MULTIDOMAINGRID_SUBDOMAINGRID_ENTITY_HH
3
4#include <utility>
5
6#include <dune/grid/common/entity.hh>
7#include <dune/grid/common/gridenums.hh>
8
9namespace Dune {
10
11namespace mdgrid {
12
13template<typename, typename>
14class MultiDomainGrid;
15
16namespace subdomain {
17
18template<int codim, int dim, typename GridImp>
19class EntityWrapper;
20
21template<typename,typename,typename>
22class IntersectionIteratorWrapper;
23
24template<typename GridImp>
25class HierarchicIteratorWrapper;
26
27template<typename MDGrid>
28class SubDomainGrid;
29
30template<typename>
31class LevelGridView;
32
33template<typename>
34class LeafGridView;
35
36template<typename HostES>
37class EntitySeedWrapper
38{
39
40 typedef HostES HostEntitySeed;
41
42 template<typename>
43 friend class SubDomainGrid;
44
45 template<typename,typename>
46 friend class ::Dune::mdgrid::MultiDomainGrid;
47
48 template<int, int, typename>
49 friend class EntityWrapper;
50
51public:
52
53 static const std::size_t codimension = HostEntitySeed::codimension;
54
55 EntitySeedWrapper()
56 {}
57
58 EntitySeedWrapper(const HostEntitySeed& hostEntitySeed)
59 : _hostEntitySeed(hostEntitySeed)
60 {}
61
62 const HostEntitySeed& hostEntitySeed() const
63 {
64 return _hostEntitySeed;
65 }
66
67 bool isValid() const
68 {
69 return _hostEntitySeed.isValid();
70 }
71
72 HostEntitySeed _hostEntitySeed;
73
74};
75
76template<int codim, int dim, typename GridImp>
77class EntityWrapperBase
78 : public EntityDefaultImplementation<codim,dim,GridImp,EntityWrapper>
79{
80
81protected:
82
83 using MultiDomainEntity = typename GridImp::MultiDomainGrid::Traits::template Codim<codim>::Entity;
84 using HostEntity = typename GridImp::HostGrid::Traits::template Codim<codim>::Entity;
85
86public:
87
88 using EntitySeed = EntitySeedWrapper<typename HostEntity::EntitySeed>;
89 using Geometry = typename GridImp::template Codim<codim>::Geometry;
90
91 EntityWrapperBase()
92 : _grid(nullptr)
93 {}
94
95 EntityWrapperBase(const GridImp* grid, const MultiDomainEntity& e)
96 : _grid(grid)
97 , _multiDomainEntity(e)
98 {}
99
100 EntityWrapperBase(const GridImp* grid, MultiDomainEntity&& e)
101 : _grid(grid)
102 , _multiDomainEntity(std::move(e))
103 {}
104
105 int level() const {
106 return multiDomainEntity().level();
107 }
108
109 PartitionType partitionType() const {
110 return multiDomainEntity().partitionType();
111 }
112
113 unsigned int subEntities(unsigned int codimSubEntitiy) const {
114 return multiDomainEntity().subEntities(codimSubEntitiy);
115 }
116
117 Geometry geometry() const {
118 return Geometry(hostEntity().geometry());
119 }
120
121 EntitySeed seed() const {
122 return EntitySeed(hostEntity().seed());
123 }
124
125 bool equals(const EntityWrapperBase& other) const
126 {
127 return grid() == other.grid() && multiDomainEntity() == other.multiDomainEntity();
128 }
129
130private:
131
132 const GridImp* _grid;
133 MultiDomainEntity _multiDomainEntity;
134
135public:
136
137 const MultiDomainEntity& multiDomainEntity() const {
138 return _multiDomainEntity;
139 }
140
141 const HostEntity& hostEntity() const {
142 return grid()._grid.hostEntity(_multiDomainEntity);
143 }
144
145 const GridImp& grid() const
146 {
147 assert(_grid);
148 return *_grid;
149 }
150
151};
152
153
154template<int codim, int dim, typename GridImp>
155class EntityWrapper
156 : public EntityWrapperBase<codim,dim,GridImp>
157{
158
159 using Base = EntityWrapperBase<codim,dim,GridImp>;
160
161 template<typename>
162 friend class SubDomainGrid;
163
164 template<typename,typename>
166
167 template<int, int, typename, template<int,int,typename> class>
168 friend class Entity;
169
170public:
171
172 // inherit constructors
173 using Base::Base;
174
175};
176
177
178template<int dim, typename GridImp>
179class EntityWrapper<0,dim,GridImp>
180 : public EntityWrapperBase<0,dim,GridImp>
181{
182
183 using Base = EntityWrapperBase<0,dim,GridImp>;
184
185 template<typename>
186 friend class SubDomainGrid;
187
188 template<typename,typename>
190
191 template<int, int, typename, template<int,int,typename> class>
192 friend class Entity;
193
194 template<typename>
195 friend class LevelGridView;
196
197 template<typename>
198 friend class LeafGridView;
199
200 using Base::multiDomainEntity;
201 using Base::hostEntity;
202 using Base::grid;
203
204public:
205
206 using LocalGeometry = typename GridImp::template Codim<0>::LocalGeometry;
207 using LeafIntersectionIterator = typename GridImp::Traits::LeafIntersectionIterator;
208 using LevelIntersectionIterator = typename GridImp::Traits::LevelIntersectionIterator;
209 using HierarchicIterator = typename GridImp::Traits::HierarchicIterator;
210
211 // inherit constructors
212 using Base::Base;
213
214 unsigned int subEntities(unsigned int codim) const {
215 return hostEntity().subEntities(codim);
216 }
217
218 template<int cc>
219 typename GridImp::template Codim<cc>::Entity subEntity(int i) const {
220 return {EntityWrapper<cc,dim,GridImp>(&grid(),multiDomainEntity().template subEntity<cc>(i))};
221 }
222
223 typename GridImp::template Codim<0>::Entity father() const {
224 return {EntityWrapper<0,dim,GridImp>(&grid(),multiDomainEntity().father())};
225 }
226
227 bool hasFather() const {
228 return multiDomainEntity().hasFather();
229 }
230
231 bool isLeaf() const {
232 return multiDomainEntity().isLeaf();
233 }
234
235 bool isRegular() const {
236 return multiDomainEntity().isRegular();
237 }
238
239 LocalGeometry geometryInFather() const {
240 return LocalGeometry(hostEntity().geometryInFather());
241 }
242
243 HierarchicIterator hbegin(int maxLevel) const {
244 return HierarchicIteratorWrapper<GridImp>(
245 &grid(),
246 multiDomainEntity().hbegin(maxLevel),
247 multiDomainEntity().hend(maxLevel)
248 );
249 }
250
251 HierarchicIterator hend(int maxLevel) const {
252 return HierarchicIteratorWrapper<GridImp>(
253 &grid(),
254 multiDomainEntity().hend(maxLevel),
255 multiDomainEntity().hend(maxLevel)
256 );
257 }
258
259 LevelIntersectionIterator ilevelbegin() const {
260 return IntersectionIteratorWrapper<
261 GridImp,
262 typename GridImp::LevelGridView::IndexSet,
263 typename GridImp::MultiDomainGrid::LevelGridView::IntersectionIterator
264 >(
265 grid().levelGridView(this->level()).indexSet(),
266 grid()._grid.levelGridView(this->level()).ibegin(multiDomainEntity())
267 );
268 }
269
270 LevelIntersectionIterator ilevelend() const {
271 return IntersectionIteratorWrapper<
272 GridImp,
273 typename GridImp::LevelGridView::IndexSet,
274 typename GridImp::MultiDomainGrid::LevelGridView::IntersectionIterator
275 >(
276 grid().levelGridView(this->level()).indexSet(),
277 grid()._grid.levelGridView(this->level()).iend(multiDomainEntity())
278 );
279 }
280
281 LeafIntersectionIterator ileafbegin() const {
282 return IntersectionIteratorWrapper<
283 GridImp,
284 typename GridImp::LeafGridView::IndexSet,
285 typename GridImp::MultiDomainGrid::LeafGridView::IntersectionIterator
286 >(
287 grid().leafGridView().indexSet(),
288 grid()._grid.leafGridView().ibegin(multiDomainEntity())
289 );
290 }
291
292 LeafIntersectionIterator ileafend() const {
293 return IntersectionIteratorWrapper<
294 GridImp,
295 typename GridImp::LeafGridView::IndexSet,
296 typename GridImp::MultiDomainGrid::LeafGridView::IntersectionIterator
297 >(
298 grid().leafGridView().indexSet(),
299 grid()._grid.leafGridView().iend(multiDomainEntity())
300 );
301 }
302
303 bool isNew() const {
304 return multiDomainEntity().isNew();
305 }
306
307 bool mightVanish() const {
308 return multiDomainEntity().mightVanish();
309 }
310
311 bool hasBoundaryIntersections () const
312 {
313 for(const auto& is : intersections(grid().levelGridView(this->level()),*this))
314 {
315 if(is.boundary())
316 return true;
317 }
318
319 if (isLeaf())
320 for(const auto& is : intersections(grid().leafGridView(),*this))
321 {
322 if(is.boundary())
323 return true;
324 }
325
326 return false;
327 }
328
329};
330
331} // namespace subdomain
332
333} // namespace mdgrid
334
335} // namespace Dune
336
337#endif // DUNE_MULTIDOMAINGRID_SUBDOMAINGRID_ENTITY_HH
A meta grid for dividing an existing DUNE grid into subdomains that can be accessed as a grid in thei...
Definition: multidomaingrid.hh:241
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 4, 22:59, 2025)