1#ifndef DUNE_SPGRID_DECOMPOSITION_HH
2#define DUNE_SPGRID_DECOMPOSITION_HH
6#include <dune/grid/spgrid/mesh.hh>
7#include <dune/grid/spgrid/multiindex.hh>
18 typedef SPDecomposition< dim > This;
21 static const int dimension = dim;
24 typedef SPMesh< dimension > Mesh;
29 Node (
const Mesh &mesh,
const unsigned int size );
32 const Mesh &mesh ()
const;
33 const Mesh &subMesh (
const unsigned int rank )
const;
34 void subMeshes ( std::vector< Mesh > &meshes )
const;
36 unsigned int size ()
const;
45 SPDecomposition (
const Mesh &mesh,
const unsigned int size );
46 SPDecomposition (
const MultiIndex &width,
const unsigned int size );
48 const Mesh &mesh ()
const;
49 const Mesh &subMesh (
const unsigned int rank )
const;
50 std::vector< Mesh > subMeshes ()
const;
52 unsigned int size ()
const;
64 inline SPDecomposition< dim >::Node::Node (
const Mesh &mesh,
const unsigned int size )
72 const int leftWeight = size_/2;
73 const int rightWeight = size_ - leftWeight;
75 const MultiIndex &width = mesh.width();
76 const std::pair< Mesh, Mesh > split
77 = mesh_.split( std::max_element( width.begin(), width.end() ) - width.begin(), leftWeight, rightWeight );
78 left_ =
new Node( split.first, leftWeight );
79 right_ =
new Node( split.second, rightWeight );
85 inline SPDecomposition< dim >::Node::~Node ()
93 inline const typename SPDecomposition< dim >::Mesh &
94 SPDecomposition< dim >::Node::mesh ()
const
101 inline const typename SPDecomposition< dim >::Mesh &
102 SPDecomposition< dim >::Node::subMesh (
const unsigned int rank )
const
104 assert( rank < size_ );
107 assert( (left_ != 0) && (right_ != 0) );
109 return left_->subMesh( rank );
111 return right_->subMesh( rank - size_/2 );
120 SPDecomposition< dim >::Node::subMeshes ( std::vector< Mesh > &meshes )
const
124 assert( (left_ != 0) && (right_ != 0) );
125 left_->subMeshes( meshes );
126 right_->subMeshes( meshes );
129 meshes.push_back( mesh() );
134 inline unsigned int SPDecomposition< dim >::Node::size ()
const
145 inline SPDecomposition< dim >
146 ::SPDecomposition (
const Mesh &mesh,
const unsigned int size )
147 : root_( mesh, size )
152 inline SPDecomposition< dim >
153 ::SPDecomposition (
const MultiIndex &width,
const unsigned int size )
154 : root_( Mesh( width ), size )
159 inline const typename SPDecomposition< dim >::Mesh &
160 SPDecomposition< dim >::mesh ()
const
167 inline const typename SPDecomposition< dim >::Mesh &
168 SPDecomposition< dim >::subMesh (
const unsigned int rank )
const
170 return root_.subMesh( rank );
175 inline std::vector< typename SPDecomposition< dim >::Mesh >
176 SPDecomposition< dim >::subMeshes ()
const
178 std::vector< Mesh > meshes;
179 meshes.reserve( root_.size() );
180 root_.subMeshes( meshes );
186 inline unsigned int SPDecomposition< dim >::size ()
const
Dune namespace.
Definition: alignedallocator.hh:13