1#ifndef DUNE_SPGRID_PARTITIONPOOL_HH
2#define DUNE_SPGRID_PARTITIONPOOL_HH
4#include <dune/grid/common/gridenums.hh>
5#include <dune/grid/common/exceptions.hh>
34 template< PartitionIteratorType pitype >
46 Partition makePartition (
const Mesh &localMesh,
const unsigned int number,
47 const unsigned int open )
const;
67 inline SPPartitionPool< dim >
68 ::SPPartitionPool (
const Mesh &localMesh,
const Mesh &globalMesh,
70 : globalMesh_( globalMesh ),
75 interiorList_ += makePartition( localMesh, 0, (1 <<
dimension) - 1 );
76 interiorBorderList_ += makePartition( localMesh, 0, 0 );
87 unsigned int openOverlap = 0;
95 openOverlap |= (
overlap[ i ] > 0 ? (1 << i) : 0);
99 if( overlapWidth[ i ] >= globalWidth[ i ] )
105 overlapMesh =
Mesh( begin, end );
110 shift[ n ] += globalWidth[ i ];
112 shift[ n ] -= globalWidth[ i ];
113 if( shift[ n ] != 0 )
118 const unsigned int size = 1 << n;
119 for(
unsigned int d = 0; d < size; ++d )
122 for(
int i = 0; i < n; ++i )
123 s[ dir[ i ] ] = ((d >> i)&1)*shift[ i ];
126 for(
int i = 0; i < n; ++i )
128 const int j = (shift[ i ] < 0) ^ ((d >> i)&1);
129 open.
neighbor( 2*dir[ i ] + j ) = d ^ (1 << i);
130 closed.
neighbor( 2*dir[ i ] + j ) = d ^ (1 << i);
132 overlapList_ += open;
133 overlapFrontList_ += closed;
139 allList_ = overlapFrontList_;
144 template< PartitionIteratorType pitype >
150 case Interior_Partition:
151 return interiorList_;
153 case InteriorBorder_Partition:
154 return interiorBorderList_;
156 case Overlap_Partition:
159 case OverlapFront_Partition:
160 return overlapFrontList_;
165 case Ghost_Partition:
169 DUNE_THROW( GridError,
"No such PartitionIteratorType." );
175 template<
int codim >
180 assert( allList_.contains(
id, number ) );
181 if( interiorBorderList_.contains(
id, number ) )
182 return ((codim == 0) || interiorList_.contains(
id, number )) ? InteriorEntity : BorderEntity;
183 else if( overlapFrontList_.contains(
id, number ) )
184 return ((codim == 0) || overlapList_.contains(
id, number )) ? OverlapEntity : FrontEntity;
194 const unsigned int open )
const
196 const MultiIndex &lbegin = localMesh.begin();
197 const MultiIndex &lend = localMesh.end();
198 const MultiIndex &gbegin = globalMesh().begin();
199 const MultiIndex &gend = globalMesh().end();
202 MultiIndex begin, end;
203 for(
int i = 0; i < dimension; ++i )
205 const int o = ((open >> i) & 1);
206 begin[ i ] = 2*lbegin[ i ] + o*int( lbegin[ i ] != gbegin[ i ] );
207 end[ i ] = 2*lend[ i ] - o*int( lend[ i ] != gend[ i ] );
209 Partition partition( begin, end, globalMesh(), number );
212 for(
int i = 0; i < dimension; ++i )
214 if( !topology().hasNeighbor( 0, 2*i ) )
216 if( (lbegin[ i ] == gbegin[ i ]) && (lend[ i ] == gend[ i ]) )
217 partition.neighbor( 2*i ) = partition.neighbor( 2*i+1 ) = number;
topology of a Cartesian grid
Definition: iostream.hh:7
void updateCache()
Definition: cachedpartitionlist.hh:116
MultiIndex width() const
Definition: mesh.hh:194
This intersect(const This &other) const
Definition: mesh.hh:157
const MultiIndex & begin() const
Definition: mesh.hh:36
This grow(int size) const
Definition: mesh.hh:135
const MultiIndex & end() const
Definition: mesh.hh:37
static This zero()
obtain the zero multiindex
Definition: multiindex.hh:196
Definition: partition.hh:79
const unsigned int & neighbor(const int face) const
Definition: partition.hh:250
Definition: partitionpool.hh:18
const Mesh & globalMesh() const
Definition: partitionpool.hh:41
PartitionList::Mesh Mesh
Definition: partitionpool.hh:29
PartitionList::Partition Partition
Definition: partitionpool.hh:27
const PartitionList & get() const
Definition: partitionpool.hh:146
PartitionList::MultiIndex MultiIndex
Definition: partitionpool.hh:28
static const int dimension
Definition: partitionpool.hh:22
SPCachedPartitionList< dimension > PartitionList
Definition: partitionpool.hh:24
const MultiIndex & overlap() const
Definition: partitionpool.hh:42
PartitionType partitionType(const MultiIndex &id, const unsigned int number) const
Definition: partitionpool.hh:178
SPPartitionPool(const Mesh &localMesh, const Mesh &globalMesh, const MultiIndex &overlap, const Topology &topology)
Definition: partitionpool.hh:68
SPTopology< dimension > Topology
Definition: partitionpool.hh:25
const Topology & topology() const
Definition: partitionpool.hh:43
bool hasNeighbor(const unsigned int node, const int face) const
check whether a node has a neighbor over a face
Definition: topology.hh:154