dune-grid 2.9.0
identitygrid.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_GRID_IDENTITYGRID_HH
6#define DUNE_GRID_IDENTITYGRID_HH
7
12#include <string>
13#include <map>
14
15#include <dune/common/parallel/communication.hh>
18
19// The components of the IdentityGrid interface
28
29namespace Dune
30{
31 // Forward declaration
32 template <class HostGrid>
33 class IdentityGrid;
34
35 // External forward declarations
36 template< class Grid >
38
39 template<int dim, class HostGrid>
41 {
42
43 public:
44
45 typedef GridTraits<
46 dim,
47 HostGrid::dimensionworld,
61 typename HostGrid::Traits::GlobalIdSet::IdType,
63 typename HostGrid::Traits::LocalIdSet::IdType,
64 Communication<No_Comm>,
69
70 };
71
72 //**********************************************************************
73 //
74 // --IdentityGrid
75 //
76 //************************************************************************
84 template <class HostGrid>
86 : public GridDefaultImplementation<HostGrid::dimension, HostGrid::dimensionworld,
87 typename HostGrid::ctype, IdentityGridFamily<HostGrid::dimension, HostGrid> >
88 {
89 friend class IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >;
90 friend class IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> >;
91 friend class IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> >;
92 friend class IdentityGridLocalIdSet<const IdentityGrid<HostGrid> >;
93 friend class IdentityGridHierarchicIterator<const IdentityGrid<HostGrid> >;
94 friend class IdentityGridLevelIntersectionIterator<const IdentityGrid<HostGrid> >;
95 friend class IdentityGridLeafIntersectionIterator<const IdentityGrid<HostGrid> >;
96
97 template<int codim, PartitionIteratorType pitype, class GridImp_>
99
100 template<int codim, PartitionIteratorType pitype, class GridImp_>
102
103
104 template<int codim_, int dim_, class GridImp_>
105 friend class IdentityGridEntity;
106
107 friend struct HostGridAccess< IdentityGrid< HostGrid > >;
108
109 public:
110
112 typedef HostGrid HostGridType;
113
114 //**********************************************************
115 // The Interface Methods
116 //**********************************************************
117
120
123
125 typedef typename HostGrid::ctype ctype;
126
127
132 explicit IdentityGrid(HostGrid& hostgrid) :
133 hostgrid_(&hostgrid),
134 leafIndexSet_(*this),
135 globalIdSet_(*this),
136 localIdSet_(*this)
137 {
138 setIndices();
139 }
140
143 {
144 // Delete level index sets
145 for (size_t i=0; i<levelIndexSets_.size(); i++)
146 if (levelIndexSets_[i])
147 delete (levelIndexSets_[i]);
148 }
149
150
155 int maxLevel() const {
156 return hostgrid_->maxLevel();
157 }
158
160 template<int codim>
161 typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const {
163 }
164
165
167 template<int codim>
168 typename Traits::template Codim<codim>::LevelIterator lend (int level) const {
170 }
171
172
174 template<int codim, PartitionIteratorType PiType>
175 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const {
177 }
178
179
181 template<int codim, PartitionIteratorType PiType>
182 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const {
184 }
185
186
188 template<int codim>
189 typename Traits::template Codim<codim>::LeafIterator leafbegin() const {
191 }
192
193
195 template<int codim>
196 typename Traits::template Codim<codim>::LeafIterator leafend() const {
198 }
199
200
202 template<int codim, PartitionIteratorType PiType>
203 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const {
205 }
206
207
209 template<int codim, PartitionIteratorType PiType>
210 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const {
212 }
213
214
217 int size (int level, int codim) const {
218 return hostgrid_->size(level,codim);
219 }
220
223 size_t numBoundarySegments () const {
224 return hostgrid_->numBoundarySegments();
225 }
226
228 int size (int codim) const {
229 return leafIndexSet().size(codim);
230 }
231
232
234 int size (int level, GeometryType type) const {
235 return levelIndexSets_[level]->size(type);
236 }
237
238
240 int size (GeometryType type) const
241 {
242 return leafIndexSet().size(type);
243 }
244
245
247 const typename Traits::GlobalIdSet& globalIdSet() const {
248 return globalIdSet_;
249 }
250
251
253 const typename Traits::LocalIdSet& localIdSet() const {
254 return localIdSet_;
255 }
256
257
259 const typename Traits::LevelIndexSet& levelIndexSet(int level) const
260 {
261 if (level < 0 || level > maxLevel())
262 {
263 DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
264 }
265 return *levelIndexSets_[level];
266 }
267
268
270 const typename Traits::LeafIndexSet& leafIndexSet() const
271 {
272 return leafIndexSet_;
273 }
274
275
277 template < class EntitySeed >
278 typename Traits::template Codim<EntitySeed::codimension>::Entity
279 entity(const EntitySeed& seed) const
280 {
281 typedef IdentityGridEntity<
283 HostGrid::dimension,
284 const typename Traits::Grid
285 > EntityImp;
286
287 return EntityImp(this, hostgrid_->entity(seed.impl().hostEntitySeed()));
288 }
289
290
293
294
298 void globalRefine (int refCount)
299 {
300 hostgrid_->globalRefine(refCount);
301 }
302
313 bool mark(int refCount, const typename Traits::template Codim<0>::Entity & e)
314 {
315 return hostgrid_->mark(refCount, getHostEntity<0>(e));
316 }
317
322 int getMark(const typename Traits::template Codim<0>::Entity & e) const
323 {
324 return hostgrid_->getMark(getHostEntity<0>(e));
325 }
326
328 bool preAdapt() {
329 return hostgrid_->preAdapt();
330 }
331
332
334 bool adapt()
335 {
336 return hostgrid_->adapt();
337 }
338
340 void postAdapt() {
341 return hostgrid_->postAdapt();
342 }
343
347 unsigned int overlapSize(int codim) const {
348 return hostgrid_->leafGridView().overlapSize(codim);
349 }
350
351
353 unsigned int ghostSize(int codim) const {
354 return hostgrid_->leafGridView().ghostSize(codim);
355 }
356
357
359 unsigned int overlapSize(int level, int codim) const {
360 return hostgrid_->levelGridView(level).overlapSize(codim);
361 }
362
363
365 unsigned int ghostSize(int level, int codim) const {
366 return hostgrid_->levelGridView(level).ghostSize(codim);
367 }
368
369
370#if 0
376 void loadBalance(int strategy, int minlevel, int depth, int maxlevel, int minelement){
377 DUNE_THROW(NotImplemented, "IdentityGrid::loadBalance()");
378 }
379#endif
380
381
384 {
385 return ccobj;
386 }
387
388
389 // **********************************************************
390 // End of Interface Methods
391 // **********************************************************
392
395 {
396 return *hostgrid_;
397 }
398
399
401 template <int codim>
402 const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
403 {
404 return e.impl().hostEntity_;
405 }
406
407 protected:
408
410 HostGrid* hostgrid_;
411
412 private:
413
415 void setIndices()
416 {
417 localIdSet_.update();
418
419 globalIdSet_.update();
420
421 // //////////////////////////////////////////
422 // Create the index sets
423 // //////////////////////////////////////////
424 for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
427 levelIndexSets_.push_back(p);
428 }
429
430 for (int i=0; i<=maxLevel(); i++)
431 if (levelIndexSets_[i])
432 levelIndexSets_[i]->update(*this, i);
433
434 leafIndexSet_.update(*this);
435
436 }
437
439 Communication<No_Comm> ccobj;
440
442 std::vector<IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >*> levelIndexSets_;
443
446
449
452
453 }; // end Class IdentityGrid
454
455
456
457
458 namespace Capabilities
459 {
463 template<class HostGrid, int codim>
464 struct hasEntity<IdentityGrid<HostGrid>, codim>
465 {
466 static const bool v = hasEntity<HostGrid,codim>::v;
467 };
468
469 template<class HostGrid, int codim>
470 struct hasEntityIterator<IdentityGrid<HostGrid>, codim>
471 {
473 };
474
478 template<class HostGrid, int codim>
479 struct canCommunicate<IdentityGrid<HostGrid>, codim>
480 {
482 };
483
487 template<class HostGrid>
489 {
491 };
492
496 template<class HostGrid>
498 {
500 };
501 } // end namespace Capabilities
502
503} // namespace Dune
504
505#endif // DUNE_GRID_IDENTITYGRID_HH
The IdentityGridLevelIterator class.
The IdentityGridLeafIterator class.
The IdentityGridLeafIntersectionIterator and IdentityGridLevelIntersectionIterator classes.
The index and id sets for the IdentityGrid class.
The IdentityGridHierarchicIterator class.
The IdentityGridGeometry class and its specializations.
The IdentityGridEntitySeed class.
The IdentityGridEntity class.
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: common/capabilities.hh:58
static const bool v
Definition: common/capabilities.hh:59
specialize with 'true' for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: common/capabilities.hh:74
static const bool v
Definition: common/capabilities.hh:75
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: common/capabilities.hh:97
static const bool v
Definition: common/capabilities.hh:98
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:106
static const bool v
Definition: common/capabilities.hh:107
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:115
static const bool v
Definition: common/capabilities.hh:116
Definition: defaultgridview.hh:26
Definition: defaultgridview.hh:219
Implementation & impl()
access to the underlying implementation
Definition: common/entity.hh:80
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:26
Implementation & impl()
access to the underlying implementation
Definition: common/entityseed.hh:59
static constexpr int codimension
codimension of underlying entity
Definition: common/entityseed.hh:30
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:20
Definition: common/grid.hh:862
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: common/grid.hh:948
Index Set Interface base class.
Definition: indexidset.hh:78
auto size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:223
Id Set Interface.
Definition: indexidset.hh:452
detected_or_fallback_t< DeprecatedCollectiveCommunication_t, Communication_t, typename GridFamily::Traits > Communication
A type that is a model of Dune::Communication. It provides a portable way for communication on the se...
Definition: common/grid.hh:525
A traits struct that collects all associated types of one grid model.
Definition: common/grid.hh:995
GridImp Grid
The type that implements the grid.
Definition: common/grid.hh:997
Provides a meta grid that is identical to its host.
Definition: identitygrid.hh:88
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark entity for refinement.
Definition: identitygrid.hh:313
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:189
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: identitygrid.hh:259
IdentityGridFamily< HostGrid::dimension, HostGrid >::Traits Traits
the Traits
Definition: identitygrid.hh:122
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: identitygrid.hh:270
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: identitygrid.hh:217
int size(int level, GeometryType type) const
number of entities per level, codim and geometry type in this process
Definition: identitygrid.hh:234
HostGridType & getHostGrid() const
Returns the hostgrid this IdentityGrid lives in.
Definition: identitygrid.hh:394
unsigned int ghostSize(int level, int codim) const
Size of the ghost cell layer on a given level.
Definition: identitygrid.hh:365
HostGrid HostGridType
Definition: identitygrid.hh:112
void postAdapt()
Clean up refinement markers.
Definition: identitygrid.hh:340
bool adapt()
Triggers the grid refinement process.
Definition: identitygrid.hh:334
HostGrid * hostgrid_
The host grid which contains the actual grid hierarchy structure.
Definition: identitygrid.hh:410
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: identitygrid.hh:247
int size(int codim) const
number of leaf entities per codim in this process
Definition: identitygrid.hh:228
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:196
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:182
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: identitygrid.hh:240
int maxLevel() const
Return maximum level defined in this grid.
Definition: identitygrid.hh:155
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:175
HostGrid::ctype ctype
The type used to store coordinates, inherited from the HostGrid.
Definition: identitygrid.hh:125
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:168
~IdentityGrid()
Desctructor.
Definition: identitygrid.hh:142
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: identitygrid.hh:223
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: identitygrid.hh:253
IdentityGridFamily< HostGrid::dimension, HostGrid > GridFamily
type of the used GridFamily for this grid
Definition: identitygrid.hh:119
void globalRefine(int refCount)
Definition: identitygrid.hh:298
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:210
unsigned int overlapSize(int codim) const
Size of the overlap on the leaf level.
Definition: identitygrid.hh:347
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:161
IdentityGrid(HostGrid &hostgrid)
Constructor.
Definition: identitygrid.hh:132
const HostGrid::Traits::template Codim< codim >::Entity & getHostEntity(const typename Traits::template Codim< codim >::Entity &e) const
Returns the hostgrid entity encapsulated in given IdentityGrid entity.
Definition: identitygrid.hh:402
unsigned int overlapSize(int level, int codim) const
Size of the overlap on a given level.
Definition: identitygrid.hh:359
bool preAdapt()
returns true, if at least one entity is marked for adaption
Definition: identitygrid.hh:328
unsigned int ghostSize(int codim) const
Size of the ghost cell layer on the leaf level.
Definition: identitygrid.hh:353
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
Create Entity from EntitySeed.
Definition: identitygrid.hh:279
const Communication< No_Comm > & comm() const
dummy communication
Definition: identitygrid.hh:383
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Return refinement mark for entity.
Definition: identitygrid.hh:322
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:203
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Definition: identitygrid.hh:41
GridTraits< dim, HostGrid::dimensionworld, Dune::IdentityGrid< HostGrid >, IdentityGridGeometry, IdentityGridEntity, IdentityGridLevelIterator, IdentityGridLeafIntersection, IdentityGridLevelIntersection, IdentityGridLeafIntersectionIterator, IdentityGridLevelIntersectionIterator, IdentityGridHierarchicIterator, IdentityGridLeafIterator, IdentityGridLevelIndexSet< const IdentityGrid< HostGrid > >, IdentityGridLeafIndexSet< const IdentityGrid< HostGrid > >, IdentityGridGlobalIdSet< const IdentityGrid< HostGrid > >, typename HostGrid::Traits::GlobalIdSet::IdType, IdentityGridLocalIdSet< const IdentityGrid< HostGrid > >, typename HostGrid::Traits::LocalIdSet::IdType, Communication< No_Comm >, DefaultLevelGridViewTraits, DefaultLeafGridViewTraits, IdentityGridEntitySeed > Traits
Definition: identitygrid.hh:68
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:55
Iterator over all entities of a given codimension and level of a grid.
Definition: identitygridleveliterator.hh:21
Definition: identitygridintersectioniterator.hh:84
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: identitygridintersectioniterator.hh:29
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: identitygridhierarchiciterator.hh:26
The EntitySeed class provides the minimal information needed to restore an Entity using the grid.
Definition: identitygridentityseed.hh:24
Definition: identitygridgeometry.hh:21
Definition: identitygridindexsets.hh:26
Definition: identitygridindexsets.hh:103
Definition: identitygridindexsets.hh:199
Definition: identitygridindexsets.hh:251
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition: identitygridintersections.hh:33
Definition: identitygridintersections.hh:192
Iterator over all entities of a given codimension and level of a grid.
Definition: identitygridleafiterator.hh:22
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.