3#ifndef DUNE_GEOGRID_GRID_HH
4#define DUNE_GEOGRID_GRID_HH
8#include <dune/common/shared_ptr.hh>
25 template<
class HostGr
id >
75 template<
class HostGr
id,
class CoordFunction = DefaultCoordFunction< HostGr
id >,
class Allocator = std::allocator<
void > >
79 < HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
80 GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > >,
88 < HostGrid::dimension, CoordFunction::dimRange,
typename HostGrid::ctype,
114 typedef typename GridFamily::Traits
Traits;
122 template<
int codim >
208 typedef typename Traits::ctype
ctype;
228 : hostGrid_(
Dune::stackobject_to_shared_ptr(
hostGrid) ),
230 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
231 storageAllocator_( allocator )
246 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
247 storageAllocator_( allocator )
261 coordFunction_(
std::make_shared<CoordFunction>( this->
hostGrid() ) ),
262 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
263 storageAllocator_( allocator )
271 for(
unsigned int i = 0; i < levelIndexSets_.size(); ++i )
273 if( levelIndexSets_[ i ] )
274 delete( levelIndexSets_[ i ] );
303 int size (
int level,
int codim )
const
327 int size (
int level, GeometryType type )
const
336 int size ( GeometryType type )
const
347 return hostGrid().numBoundarySegments( );
355 assert( globalIdSet_ );
363 assert( localIdSet_ );
369 assert( levelIndexSets_.size() == (
size_t)(
maxLevel()+1) );
370 if( (level < 0) || (level >
maxLevel()) )
372 DUNE_THROW(
GridError,
"LevelIndexSet for nonexisting level " << level
387 assert( leafIndexSet_ );
388 return leafIndexSet_;
393 hostGrid().globalRefine( refCount );
399 return hostGrid().mark( refCount, getHostEntity< 0 >( entity_ ) );
404 return hostGrid().getMark( getHostEntity< 0 >( entity_ ) );
454 const bool gridChanged=
hostGrid().loadBalance();
475 template<
class DataHandle,
class Data >
476 bool loadBalance ( CommDataHandleIF< DataHandle, Data > &datahandle )
478 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
479 typedef GeoGrid :: CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
481 WrappedDataHandle wrappedDataHandle( *
this, datahandle );
482 const bool gridChanged =
hostGrid().loadBalance( wrappedDataHandle );
508 template<
class EntitySeed >
513 return EntityImpl( *
this, seed );
524 typedef typename LevelGridView::GridViewImp ViewImp;
531 typedef typename LeafGridView::GridViewImp ViewImp;
565 const int newNumLevels =
maxLevel()+1;
566 const int oldNumLevels = levelIndexSets_.size();
568 for(
int i = newNumLevels; i < oldNumLevels; ++i )
570 if( levelIndexSets_[ i ] )
571 delete levelIndexSets_[ i ];
573 levelIndexSets_.resize( newNumLevels,
nullptr );
586 template<
int codim >
595 return storageAllocator_.allocate(
size );
600 storageAllocator_.deallocate( (
char *)p,
size );
604 std::shared_ptr<HostGrid>
const hostGrid_;
605 std::shared_ptr<CoordFunction> coordFunction_;
606 mutable std::vector< LevelIndexSet *, typename std::allocator_traits<Allocator>::template rebind_alloc< LevelIndexSet * > > levelIndexSets_;
610 mutable typename std::allocator_traits<Allocator>::template rebind_alloc< char > storageAllocator_;
618 template<
class HostGr
id,
class CoordFunction,
class Allocator >
619 template<
int codim >
621 :
public Base::template
Codim< codim >
662 template< PartitionIteratorType pitype >
Include standard header files.
Definition: agrid.hh:58
Implementation & impl()
access to the underlying implementation
Definition: common/entity.hh:78
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:24
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Definition: common/grid.hh:851
Definition: geometrygrid/backuprestore.hh:25
static void adapt(CoordFunctionInterface &)
Definition: coordfunction.hh:324
Definition: geometrygrid/datahandle.hh:25
grid wrapper replacing the geometries
Definition: geometrygrid/grid.hh:84
const LeafIndexSet & leafIndexSet() const
Definition: geometrygrid/grid.hh:383
int maxLevel() const
obtain maximal grid level
Definition: geometrygrid/grid.hh:290
CoordFunction & coordFunction()
obtain mutable reference to the coordinate function.
Definition: geometrygrid/grid.hh:581
int size(int codim) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:314
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:327
const CoordFunction & coordFunction() const
obtain constant reference to the coordinate function
Definition: geometrygrid/grid.hh:578
void postAdapt()
Definition: geometrygrid/grid.hh:419
static const HostGrid::template Codim< codim >::Entity & getHostEntity(const typename Codim< codim >::Entity &entity)
Definition: geometrygrid/grid.hh:588
LeafGridView leafGridView() const
View for the leaf grid.
Definition: geometrygrid/grid.hh:529
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: geometrygrid/grid.hh:135
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed
Definition: geometrygrid/grid.hh:510
LevelGridView levelGridView(int level) const
View for a grid level.
Definition: geometrygrid/grid.hh:522
const LocalIdSet & localIdSet() const
Definition: geometrygrid/grid.hh:359
GeometryGrid(std::shared_ptr< HostGrid > hostGrid, std::shared_ptr< CoordFunction > coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:243
int size(int level, int codim) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:303
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: geometrygrid/grid.hh:161
bool adapt()
Definition: geometrygrid/grid.hh:412
const GlobalIdSet & globalIdSet() const
Definition: geometrygrid/grid.hh:351
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: geometrygrid/grid.hh:131
bool mark(int refCount, const typename Codim< 0 >::Entity &entity_)
Definition: geometrygrid/grid.hh:397
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition: geometrygrid/grid.hh:541
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: geometrygrid/grid.hh:208
GridFamily::Traits Traits
type of the grid traits
Definition: geometrygrid/grid.hh:114
~GeometryGrid()
destructor
Definition: geometrygrid/grid.hh:269
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: geometrygrid/grid.hh:145
HostGrid & hostGrid()
obtain mutable reference to the host grid
Definition: geometrygrid/grid.hh:547
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: geometrygrid/grid.hh:171
int getMark(const typename Codim< 0 >::Entity &entity_) const
Definition: geometrygrid/grid.hh:402
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: geometrygrid/grid.hh:200
void deallocateStorage(void *p, std::size_t size) const
Definition: geometrygrid/grid.hh:598
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: geometrygrid/grid.hh:183
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: geometrygrid/grid.hh:133
void globalRefine(int refCount)
Definition: geometrygrid/grid.hh:391
GeometryGrid(std::shared_ptr< HostGrid > hostGrid, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:259
GridFamily::Traits::LeafGridView LeafGridView
type of view for leaf grid
Definition: geometrygrid/grid.hh:143
bool preAdapt()
Definition: geometrygrid/grid.hh:407
Traits::CollectiveCommunication CollectiveCommunication
communicator with all other processes having some part of the grid
Definition: geometrygrid/grid.hh:211
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: geometrygrid/grid.hh:345
int size(GeometryType type) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:336
const LevelIndexSet & levelIndexSet(int level) const
Definition: geometrygrid/grid.hh:367
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:227
void update()
update grid caches
Definition: geometrygrid/grid.hh:560
void * allocateStorage(std::size_t size) const
Definition: geometrygrid/grid.hh:593
const CollectiveCommunication & comm() const
obtain CollectiveCommunication object
Definition: geometrygrid/grid.hh:435
actual implementation of the entity
Definition: geometrygrid/entity.hh:32
Definition: iterator.hh:372
Definition: geometrygrid/intersectioniterator.hh:19
Definition: geometrygrid/geometry.hh:87
Definition: geometrygrid/grid.hh:28
traits structure containing types for a codimension
Definition: geometrygrid/grid.hh:622
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: geometrygrid/grid.hh:655
Partition< All_Partition >::LeafIterator LeafIterator
type of leaf iterator
Definition: geometrygrid/grid.hh:680
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: geometrygrid/grid.hh:630
Partition< All_Partition >::LevelIterator LevelIterator
type of level iterator
Definition: geometrygrid/grid.hh:689
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: geometrygrid/grid.hh:645
Definition: geometrygrid/grid.hh:664
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: geometrygrid/grid.hh:670
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: geometrygrid/grid.hh:667
Definition: geometrygrid/gridfamily.hh:33
Definition: geometrygrid/gridfamily.hh:49
Definition: geometrygrid/gridview.hh:89
Definition: identity.hh:15
Definition: geometrygrid/indexsets.hh:27
Definition: geometrygrid/intersection.hh:20
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:35
Different resources needed by all grid implementations.