3 #ifndef DUNE_GEOGRID_GRID_HH
4 #define DUNE_GEOGRID_GRID_HH
8 #include <dune/common/deprecated.hh>
9 #include <dune/common/shared_ptr.hh>
26 template<
class HostGr
id >
76 template<
class HostGr
id,
class CoordFunction = DefaultCoordFunction< HostGr
id >,
class Allocator = std::allocator<
void > >
80 < HostGrid::dimension, CoordFunction::dimRange, typename HostGrid::ctype,
81 GeoGrid::GridFamily< HostGrid, CoordFunction, Allocator > >,
89 < HostGrid::dimension, CoordFunction::dimRange,
typename HostGrid::ctype,
115 typedef typename GridFamily::Traits
Traits;
123 template<
int codim >
209 typedef typename Traits::ctype
ctype;
229 : hostGrid_(
Dune::stackobject_to_shared_ptr(
hostGrid) ),
231 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
232 storageAllocator_( allocator )
247 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
248 storageAllocator_( allocator )
262 coordFunction_( std::make_shared<CoordFunction>( this->
hostGrid() ) ),
263 levelIndexSets_( hostGrid_->
maxLevel()+1, nullptr, allocator ),
264 storageAllocator_( allocator )
277 DUNE_DEPRECATED_MSG("Pass the host grid and coord function as shared_ptr instead of a raw pointer. This constructor will be removed after
Dune 2.7.")
280 levelIndexSets_( hostGrid_->
maxLevel()+1,
nullptr, allocator ),
281 storageAllocator_( allocator )
294 DUNE_DEPRECATED_MSG("Pass the host grid as shared_ptr instead of a raw pointer. This constructor will be removed after
Dune 2.7.")
296 coordFunction_( std::make_shared<CoordFunction>( this->
hostGrid() ) ),
297 levelIndexSets_( hostGrid_->
maxLevel()+1,
nullptr, allocator ),
298 storageAllocator_( allocator )
306 for(
unsigned int i = 0; i < levelIndexSets_.size(); ++i )
308 if( levelIndexSets_[ i ] )
309 delete( levelIndexSets_[ i ] );
338 int size (
int level,
int codim )
const
382 return hostGrid().numBoundarySegments( );
390 assert( globalIdSet_ );
398 assert( localIdSet_ );
404 assert( levelIndexSets_.size() == (
size_t)(
maxLevel()+1) );
405 if( (level < 0) || (level >
maxLevel()) )
407 DUNE_THROW(
GridError,
"LevelIndexSet for nonexisting level " << level
422 assert( leafIndexSet_ );
423 return leafIndexSet_;
428 hostGrid().globalRefine( refCount );
489 const bool gridChanged=
hostGrid().loadBalance();
510 template<
class DataHandle,
class Data >
511 bool loadBalance ( CommDataHandleIF< DataHandle, Data > &datahandle )
513 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
514 typedef GeoGrid :: CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
516 WrappedDataHandle wrappedDataHandle( *
this, datahandle );
517 const bool gridChanged =
hostGrid().loadBalance( wrappedDataHandle );
543 template<
class EntitySeed >
548 return EntityImpl( *
this, seed );
559 typedef typename LevelGridView::GridViewImp ViewImp;
566 typedef typename LeafGridView::GridViewImp ViewImp;
600 const int newNumLevels =
maxLevel()+1;
601 const int oldNumLevels = levelIndexSets_.size();
603 for(
int i = newNumLevels; i < oldNumLevels; ++i )
605 if( levelIndexSets_[ i ] )
606 delete levelIndexSets_[ i ];
608 levelIndexSets_.resize( newNumLevels,
nullptr );
623 template<
int codim >
632 return storageAllocator_.allocate(
size );
637 storageAllocator_.deallocate( (
char *)p,
size );
641 std::shared_ptr<HostGrid>
const hostGrid_;
642 std::shared_ptr<CoordFunction> coordFunction_;
643 mutable std::vector< LevelIndexSet *, typename std::allocator_traits<Allocator>::template rebind_alloc< LevelIndexSet * > > levelIndexSets_;
647 mutable typename std::allocator_traits<Allocator>::template rebind_alloc< char > storageAllocator_;
655 template<
class HostGr
id,
class CoordFunction,
class Allocator >
656 template<
int codim >
658 :
public Base::template
Codim< codim >
699 template< PartitionIteratorType pitype >
Include standard header files.
Definition: agrid.hh:59
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:180
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:855
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:1027
Definition: geometrygrid/backuprestore.hh:25
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:324
Definition: geometrygrid/datahandle.hh:25
grid wrapper replacing the geometries
Definition: geometrygrid/grid.hh:85
int maxLevel() const
obtain maximal grid level
Definition: geometrygrid/grid.hh:325
CoordFunction & coordFunction()
obtain mutable reference to the coordinate function.
Definition: geometrygrid/grid.hh:618
HostGrid & hostGrid()
obtain mutable reference to the host grid
Definition: geometrygrid/grid.hh:582
int size(int codim) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:349
int size(int level, GeometryType type) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:362
bool mark(int refCount, const typename Codim< 0 >::Entity &entity)
Definition: geometrygrid/grid.hh:432
void postAdapt()
Definition: geometrygrid/grid.hh:454
const LocalIdSet & localIdSet() const
Definition: geometrygrid/grid.hh:394
LeafGridView leafGridView() const
View for the leaf grid.
Definition: geometrygrid/grid.hh:564
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: geometrygrid/grid.hh:136
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed
Definition: geometrygrid/grid.hh:545
LevelGridView levelGridView(int level) const
View for a grid level.
Definition: geometrygrid/grid.hh:557
GeometryGrid(std::shared_ptr< HostGrid > hostGrid, std::shared_ptr< CoordFunction > coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:244
int size(int level, int codim) const
obtain number of entites on a level
Definition: geometrygrid/grid.hh:338
const CollectiveCommunication & comm() const
obtain CollectiveCommunication object
Definition: geometrygrid/grid.hh:470
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: geometrygrid/grid.hh:162
const LevelIndexSet & levelIndexSet(int level) const
Definition: geometrygrid/grid.hh:402
bool adapt()
Definition: geometrygrid/grid.hh:447
GeometryGrid(HostGrid *hostGrid, CoordFunction *coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:276
GeometryGrid(HostGrid *hostGrid, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:293
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: geometrygrid/grid.hh:132
static const HostGrid::template Codim< codim >::Entity & getHostEntity(const typename Codim< codim >::Entity &entity)
Definition: geometrygrid/grid.hh:625
const GlobalIdSet & globalIdSet() const
Definition: geometrygrid/grid.hh:386
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: geometrygrid/grid.hh:209
GridFamily::Traits Traits
type of the grid traits
Definition: geometrygrid/grid.hh:115
~GeometryGrid()
destructor
Definition: geometrygrid/grid.hh:304
GridFamily::Traits::LevelGridView LevelGridView
type of view for level grid
Definition: geometrygrid/grid.hh:146
void * allocateStorage(std::size_t size) const
Definition: geometrygrid/grid.hh:630
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: geometrygrid/grid.hh:172
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: geometrygrid/grid.hh:201
void deallocateStorage(void *p, std::size_t size) const
Definition: geometrygrid/grid.hh:635
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: geometrygrid/grid.hh:184
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: geometrygrid/grid.hh:134
void globalRefine(int refCount)
Definition: geometrygrid/grid.hh:426
GeometryGrid(std::shared_ptr< HostGrid > hostGrid, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:260
GridFamily::Traits::LeafGridView LeafGridView
type of view for leaf grid
Definition: geometrygrid/grid.hh:144
bool preAdapt()
Definition: geometrygrid/grid.hh:442
Traits::CollectiveCommunication CollectiveCommunication
communicator with all other processes having some part of the grid
Definition: geometrygrid/grid.hh:212
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: geometrygrid/grid.hh:380
int getMark(const typename Codim< 0 >::Entity &entity) const
Definition: geometrygrid/grid.hh:437
int size(GeometryType type) const
obtain number of leaf entities
Definition: geometrygrid/grid.hh:371
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition: geometrygrid/grid.hh:576
GeometryGrid(HostGrid &hostGrid, CoordFunction &coordFunction, const Allocator &allocator=Allocator())
constructor
Definition: geometrygrid/grid.hh:228
const CoordFunction & coordFunction() const
obtain constant reference to the coordinate function
Definition: geometrygrid/grid.hh:615
const LeafIndexSet & leafIndexSet() const
Definition: geometrygrid/grid.hh:418
void update()
update grid caches
Definition: geometrygrid/grid.hh:595
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:29
traits structure containing types for a codimension
Definition: geometrygrid/grid.hh:659
Partition< All_Partition >::LevelIterator LevelIterator
type of level iterator
Definition: geometrygrid/grid.hh:726
Partition< All_Partition >::LeafIterator LeafIterator
type of leaf iterator
Definition: geometrygrid/grid.hh:717
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: geometrygrid/grid.hh:682
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: geometrygrid/grid.hh:692
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: geometrygrid/grid.hh:667
Definition: geometrygrid/grid.hh:701
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: geometrygrid/grid.hh:704
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: geometrygrid/grid.hh:707
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: hostgridaccess.hh:27
Different resources needed by all grid implementations.