libMesh
Loading...
Searching...
No Matches
mapped_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/mapped_subdomain_partitioner.h"
22#include "libmesh/elem.h"
23#include "libmesh/enum_partitioner_type.h"
24#include "libmesh/libmesh_logging.h"
25#include "libmesh/mesh_base.h"
26#include "libmesh/utility.h"
27
28namespace libMesh
29{
30
31
36
37
41 const unsigned int n)
42{
43 libmesh_assert_greater (n, 0);
44
45 // Check for an easy return. If the user has not specified any
46 // entries in subdomain_to_proc, we just do a single partitioning.
47 if ((n == 1) || subdomain_to_proc.empty())
48 {
49 this->single_partition_range (it, end);
50 return;
51 }
52
53 // Now actually do the partitioning.
54 LOG_SCOPE ("partition_range()", "MappedSubdomainPartitioner");
55
56 for (auto & elem : as_range(it, end))
57 {
58 subdomain_id_type sbd_id = elem->subdomain_id();
59
60 // Find which processor id corresponds to this element's subdomain id.
61 elem->processor_id() = libmesh_map_find(subdomain_to_proc, sbd_id);
62 }
63}
64
65
66
68 const unsigned int n)
69{
70 this->partition_range(mesh,
71 mesh.active_elements_begin(),
72 mesh.active_elements_end(),
73 n);
74}
75
76} // namespace libMesh
virtual void partition_range(MeshBase &mesh, MeshBase::element_iterator it, MeshBase::element_iterator end, const unsigned int n) override
Called by the SubdomainPartitioner to partition elements in the range (it, end).
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
Partition the MeshBase into n subdomains.
std::map< subdomain_id_type, processor_id_type > subdomain_to_proc
Before calling partition() or partition_range(), the user must assign all the Mesh subdomains to cert...
virtual PartitionerType type() const override
This is the MeshBase class.
Definition mesh_base.h:81
bool single_partition_range(MeshBase::element_iterator it, MeshBase::element_iterator end)
Slightly generalized version of single_partition which acts on a range of elements defined by the pai...
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
PartitionerType
Defines an enum for mesh partitioner types.
The definition of the element_iterator struct.
Definition mesh_base.h:2538