Dune Core Modules (2.4.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
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 namespace {
40
41 // This is just a placeholder to stuff into the standard
42 // GridTraits, as those expect an EntityPointer implementation
43 // with two template parameters, but our EntityPointer uses three.
44 template<int,typename>
45 struct DummyIdentityGridEntityPointer
46 {};
47
48 }
49
50
51 template<int dim, class HostGrid>
52 struct IdentityGridFamily
53 {
54
55 private:
56
57 // The type signature of our EntityPointer implementation does not fit into
58 // the scheme expected by GridTraits, so we have to provide our own Traits
59 // On the other hand, we don't want to retype everything, so we just inherit
60 // from the default Traits and just tweak the EntityPointer type in the derived
61 // Traits class
62
63 typedef GridTraits<
64 dim,
65 HostGrid::dimensionworld,
67 IdentityGridGeometry,
68 IdentityGridEntity,
69 DummyIdentityGridEntityPointer, // placeholder
70 IdentityGridLevelIterator,
71 IdentityGridLeafIntersection,
72 IdentityGridLevelIntersection,
73 IdentityGridLeafIntersectionIterator,
74 IdentityGridLevelIntersectionIterator,
75 IdentityGridHierarchicIterator,
76 IdentityGridLeafIterator,
77 IdentityGridLevelIndexSet< const IdentityGrid<HostGrid> >,
78 IdentityGridLeafIndexSet< const IdentityGrid<HostGrid> >,
79 IdentityGridGlobalIdSet< const IdentityGrid<HostGrid> >,
80 typename HostGrid::Traits::GlobalIdSet::IdType,
81 IdentityGridLocalIdSet< const IdentityGrid<HostGrid> >,
82 typename HostGrid::Traits::LocalIdSet::IdType,
83 CollectiveCommunication<IdentityGrid<HostGrid> >,
84 DefaultLevelGridViewTraits,
85 DefaultLeafGridViewTraits,
86 IdentityGridEntitySeed
87 > BaseTraits;
88
89 public:
90
91 // inherit everyting from the default Traits...
92 struct Traits
93 : public BaseTraits
94 {
95
96 // Except for the Codim struct, which we reimplement, but which
97 // again inherits everything from the base class...
98 template<int codim>
99 struct Codim
100 : public BaseTraits::template Codim<codim>
101 {
102
103 // ... except for the EntityPointer, which we override with our
104 // actual implementation
105 typedef Dune::EntityPointer<
106 const typename BaseTraits::Grid,
107 IdentityGridEntityPointer<
108 codim,
109 const typename BaseTraits::Grid,
110 typename HostGrid::template Codim<codim>::EntityPointer
111 >
112 > EntityPointer;
113
114 };
115
116 };
117
118 };
119
120 //**********************************************************************
121 //
122 // --IdentityGrid
123 //
124 //************************************************************************
132 template <class HostGrid>
134 : public GridDefaultImplementation<HostGrid::dimension, HostGrid::dimensionworld,
135 typename HostGrid::ctype, IdentityGridFamily<HostGrid::dimension, HostGrid> >
136 {
137 friend class IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >;
138 friend class IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> >;
139 friend class IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> >;
140 friend class IdentityGridLocalIdSet<const IdentityGrid<HostGrid> >;
141 friend class IdentityGridHierarchicIterator<const IdentityGrid<HostGrid> >;
142 friend class IdentityGridLevelIntersectionIterator<const IdentityGrid<HostGrid> >;
143 friend class IdentityGridLeafIntersectionIterator<const IdentityGrid<HostGrid> >;
144
145 template<int codim, PartitionIteratorType pitype, class GridImp_>
146 friend class IdentityGridLevelIterator;
147
148 template<int codim, PartitionIteratorType pitype, class GridImp_>
149 friend class IdentityGridLeafIterator;
150
151
152 template<int codim_, int dim_, class GridImp_>
153 friend class IdentityGridEntity;
154
155 friend struct HostGridAccess< IdentityGrid< HostGrid > >;
156
157 public:
158
160 typedef HostGrid HostGridType;
161
162 //**********************************************************
163 // The Interface Methods
164 //**********************************************************
165
167 typedef IdentityGridFamily<HostGrid::dimension,HostGrid> GridFamily;
168
170 typedef typename IdentityGridFamily<HostGrid::dimension,HostGrid>::Traits Traits;
171
173 typedef typename HostGrid::ctype ctype;
174
175
180 explicit IdentityGrid(HostGrid& hostgrid) :
181 hostgrid_(&hostgrid),
182 leafIndexSet_(*this),
183 globalIdSet_(*this),
184 localIdSet_(*this)
185 {
186 setIndices();
187 }
188
191 {
192 // Delete level index sets
193 for (size_t i=0; i<levelIndexSets_.size(); i++)
194 if (levelIndexSets_[i])
195 delete (levelIndexSets_[i]);
196 }
197
198
203 int maxLevel() const {
204 return hostgrid_->maxLevel();
205 }
206
208 template<int codim>
209 typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const {
211 }
212
213
215 template<int codim>
216 typename Traits::template Codim<codim>::LevelIterator lend (int level) const {
218 }
219
220
222 template<int codim, PartitionIteratorType PiType>
223 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const {
225 }
226
227
229 template<int codim, PartitionIteratorType PiType>
230 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const {
232 }
233
234
236 template<int codim>
237 typename Traits::template Codim<codim>::LeafIterator leafbegin() const {
239 }
240
241
243 template<int codim>
244 typename Traits::template Codim<codim>::LeafIterator leafend() const {
246 }
247
248
250 template<int codim, PartitionIteratorType PiType>
251 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const {
253 }
254
255
257 template<int codim, PartitionIteratorType PiType>
258 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const {
260 }
261
262
265 int size (int level, int codim) const {
266 return hostgrid_->size(level,codim);
267 }
268
271 size_t numBoundarySegments () const {
272 return hostgrid_->numBoundarySegments();
273 }
274
276 int size (int codim) const {
277 return leafIndexSet().size(codim);
278 }
279
280
282 int size (int level, GeometryType type) const {
283 return levelIndexSets_[level]->size(type);
284 }
285
286
288 int size (GeometryType type) const
289 {
290 return leafIndexSet().size(type);
291 }
292
293
295 const typename Traits::GlobalIdSet& globalIdSet() const {
296 return globalIdSet_;
297 }
298
299
301 const typename Traits::LocalIdSet& localIdSet() const {
302 return localIdSet_;
303 }
304
305
307 const typename Traits::LevelIndexSet& levelIndexSet(int level) const
308 {
309 if (level < 0 || level > maxLevel())
310 {
311 DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
312 }
313 return *levelIndexSets_[level];
314 }
315
316
318 const typename Traits::LeafIndexSet& leafIndexSet() const
319 {
320 return leafIndexSet_;
321 }
322
323
332 template < class EntitySeed >
333 DUNE_DEPRECATED_MSG("entityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use entity() instead to directly obtain an Entity object.")
334 typename Traits::template Codim<EntitySeed::codimension>::EntityPointer
335 entityPointer(const EntitySeed& seed) const
336 {
337 typedef typename Traits::template Codim<EntitySeed::codimension>::EntityPointer EntityPointer;
339 EntitySeed::codimension,
340 const typename Traits::Grid,
341 typename HostGrid::template Codim<EntitySeed::codimension>::EntityPointer
342 > EntityPointerImp;
343
344 return EntityPointer(EntityPointerImp(this, hostgrid_->entity(this->getRealImplementation(seed).hostEntitySeed())));
345 }
346
348 template < class EntitySeed >
349 typename Traits::template Codim<EntitySeed::codimension>::Entity
350 entity(const EntitySeed& seed) const
351 {
352 typedef IdentityGridEntity<
353 EntitySeed::codimension,
354 HostGrid::dimension,
355 const typename Traits::Grid
356 > EntityImp;
357
358 return EntityImp(this, hostgrid_->entity(this->getRealImplementation(seed).hostEntitySeed()));
359 }
360
361
364
365
369 void globalRefine (int refCount)
370 {
371 hostgrid_->globalRefine(refCount);
372 }
373
384 bool mark(int refCount, const typename Traits::template Codim<0>::Entity & e)
385 {
386 return hostgrid_->mark(refCount, getHostEntity<0>(e));
387 }
388
393 int getMark(const typename Traits::template Codim<0>::Entity & e) const
394 {
395 return hostgrid_->getMark(getHostEntity<0>(e));
396 }
397
399 bool preAdapt() {
400 return hostgrid_->preAdapt();
401 }
402
403
405 bool adapt()
406 {
407 return hostgrid_->adapt();
408 }
409
411 void postAdapt() {
412 return hostgrid_->postAdapt();
413 }
414
418 unsigned int overlapSize(int codim) const {
419 return hostgrid_->overlapSize(codim);
420 }
421
422
424 unsigned int ghostSize(int codim) const {
425 return hostgrid_->ghostSize(codim);
426 }
427
428
430 unsigned int overlapSize(int level, int codim) const {
431 return hostgrid_->overlapSize(level,codim);
432 }
433
434
436 unsigned int ghostSize(int level, int codim) const {
437 return hostgrid_->ghostSize(level,codim);
438 }
439
440
441#if 0
447 void loadBalance(int strategy, int minlevel, int depth, int maxlevel, int minelement){
448 DUNE_THROW(NotImplemented, "IdentityGrid::loadBalance()");
449 }
450
462 template<class T, template<class> class P, int codim>
463 void communicate (T& t, InterfaceType iftype, CommunicationDirection dir, int level);
464
469 template<class DataHandle>
470 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
471 {}
472
473 template<class DataHandle>
474 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
475 {}
476#endif
477
478
481 {
482 return ccobj;
483 }
484
485
486 // **********************************************************
487 // End of Interface Methods
488 // **********************************************************
489
492 {
493 return *hostgrid_;
494 }
495
496
498 template <int codim>
499 DUNE_DEPRECATED_MSG("getHostEntityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use getHostEntity() instead to obtain a reference to the host entity object.")
500 typename HostGrid::Traits::template Codim<codim>::EntityPointer getHostEntityPointer(const typename Traits::template Codim<codim>::Entity& e) const
501 {
502 return this->getRealImplementation(e).hostEntity_;
503 }
504
505 template <int codim>
506 const typename HostGrid::Traits::template Codim<codim>::Entity& getHostEntity(const typename Traits::template Codim<codim>::Entity& e) const
507 {
508 return this->getRealImplementation(e).hostEntity_;
509 }
510
511 protected:
512
514 HostGrid* hostgrid_;
515
516 private:
517
519 void setIndices()
520 {
521 localIdSet_.update();
522
523 globalIdSet_.update();
524
525 // //////////////////////////////////////////
526 // Create the index sets
527 // //////////////////////////////////////////
528 for (int i=levelIndexSets_.size(); i<=maxLevel(); i++) {
529 IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >* p
530 = new IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >();
531 levelIndexSets_.push_back(p);
532 }
533
534 for (int i=0; i<=maxLevel(); i++)
535 if (levelIndexSets_[i])
536 levelIndexSets_[i]->update(*this, i);
537
538 leafIndexSet_.update(*this);
539
540 }
541
543 CollectiveCommunication<IdentityGrid> ccobj;
544
546 std::vector<IdentityGridLevelIndexSet<const IdentityGrid<HostGrid> >*> levelIndexSets_;
547
549 IdentityGridLeafIndexSet<const IdentityGrid<HostGrid> > leafIndexSet_;
550
552 IdentityGridGlobalIdSet<const IdentityGrid<HostGrid> > globalIdSet_;
553
555 IdentityGridLocalIdSet<const IdentityGrid<HostGrid> > localIdSet_;
556
557 }; // end Class IdentityGrid
558
559
560
561
562 namespace Capabilities
563 {
567 template<class HostGrid, int codim>
568 struct hasEntity<IdentityGrid<HostGrid>, codim>
569 {
570 static const bool v = hasEntity<HostGrid,codim>::v;
571 };
572
576 template<class HostGrid>
577 struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel<IdentityGrid<HostGrid> >
578 {
579 static const bool DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") v = isParallel<HostGrid>::v;
580 };
581
585 template<class HostGrid>
587 {
588 static const bool v = isLevelwiseConforming<HostGrid>::v;
589 };
590
594 template<class HostGrid>
596 {
597 static const bool v = isLeafwiseConforming<HostGrid>::v;
598 };
599 } // end namespace Capabilities
600
601} // namespace Dune
602
603#endif // DUNE_GRID_IDENTITYGRID_HH
Wrapper class for pointers to entities.
Definition: entitypointer.hh:113
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Wrapper class for entities.
Definition: entity.hh:62
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Definition: grid.hh:1030
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:1305
Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.") lbegin(int level) const
Iterator to first entity of given codim on level for PartitionType All_Partition.
Definition: grid.hh:1043
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition: grid.hh:1209
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: grid.hh:1220
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:545
void globalRefine(int refCount)
Refine the grid refCount times using the default refinement rule.
Definition: grid.hh:781
Id Set Interface.
Definition: indexidset.hh:414
Definition: identitygridentitypointer.hh:19
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:56
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: identitygridhierarchiciterator.hh:26
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: identitygridintersectioniterator.hh:27
Iterator over all entities of a given codimension and level of a grid.
Definition: identitygridleafiterator.hh:21
Definition: identitygridindexsets.hh:24
Definition: identitygridintersectioniterator.hh:82
Iterator over all entities of a given codimension and level of a grid.
Definition: identitygridleveliterator.hh:26
Provides a meta grid that is identical to its host.
Definition: identitygrid.hh:136
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark entity for refinement.
Definition: identitygrid.hh:384
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:237
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: identitygrid.hh:307
const CollectiveCommunication< IdentityGrid > & comm() const
dummy collective communication
Definition: identitygrid.hh:480
IdentityGridFamily< HostGrid::dimension, HostGrid >::Traits Traits
the Traits
Definition: identitygrid.hh:170
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: identitygrid.hh:318
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: identitygrid.hh:265
int size(int level, GeometryType type) const
number of entities per level, codim and geometry type in this process
Definition: identitygrid.hh:282
HostGridType & getHostGrid() const
Returns the hostgrid this IdentityGrid lives in.
Definition: identitygrid.hh:491
unsigned int ghostSize(int level, int codim) const
Size of the ghost cell layer on a given level.
Definition: identitygrid.hh:436
HostGrid HostGridType
Definition: identitygrid.hh:160
void postAdapt()
Clean up refinement markers.
Definition: identitygrid.hh:411
bool adapt()
Triggers the grid refinement process.
Definition: identitygrid.hh:405
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: identitygrid.hh:295
int size(int codim) const
number of leaf entities per codim in this process
Definition: identitygrid.hh:276
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:244
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:230
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: identitygrid.hh:288
int maxLevel() const
Return maximum level defined in this grid.
Definition: identitygrid.hh:203
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:223
HostGrid::ctype ctype
The type used to store coordinates, inherited from the HostGrid.
Definition: identitygrid.hh:173
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Definition: identitygrid.hh:216
~IdentityGrid()
Desctructor.
Definition: identitygrid.hh:190
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: identitygrid.hh:271
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: identitygrid.hh:301
IdentityGridFamily< HostGrid::dimension, HostGrid > GridFamily
type of the used GridFamily for this grid
Definition: identitygrid.hh:167
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: identitygrid.hh:258
unsigned int overlapSize(int codim) const
Size of the overlap on the leaf level.
Definition: identitygrid.hh:418
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: identitygrid.hh:209
IdentityGrid(HostGrid &hostgrid)
Constructor.
Definition: identitygrid.hh:180
unsigned int overlapSize(int level, int codim) const
Size of the overlap on a given level.
Definition: identitygrid.hh:430
bool preAdapt()
returns true, if at least one entity is marked for adaption
Definition: identitygrid.hh:399
unsigned int ghostSize(int codim) const
Size of the ghost cell layer on the leaf level.
Definition: identitygrid.hh:424
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Return refinement mark for entity.
Definition: identitygrid.hh:393
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: identitygrid.hh:251
Index Set Interface base class.
Definition: indexidset.hh:76
Default exception for dummy implementations.
Definition: exceptions.hh:288
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:243
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
struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel< ALU3dGrid< elType
YaspGrid is parallel.
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.
Dune namespace.
Definition: alignment.hh:10
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:108
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:99
Specialize with 'true' if implementation supports parallelism. (default=false)
Definition: capabilities.hh:73
Static tag representing a codimension.
Definition: dimension.hh:22
GridImp Grid
The type that implements the grid.
Definition: grid.hh:1346
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)