1#ifndef DUNE_SPGRID_DECOMPOSITION_HH
2#define DUNE_SPGRID_DECOMPOSITION_HH
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;
49 const Mesh &
subMesh (
const unsigned int rank )
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;
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 ()
94 SPDecomposition< dim >::Node::mesh ()
const
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 )
154 : root_(
Mesh( width ), size )
170 return root_.subMesh( rank );
175 inline std::vector< typename SPDecomposition< dim >::Mesh >
178 std::vector< Mesh > meshes;
179 meshes.reserve( root_.size() );
180 root_.subMeshes( meshes );
Definition: iostream.hh:7
Definition: decomposition.hh:17
const Mesh & subMesh(const unsigned int rank) const
Definition: decomposition.hh:168
static const int dimension
Definition: decomposition.hh:21
SPMultiIndex< dimension > MultiIndex
Definition: decomposition.hh:23
std::vector< Mesh > subMeshes() const
Definition: decomposition.hh:176
SPMesh< dimension > Mesh
Definition: decomposition.hh:24
const Mesh & mesh() const
Definition: decomposition.hh:160
unsigned int size() const
Definition: decomposition.hh:186
MultiIndex width() const
Definition: mesh.hh:194