1#ifndef DUNE_SPGRID_TOPOLOGY_HH
2#define DUNE_SPGRID_TOPOLOGY_HH
55 unsigned int numNodes ()
const {
return data_[ 0 ]; }
64 bool hasNeighbor (
const unsigned int node,
const int face )
const;
76 unsigned int neighbor (
const unsigned int node,
const int face )
const;
97 unsigned int &refCount ()
const {
return data_[ 1 ]; }
98 unsigned int &nb (
const unsigned int node,
const int face );
111 const unsigned int numNodes = 1;
112 data_ =
new unsigned int[ 2 + numFaces*numNodes ];
113 data_[ 0 ] = numNodes;
117 for(
int i = 0; i < dimension; ++i )
119 const unsigned int b = (periodic >> i) & 1;
120 nb( 0, 2*i ) = nb( 0, 2*i+1 ) = (1-b)*
max;
127 : data_( other.data_ )
136 if( --refCount() == 0 )
146 if( --refCount() == 0 )
156 return (neighbor( node, face ) < numNodes());
163 assert( node < numNodes() );
164 assert( (face >= 0) && (face < numFaces) );
165 return data_[ node * numFaces + face + 2 ];
172 assert( numNodes() == 1 );
173 assert( (i >= 0) && (i < dimension) );
174 return (neighbor( 0, 2*i ) == 0);
182 for(
int i = 0; i < dimension; ++i )
183 p |= (1u << i) * (
unsigned int)periodic( i );
189 inline unsigned int &
192 assert( node < numNodes() );
193 assert( (face >= 0) && (face < numFaces) );
194 return data_[ node * numFaces + face + 2 ];
202 template<
class char_type,
class traits,
int dim >
203 inline std::basic_ostream< char_type, traits > &
204 operator<< ( std::basic_ostream< char_type, traits > &out,
205 const SPTopology< dim > &topology )
207 typedef SPTopology< dim > Topology;
209 const unsigned int numNodes = topology().numNodes();
211 for(
unsigned int node = 0; node < numNodes; ++node )
214 for(
int face = 0; face < Topology::numFaces; ++face )
216 if( topology.hasNeighbor( node, face ) )
217 out <<
" " << topology.neighbor( node, face );
227 template<
class char_type,
class traits,
int dim >
228 inline std::basic_ostream< char_type, traits > &
Dune::SPMultiIndex< dim > max(const Dune::SPMultiIndex< dim > &a, const Dune::SPMultiIndex< dim > &b)
Definition: multiindex.hh:305
Definition: iostream.hh:7
std::basic_ostream< char_type, traits > & operator<<(std::basic_ostream< char_type, traits > &out, const SPCube< ct, dim > &cube)
Definition: cube.hh:148
std::basic_istream< char_type, traits > & operator>>(std::basic_istream< char_type, traits > &in, SPCube< ct, dim > &cube)
Definition: cube.hh:162
description of the grid's topology
Definition: topology.hh:31
bool periodic(const int i) const
determine whether a direction is periodic
Definition: topology.hh:170
static const int dimension
dimension of the domain
Definition: topology.hh:36
SPTopology(const This &other)
Definition: topology.hh:126
~SPTopology()
Definition: topology.hh:134
static const int numFaces
number of faces of a cube
Definition: topology.hh:39
unsigned int numNodes() const
number of cubes forming this topology
Definition: topology.hh:55
unsigned int neighbor(const unsigned int node, const int face) const
obtain neighbor of a node over a face
Definition: topology.hh:161
const This & operator=(const This &other)
Definition: topology.hh:143
SPTopology(const unsigned int periodic=0)
constructor
Definition: topology.hh:109
unsigned int periodic() const
obtain the periodicity bit field
Definition: topology.hh:179
bool hasNeighbor(const unsigned int node, const int face) const
check whether a node has a neighbor over a face
Definition: topology.hh:154