libMesh
subdomain_partitioner.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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
21 #include "libmesh/subdomain_partitioner.h"
22 #include "libmesh/libmesh_logging.h"
23 #include "libmesh/elem.h"
24 #include "libmesh/metis_partitioner.h"
25 
26 namespace libMesh
27 {
28 
30  _internal_partitioner(new MetisPartitioner)
31 {}
32 
33 
35  const unsigned int n)
36 {
37  libmesh_assert_greater (n, 0);
38 
39  // Check for an easy return. If the user has not specified any
40  // entries in the chunks vector, we just do a single partitioning.
41  if ((n == 1) || chunks.empty())
42  {
43  this->single_partition (mesh);
44  return;
45  }
46 
47  // Now actually do the partitioning.
48  LOG_SCOPE ("_do_partition()", "SubdomainPartitioner");
49 
50  // For each chunk, construct an iterator range for the set of
51  // subdomains in question, and pass it to the internal Partitioner.
52  for (std::size_t c=0; c<chunks.size(); ++c)
53  {
57 
58  _internal_partitioner->partition_range(mesh, it, end, n);
59  }
60 }
61 
62 } // namespace libMesh
The definition of the element_iterator struct.
Definition: mesh_base.h:1476
void single_partition(MeshBase &mesh)
Trivially "partitions" the mesh for one processor.
Definition: partitioner.C:151
virtual element_iterator active_subdomain_set_elements_end(std::set< subdomain_id_type > ss)=0
SubdomainPartitioner()
Constructor, default initializes the internal Partitioner object to a MetisPartitioner so the class i...
MeshBase & mesh
std::vector< std::set< subdomain_id_type > > chunks
Each entry of "chunks" represents a set of subdomains which are to be partitioned together...
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
The MetisPartitioner uses the Metis graph partitioner to partition the elements.
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
Definition: mesh_base.h:68
virtual element_iterator active_subdomain_set_elements_begin(std::set< subdomain_id_type > ss)=0
UniquePtr< Partitioner > _internal_partitioner
The internal Partitioner we use.
virtual void _do_partition(MeshBase &mesh, const unsigned int n) libmesh_override
Partition the MeshBase into n subdomains.