libMesh
Loading...
Searching...
No Matches
subdomain_partitioner.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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/elem.h"
23#include "libmesh/enum_partitioner_type.h"
24#include "libmesh/int_range.h"
25#include "libmesh/libmesh_logging.h"
26#include "libmesh/metis_partitioner.h"
27
28namespace libMesh
29{
30
32 _internal_partitioner(std::make_unique<MetisPartitioner>())
33{}
34
35
37 : Partitioner(other),
38 chunks(other.chunks),
39 _internal_partitioner(other._internal_partitioner->clone())
40{}
41
42
47
48
50 const unsigned int n)
51{
52 libmesh_assert_greater (n, 0);
53
54 // Check for an easy return. If the user has not specified any
55 // entries in the chunks vector, we just do a single partitioning.
56 if ((n == 1) || chunks.empty())
57 {
58 this->single_partition (mesh);
59 return;
60 }
61
62 // Now actually do the partitioning.
63 LOG_SCOPE ("_do_partition()", "SubdomainPartitioner");
64
65 // For each chunk, construct an iterator range for the set of
66 // subdomains in question, and pass it to the internal Partitioner.
67 for (const auto & id_set : chunks)
70 mesh.active_subdomain_set_elements_begin(id_set),
71 mesh.active_subdomain_set_elements_end(id_set),
72 n);
73}
74
75} // namespace libMesh
This is the MeshBase class.
Definition mesh_base.h:81
The MetisPartitioner uses the Metis graph partitioner to partition the elements.
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition partitioner.h:52
bool single_partition(MeshBase &mesh)
Trivially "partitions" the mesh for one processor.
virtual void partition_range(MeshBase &, MeshBase::element_iterator, MeshBase::element_iterator, const unsigned int)
Partitions elements in the range (it, end) into n parts.
The SubdomainPartitioner partitions the elements in "chunks" of user-specified subdomain ids.
std::vector< std::set< subdomain_id_type > > chunks
Each entry of "chunks" represents a set of subdomains which are to be partitioned together.
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
Partition the MeshBase into n subdomains.
virtual PartitionerType type() const override
std::unique_ptr< Partitioner > _internal_partitioner
The internal Partitioner we use.
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
PartitionerType
Defines an enum for mesh partitioner types.