Dune Core Modules (2.5.2)

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_->overlapSize(codim);
348 }
349
350
352 unsigned int ghostSize(int codim) const {
353 return hostgrid_->ghostSize(codim);
354 }
355
356
358 unsigned int overlapSize(int level, int codim) const {
359 return hostgrid_->overlapSize(level,codim);
360 }
361
362
364 unsigned int ghostSize(int level, int codim) const {
365 return hostgrid_->ghostSize(level,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
390 template<class T, template<class> class P, int codim>
391 void communicate (T& t, InterfaceType iftype, CommunicationDirection dir, int level);
392
397 template<class DataHandle>
398 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
399 {}
400
401 template<class DataHandle>
402 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
403 {}
404#endif
405
406
409 {
410 return ccobj;
411 }
412
413
414 // **********************************************************
415 // End of Interface Methods
416 // **********************************************************
417
420 {
421 return *hostgrid_;
422 }
423
424
426 template <int codim>
427 const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
428 {
429 return this->getRealImplementation(e).hostEntity_;
430 }
431
432 protected:
433
435 HostGrid* hostgrid_;
436
437 private:
438
440 void setIndices()
441 {
442 localIdSet_.update();
443
444 globalIdSet_.update();
445
446 // //////////////////////////////////////////
447 // Create the index sets
448 // //////////////////////////////////////////
449 for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
452 levelIndexSets_.push_back(p);
453 }
454
455 for (int i=0; i<=maxLevel(); i++)
456 if (levelIndexSets_[i])
457 levelIndexSets_[i]->update(*this, i);
458
459 leafIndexSet_.update(*this);
460
461 }
462
465
467 std::vector<IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >*> levelIndexSets_;
468
470 IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> > leafIndexSet_;
471
473 IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> > globalIdSet_;
474
476 IdentityGridLocalIdSet<const IdentityGrid<HostGrid> > localIdSet_;
477
478 }; // end Class IdentityGrid
479
480
481
482
483 namespace Capabilities
484 {
488 template<class HostGrid, int codim>
489 struct hasEntity<IdentityGrid<HostGrid>, codim>
490 {
491 static const bool v = hasEntity<HostGrid,codim>::v;
492 };
493
497 template<class HostGrid>
499 {
500 static const bool v = isLevelwiseConforming<HostGrid>::v;
501 };
502
506 template<class HostGrid>
508 {
509 static const bool v = isLeafwiseConforming<HostGrid>::v;
510 };
511 } // end namespace Capabilities
512
513} // namespace Dune
514
515#endif // DUNE_GRID_IDENTITYGRID_HH
Collective communication interface and sequential default implementation.
Definition: collectivecommunication.hh:79
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:268
Definition: grid.hh:920
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:1115
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition: grid.hh:1019
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: grid.hh:1030
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:402
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:196
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:408
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:419
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:435
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:427
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
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
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: alignment.hh:11
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:87
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:78
Static tag representing a codimension.
Definition: dimension.hh:22
A traits struct that collects all associated types of one grid model.
Definition: grid.hh:1153
GridImp Grid
The type that implements the grid.
Definition: grid.hh:1155
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 12, 23:30, 2024)