Dune Core Modules (2.8.0)

identitygrid.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_IDENTITYGRID_HH
4#define DUNE_GRID_IDENTITYGRID_HH
5
10#include <string>
11#include <map>
12
16
17// The components of the IdentityGrid interface
26
27namespace Dune
28{
29 // Forward declaration
30 template <class HostGrid>
31 class IdentityGrid;
32
33 // External forward declarations
34 template< class Grid >
36
37 template<int dim, class HostGrid>
38 struct IdentityGridFamily
39 {
40
41 public:
42
43 typedef GridTraits<
44 dim,
45 HostGrid::dimensionworld,
47 IdentityGridGeometry,
57 IdentityGridLeafIndexSet< const IdentityGrid<HostGrid> >,
58 IdentityGridGlobalIdSet< const IdentityGrid<HostGrid> >,
59 typename HostGrid::Traits::GlobalIdSet::IdType,
60 IdentityGridLocalIdSet< const IdentityGrid<HostGrid> >,
61 typename HostGrid::Traits::LocalIdSet::IdType,
63 DefaultLevelGridViewTraits,
64 DefaultLeafGridViewTraits,
66 > Traits;
67
68 };
69
70 //**********************************************************************
71 //
72 // --IdentityGrid
73 //
74 //************************************************************************
82 template <class HostGrid>
84 : public GridDefaultImplementation<HostGrid::dimension, HostGrid::dimensionworld,
85 typename HostGrid::ctype, IdentityGridFamily<HostGrid::dimension, HostGrid> >
86 {
87 friend class IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >;
88 friend class IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> >;
89 friend class IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> >;
90 friend class IdentityGridLocalIdSet<const IdentityGrid<HostGrid> >;
91 friend class IdentityGridHierarchicIterator<const IdentityGrid<HostGrid> >;
92 friend class IdentityGridLevelIntersectionIterator<const IdentityGrid<HostGrid> >;
93 friend class IdentityGridLeafIntersectionIterator<const IdentityGrid<HostGrid> >;
94
95 template<int codim, PartitionIteratorType pitype, class GridImp_>
96 friend class IdentityGridLevelIterator;
97
98 template<int codim, PartitionIteratorType pitype, class GridImp_>
99 friend class IdentityGridLeafIterator;
100
101
102 template<int codim_, int dim_, class GridImp_>
103 friend class IdentityGridEntity;
104
105 friend struct HostGridAccess< IdentityGrid< HostGrid > >;
106
107 public:
108
110 typedef HostGrid HostGridType;
111
112 //**********************************************************
113 // The Interface Methods
114 //**********************************************************
115
117 typedef IdentityGridFamily<HostGrid::dimension,HostGrid> GridFamily;
118
121
123 typedef typename HostGrid::ctype ctype;
124
125
130 explicit IdentityGrid(HostGrid& hostgrid) :
131 hostgrid_(&hostgrid),
132 leafIndexSet_(*this),
133 globalIdSet_(*this),
134 localIdSet_(*this)
135 {
136 setIndices();
137 }
138
141 {
142 // Delete level index sets
143 for (size_t i=0; i<levelIndexSets_.size(); i++)
144 if (levelIndexSets_[i])
145 delete (levelIndexSets_[i]);
146 }
147
148
153 int maxLevel() const {
154 return hostgrid_->maxLevel();
155 }
156
158 template<int codim>
159 typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const {
161 }
162
163
165 template<int codim>
166 typename Traits::template Codim<codim>::LevelIterator lend (int level) const {
168 }
169
170
172 template<int codim, PartitionIteratorType PiType>
173 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const {
175 }
176
177
179 template<int codim, PartitionIteratorType PiType>
180 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const {
182 }
183
184
186 template<int codim>
187 typename Traits::template Codim<codim>::LeafIterator leafbegin() const {
189 }
190
191
193 template<int codim>
194 typename Traits::template Codim<codim>::LeafIterator leafend() const {
196 }
197
198
200 template<int codim, PartitionIteratorType PiType>
201 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const {
203 }
204
205
207 template<int codim, PartitionIteratorType PiType>
208 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const {
210 }
211
212
215 int size (int level, int codim) const {
216 return hostgrid_->size(level,codim);
217 }
218
221 size_t numBoundarySegments () const {
222 return hostgrid_->numBoundarySegments();
223 }
224
226 int size (int codim) const {
227 return leafIndexSet().size(codim);
228 }
229
230
232 int size (int level, GeometryType type) const {
233 return levelIndexSets_[level]->size(type);
234 }
235
236
238 int size (GeometryType type) const
239 {
240 return leafIndexSet().size(type);
241 }
242
243
245 const typename Traits::GlobalIdSet& globalIdSet() const {
246 return globalIdSet_;
247 }
248
249
251 const typename Traits::LocalIdSet& localIdSet() const {
252 return localIdSet_;
253 }
254
255
257 const typename Traits::LevelIndexSet& levelIndexSet(int level) const
258 {
259 if (level < 0 || level > maxLevel())
260 {
261 DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
262 }
263 return *levelIndexSets_[level];
264 }
265
266
268 const typename Traits::LeafIndexSet& leafIndexSet() const
269 {
270 return leafIndexSet_;
271 }
272
273
275 template < class EntitySeed >
276 typename Traits::template Codim<EntitySeed::codimension>::Entity
277 entity(const EntitySeed& seed) const
278 {
279 typedef IdentityGridEntity<
280 EntitySeed::codimension,
281 HostGrid::dimension,
282 const typename Traits::Grid
283 > EntityImp;
284
285 return EntityImp(this, hostgrid_->entity(seed.impl().hostEntitySeed()));
286 }
287
288
291
292
296 void globalRefine (int refCount)
297 {
298 hostgrid_->globalRefine(refCount);
299 }
300
311 bool mark(int refCount, const typename Traits::template Codim<0>::Entity & e)
312 {
313 return hostgrid_->mark(refCount, getHostEntity<0>(e));
314 }
315
320 int getMark(const typename Traits::template Codim<0>::Entity & e) const
321 {
322 return hostgrid_->getMark(getHostEntity<0>(e));
323 }
324
326 bool preAdapt() {
327 return hostgrid_->preAdapt();
328 }
329
330
332 bool adapt()
333 {
334 return hostgrid_->adapt();
335 }
336
338 void postAdapt() {
339 return hostgrid_->postAdapt();
340 }
341
345 unsigned int overlapSize(int codim) const {
346 return hostgrid_->leafGridView().overlapSize(codim);
347 }
348
349
351 unsigned int ghostSize(int codim) const {
352 return hostgrid_->leafGridView().ghostSize(codim);
353 }
354
355
357 unsigned int overlapSize(int level, int codim) const {
358 return hostgrid_->levelGridView(level).overlapSize(codim);
359 }
360
361
363 unsigned int ghostSize(int level, int codim) const {
364 return hostgrid_->levelGridView(level).ghostSize(codim);
365 }
366
367
368#if 0
374 void loadBalance(int strategy, int minlevel, int depth, int maxlevel, int minelement){
375 DUNE_THROW(NotImplemented, "IdentityGrid::loadBalance()");
376 }
377#endif
378
379
382 {
383 return ccobj;
384 }
385
386
387 // **********************************************************
388 // End of Interface Methods
389 // **********************************************************
390
393 {
394 return *hostgrid_;
395 }
396
397
399 template <int codim>
400 const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
401 {
402 return e.impl().hostEntity_;
403 }
404
405 protected:
406
408 HostGrid* hostgrid_;
409
410 private:
411
413 void setIndices()
414 {
415 localIdSet_.update();
416
417 globalIdSet_.update();
418
419 // //////////////////////////////////////////
420 // Create the index sets
421 // //////////////////////////////////////////
422 for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
425 levelIndexSets_.push_back(p);
426 }
427
428 for (int i=0; i<=maxLevel(); i++)
429 if (levelIndexSets_[i])
430 levelIndexSets_[i]->update(*this, i);
431
432 leafIndexSet_.update(*this);
433
434 }
435
438
440 std::vector<IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >*> levelIndexSets_;
441
443 IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> > leafIndexSet_;
444
446 IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> > globalIdSet_;
447
449 IdentityGridLocalIdSet<const IdentityGrid<HostGrid> > localIdSet_;
450
451 }; // end Class IdentityGrid
452
453
454
455
456 namespace Capabilities
457 {
461 template<class HostGrid, int codim>
462 struct hasEntity<IdentityGrid<HostGrid>, codim>
463 {
464 static const bool v = hasEntity<HostGrid,codim>::v;
465 };
466
467 template<class HostGrid, int codim>
468 struct hasEntityIterator<IdentityGrid<HostGrid>, codim>
469 {
470 static const bool v = hasEntityIterator<HostGrid, codim>::v;
471 };
472
476 template<class HostGrid, int codim>
477 struct canCommunicate<IdentityGrid<HostGrid>, codim>
478 {
479 static const bool v = canCommunicate<HostGrid, codim>::v;
480 };
481
485 template<class HostGrid>
487 {
488 static const bool v = isLevelwiseConforming<HostGrid>::v;
489 };
490
494 template<class HostGrid>
496 {
497 static const bool v = isLeafwiseConforming<HostGrid>::v;
498 };
499 } // end namespace Capabilities
500
501} // namespace Dune
502
503#endif // DUNE_GRID_IDENTITYGRID_HH
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Implementation & impl()
access to the underlying implementation
Definition: entityseed.hh:57
Implementation & impl()
access to the underlying implementation
Definition: entity.hh:78
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
Definition: grid.hh:851
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: grid.hh:937
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
GridFamily::Traits::CollectiveCommunication CollectiveCommunication
A type that is a model of Dune::CollectiveCommunication. It provides a portable way for collective co...
Definition: grid.hh:518
Id Set Interface.
Definition: indexidset.hh:450
The EntitySeed class provides the minimal information needed to restore an Entity using the grid.
Definition: identitygridentityseed.hh:22
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:53
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: identitygridhierarchiciterator.hh:24
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: identitygridintersectioniterator.hh:27
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition: identitygridintersections.hh:31
Iterator over all entities of a given codimension and level of a grid.
Definition: identitygridleafiterator.hh:20
Definition: identitygridindexsets.hh:24
Definition: identitygridintersectioniterator.hh:82
Definition: identitygridintersections.hh:190
Iterator over all entities of a given codimension and level of a grid.
Definition: identitygridleveliterator.hh:19
Provides a meta grid that is identical to its host.
Definition: identitygrid.hh:86
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark entity for refinement.
Definition: identitygrid.hh:311
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:187
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: identitygrid.hh:257
IdentityGridFamily< HostGrid::dimension, HostGrid >::Traits Traits
the Traits
Definition: identitygrid.hh:120
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: identitygrid.hh:268
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: identitygrid.hh:215
int size(int level, GeometryType type) const
number of entities per level, codim and geometry type in this process
Definition: identitygrid.hh:232
HostGridType & getHostGrid() const
Returns the hostgrid this IdentityGrid lives in.
Definition: identitygrid.hh:392
unsigned int ghostSize(int level, int codim) const
Size of the ghost cell layer on a given level.
Definition: identitygrid.hh:363
HostGrid HostGridType
Definition: identitygrid.hh:110
void postAdapt()
Clean up refinement markers.
Definition: identitygrid.hh:338
bool adapt()
Triggers the grid refinement process.
Definition: identitygrid.hh:332
HostGrid * hostgrid_
The host grid which contains the actual grid hierarchy structure.
Definition: identitygrid.hh:408
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: identitygrid.hh:245
int size(int codim) const
number of leaf entities per codim in this process
Definition: identitygrid.hh:226
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:194
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:180
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: identitygrid.hh:238
int maxLevel() const
Return maximum level defined in this grid.
Definition: identitygrid.hh:153
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:173
HostGrid::ctype ctype
The type used to store coordinates, inherited from the HostGrid.
Definition: identitygrid.hh:123
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:166
~IdentityGrid()
Desctructor.
Definition: identitygrid.hh:140
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: identitygrid.hh:221
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: identitygrid.hh:251
IdentityGridFamily< HostGrid::dimension, HostGrid > GridFamily
type of the used GridFamily for this grid
Definition: identitygrid.hh:117
void globalRefine(int refCount)
Definition: identitygrid.hh:296
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:208
unsigned int overlapSize(int codim) const
Size of the overlap on the leaf level.
Definition: identitygrid.hh:345
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:159
const CollectiveCommunication< No_Comm > & comm() const
dummy collective communication
Definition: identitygrid.hh:381
IdentityGrid(HostGrid &hostgrid)
Constructor.
Definition: identitygrid.hh:130
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:400
unsigned int overlapSize(int level, int codim) const
Size of the overlap on a given level.
Definition: identitygrid.hh:357
bool preAdapt()
returns true, if at least one entity is marked for adaption
Definition: identitygrid.hh:326
unsigned int ghostSize(int codim) const
Size of the ghost cell layer on the leaf level.
Definition: identitygrid.hh:351
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
Create Entity from EntitySeed.
Definition: identitygrid.hh:277
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Return refinement mark for entity.
Definition: identitygrid.hh:320
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:201
Index Set Interface base class.
Definition: indexidset.hh:76
auto size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:221
Default exception for dummy implementations.
Definition: exceptions.hh:261
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.
Implements an utility class that provides collective communication methods for sequential programs.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
The IdentityGridEntity class.
The IdentityGridEntitySeed class.
The IdentityGridGeometry class and its specializations.
The IdentityGridHierarchicIterator class.
The index and id sets for the IdentityGrid class.
The IdentityGridLeafIntersectionIterator and IdentityGridLevelIntersectionIterator classes.
The IdentityGridLeafIterator class.
The IdentityGridLevelIterator class.
Dune namespace.
Definition: alignedallocator.hh:11
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: capabilities.hh:95
specialize with 'true' for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: capabilities.hh:72
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:56
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:113
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:104
Static tag representing a codimension.
Definition: dimension.hh:22
A traits struct that collects all associated types of one grid model.
Definition: grid.hh:984
GridImp Grid
The type that implements the grid.
Definition: grid.hh:986
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:35
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)