subdomain_partitioner.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 // Local Includes
23 #include "libmesh/elem.h"
25 
26 namespace libMesh
27 {
28 
30  _internal_partitioner(libmesh_make_unique<MetisPartitioner>())
31 {}
32 
33 
35  : Partitioner(other),
36  chunks(other.chunks),
37  _internal_partitioner(other._internal_partitioner->clone())
38 {}
39 
40 
42  const unsigned int n)
43 {
44  libmesh_assert_greater (n, 0);
45 
46  // Check for an easy return. If the user has not specified any
47  // entries in the chunks vector, we just do a single partitioning.
48  if ((n == 1) || chunks.empty())
49  {
50  this->single_partition (mesh);
51  return;
52  }
53 
54  // Now actually do the partitioning.
55  LOG_SCOPE ("_do_partition()", "SubdomainPartitioner");
56 
57  // For each chunk, construct an iterator range for the set of
58  // subdomains in question, and pass it to the internal Partitioner.
59  for (std::size_t c=0; c<chunks.size(); ++c)
60  {
62  it = mesh.active_subdomain_set_elements_begin(chunks[c]),
63  end = mesh.active_subdomain_set_elements_end(chunks[c]);
64 
65  _internal_partitioner->partition_range(mesh, it, end, n);
66  }
67 }
68 
69 } // namespace libMesh
void single_partition(MeshBase &mesh)
Definition: partitioner.C:159
MeshBase & mesh
Independently partitions chunks of subdomains and combines the results.
std::vector< std::set< subdomain_id_type > > chunks
IterBase * end
Partitioner which interfaces with the METIS library.
Base class for Mesh.
Definition: mesh_base.h:77
Base class for all concrete Partitioner instantiations.
Definition: partitioner.h:50
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
std::unique_ptr< Partitioner > _internal_partitioner