3 #ifndef DUNE_GEOGRID_GRID_HH 4 #define DUNE_GEOGRID_GRID_HH 6 #include <dune/common/deprecated.hh> 23 template<
class HostGr
id >
73 template<
class HostGr
id,
class CoordFunction = DefaultCoordFunction< HostGr
id >,
class Allocator = std::allocator<
void > >
77 < HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
78 GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > >,
86 < HostGrid::dimension, CoordFunction::dimRange,
typename HostGrid::ctype,
111 typedef typename GridFamily::Traits
Traits;
120 template<
int codim >
205 typedef typename Traits::ctype
ctype;
225 GeometryGrid ( HostGrid &hostGrid, CoordFunction &coordFunction,
const Allocator &allocator = Allocator() )
226 : hostGrid_( &hostGrid ),
227 coordFunction_( &coordFunction ),
228 removeHostGrid_( false ),
229 levelIndexSets_( hostGrid_->maxLevel()+1, nullptr, allocator ),
230 storageAllocator_( allocator )
242 GeometryGrid ( HostGrid *hostGrid, CoordFunction *coordFunction,
const Allocator &allocator = Allocator() )
243 : hostGrid_( hostGrid ),
244 coordFunction_( coordFunction ),
245 removeHostGrid_( true ),
246 levelIndexSets_( hostGrid_->maxLevel()+1, nullptr, allocator ),
247 storageAllocator_( allocator )
259 GeometryGrid ( HostGrid *hostGrid,
const Allocator &allocator = Allocator() )
260 : hostGrid_( hostGrid ),
261 coordFunction_( new CoordFunction( this->hostGrid() ) ),
262 removeHostGrid_( true ),
263 levelIndexSets_( hostGrid_->maxLevel()+1, nullptr, allocator ),
264 storageAllocator_( allocator )
272 for(
unsigned int i = 0; i < levelIndexSets_.size(); ++i )
274 if( levelIndexSets_[ i ] )
275 delete( levelIndexSets_[ i ] );
278 if( removeHostGrid_ )
280 delete coordFunction_;
299 return hostGrid().maxLevel();
310 int size (
int level,
int codim )
const 354 return hostGrid().numBoundarySegments( );
361 globalIdSet_ = GlobalIdSet( hostGrid().globalIdSet() );
362 assert( globalIdSet_ );
369 localIdSet_ = LocalIdSet( hostGrid().localIdSet() );
370 assert( localIdSet_ );
376 assert( levelIndexSets_.size() == (size_t)(maxLevel()+1) );
377 if( (level < 0) || (level > maxLevel()) )
379 DUNE_THROW(
GridError,
"LevelIndexSet for nonexisting level " << level
383 LevelIndexSet *&levelIndexSet = levelIndexSets_[ level ];
385 levelIndexSet =
new LevelIndexSet( hostGrid().levelIndexSet( level ) );
386 assert( levelIndexSet );
387 return *levelIndexSet;
393 leafIndexSet_ = LeafIndexSet( hostGrid().leafIndexSet() );
394 assert( leafIndexSet_ );
395 return leafIndexSet_;
400 hostGrid().globalRefine( refCount );
406 return hostGrid().mark( refCount, getHostEntity< 0 >( entity ) );
411 return hostGrid().getMark( getHostEntity< 0 >( entity ) );
416 return hostGrid().preAdapt();
421 bool ret = hostGrid().adapt();
428 hostGrid().postAdapt();
485 template<
class DataHandle,
class Data >
491 levelGridView( level ).communicate( dataHandle, interface, direction );
506 template<
class DataHandle,
class Data >
511 leafGridView().communicate( dataHandle, interface, direction );
522 const CollectiveCommunication &
comm ()
const 524 return hostGrid().comm();
541 const bool gridChanged= hostGrid().loadBalance();
562 template<
class DataHandle,
class Data >
566 typedef GeoGrid :: CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
568 WrappedDataHandle wrappedDataHandle( *
this, datahandle );
569 const bool gridChanged = hostGrid().loadBalance( wrappedDataHandle );
595 template<
class EntitySeed >
600 return EntityImpl( *
this, seed );
611 typedef typename LevelGridView::GridViewImp ViewImp;
612 return LevelGridView( ViewImp( *
this, hostGrid().
levelGridView( level ) ) );
618 typedef typename LeafGridView::GridViewImp ViewImp;
619 return LeafGridView( ViewImp( *
this, hostGrid().
leafGridView() ) );
652 const int newNumLevels = maxLevel()+1;
653 const int oldNumLevels = levelIndexSets_.size();
655 for(
int i = newNumLevels; i < oldNumLevels; ++i )
657 if( levelIndexSets_[ i ] )
658 delete levelIndexSets_[ i ];
660 levelIndexSets_.resize( newNumLevels,
nullptr );
664 using Base::getRealImplementation;
675 template<
int codim >
679 return getRealImplementation( entity ).hostEntity();
684 return storageAllocator_.allocate( size );
689 storageAllocator_.deallocate( (
char *)p, size );
693 HostGrid *
const hostGrid_;
694 CoordFunction *coordFunction_;
695 bool removeHostGrid_;
696 mutable std::vector< LevelIndexSet *, typename Allocator::template rebind< LevelIndexSet * >::other > levelIndexSets_;
697 mutable LeafIndexSet leafIndexSet_;
698 mutable GlobalIdSet globalIdSet_;
699 mutable LocalIdSet localIdSet_;
700 mutable typename Allocator::template rebind< char >::other storageAllocator_;
708 template<
class HostGr
id,
class CoordFunction,
class Allocator >
709 template<
int codim >
711 :
public Base::template
Codim< codim >
752 template< PartitionIteratorType pitype >
786 #endif // #ifndef DUNE_GEOGRID_GRID_HH Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: geometrygrid/grid.hh:735
Definition: geometrygrid/gridfamily.hh:33
static const HostGrid::template Codim< codim >::Entity & getHostEntity(const typename Codim< codim >::Entity &entity)
Definition: geometrygrid/grid.hh:677
Definition: geometrygrid/grid.hh:24
void update()
update grid caches
Definition: geometrygrid/grid.hh:647
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: geometrygrid/grid.hh:447
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: geometrygrid/grid.hh:169
CoordFunction & coordFunction()
obtain mutable reference to the coordinate function.
Definition: geometrygrid/grid.hh:670
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: geometrygrid/grid.hh:143
Grid< dim, dimworld, ct, GridFamily >::LevelGridView levelGridView(const Grid< dim, dimworld, ct, GridFamily > &grid, int level)
level grid view for the given grid and level.
Definition: common/grid.hh:857
Definition: geometrygrid/gridview.hh:27
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: geometrygrid/grid.hh:159
GridFamily::Traits::LeafGridView LeafGridView
type of view for leaf grid
Definition: geometrygrid/grid.hh:141
Definition: geometrygrid/datahandle.hh:23
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:36
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
int maxLevel() const
obtain maximal grid level
Definition: geometrygrid/grid.hh:297
int getMark(const typename Codim< 0 >::Entity &entity) const
Definition: geometrygrid/grid.hh:409
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: geometrygrid/grid.hh:181
const LeafIndexSet & leafIndexSet() const
Definition: geometrygrid/grid.hh:390
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:23
Definition: geometrygrid/entity.hh:58
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
int size(GeometryType type) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:343
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: geometrygrid/grid.hh:757
const CollectiveCommunication & comm() const
obtain CollectiveCommunication object
Definition: geometrygrid/grid.hh:522
int size(int codim) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:321
LevelGridView levelGridView(int level) const
View for a grid level.
Definition: geometrygrid/grid.hh:609
Definition: common/geometry.hh:24
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed
Definition: geometrygrid/grid.hh:597
const LevelIndexSet & levelIndexSet(int level) const
Definition: geometrygrid/grid.hh:374
HostGrid & hostGrid()
obtain mutable reference to the host grid
Definition: geometrygrid/grid.hh:634
bool preAdapt()
Definition: geometrygrid/grid.hh:414
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: geometrygrid/grid.hh:352
Definition: geometrygrid/intersection.hh:19
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction) const
communicate information on leaf entities
Definition: geometrygrid/grid.hh:507
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: geometrygrid/grid.hh:720
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction, int level) const
communicate information on a grid level
Definition: geometrygrid/grid.hh:486
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:225
void postAdapt()
Definition: geometrygrid/grid.hh:426
const CoordFunction & coordFunction() const
obtain constant reference to the coordinate function
Definition: geometrygrid/grid.hh:667
void deallocateStorage(void *p, std::size_t size) const
Definition: geometrygrid/grid.hh:687
int size(int level, int codim) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:310
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: geometrygrid/grid.hh:129
int overlapSize(int level, int codim) const
obtain size of overlap region for a grid level
Definition: geometrygrid/grid.hh:457
bool mark(int refCount, const typename Codim< 0 >::Entity &entity)
Definition: geometrygrid/grid.hh:404
Partition< All_Partition >::LevelIterator LevelIterator
type of level iterator
Definition: geometrygrid/grid.hh:779
GeometryGrid(HostGrid *hostGrid, CoordFunction *coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:242
Traits::CollectiveCommunication CollectiveCommunication
communicator with all other processes having some part of the grid
Definition: geometrygrid/grid.hh:209
int overlapSize(int codim) const
obtain size of overlap region for the leaf grid
Definition: geometrygrid/grid.hh:438
Definition: identity.hh:12
int ghostSize(int level, int codim) const
obtain size of ghost region for a grid level
Definition: geometrygrid/grid.hh:467
Definition: geometrygrid/grid.hh:753
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:287
void globalRefine(int refCount)
Definition: geometrygrid/grid.hh:398
const GlobalIdSet & globalIdSet() const
Definition: geometrygrid/grid.hh:358
bool adapt()
Definition: geometrygrid/grid.hh:419
Include standard header files.
Definition: agrid.hh:59
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: geometrygrid/grid.hh:198
GridFamily::Traits Traits
type of the grid traits
Definition: geometrygrid/grid.hh:112
HostGrid::ctype ctype
field type of the coordinate vector
Definition: coordfunction.hh:49
Grid< dim, dimworld, ct, GridFamily >::LeafGridView leafGridView(const Grid< dim, dimworld, ct, GridFamily > &grid)
leaf grid view for the given grid
Definition: common/grid.hh:874
actual implementation of the entity
Definition: geometrygrid/entity.hh:32
Definition: geometrygrid/indexsets.hh:25
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: geometrygrid/grid.hh:745
~GeometryGrid()
destructor
Definition: geometrygrid/grid.hh:270
LeafGridView leafGridView() const
View for the leaf grid.
Definition: geometrygrid/grid.hh:616
GeometryGrid(HostGrid *hostGrid, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:259
void * allocateStorage(std::size_t size) const
Definition: geometrygrid/grid.hh:682
Definition: geometrygrid/backuprestore.hh:21
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: geometrygrid/grid.hh:760
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition: geometrygrid/grid.hh:628
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: geometrygrid/grid.hh:133
const LocalIdSet & localIdSet() const
Definition: geometrygrid/grid.hh:366
Definition: geometrygrid/gridfamily.hh:49
traits structure containing types for a codimension
Definition: geometrygrid/grid.hh:121
Different resources needed by all grid implementations.
Definition: geometrygrid/geometry.hh:86
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:373
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: geometrygrid/grid.hh:131
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:334
Definition: geometrygrid/entity.hh:55
Partition< All_Partition >::LeafIterator LeafIterator
type of leaf iterator
Definition: geometrygrid/grid.hh:770
grid wrapper replacing the geometriesGeometryGrid wraps another DUNE grid and replaces its geometry b...
Definition: declaration.hh:10