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
traits structure containing types for a codimension
Definition: geometrygrid/grid.hh:122
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: geometrygrid/grid.hh:132
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
Traits::CollectiveCommunication CollectiveCommunication
communicator with all other processes having some part of the grid
Definition: geometrygrid/grid.hh:219
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:23
const LocalIdSet & localIdSet() const
Definition: geometrygrid/grid.hh:358
int size(int level, int codim) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:302
GridFamily::Traits Traits
type of the grid traits
Definition: geometrygrid/grid.hh:113
Definition: geometrygrid/geometry.hh:86
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction, int level) const
communicate information on a grid level
Definition: geometrygrid/grid.hh:478
Definition: common/entitypointer.hh:595
Definition: geometrygrid/datahandle.hh:23
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: geometrygrid/grid.hh:216
Wrapper class for entities.
Definition: common/entity.hh:61
bool mark(int refCount, const typename Codim< 0 >::Entity &entity)
Definition: geometrygrid/grid.hh:396
Partition< All_Partition >::LeafGridView LeafGridView
Definition: geometrygrid/grid.hh:153
HostGrid & hostGrid()
Definition: geometrygrid/grid.hh:634
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: geometrygrid/grid.hh:169
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: geometrygrid/grid.hh:344
Definition: geometrygrid/intersection.hh:19
bool adapt()
Definition: geometrygrid/grid.hh:411
static const HostGrid::template Codim< codim >::Entity & getHostEntity(const typename Codim< codim >::Entity &entity)
Definition: geometrygrid/grid.hh:673
const LeafIndexSet & leafIndexSet() const
Definition: geometrygrid/grid.hh:382
const LevelIndexSet & levelIndexSet(int level) const
Definition: geometrygrid/grid.hh:366
Definition: geometrygrid/indexsets.hh:25
int size(int codim) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:313
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: geometrygrid/grid.hh:191
Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: geometrygrid/grid.hh:594
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
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: geometrygrid/grid.hh:737
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:284
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Traits::template Codim< codim >::EntityPointer EntityPointer
type of entity pointer
Definition: geometrygrid/grid.hh:722
Definition: geometrygrid/gridfamily.hh:49
GridFamily::Traits::template Partition< pitype >::LevelGridView LevelGridView
Definition: geometrygrid/grid.hh:146
void * allocateStorage(std::size_t size) const
Definition: geometrygrid/grid.hh:678
void communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction) const
communicate information on leaf entities
Definition: geometrygrid/grid.hh:499
~GeometryGrid()
destructor
Definition: geometrygrid/grid.hh:262
grid wrapper replacing the geometriesGeometryGrid wraps another DUNE grid and replaces its geometry b...
Definition: geometrygrid/declaration.hh:10
Definition: geometrygrid/entity.hh:60
Definition: identity.hh:12
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:326
Definition: geometrygrid/grid.hh:25
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: geometrygrid/grid.hh:152
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: geometrygrid/grid.hh:759
Definition: geometrygrid/gridfamily.hh:33
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: geometrygrid/grid.hh:130
Partition< All_Partition >::LevelIterator LevelIterator
type of leaf iterator
Definition: geometrygrid/grid.hh:781
Different resources needed by all grid implementations.
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
const CollectiveCommunication & comm() const
obtain CollectiveCommunication object
Definition: geometrygrid/grid.hh:514
int overlapSize(int level, int codim) const
obtain size of overlap region for a grid level
Definition: geometrygrid/grid.hh:449
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Definition: geometrygrid/grid.hh:755
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: geometrygrid/grid.hh:716
const CoordFunction & coordFunction() const
Definition: geometrygrid/grid.hh:667
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: geometrygrid/grid.hh:747
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: geometrygrid/grid.hh:208
int getMark(const typename Codim< 0 >::Entity &entity) const
Definition: geometrygrid/grid.hh:401
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
int overlapSize(int codim) const
obtain size of overlap region for the leaf grid
Definition: geometrygrid/grid.hh:430
Definition: common/geometry.hh:24
void postAdapt()
Definition: geometrygrid/grid.hh:418
LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: geometrygrid/grid.hh:618
const GlobalIdSet & globalIdSet() const
Definition: geometrygrid/grid.hh:350
void deallocateStorage(void *p, std::size_t size) const
Definition: geometrygrid/grid.hh:683
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: geometrygrid/grid.hh:439
GridFamily::Traits::template Partition< pitype >::LeafGridView LeafGridView
Definition: geometrygrid/grid.hh:148
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
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: geometrygrid/grid.hh:179
int maxLevel() const
obtain maximal grid level
Definition: geometrygrid/grid.hh:289
void update()
update grid caches
Definition: geometrygrid/grid.hh:647
Traits::template Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: geometrygrid/grid.hh:572
Partition< All_Partition >::LeafIterator LeafIterator
type of level iterator
Definition: geometrygrid/grid.hh:772
Definition: geometrygrid/entity.hh:57
int size(GeometryType type) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:335
Include standard header files.
Definition: agrid.hh:59
Definition: geometrygrid/gridview.hh:27
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
Types for GridView.
Definition: geometrygrid/grid.hh:143
GeometryGrid(HostGrid *hostGrid, CoordFunction *coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:252
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: geometrygrid/grid.hh:581
Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: geometrygrid/grid.hh:603
const HostGrid & hostGrid() const
Definition: geometrygrid/grid.hh:629
CoordFunction & coordFunction()
Definition: geometrygrid/grid.hh:668
Definition: geometrygrid/backuprestore.hh:22
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: geometrygrid/grid.hh:762
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:235
bool preAdapt()
Definition: geometrygrid/grid.hh:406