1#ifndef DUNE_SPGRID_TOPOLOGY_HH
2#define DUNE_SPGRID_TOPOLOGY_HH
52 const This &operator= (
const This &other );
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_ )
134 inline SPTopology< dim >::~SPTopology ()
136 if( --refCount() == 0 )
142 inline const typename SPTopology< dim >::This &
143 SPTopology< dim >::operator= (
const This &other )
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 > &
229 operator>> ( std::basic_istream< char_type, traits > &in,
230 SPTopology< dim > &topology )
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
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
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
Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
Read a std::tuple.
Definition: streamoperators.hh:43
auto periodic(RawPreBasisIndicator &&rawPreBasisIndicator, PIS &&periodicIndexSet)
Create a pre-basis factory that can create a periodic pre-basis.
Definition: periodicbasis.hh:191
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:81
Dune namespace.
Definition: alignedallocator.hh:13