3#ifndef DUNE_GEOGRID_GRID_HH
4#define DUNE_GEOGRID_GRID_HH
11#include <dune/grid/geometrygrid/backuprestore.hh>
12#include <dune/grid/geometrygrid/capabilities.hh>
13#include <dune/grid/geometrygrid/datahandle.hh>
14#include <dune/grid/geometrygrid/gridfamily.hh>
15#include <dune/grid/geometrygrid/identity.hh>
16#include <dune/grid/geometrygrid/persistentcontainer.hh>
24 template<
class HostGr
id >
25 class DefaultCoordFunction
26 :
public IdenticalCoordFunction< typename HostGrid::ctype, HostGrid::dimensionworld >
74 template<
class HostGr
id,
class CoordFunction = DefaultCoordFunction< HostGr
id >,
class Allocator = std::allocator<
void > >
78 < HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
79 GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > >,
80 public GeoGrid::ExportParams< HostGrid, CoordFunction >,
81 public GeoGrid::BackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
87 < HostGrid::dimension, CoordFunction::dimRange,
typename HostGrid::ctype,
88 GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > >
91 friend class GeoGrid::HierarchicIterator< const
Grid >;
94 template<
class,
bool >
friend class GeoGrid::EntityPointer;
95 template<
int,
class >
friend class GeoGrid::EntityProxy;
96 template<
int,
int,
class >
friend class GeoGrid::Geometry;
97 template<
class,
class,
class, PartitionIteratorType >
friend class GeoGrid::GridView;
98 template<
class,
class >
friend class GeoGrid::Intersection;
99 template<
class,
class >
friend class GeoGrid::IntersectionIterator;
100 template<
class,
class >
friend class GeoGrid::IdSet;
101 template<
class,
class >
friend class GeoGrid::IndexSet;
104 template<
class,
class >
friend class GeoGrid::CommDataHandle;
108 typedef GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > GridFamily;
115 typedef typename GridFamily::Traits
Traits;
123 template<
int codim >
144 template< PartitionIteratorType pitype >
147 typedef typename GridFamily::Traits::template Partition< pitype >::LevelGridView
149 typedef typename GridFamily::Traits::template Partition< pitype >::LeafGridView
155 typedef typename Partition< All_Partition >::LeafGridView LeafGridView;
218 typedef typename Traits::ctype
ctype;
237 GeometryGrid ( HostGrid &hostGrid, CoordFunction &coordFunction,
const Allocator &allocator = Allocator() )
238 : hostGrid_( &hostGrid ),
239 coordFunction_( coordFunction ),
240 removeHostGrid_( false ),
241 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
242 storageAllocator_( allocator )
254 GeometryGrid ( HostGrid *hostGrid, CoordFunction *coordFunction,
const Allocator &allocator = Allocator() )
255 : hostGrid_( hostGrid ),
256 coordFunction_( *coordFunction ),
257 removeHostGrid_( true ),
258 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
259 storageAllocator_( allocator )
266 for(
unsigned int i = 0; i < levelIndexSets_.size(); ++i )
268 if( levelIndexSets_[ i ] )
269 delete( levelIndexSets_[ i ] );
272 if( removeHostGrid_ )
274 delete &coordFunction_;
293 return hostGrid().maxLevel();
304 int size (
int level,
int codim )
const
348 return hostGrid().numBoundarySegments( );
352 template<
int codim >
355 return levelView( level ).template begin< codim >();
358 template<
int codim >
361 return levelView( level ).template end< codim >();
364 template<
int codim, PartitionIteratorType pitype >
365 typename Codim< codim >::template Partition< pitype >::LevelIterator
366 lbegin (
int level )
const
368 return levelView( level ).template begin< codim, pitype >();
371 template<
int codim, PartitionIteratorType pitype >
372 typename Codim< codim >::template Partition< pitype >::LevelIterator
373 lend (
int level )
const
375 return levelView( level ).template end< codim, pitype >();
378 template<
int codim >
381 return leafView().template begin< codim >();
384 template<
int codim >
387 return leafView().template end< codim >();
390 template<
int codim, PartitionIteratorType pitype >
391 typename Codim< codim >::template Partition< pitype >::LeafIterator
394 return leafView().template begin< codim, pitype >();
397 template<
int codim, PartitionIteratorType pitype >
398 typename Codim< codim >::template Partition< pitype >::LeafIterator
401 return leafView().template end< codim, pitype >();
407 globalIdSet_ =
GlobalIdSet( hostGrid().globalIdSet() );
408 assert( globalIdSet_ );
415 localIdSet_ =
LocalIdSet( hostGrid().localIdSet() );
416 assert( localIdSet_ );
422 assert( levelIndexSets_.size() == (
size_t)(
maxLevel()+1) );
423 if( (level < 0) || (level >
maxLevel()) )
425 DUNE_THROW( GridError,
"LevelIndexSet for nonexisting level " << level
431 levelIndexSet =
new LevelIndexSet( hostGrid().levelIndexSet( level ) );
432 assert( levelIndexSet );
433 return *levelIndexSet;
439 leafIndexSet_ =
LeafIndexSet( hostGrid().leafIndexSet() );
440 assert( leafIndexSet_ );
441 return leafIndexSet_;
444 void globalRefine (
int refCount )
446 hostGrid().globalRefine( refCount );
452 return hostGrid().mark( refCount, getHostEntity< 0 >( entity ) );
457 return hostGrid().getMark( getHostEntity< 0 >( entity ) );
462 return hostGrid().preAdapt();
467 bool ret = hostGrid().adapt();
474 hostGrid().postAdapt();
486 return leafView().overlapSize( codim );
495 return leafView().ghostSize( codim );
505 return levelView( level ).overlapSize( codim );
515 return levelView( level ).ghostSize( codim );
531 template<
class DataHandle,
class Data >
537 levelView( level ).communicate( dataHandle, interface, direction );
552 template<
class DataHandle,
class Data >
557 leafView().communicate( dataHandle, interface, direction );
570 return hostGrid().comm();
587 const bool gridChanged= hostGrid().loadBalance();
608 template<
class DataHandle,
class Data >
609 bool loadBalance ( CommDataHandleIF< DataHandle, Data > &datahandle )
611 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
612 typedef GeoGrid :: CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
614 WrappedDataHandle wrappedDataHandle( *
this, datahandle );
615 const bool gridChanged = hostGrid().loadBalance( wrappedDataHandle );
623 template<
class EntitySeed >
628 return EntityPointerImpl( *
this, seed );
637 template< PartitionIteratorType pitype >
638 typename Partition< pitype >::LevelGridView
levelView (
int level )
const
640 typedef typename Partition< pitype >::LevelGridView View;
641 typedef typename View::GridViewImp ViewImp;
642 return View( ViewImp( *
this, hostGrid().
levelView( level ) ) );
645 template< PartitionIteratorType pitype >
646 typename Partition< pitype >::LevelGridView levelGridView (
int level )
const
648 return levelView<pitype>(level);
652 template< PartitionIteratorType pitype >
653 typename Partition< pitype >::LeafGridView
leafView ()
const
655 typedef typename Traits::template Partition< pitype >::LeafGridView View;
656 typedef typename View::GridViewImp ViewImp;
657 return View( ViewImp( *
this, hostGrid().
leafView() ) );
660 template< PartitionIteratorType pitype >
661 typename Partition< pitype >::LeafGridView leafGridView ()
const
663 return leafGridView<pitype>();
669 typedef typename LevelGridView::GridViewImp ViewImp;
682 typedef typename LeafGridView::GridViewImp ViewImp;
683 return LeafGridView( ViewImp( *
this, hostGrid().
leafView() ) );
686 LeafGridView leafGridView ()
const
696 const HostGrid &hostGrid ()
const
701 HostGrid &hostGrid ()
717 GeoGrid::AdaptCoordFunction< typename CoordFunction::Interface >::adapt( coordFunction_ );
719 const int newNumLevels =
maxLevel()+1;
720 const int oldNumLevels = levelIndexSets_.size();
722 for(
int i = newNumLevels; i < oldNumLevels; ++i )
724 if( levelIndexSets_[ i ] )
725 delete levelIndexSets_[ i ];
727 levelIndexSets_.resize( newNumLevels,
nullptr );
735 const CoordFunction &coordFunction ()
const
737 return coordFunction_;
740 template<
int codim >
747 void *allocateStorage ( std::size_t
size )
const
749 return storageAllocator_.allocate(
size );
752 void deallocateStorage (
void *p, std::size_t
size )
const
754 storageAllocator_.deallocate( (
char *)p,
size );
758 HostGrid *
const hostGrid_;
759 CoordFunction &coordFunction_;
760 bool removeHostGrid_;
761 mutable std::vector< LevelIndexSet *, typename Allocator::template rebind< LevelIndexSet * >::other > levelIndexSets_;
765 mutable typename Allocator::template rebind< char >::other storageAllocator_;
773 template<
class HostGr
id,
class CoordFunction,
class Allocator >
774 template<
int codim >
776 :
public Base::template
Codim< codim >
823 template< PartitionIteratorType pitype >
827 ::template Partition< pitype >::LeafIterator
830 ::template Partition< pitype >::LevelIterator
841 typedef typename Partition< All_Partition >::LeafIterator
LeafIterator;
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:75
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
actual implementation of the entity
Definition: entity.hh:34
grid wrapper replacing the geometries
Definition: grid.hh:83
Partition< pitype >::LeafGridView leafView() const
View for the leaf grid.
Definition: grid.hh:653
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: grid.hh:154
int maxLevel() const
obtain maximal grid level
Definition: grid.hh:291
int size(int codim) const
obtain number of leaf entities
Definition: grid.hh:315
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: grid.hh:328
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: grid.hh:136
Traits::template Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: grid.hh:625
Partition< pitype >::LevelGridView levelView(int level) const
View for a grid level.
Definition: grid.hh:638
LevelGridView levelView(int level) const
View for a grid level for All_Partition.
Definition: grid.hh:667
int size(int level, int codim) const
obtain number of entites on a level
Definition: grid.hh:304
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: grid.hh:171
GeometryGrid(HostGrid *hostGrid, CoordFunction *coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: grid.hh:254
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: grid.hh:132
static ReturnImplementationType< InterfaceType >::ImplementationType & getRealImplementation(InterfaceType &i)
return real implementation of interface class
Definition: grid.hh:1223
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: grid.hh:218
GridFamily::Traits Traits
type of the grid traits
Definition: grid.hh:115
~GeometryGrid()
destructor
Definition: grid.hh:264
int overlapSize(int codim) const
obtain size of overlap region for the leaf grid
Definition: grid.hh:484
LeafGridView leafView() const
View for the leaf grid for All_Partition.
Definition: grid.hh:680
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction) const
communicate information on leaf entities
Definition: grid.hh:553
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: grid.hh:181
int ghostSize(int level, int codim) const
obtain size of ghost region for a grid level
Definition: grid.hh:513
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction, int level) const
communicate information on a grid level
Definition: grid.hh:532
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: grid.hh:210
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: grid.hh:193
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: grid.hh:134
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: grid.hh:493
Traits::CollectiveCommunication CollectiveCommunication
communicator with all other processes having some part of the grid
Definition: grid.hh:221
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: grid.hh:346
int size(GeometryType type) const
obtain number of leaf entities
Definition: grid.hh:337
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: grid.hh:237
void update()
update grid caches
Definition: grid.hh:714
int overlapSize(int level, int codim) const
obtain size of overlap region for a grid level
Definition: grid.hh:503
const CollectiveCommunication & comm() const
obtain CollectiveCommunication object
Definition: grid.hh:568
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
static ReturnImplementationType< InterfaceType >::ImplementationType & getRealImplementation(InterfaceType &i)
return real implementation of interface class
Definition: grid.hh:1223
Different resources needed by all grid implementations.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Dune namespace.
Definition: alignment.hh:14
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:164
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
Fallback implementation of the nullptr object in C++0x.
Fallback implementation of the C++0x static_assert feature.
traits structure containing types for a codimension
Definition: grid.hh:777
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: grid.hh:816
Partition< All_Partition >::LeafIterator LeafIterator
type of level iterator
Definition: grid.hh:841
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: grid.hh:785
Partition< All_Partition >::LevelIterator LevelIterator
type of leaf iterator
Definition: grid.hh:850
Traits::template Codim< codim >::EntityPointer EntityPointer
type of entity pointer
Definition: grid.hh:791
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: grid.hh:806
Types for GridView.
Definition: grid.hh:146
provides access to host grid objects
Definition: hostgridaccess.hh:25