5#ifndef DUNE_GEOGRID_GRID_HH
6#define DUNE_GEOGRID_GRID_HH
10#include <dune/common/shared_ptr.hh>
27 template<
class HostGr
id >
77 template<
class HostGr
id,
class CoordFunction = DefaultCoordFunction< HostGr
id >,
class Allocator = std::allocator<
void > >
81 < HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
82 GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > >,
90 < HostGrid::dimension, CoordFunction::dimRange,
typename HostGrid::ctype,
116 typedef typename GridFamily::Traits
Traits;
124 template<
int codim >
210 typedef typename Traits::ctype
ctype;
217 [[deprecated(
"Use Communication instead!!")]]
235 : hostGrid_(
Dune::stackobject_to_shared_ptr(
hostGrid) ),
237 levelIndexSets_( hostGrid_->
maxLevel()+1 ),
238 storageAllocator_( allocator )
253 levelIndexSets_( hostGrid_->
maxLevel()+1 ),
254 storageAllocator_( allocator )
268 coordFunction_(
std::make_shared<CoordFunction>( this->
hostGrid() ) ),
269 levelIndexSets_( hostGrid_->
maxLevel()+1 ),
270 storageAllocator_( allocator )
300 int size (
int level,
int codim )
const
344 return hostGrid().numBoundarySegments( );
352 assert( globalIdSet_ );
360 assert( localIdSet_ );
366 assert( levelIndexSets_.size() == (
size_t)(
maxLevel()+1) );
367 if( (level < 0) || (level >
maxLevel()) )
369 DUNE_THROW(
GridError,
"LevelIndexSet for nonexisting level " << level
373 auto& levelIndexSetPtr = levelIndexSets_[ level ];
374 if( !levelIndexSetPtr )
376 assert( levelIndexSetPtr );
377 return *levelIndexSetPtr;
384 assert( leafIndexSet_ );
385 return leafIndexSet_;
390 hostGrid().globalRefine( refCount );
396 return hostGrid().mark( refCount, getHostEntity< 0 >( entity_ ) );
401 return hostGrid().getMark( getHostEntity< 0 >( entity_ ) );
451 const bool gridChanged=
hostGrid().loadBalance();
472 template<
class DataHandle,
class Data >
473 bool loadBalance ( CommDataHandleIF< DataHandle, Data > &datahandle )
475 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
476 typedef GeoGrid :: CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
478 WrappedDataHandle wrappedDataHandle( *
this, datahandle );
479 const bool gridChanged =
hostGrid().loadBalance( wrappedDataHandle );
505 template<
class EntitySeed >
510 return EntityImpl( *
this, seed );
521 typedef typename LevelGridView::GridViewImp ViewImp;
528 typedef typename LeafGridView::GridViewImp ViewImp;
562 levelIndexSets_.resize(
maxLevel()+1 );
575 template<
int codim >
584 return storageAllocator_.allocate(
size );
589 storageAllocator_.deallocate( (
char *)p,
size );
593 std::shared_ptr<HostGrid>
const hostGrid_;
594 std::shared_ptr<CoordFunction> coordFunction_;
595 mutable std::vector<std::unique_ptr<LevelIndexSet>> levelIndexSets_;
599 mutable typename std::allocator_traits<Allocator>::template rebind_alloc< char > storageAllocator_;
607 template<
class HostGr
id,
class CoordFunction,
class Allocator >
608 template<
int codim >
610 :
public Base::template
Codim< codim >
651 template< PartitionIteratorType pitype >
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Implementation & impl()
access to the underlying implementation
Definition: common/entity.hh:80
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:26
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:20
Definition: common/grid.hh:862
Definition: geometrygrid/backuprestore.hh:27
static void adapt(CoordFunctionInterface &)
Definition: coordfunction.hh:326
Definition: geometrygrid/datahandle.hh:27
grid wrapper replacing the geometries
Definition: geometrygrid/grid.hh:86
const LeafIndexSet & leafIndexSet() const
Definition: geometrygrid/grid.hh:380
int maxLevel() const
obtain maximal grid level
Definition: geometrygrid/grid.hh:287
CoordFunction & coordFunction()
obtain mutable reference to the coordinate function.
Definition: geometrygrid/grid.hh:570
int size(int codim) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:311
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:324
const CoordFunction & coordFunction() const
obtain constant reference to the coordinate function
Definition: geometrygrid/grid.hh:567
void postAdapt()
Definition: geometrygrid/grid.hh:416
static const HostGrid::template Codim< codim >::Entity & getHostEntity(const typename Codim< codim >::Entity &entity)
Definition: geometrygrid/grid.hh:577
LeafGridView leafGridView() const
View for the leaf grid.
Definition: geometrygrid/grid.hh:526
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: geometrygrid/grid.hh:137
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed
Definition: geometrygrid/grid.hh:507
LevelGridView levelGridView(int level) const
View for a grid level.
Definition: geometrygrid/grid.hh:519
const LocalIdSet & localIdSet() const
Definition: geometrygrid/grid.hh:356
GeometryGrid(std::shared_ptr< HostGrid > hostGrid, std::shared_ptr< CoordFunction > coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:250
int size(int level, int codim) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:300
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: geometrygrid/grid.hh:163
bool adapt()
Definition: geometrygrid/grid.hh:409
const GlobalIdSet & globalIdSet() const
Definition: geometrygrid/grid.hh:348
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: geometrygrid/grid.hh:133
Traits::Communication Communication
communicator with all other processes having some part of the grid
Definition: geometrygrid/grid.hh:213
bool mark(int refCount, const typename Codim< 0 >::Entity &entity_)
Definition: geometrygrid/grid.hh:394
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition: geometrygrid/grid.hh:538
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: geometrygrid/grid.hh:210
const Communication & comm() const
obtain Communication object
Definition: geometrygrid/grid.hh:432
GridFamily::Traits Traits
type of the grid traits
Definition: geometrygrid/grid.hh:116
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: geometrygrid/grid.hh:147
HostGrid & hostGrid()
obtain mutable reference to the host grid
Definition: geometrygrid/grid.hh:544
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: geometrygrid/grid.hh:173
int getMark(const typename Codim< 0 >::Entity &entity_) const
Definition: geometrygrid/grid.hh:399
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: geometrygrid/grid.hh:202
void deallocateStorage(void *p, std::size_t size) const
Definition: geometrygrid/grid.hh:587
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: geometrygrid/grid.hh:185
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: geometrygrid/grid.hh:135
void globalRefine(int refCount)
Definition: geometrygrid/grid.hh:388
GeometryGrid(std::shared_ptr< HostGrid > hostGrid, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:266
GridFamily::Traits::LeafGridView LeafGridView
type of view for leaf grid
Definition: geometrygrid/grid.hh:145
bool preAdapt()
Definition: geometrygrid/grid.hh:404
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: geometrygrid/grid.hh:342
Communication CollectiveCommunication
Definition: geometrygrid/grid.hh:218
int size(GeometryType type) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:333
const LevelIndexSet & levelIndexSet(int level) const
Definition: geometrygrid/grid.hh:364
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:234
void update()
update grid caches
Definition: geometrygrid/grid.hh:557
void * allocateStorage(std::size_t size) const
Definition: geometrygrid/grid.hh:582
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
Definition: iterator.hh:374
Definition: geometrygrid/intersectioniterator.hh:21
Definition: geometrygrid/geometry.hh:89
Definition: geometrygrid/grid.hh:30
traits structure containing types for a codimension
Definition: geometrygrid/grid.hh:611
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: geometrygrid/grid.hh:644
Partition< All_Partition >::LeafIterator LeafIterator
type of leaf iterator
Definition: geometrygrid/grid.hh:669
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: geometrygrid/grid.hh:619
Partition< All_Partition >::LevelIterator LevelIterator
type of level iterator
Definition: geometrygrid/grid.hh:678
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: geometrygrid/grid.hh:634
Definition: geometrygrid/grid.hh:653
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: geometrygrid/grid.hh:659
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: geometrygrid/grid.hh:656
Definition: geometrygrid/gridfamily.hh:35
Definition: geometrygrid/gridfamily.hh:51
Definition: geometrygrid/gridview.hh:97
Definition: identity.hh:17
Definition: geometrygrid/indexsets.hh:29
Definition: geometrygrid/intersection.hh:22
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Different resources needed by all grid implementations.