dune-grid 3.0-git
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
13#include <dune/common/deprecated.hh>
14#include <dune/common/parallel/collectivecommunication.hh>
17
18// 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>
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>
192
193
195 template<int codim>
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(this->getRealImplementation(seed).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_->overlapSize(codim);
349 }
350
351
353 unsigned int ghostSize(int codim) const {
354 return hostgrid_->ghostSize(codim);
355 }
356
357
359 unsigned int overlapSize(int level, int codim) const {
360 return hostgrid_->overlapSize(level,codim);
361 }
362
363
365 unsigned int ghostSize(int level, int codim) const {
366 return hostgrid_->ghostSize(level,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
391 template<class T, template<class> class P, int codim>
392 void communicate (T& t, InterfaceType iftype, CommunicationDirection dir, int level);
393
398 template<class DataHandle>
399 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
400 {}
401
402 template<class DataHandle>
403 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
404 {}
405#endif
406
407
410 {
411 return ccobj;
412 }
413
414
415 // **********************************************************
416 // End of Interface Methods
417 // **********************************************************
418
421 {
422 return *hostgrid_;
423 }
424
425
427 template <int codim>
428 const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
429 {
430 return this->getRealImplementation(e).hostEntity_;
431 }
432
433 protected:
434
436 HostGrid* hostgrid_;
437
438 private:
439
441 void setIndices()
442 {
443 localIdSet_.update();
444
445 globalIdSet_.update();
446
447 // //////////////////////////////////////////
448 // Create the index sets
449 // //////////////////////////////////////////
450 for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
453 levelIndexSets_.push_back(p);
454 }
455
456 for (int i=0; i<=maxLevel(); i++)
457 if (levelIndexSets_[i])
458 levelIndexSets_[i]->update(*this, i);
459
460 leafIndexSet_.update(*this);
461
462 }
463
465 CollectiveCommunication<IdentityGrid> ccobj;
466
468 std::vector<IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >*> levelIndexSets_;
469
472
475
478
479 }; // end Class IdentityGrid
480
481
482
483
484 namespace Capabilities
485 {
489 template<class HostGrid, int codim>
490 struct hasEntity<IdentityGrid<HostGrid>, codim>
491 {
492 static const bool v = hasEntity<HostGrid,codim>::v;
493 };
494
498 template<class HostGrid>
499 struct isLevelwiseConforming<IdentityGrid<HostGrid> >
500 {
501 static const bool v = isLevelwiseConforming<HostGrid>::v;
502 };
503
507 template<class HostGrid>
508 struct isLeafwiseConforming<IdentityGrid<HostGrid> >
509 {
510 static const bool v = isLeafwiseConforming<HostGrid>::v;
511 };
512 } // end namespace Capabilities
513
514} // namespace Dune
515
516#endif // DUNE_GRID_IDENTITYGRID_HH
The IdentityGridEntity class.
The IdentityGridEntityPointer 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 and its specializations.
CommunicationDirection
Define a type for communication direction parameter.
Definition gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition gridenums.hh:84
Include standard header files.
Definition agrid.hh:60
static const bool v
Definition common/capabilities.hh:57
static const bool v
Definition common/capabilities.hh:79
static const bool v
Definition common/capabilities.hh:88
Definition defaultgridview.hh:24
Definition defaultgridview.hh:221
Store a reference to an entity with a minimal memory footprint.
Definition common/entityseed.hh:24
@ codimension
Definition common/entityseed.hh:28
Base class for exceptions in Dune grid modules.
Definition exceptions.hh:18
Definition common/grid.hh:924
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition common/grid.hh:1119
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition common/grid.hh:1023
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition common/grid.hh:1034
Index Set Interface base class.
Definition indexidset.hh:76
IndexType size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition indexidset.hh:215
Id Set Interface.
Definition indexidset.hh:397
GridFamily::Traits::CollectiveCommunication CollectiveCommunication
A type that is a model of Dune::CollectiveCommunication. It provides a portable way for collective co...
Definition common/grid.hh:519
A Traits struct that collects all associated types of one implementation.
Definition common/grid.hh:415
A traits struct that collects all associated types of one grid model.
Definition common/grid.hh:1157
GridImp Grid
The type that implements the grid.
Definition common/grid.hh:1159
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
const CollectiveCommunication< IdentityGrid > & comm() const
dummy collective communication
Definition identitygrid.hh:409
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:420
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:436
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:428
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
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, CollectiveCommunication< IdentityGrid< HostGrid > >, DefaultLevelGridViewTraits, DefaultLeafGridViewTraits, IdentityGridEntitySeed > Traits
Definition identitygrid.hh:68
The implementation of entities in a IdentityGrid.
Definition identitygridentity.hh:56
Iterator over all entities of a given codimension and level of a grid.
Definition identitygridleveliterator.hh:26
Definition identitygridintersectioniterator.hh:82
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition identitygridintersectioniterator.hh:27
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:22
Definition identitygridgeometry.hh:19
Definition identitygridindexsets.hh:24
Definition identitygridindexsets.hh:101
Definition identitygridindexsets.hh:197
Definition identitygridindexsets.hh:249
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition identitygridintersections.hh:30
Definition identitygridintersections.hh:195
Iterator over all entities of a given codimension and level of a grid.
Definition identitygridleafiterator.hh:21
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.