3 #ifndef DUNE_GEOGRID_GRID_HH
4 #define DUNE_GEOGRID_GRID_HH
6 #include <dune/common/nullptr.hh>
7 #include <dune/common/deprecated.hh>
24 template<
class HostGr
id >
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 > >,
87 < HostGrid::dimension, CoordFunction::dimRange,
typename HostGrid::ctype,
112 typedef typename GridFamily::Traits
Traits;
121 template<
int codim >
142 template< PartitionIteratorType pitype >
215 typedef typename Traits::ctype
ctype;
236 : hostGrid_( &hostGrid ),
237 coordFunction_( coordFunction ),
238 removeHostGrid_( false ),
239 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
240 storageAllocator_( allocator )
252 GeometryGrid ( HostGrid *hostGrid, CoordFunction *coordFunction,
const Allocator &allocator = Allocator() )
253 : hostGrid_( hostGrid ),
254 coordFunction_( *coordFunction ),
255 removeHostGrid_( true ),
256 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
257 storageAllocator_( allocator )
264 for(
unsigned int i = 0; i < levelIndexSets_.size(); ++i )
266 if( levelIndexSets_[ i ] )
267 delete( levelIndexSets_[ i ] );
270 if( removeHostGrid_ )
272 delete &coordFunction_;
302 int size (
int level,
int codim )
const
346 return hostGrid().numBoundarySegments( );
354 assert( globalIdSet_ );
362 assert( localIdSet_ );
368 assert( levelIndexSets_.size() == (size_t)(
maxLevel()+1) );
369 if( (level < 0) || (level >
maxLevel()) )
371 DUNE_THROW(
GridError,
"LevelIndexSet for nonexisting level " << level
378 assert( levelIndexSet );
386 assert( leafIndexSet_ );
387 return leafIndexSet_;
392 hostGrid().globalRefine( refCount );
398 return hostGrid().mark( refCount, getHostEntity< 0 >( entity ) );
403 return hostGrid().getMark( getHostEntity< 0 >( entity ) );
477 template<
class DataHandle,
class Data >
483 levelGridView( level ).communicate( dataHandle, interface, direction );
498 template<
class DataHandle,
class Data >
503 leafGridView().communicate( dataHandle, interface, direction );
514 const CollectiveCommunication &
comm ()
const
533 const bool gridChanged=
hostGrid().loadBalance();
554 template<
class DataHandle,
class Data >
555 bool loadBalance ( CommDataHandleIF< DataHandle, Data > &datahandle )
557 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
558 typedef GeoGrid :: CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
560 WrappedDataHandle wrappedDataHandle( *
this, datahandle );
561 const bool gridChanged =
hostGrid().loadBalance( wrappedDataHandle );
569 template<
class EntitySeed >
570 typename Traits::template Codim< EntitySeed::codimension >::EntityPointer
571 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.")
579 template<
class EntitySeed >
580 typename Traits::template Codim< EntitySeed::codimension >::Entity
584 return EntityImpl( *
this, seed );
593 template< PartitionIteratorType pitype >
597 typedef typename View::GridViewImp ViewImp;
602 template< PartitionIteratorType pitype >
606 typedef typename View::GridViewImp ViewImp;
613 typedef typename LevelGridView::GridViewImp ViewImp;
620 typedef typename LeafGridView::GridViewImp ViewImp;
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 );
671 template<
int codim >
672 static const typename HostGrid::template Codim< codim >::Entity &
675 return getRealImplementation( entity ).hostEntity();
680 return storageAllocator_.allocate( size );
685 storageAllocator_.deallocate( (
char *)p, size );
689 HostGrid *
const hostGrid_;
690 CoordFunction &coordFunction_;
691 bool removeHostGrid_;
692 mutable std::vector< LevelIndexSet *, typename Allocator::template rebind< LevelIndexSet * >::other > levelIndexSets_;
693 mutable LeafIndexSet leafIndexSet_;
694 mutable GlobalIdSet globalIdSet_;
695 mutable LocalIdSet localIdSet_;
696 mutable typename Allocator::template rebind< char >::other storageAllocator_;
704 template<
class HostGr
id,
class CoordFunction,
class Allocator >
705 template<
int codim >
706 struct GeometryGrid< HostGrid, CoordFunction, Allocator >::Codim
707 :
public Base::template Codim< codim >
754 template< PartitionIteratorType pitype >
788 #endif // #ifndef DUNE_GEOGRID_GRID_HH
Definition: geometrygrid/indexsets.hh:25
void update()
update grid caches
Definition: geometrygrid/grid.hh:647
int size(int level, int codim) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:302
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: geometrygrid/grid.hh:132
Definition: common/geometry.hh:24
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction) const
communicate information on leaf entities
Definition: geometrygrid/grid.hh:499
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Partition< All_Partition >::LeafGridView LeafGridView
Definition: geometrygrid/grid.hh:153
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: geometrygrid/grid.hh:169
Definition: identity.hh:12
Definition: geometrygrid/grid.hh:25
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: geometrygrid/grid.hh:344
static const HostGrid::template Codim< codim >::Entity & getHostEntity(const typename Codim< codim >::Entity &entity)
Definition: geometrygrid/grid.hh:673
Definition: geometrygrid/gridfamily.hh:33
const LevelIndexSet & levelIndexSet(int level) const
Definition: geometrygrid/grid.hh:366
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: geometrygrid/grid.hh:191
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction, int level) const
communicate information on a grid level
Definition: geometrygrid/grid.hh:478
traits structure containing types for a codimension
Definition: geometrygrid/grid.hh:122
bool mark(int refCount, const typename Codim< 0 >::Entity &entity)
Definition: geometrygrid/grid.hh:396
Include standard header files.
Definition: agrid.hh:59
HostGrid & hostGrid()
Definition: geometrygrid/grid.hh:634
const CollectiveCommunication & comm() const
obtain CollectiveCommunication object
Definition: geometrygrid/grid.hh:514
Traits::CollectiveCommunication CollectiveCommunication
communicator with all other processes having some part of the grid
Definition: geometrygrid/grid.hh:219
int size(int codim) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:313
void * allocateStorage(std::size_t size) const
Definition: geometrygrid/grid.hh:678
const LocalIdSet & localIdSet() const
Definition: geometrygrid/grid.hh:358
GridFamily::Traits::template Partition< pitype >::LevelGridView LevelGridView
Definition: geometrygrid/grid.hh:146
Definition: geometrygrid/entity.hh:60
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:284
Partition< All_Partition >::LevelIterator LevelIterator
type of leaf iterator
Definition: geometrygrid/grid.hh:781
int getMark(const typename Codim< 0 >::Entity &entity) const
Definition: geometrygrid/grid.hh:401
~GeometryGrid()
destructor
Definition: geometrygrid/grid.hh:262
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: geometrygrid/grid.hh:759
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:326
void postAdapt()
Definition: geometrygrid/grid.hh:418
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:388
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: geometrygrid/grid.hh:737
Definition: geometrygrid/intersection.hh:19
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: geometrygrid/grid.hh:152
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
Different resources needed by all grid implementations.
static std::conditional< std::is_reference< InterfaceType >::value, typename std::add_lvalue_reference< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type, typename std::remove_const< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: common/grid.hh:1305
int overlapSize(int level, int codim) const
obtain size of overlap region for a grid level
Definition: geometrygrid/grid.hh:449
Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: geometrygrid/grid.hh:594
const CoordFunction & coordFunction() const
Definition: geometrygrid/grid.hh:667
Definition: geometrygrid/grid.hh:755
Partition< All_Partition >::LeafIterator LeafIterator
type of level iterator
Definition: geometrygrid/grid.hh:772
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: geometrygrid/grid.hh:747
const GlobalIdSet & globalIdSet() const
Definition: geometrygrid/grid.hh:350
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: geometrygrid/grid.hh:208
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: geometrygrid/grid.hh:130
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
int overlapSize(int codim) const
obtain size of overlap region for the leaf grid
Definition: geometrygrid/grid.hh:430
void globalRefine(int refCount)
Definition: geometrygrid/grid.hh:390
LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: geometrygrid/grid.hh:611
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:23
Traits::template Codim< codim >::EntityPointer EntityPointer
type of entity pointer
Definition: geometrygrid/grid.hh:722
void deallocateStorage(void *p, std::size_t size) const
Definition: geometrygrid/grid.hh:683
GridFamily::Traits::template Partition< pitype >::LeafGridView LeafGridView
Definition: geometrygrid/grid.hh:148
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: geometrygrid/grid.hh:439
Definition: geometrygrid/gridfamily.hh:49
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:235
int maxLevel() const
obtain maximal grid level
Definition: geometrygrid/grid.hh:289
int ghostSize(int level, int codim) const
obtain size of ghost region for a grid level
Definition: geometrygrid/grid.hh:459
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: geometrygrid/grid.hh:134
Definition: geometrygrid/datahandle.hh:23
Traits::template Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: geometrygrid/grid.hh:572
Definition: common/entitypointer.hh:595
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
Definition: geometrygrid/entity.hh:57
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: geometrygrid/grid.hh:179
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: geometrygrid/grid.hh:581
Definition: geometrygrid/gridview.hh:27
Types for GridView.
Definition: geometrygrid/grid.hh:143
LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: geometrygrid/grid.hh:618
GridFamily::Traits Traits
type of the grid traits
Definition: geometrygrid/grid.hh:113
int size(GeometryType type) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:335
Definition: geometrygrid/geometry.hh:86
bool preAdapt()
Definition: geometrygrid/grid.hh:406
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: geometrygrid/grid.hh:216
GeometryGrid(HostGrid *hostGrid, CoordFunction *coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:252
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: geometrygrid/grid.hh:716
Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: geometrygrid/grid.hh:603
Wrapper class for entities.
Definition: common/entity.hh:61
Definition: geometrygrid/backuprestore.hh:22
const HostGrid & hostGrid() const
Definition: geometrygrid/grid.hh:629
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: geometrygrid/grid.hh:762
CoordFunction & coordFunction()
Definition: geometrygrid/grid.hh:668
bool adapt()
Definition: geometrygrid/grid.hh:411
grid wrapper replacing the geometriesGeometryGrid wraps another DUNE grid and replaces its geometry b...
Definition: geometrygrid/declaration.hh:10
const LeafIndexSet & leafIndexSet() const
Definition: geometrygrid/grid.hh:382