linear_partitioner.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // C++ Includes -----------------------------------
21 
22 // Local Includes -----------------------------------
23 #include "libmesh/mesh_base.h"
26 #include "libmesh/elem.h"
27 
28 namespace libMesh
29 {
30 
31 
32 // ------------------------------------------------------------
33 // LinearPartitioner implementation
35  const unsigned int n)
36 {
38 
39  // Check for an easy return
40  if (n == 1)
41  {
42  this->single_partition (mesh);
43  return;
44  }
45 
46  // Create a simple linear partitioning
47  {
48  START_LOG ("partition()", "LinearPartitioner");
49 
50  const dof_id_type n_active_elem = mesh.n_active_elem();
51  const dof_id_type blksize = n_active_elem/n;
52 
53  dof_id_type e = 0;
54 
56  const MeshBase::element_iterator elem_end = mesh.active_elements_end();
57 
58  for ( ; elem_it != elem_end; ++elem_it)
59  {
60  if ((e/blksize) < n)
61  {
62  Elem *elem = *elem_it;
63  elem->processor_id() =
64  libmesh_cast_int<processor_id_type>(e/blksize);
65  }
66  else
67  {
68  Elem *elem = *elem_it;
69  elem->processor_id() = 0;
70  elem = elem->parent();
71  }
72 
73  e++;
74  }
75 
76  STOP_LOG ("partition()", "LinearPartitioner");
77  }
78 }
79 
80 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo