Independently partitions chunks of subdomains and combines the results. More...
#include <subdomain_partitioner.h>
Public Member Functions | |
SubdomainPartitioner () | |
SubdomainPartitioner (const SubdomainPartitioner &other) | |
SubdomainPartitioner & | operator= (const SubdomainPartitioner &)=delete |
SubdomainPartitioner (SubdomainPartitioner &&)=default | |
SubdomainPartitioner & | operator= (SubdomainPartitioner &&)=default |
virtual | ~SubdomainPartitioner ()=default |
virtual std::unique_ptr< Partitioner > | clone () const override |
std::unique_ptr< Partitioner > & | internal_partitioner () |
virtual void | partition (MeshBase &mesh, const unsigned int n) |
virtual void | partition (MeshBase &mesh) |
virtual void | partition_range (MeshBase &, MeshBase::element_iterator, MeshBase::element_iterator, const unsigned int) |
void | repartition (MeshBase &mesh, const unsigned int n) |
void | repartition (MeshBase &mesh) |
virtual void | attach_weights (ErrorVector *) |
Static Public Member Functions | |
static void | partition_unpartitioned_elements (MeshBase &mesh) |
static void | partition_unpartitioned_elements (MeshBase &mesh, const unsigned int n) |
static void | set_parent_processor_ids (MeshBase &mesh) |
static void | set_node_processor_ids (MeshBase &mesh) |
static void | processor_pairs_to_interface_nodes (MeshBase &mesh, std::map< std::pair< processor_id_type, processor_id_type >, std::set< dof_id_type >> &processor_pair_to_nodes) |
static void | set_interface_node_processor_ids_linear (MeshBase &mesh) |
static void | set_interface_node_processor_ids_BFS (MeshBase &mesh) |
static void | set_interface_node_processor_ids_petscpartitioner (MeshBase &mesh) |
Public Attributes | |
std::vector< std::set< subdomain_id_type > > | chunks |
Protected Member Functions | |
virtual void | _do_partition (MeshBase &mesh, const unsigned int n) override |
void | single_partition (MeshBase &mesh) |
void | single_partition_range (MeshBase::element_iterator it, MeshBase::element_iterator end) |
virtual void | _do_repartition (MeshBase &mesh, const unsigned int n) |
virtual void | _find_global_index_by_pid_map (const MeshBase &mesh) |
virtual void | build_graph (const MeshBase &mesh) |
void | assign_partitioning (const MeshBase &mesh, const std::vector< dof_id_type > &parts) |
Protected Attributes | |
std::unique_ptr< Partitioner > | _internal_partitioner |
ErrorVector * | _weights |
std::unordered_map< dof_id_type, dof_id_type > | _global_index_by_pid_map |
std::vector< dof_id_type > | _n_active_elem_on_proc |
std::vector< std::vector< dof_id_type > > | _dual_graph |
std::vector< Elem * > | _local_id_to_elem |
Static Protected Attributes | |
static const dof_id_type | communication_blocksize = 1000000 |
Independently partitions chunks of subdomains and combines the results.
The SubdomainPartitioner
partitions the elements in "chunks" of user-specified subdomain ids. Once all the chunks are partitioned, the overall mesh partitioning is simply the union of the chunk partitionings. For example, if the "chunks" vector is given by: chunks[0] = {1, 2, 4} chunks[1] = {3, 7, 8} chunks[2] = {5, 6} then we will call the internal Partitioner three times, once for subdomains 1, 2, and 4, once for subdomains 3, 7, and 8, and once for subdomains 5 and 6.
Definition at line 55 of file subdomain_partitioner.h.
libMesh::SubdomainPartitioner::SubdomainPartitioner | ( | ) |
Constructors. The default ctor initializes the internal Partitioner object to a MetisPartitioner so the class is usable, although this type can be customized later.
Definition at line 29 of file subdomain_partitioner.C.
libMesh::SubdomainPartitioner::SubdomainPartitioner | ( | const SubdomainPartitioner & | other | ) |
Definition at line 34 of file subdomain_partitioner.C.
|
default |
Move ctor, move assignment operator, and destructor are all explicitly defaulted for this class.
|
virtualdefault |
|
overrideprotectedvirtual |
Partition the MeshBase
into n
subdomains.
Implements libMesh::Partitioner.
Definition at line 41 of file subdomain_partitioner.C.
References _internal_partitioner, chunks, end, mesh, and libMesh::Partitioner::single_partition().
|
inlineprotectedvirtualinherited |
This is the actual re-partitioning method which can be overridden in derived classes.
Reimplemented in libMesh::ParmetisPartitioner.
Definition at line 237 of file partitioner.h.
References libMesh::Partitioner::_do_partition().
Referenced by libMesh::Partitioner::repartition().
|
protectedvirtualinherited |
Construct contiguous global indices for the current partitioning. The global indices are ordered part-by-part
Definition at line 907 of file partitioner.C.
References libMesh::Partitioner::_global_index_by_pid_map, libMesh::Partitioner::_n_active_elem_on_proc, libMesh::as_range(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshCommunication::find_local_indices(), mesh, and libMesh::Parallel::sync_dofobject_data_by_id().
Referenced by libMesh::Partitioner::build_graph().
|
protectedinherited |
Assign the computed partitioning to the mesh.
Definition at line 1113 of file partitioner.C.
References libMesh::Partitioner::_global_index_by_pid_map, libMesh::Partitioner::_n_active_elem_on_proc, data, mesh, and libMesh::Parallel::pull_parallel_vector_data().
|
inlinevirtualinherited |
Attach weights that can be used for partitioning. This ErrorVector should be exactly the same on every processor and should have mesh->max_elem_id() entries.
Reimplemented in libMesh::MetisPartitioner.
Definition at line 203 of file partitioner.h.
|
protectedvirtualinherited |
Build a dual graph for partitioner
Reimplemented in libMesh::ParmetisPartitioner.
Definition at line 950 of file partitioner.C.
References libMesh::Partitioner::_dual_graph, libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::Partitioner::_global_index_by_pid_map, libMesh::Partitioner::_local_id_to_elem, libMesh::Partitioner::_n_active_elem_on_proc, libMesh::Elem::active(), libMesh::as_range(), libMesh::DofObject::id(), mesh, and libMesh::Elem::neighbor_ptr().
|
inlineoverridevirtual |
Implements libMesh::Partitioner.
Definition at line 84 of file subdomain_partitioner.h.
|
inline |
Get a reference to the Partitioner used internally by the SubdomainPartitioner.
Definition at line 111 of file subdomain_partitioner.h.
References _internal_partitioner.
|
delete |
This class contains a unique_ptr member, so it can't be default copy assigned.
|
default |
|
virtualinherited |
Partitions the MeshBase
into n
parts by setting processor_id() on Nodes and Elems.
Definition at line 57 of file partitioner.C.
References libMesh::Partitioner::_do_partition(), libMesh::MeshTools::libmesh_assert_valid_remote_elems(), mesh, std::min(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Partitioner::set_parent_processor_ids(), and libMesh::Partitioner::single_partition().
Referenced by libMesh::ParmetisPartitioner::_do_repartition(), and libMesh::Partitioner::partition().
|
virtualinherited |
Partitions the MeshBase
into mesh.n_processors()
by setting processor_id() on Nodes and Elems.
Definition at line 50 of file partitioner.C.
References mesh, and libMesh::Partitioner::partition().
|
inlinevirtualinherited |
Partitions elements in the range (it, end) into n parts. The mesh from which the iterators are created must also be passed in, since it is a parallel object and has other useful information in it.
Although partition_range() is part of the public Partitioner interface, it should not generally be called by applications. Its main purpose is to support the SubdomainPartitioner, which uses it internally to individually partition ranges of elements before combining them into the final partitioning. Most of the time, the protected _do_partition() function is implemented in terms of partition_range() by passing a range which includes all the elements of the Mesh.
Reimplemented in libMesh::CentroidPartitioner, libMesh::SFCPartitioner, libMesh::MappedSubdomainPartitioner, libMesh::LinearPartitioner, and libMesh::MetisPartitioner.
Definition at line 127 of file partitioner.h.
|
staticinherited |
These functions assign processor IDs to newly-created elements (in parallel) which are currently assigned to processor 0.
Definition at line 187 of file partitioner.C.
References mesh.
Referenced by libMesh::Partitioner::partition(), and libMesh::Partitioner::repartition().
|
staticinherited |
Definition at line 194 of file partitioner.C.
References libMesh::as_range(), libMesh::MeshTools::create_bounding_box(), end, libMesh::MeshCommunication::find_global_indices(), mesh, and libMesh::MeshTools::n_elem().
|
staticinherited |
On the partitioning interface, a surface is shared by two and only two processors. Try to find which pair of processors corresponds to which surfaces, and store their nodes.
Definition at line 421 of file partitioner.C.
References libMesh::DofObject::invalid_processor_id, std::max(), mesh, std::min(), and n_nodes.
Referenced by libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), and libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner().
|
inherited |
Repartitions the MeshBase
into n
parts. (Some partitioning algorithms can repartition more efficiently than computing a new partitioning from scratch.) The default behavior is to simply call this->partition(mesh,n).
Definition at line 124 of file partitioner.C.
References libMesh::Partitioner::_do_repartition(), mesh, std::min(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Partitioner::set_parent_processor_ids(), and libMesh::Partitioner::single_partition().
Referenced by libMesh::Partitioner::repartition().
|
inherited |
Repartitions the MeshBase
into mesh.n_processors()
parts. This is required since some partitioning algorithms can repartition more efficiently than computing a new partitioning from scratch.
Definition at line 117 of file partitioner.C.
References mesh, and libMesh::Partitioner::repartition().
|
staticinherited |
Nodes on the partitioning interface is clustered into two groups BFS (Breadth First Search)scheme for per pair of processors
Definition at line 498 of file partitioner.C.
References libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::MeshTools::find_nodal_neighbors(), mesh, and libMesh::Partitioner::processor_pairs_to_interface_nodes().
Referenced by libMesh::Partitioner::set_node_processor_ids().
|
staticinherited |
Nodes on the partitioning interface is linearly assigned to each pair of processors
Definition at line 474 of file partitioner.C.
References mesh, and libMesh::Partitioner::processor_pairs_to_interface_nodes().
Referenced by libMesh::Partitioner::set_node_processor_ids().
|
staticinherited |
Nodes on the partitioning interface is partitioned into two groups using a PETSc partitioner for each pair of processors
Definition at line 575 of file partitioner.C.
References libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::MeshTools::find_nodal_neighbors(), libMesh::libmesh_ignore(), mesh, and libMesh::Partitioner::processor_pairs_to_interface_nodes().
Referenced by libMesh::Partitioner::set_node_processor_ids().
|
staticinherited |
This function is called after partitioning to set the processor IDs for the nodes. By definition, a Node's processor ID is the minimum processor ID for all of the elements which share the node.
Definition at line 679 of file partitioner.C.
References libMesh::as_range(), libMesh::Node::choose_processor_id(), libMesh::DofObject::invalid_processor_id, mesh, libMesh::MeshTools::n_elem(), libMesh::on_command_line(), libMesh::DofObject::processor_id(), libMesh::Parallel::pull_parallel_vector_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), and libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner().
Referenced by libMesh::MeshRefinement::_refine_elements(), libMesh::UnstructuredMesh::all_first_order(), libMesh::Partitioner::partition(), libMesh::XdrIO::read(), libMesh::Partitioner::repartition(), and libMesh::BoundaryInfo::sync().
|
staticinherited |
This function is called after partitioning to set the processor IDs for the inactive parent elements. A parent's processor ID is the same as its first child.
Definition at line 268 of file partitioner.C.
References libMesh::as_range(), libMesh::Elem::child_ref_range(), libMesh::Partitioner::communication_blocksize, libMesh::DofObject::invalid_processor_id, libMesh::DofObject::invalidate_processor_id(), libMesh::libmesh_ignore(), mesh, std::min(), libMesh::MeshTools::n_elem(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), and libMesh::Elem::total_family_tree().
Referenced by libMesh::Partitioner::partition(), and libMesh::Partitioner::repartition().
|
protectedinherited |
Trivially "partitions" the mesh for one processor. Simply loops through the elements and assigns all of them to processor 0. Is is provided as a separate function so that derived classes may use it without reimplementing it.
Definition at line 159 of file partitioner.C.
References libMesh::MeshBase::elements_begin(), mesh, and libMesh::Partitioner::single_partition_range().
Referenced by _do_partition(), libMesh::Partitioner::partition(), and libMesh::Partitioner::repartition().
|
protectedinherited |
Slightly generalized version of single_partition which acts on a range of elements defined by the pair of iterators (it, end).
Definition at line 172 of file partitioner.C.
References libMesh::as_range(), and end.
Referenced by libMesh::LinearPartitioner::partition_range(), libMesh::MetisPartitioner::partition_range(), libMesh::MappedSubdomainPartitioner::partition_range(), libMesh::SFCPartitioner::partition_range(), libMesh::CentroidPartitioner::partition_range(), and libMesh::Partitioner::single_partition().
|
protectedinherited |
A dual graph corresponds to the mesh, and it is typically used in paritioner. A vertex represents an element, and its neighbors are the element neighbors.
Definition at line 288 of file partitioner.h.
Referenced by libMesh::Partitioner::build_graph().
|
protectedinherited |
Maps active element ids into a contiguous range, as needed by parallel partitioner.
Definition at line 272 of file partitioner.h.
Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::Partitioner::assign_partitioning(), and libMesh::Partitioner::build_graph().
|
protected |
The internal Partitioner we use. Public access via the internal_partitioner() member function.
Definition at line 118 of file subdomain_partitioner.h.
Referenced by _do_partition(), and internal_partitioner().
|
protectedinherited |
Definition at line 291 of file partitioner.h.
Referenced by libMesh::Partitioner::build_graph().
|
protectedinherited |
The number of active elements on each processor.
Definition at line 281 of file partitioner.h.
Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::Partitioner::assign_partitioning(), and libMesh::Partitioner::build_graph().
|
protectedinherited |
The weights that might be used for partitioning.
Definition at line 267 of file partitioner.h.
Referenced by libMesh::MetisPartitioner::attach_weights(), and libMesh::MetisPartitioner::partition_range().
std::vector<std::set<subdomain_id_type> > libMesh::SubdomainPartitioner::chunks |
Each entry of "chunks" represents a set of subdomains which are to be partitioned together. The internal Partitioner will be called once for each entry of chunks, and the resulting partitioning will simply be the union of all these partitionings.
Definition at line 95 of file subdomain_partitioner.h.
Referenced by _do_partition().
|
staticprotectedinherited |
The blocksize to use when doing blocked parallel communication. This limits the maximum vector size which can be used in a single communication step.
Definition at line 244 of file partitioner.h.
Referenced by libMesh::Partitioner::set_parent_processor_ids().