Dune Core Modules (2.6.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
17
18// The components of the IdentityGrid interface
27
28namespace Dune
29{
30 // Forward declaration
31 template <class HostGrid>
32 class IdentityGrid;
33
34 // External forward declarations
35 template< class Grid >
37
38 template<int dim, class HostGrid>
39 struct IdentityGridFamily
40 {
41
42 public:
43
44 typedef GridTraits<
45 dim,
46 HostGrid::dimensionworld,
48 IdentityGridGeometry,
58 IdentityGridLeafIndexSet< const IdentityGrid<HostGrid> >,
59 IdentityGridGlobalIdSet< const IdentityGrid<HostGrid> >,
60 typename HostGrid::Traits::GlobalIdSet::IdType,
61 IdentityGridLocalIdSet< const IdentityGrid<HostGrid> >,
62 typename HostGrid::Traits::LocalIdSet::IdType,
64 DefaultLevelGridViewTraits,
65 DefaultLeafGridViewTraits,
67 > Traits;
68
69 };
70
71 //**********************************************************************
72 //
73 // --IdentityGrid
74 //
75 //************************************************************************
83 template <class HostGrid>
85 : public GridDefaultImplementation<HostGrid::dimension, HostGrid::dimensionworld,
86 typename HostGrid::ctype, IdentityGridFamily<HostGrid::dimension, HostGrid> >
87 {
88 friend class IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >;
89 friend class IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> >;
90 friend class IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> >;
91 friend class IdentityGridLocalIdSet<const IdentityGrid<HostGrid> >;
92 friend class IdentityGridHierarchicIterator<const IdentityGrid<HostGrid> >;
93 friend class IdentityGridLevelIntersectionIterator<const IdentityGrid<HostGrid> >;
94 friend class IdentityGridLeafIntersectionIterator<const IdentityGrid<HostGrid> >;
95
96 template<int codim, PartitionIteratorType pitype, class GridImp_>
97 friend class IdentityGridLevelIterator;
98
99 template<int codim, PartitionIteratorType pitype, class GridImp_>
100 friend class IdentityGridLeafIterator;
101
102
103 template<int codim_, int dim_, class GridImp_>
104 friend class IdentityGridEntity;
105
106 friend struct HostGridAccess< IdentityGrid< HostGrid > >;
107
108 public:
109
111 typedef HostGrid HostGridType;
112
113 //**********************************************************
114 // The Interface Methods
115 //**********************************************************
116
118 typedef IdentityGridFamily<HostGrid::dimension,HostGrid> GridFamily;
119
122
124 typedef typename HostGrid::ctype ctype;
125
126
131 explicit IdentityGrid(HostGrid& hostgrid) :
132 hostgrid_(&hostgrid),
133 leafIndexSet_(*this),
134 globalIdSet_(*this),
135 localIdSet_(*this)
136 {
137 setIndices();
138 }
139
142 {
143 // Delete level index sets
144 for (size_t i=0; i<levelIndexSets_.size(); i++)
145 if (levelIndexSets_[i])
146 delete (levelIndexSets_[i]);
147 }
148
149
154 int maxLevel() const {
155 return hostgrid_->maxLevel();
156 }
157
159 template<int codim>
160 typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const {
162 }
163
164
166 template<int codim>
167 typename Traits::template Codim<codim>::LevelIterator lend (int level) const {
169 }
170
171
173 template<int codim, PartitionIteratorType PiType>
174 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const {
176 }
177
178
180 template<int codim, PartitionIteratorType PiType>
181 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const {
183 }
184
185
187 template<int codim>
188 typename Traits::template Codim<codim>::LeafIterator leafbegin() const {
190 }
191
192
194 template<int codim>
195 typename Traits::template Codim<codim>::LeafIterator leafend() const {
197 }
198
199
201 template<int codim, PartitionIteratorType PiType>
202 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const {
204 }
205
206
208 template<int codim, PartitionIteratorType PiType>
209 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const {
211 }
212
213
216 int size (int level, int codim) const {
217 return hostgrid_->size(level,codim);
218 }
219
222 size_t numBoundarySegments () const {
223 return hostgrid_->numBoundarySegments();
224 }
225
227 int size (int codim) const {
228 return leafIndexSet().size(codim);
229 }
230
231
233 int size (int level, GeometryType type) const {
234 return levelIndexSets_[level]->size(type);
235 }
236
237
239 int size (GeometryType type) const
240 {
241 return leafIndexSet().size(type);
242 }
243
244
246 const typename Traits::GlobalIdSet& globalIdSet() const {
247 return globalIdSet_;
248 }
249
250
252 const typename Traits::LocalIdSet& localIdSet() const {
253 return localIdSet_;
254 }
255
256
258 const typename Traits::LevelIndexSet& levelIndexSet(int level) const
259 {
260 if (level < 0 || level > maxLevel())
261 {
262 DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
263 }
264 return *levelIndexSets_[level];
265 }
266
267
269 const typename Traits::LeafIndexSet& leafIndexSet() const
270 {
271 return leafIndexSet_;
272 }
273
274
276 template < class EntitySeed >
277 typename Traits::template Codim<EntitySeed::codimension>::Entity
278 entity(const EntitySeed& seed) const
279 {
280 typedef IdentityGridEntity<
281 EntitySeed::codimension,
282 HostGrid::dimension,
283 const typename Traits::Grid
284 > EntityImp;
285
286 return EntityImp(this, hostgrid_->entity(this->getRealImplementation(seed).hostEntitySeed()));
287 }
288
289
292
293
297 void globalRefine (int refCount)
298 {
299 hostgrid_->globalRefine(refCount);
300 }
301
312 bool mark(int refCount, const typename Traits::template Codim<0>::Entity & e)
313 {
314 return hostgrid_->mark(refCount, getHostEntity<0>(e));
315 }
316
321 int getMark(const typename Traits::template Codim<0>::Entity & e) const
322 {
323 return hostgrid_->getMark(getHostEntity<0>(e));
324 }
325
327 bool preAdapt() {
328 return hostgrid_->preAdapt();
329 }
330
331
333 bool adapt()
334 {
335 return hostgrid_->adapt();
336 }
337
339 void postAdapt() {
340 return hostgrid_->postAdapt();
341 }
342
346 unsigned int overlapSize(int codim) const {
347 return hostgrid_->leafGridView().overlapSize(codim);
348 }
349
350
352 unsigned int ghostSize(int codim) const {
353 return hostgrid_->leafGridView().ghostSize(codim);
354 }
355
356
358 unsigned int overlapSize(int level, int codim) const {
359 return hostgrid_->levelGridView(level).overlapSize(codim);
360 }
361
362
364 unsigned int ghostSize(int level, int codim) const {
365 return hostgrid_->levelGridView(level).ghostSize(codim);
366 }
367
368
369#if 0
375 void loadBalance(int strategy, int minlevel, int depth, int maxlevel, int minelement){
376 DUNE_THROW(NotImplemented, "IdentityGrid::loadBalance()");
377 }
378#endif
379
380
383 {
384 return ccobj;
385 }
386
387
388 // **********************************************************
389 // End of Interface Methods
390 // **********************************************************
391
394 {
395 return *hostgrid_;
396 }
397
398
400 template <int codim>
401 const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
402 {
403 return this->getRealImplementation(e).hostEntity_;
404 }
405
406 protected:
407
409 HostGrid* hostgrid_;
410
411 private:
412
414 void setIndices()
415 {
416 localIdSet_.update();
417
418 globalIdSet_.update();
419
420 // //////////////////////////////////////////
421 // Create the index sets
422 // //////////////////////////////////////////
423 for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
426 levelIndexSets_.push_back(p);
427 }
428
429 for (int i=0; i<=maxLevel(); i++)
430 if (levelIndexSets_[i])
431 levelIndexSets_[i]->update(*this, i);
432
433 leafIndexSet_.update(*this);
434
435 }
436
439
441 std::vector<IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >*> levelIndexSets_;
442
444 IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> > leafIndexSet_;
445
447 IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> > globalIdSet_;
448
450 IdentityGridLocalIdSet<const IdentityGrid<HostGrid> > localIdSet_;
451
452 }; // end Class IdentityGrid
453
454
455
456
457 namespace Capabilities
458 {
462 template<class HostGrid, int codim>
463 struct hasEntity<IdentityGrid<HostGrid>, codim>
464 {
465 static const bool v = hasEntity<HostGrid,codim>::v;
466 };
467
468 template<class HostGrid, int codim>
469 struct hasEntityIterator<IdentityGrid<HostGrid>, codim>
470 {
471 static const bool v = hasEntityIterator<HostGrid, codim>::v;
472 };
473
477 template<class HostGrid>
479 {
480 static const bool v = isLevelwiseConforming<HostGrid>::v;
481 };
482
486 template<class HostGrid>
488 {
489 static const bool v = isLeafwiseConforming<HostGrid>::v;
490 };
491 } // end namespace Capabilities
492
493} // namespace Dune
494
495#endif // DUNE_GRID_IDENTITYGRID_HH
Collective communication interface and sequential default implementation.
Definition: collectivecommunication.hh:80
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
Definition: grid.hh:855
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: grid.hh:1026
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: grid.hh:941
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:519
Id Set Interface.
Definition: indexidset.hh:441
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:87
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark entity for refinement.
Definition: identitygrid.hh:312
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:188
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: identitygrid.hh:258
const CollectiveCommunication< IdentityGrid > & comm() const
dummy collective communication
Definition: identitygrid.hh:382
IdentityGridFamily< HostGrid::dimension, HostGrid >::Traits Traits
the Traits
Definition: identitygrid.hh:121
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: identitygrid.hh:269
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: identitygrid.hh:216
int size(int level, GeometryType type) const
number of entities per level, codim and geometry type in this process
Definition: identitygrid.hh:233
HostGridType & getHostGrid() const
Returns the hostgrid this IdentityGrid lives in.
Definition: identitygrid.hh:393
unsigned int ghostSize(int level, int codim) const
Size of the ghost cell layer on a given level.
Definition: identitygrid.hh:364
HostGrid HostGridType
Definition: identitygrid.hh:111
void postAdapt()
Clean up refinement markers.
Definition: identitygrid.hh:339
bool adapt()
Triggers the grid refinement process.
Definition: identitygrid.hh:333
HostGrid * hostgrid_
The host grid which contains the actual grid hierarchy structure.
Definition: identitygrid.hh:409
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: identitygrid.hh:246
int size(int codim) const
number of leaf entities per codim in this process
Definition: identitygrid.hh:227
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:195
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:181
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: identitygrid.hh:239
int maxLevel() const
Return maximum level defined in this grid.
Definition: identitygrid.hh:154
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:174
HostGrid::ctype ctype
The type used to store coordinates, inherited from the HostGrid.
Definition: identitygrid.hh:124
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:167
~IdentityGrid()
Desctructor.
Definition: identitygrid.hh:141
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: identitygrid.hh:222
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: identitygrid.hh:252
IdentityGridFamily< HostGrid::dimension, HostGrid > GridFamily
type of the used GridFamily for this grid
Definition: identitygrid.hh:118
void globalRefine(int refCount)
Definition: identitygrid.hh:297
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:209
unsigned int overlapSize(int codim) const
Size of the overlap on the leaf level.
Definition: identitygrid.hh:346
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:160
IdentityGrid(HostGrid &hostgrid)
Constructor.
Definition: identitygrid.hh:131
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:401
unsigned int overlapSize(int level, int codim) const
Size of the overlap on a given level.
Definition: identitygrid.hh:358
bool preAdapt()
returns true, if at least one entity is marked for adaption
Definition: identitygrid.hh:327
unsigned int ghostSize(int codim) const
Size of the ghost cell layer on the leaf level.
Definition: identitygrid.hh:352
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
Create Entity from EntitySeed.
Definition: identitygrid.hh:278
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Return refinement mark for entity.
Definition: identitygrid.hh:321
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:202
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:220
Default exception for dummy implementations.
Definition: exceptions.hh:261
Implements an utility class that provides collective communication methods for sequential programs.
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
#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:10
specialize with 'true' for all codims that a grid provides an iterator for (default=false)
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:1064
GridImp Grid
The type that implements the grid.
Definition: grid.hh:1066
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:36
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)