libMesh
|
Partitions the Mesh based on the locations of element vertex averages. More...
#include <centroid_partitioner.h>
Public Types | |
enum | CentroidSortMethod { X =0, Y, Z, RADIAL, INVALID_METHOD } |
A typedef which controls the sorting method used for ordering the vertex averages. More... | |
Public Member Functions | |
CentroidPartitioner (const CentroidSortMethod sm=X) | |
Constructor. More... | |
CentroidPartitioner (const CentroidPartitioner &)=default | |
Copy/move ctor, copy/move assignment operator, and destructor are all explicitly defaulted for this class. More... | |
CentroidPartitioner (CentroidPartitioner &&)=default | |
CentroidPartitioner & | operator= (const CentroidPartitioner &)=default |
CentroidPartitioner & | operator= (CentroidPartitioner &&)=default |
virtual | ~CentroidPartitioner ()=default |
virtual PartitionerType | type () const override |
virtual std::unique_ptr< Partitioner > | clone () const override |
CentroidSortMethod | sort_method () const |
Getter for the current sorting method. More... | |
void | set_sort_method (const CentroidSortMethod sm) |
Setter for the current sorting method. More... | |
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). More... | |
virtual void | partition (MeshBase &mesh, const unsigned int n) |
Partitions the MeshBase into n parts by setting processor_id() on Nodes and Elems. More... | |
virtual void | partition (MeshBase &mesh) |
Partitions the MeshBase into mesh.n_processors() by setting processor_id() on Nodes and Elems. More... | |
void | repartition (MeshBase &mesh, const unsigned int n) |
Repartitions the MeshBase into n parts. More... | |
void | repartition (MeshBase &mesh) |
Repartitions the MeshBase into mesh.n_processors() parts. More... | |
virtual void | attach_weights (ErrorVector *) |
Attach weights that can be used for partitioning. More... | |
Static Public Member Functions | |
static std::unique_ptr< Partitioner > | build (const PartitionerType solver_package) |
Builds a Partitioner of the type specified by partitioner_type . More... | |
static void | partition_unpartitioned_elements (MeshBase &mesh) |
These functions assign processor IDs to newly-created elements (in parallel) which are currently assigned to processor 0. More... | |
static void | partition_unpartitioned_elements (MeshBase &mesh, const unsigned int n) |
static void | set_parent_processor_ids (MeshBase &mesh) |
This function is called after partitioning to set the processor IDs for the inactive parent elements. More... | |
static void | set_node_processor_ids (MeshBase &mesh) |
This function is called after partitioning to set the processor IDs for the nodes. More... | |
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) |
On the partitioning interface, a surface is shared by two and only two processors. More... | |
static void | set_interface_node_processor_ids_linear (MeshBase &mesh) |
Nodes on the partitioning interface is linearly assigned to each pair of processors. More... | |
static void | set_interface_node_processor_ids_BFS (MeshBase &mesh) |
Nodes on the partitioning interface is clustered into two groups BFS (Breadth First Search)scheme for per pair of processors. More... | |
static void | set_interface_node_processor_ids_petscpartitioner (MeshBase &mesh) |
Nodes on the partitioning interface is partitioned into two groups using a PETSc partitioner for each pair of processors. More... | |
Protected Member Functions | |
virtual void | _do_partition (MeshBase &mesh, const unsigned int n) override |
Partitions the mesh into n subdomains. More... | |
bool | single_partition (MeshBase &mesh) |
Trivially "partitions" the mesh for one processor. More... | |
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 pair of iterators (it, end). More... | |
virtual void | _do_repartition (MeshBase &mesh, const unsigned int n) |
This is the actual re-partitioning method which can be overridden in derived classes. More... | |
virtual void | _find_global_index_by_pid_map (const MeshBase &mesh) |
Construct contiguous global indices for the current partitioning. More... | |
virtual void | build_graph (const MeshBase &mesh) |
Build a dual graph for partitioner. More... | |
void | assign_partitioning (MeshBase &mesh, const std::vector< dof_id_type > &parts) |
Assign the computed partitioning to the mesh. More... | |
Protected Attributes | |
ErrorVector * | _weights |
The weights that might be used for partitioning. More... | |
std::unordered_map< dof_id_type, dof_id_type > | _global_index_by_pid_map |
Maps active element ids into a contiguous range, as needed by parallel partitioner. More... | |
std::vector< dof_id_type > | _n_active_elem_on_proc |
The number of active elements on each processor. More... | |
std::vector< std::vector< dof_id_type > > | _dual_graph |
A dual graph corresponds to the mesh, and it is typically used in paritioner. More... | |
std::vector< Elem * > | _local_id_to_elem |
Static Protected Attributes | |
static const dof_id_type | communication_blocksize |
The blocksize to use when doing blocked parallel communication. More... | |
Private Member Functions | |
void | compute_vertex_avgs (MeshBase::element_iterator it, MeshBase::element_iterator end) |
Computes a list of element vertex averages for the mesh. More... | |
Static Private Member Functions | |
static bool | sort_x (const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs) |
Helper function which sorts by the vertex average's x-coordinate in the internal std::sort call. More... | |
static bool | sort_y (const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs) |
Helper function which sorts by the vertex average's y-coordinate in the internal std::sort call. More... | |
static bool | sort_z (const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs) |
Helper function which sorts by the vertex average's z-coordinate in the internal std::sort call. More... | |
static bool | sort_radial (const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs) |
Helper function which sorts by the vertex averages's distance from the origin in the internal std::sort call. More... | |
Private Attributes | |
CentroidSortMethod | _sort_method |
Flag indicating the type of sort method we are using. More... | |
std::vector< std::pair< Point, Elem * > > | _elem_vertex_avgs |
Vector which holds pairs of vertex averages and their respective element pointers. More... | |
Partitions the Mesh based on the locations of element vertex averages.
You must define what you mean by "less than" for the list of element vertex averages, e.g. if you only care about distance in the z-direction, you would define "less than" differently than if you cared about radial distance.
Definition at line 53 of file centroid_partitioner.h.
A typedef which controls the sorting method used for ordering the vertex averages.
If e.g. X
is chosen, then the vertex averages will be sorted according to their x-coordinate.
Enumerator | |
---|---|
X | |
Y | |
Z | |
RADIAL | |
INVALID_METHOD |
Definition at line 62 of file centroid_partitioner.h.
|
inlineexplicit |
Constructor.
Takes the CentroidSortMethod
to use, which defaults to X
ordering.
Definition at line 73 of file centroid_partitioner.h.
|
default |
Copy/move ctor, copy/move assignment operator, and destructor are all explicitly defaulted for this class.
|
default |
|
virtualdefault |
|
overrideprotectedvirtual |
Partitions the mesh into n subdomains.
Implements libMesh::Partitioner.
Definition at line 129 of file centroid_partitioner.C.
References mesh, and partition_range().
|
inlineprotectedvirtualinherited |
This is the actual re-partitioning method which can be overridden in derived classes.
Reimplemented in libMesh::ParmetisPartitioner.
Definition at line 251 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 1067 of file partitioner.C.
References libMesh::Partitioner::_global_index_by_pid_map, libMesh::Partitioner::_n_active_elem_on_proc, TIMPI::Communicator::allgather(), libMesh::ParallelObject::comm(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshCommunication::find_local_indices(), libMesh::make_range(), mesh, libMesh::MeshBase::n_active_local_elem(), libMesh::ParallelObject::n_processors(), 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 1334 of file partitioner.C.
References libMesh::Partitioner::_global_index_by_pid_map, libMesh::Partitioner::_n_active_elem_on_proc, libMesh::ParallelObject::comm(), libMesh::libmesh_assert(), libMesh::make_range(), mesh, libMesh::MeshBase::n_active_local_elem(), libMesh::MeshBase::n_partitions(), libMesh::ParallelObject::n_processors(), and libMesh::ParallelObject::processor_id().
|
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 213 of file partitioner.h.
|
staticinherited |
Builds a Partitioner
of the type specified by partitioner_type
.
Definition at line 158 of file partitioner.C.
References libMesh::CENTROID_PARTITIONER, libMesh::Utility::enum_to_string(), libMesh::HILBERT_SFC_PARTITIONER, libMesh::LINEAR_PARTITIONER, libMesh::MAPPED_SUBDOMAIN_PARTITIONER, libMesh::METIS_PARTITIONER, libMesh::MORTON_SFC_PARTITIONER, libMesh::PARMETIS_PARTITIONER, libMesh::SFC_PARTITIONER, and libMesh::SUBDOMAIN_PARTITIONER.
Referenced by libMesh::DistributedMesh::DistributedMesh(), libMesh::ReplicatedMesh::ReplicatedMesh(), PartitionerTest< PartitionerSubclass, MeshClass >::testBuild(), and MeshDeletionsTest::testDeleteElem().
|
protectedvirtualinherited |
Build a dual graph for partitioner.
Reimplemented in libMesh::ParmetisPartitioner.
Definition at line 1111 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::as_range(), libMesh::MeshBase::get_constraint_rows(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::make_range(), mesh, libMesh::MeshBase::n_active_local_elem(), and libMesh::ParallelObject::processor_id().
|
inlineoverridevirtual |
Implements libMesh::Partitioner.
Definition at line 90 of file centroid_partitioner.h.
|
private |
Computes a list of element vertex averages for the mesh.
Definition at line 140 of file centroid_partitioner.C.
References _elem_vertex_avgs, and libMesh::as_range().
Referenced by partition_range().
|
default |
|
default |
Partitions the MeshBase
into n
parts by setting processor_id() on Nodes and Elems.
Definition at line 195 of file partitioner.C.
References libMesh::Partitioner::_do_partition(), libMesh::ParallelObject::comm(), libMesh::MeshTools::libmesh_assert_valid_remote_elems(), mesh, libMesh::MeshBase::n_active_elem(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::MeshBase::redistribute(), libMesh::MeshBase::set_n_partitions(), libMesh::Partitioner::set_node_processor_ids(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::Partitioner::single_partition(), and libMesh::MeshBase::update_post_partitioning().
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 188 of file partitioner.C.
References mesh, libMesh::ParallelObject::n_processors(), and libMesh::Partitioner::partition().
|
overridevirtual |
Called by the SubdomainPartitioner to partition elements in the range (it, end).
Reimplemented from libMesh::Partitioner.
Definition at line 37 of file centroid_partitioner.C.
References _elem_vertex_avgs, compute_vertex_avgs(), libMesh::index_range(), mesh, libMesh::DofObject::processor_id(), RADIAL, libMesh::Partitioner::single_partition_range(), sort_method(), sort_radial(), sort_x(), sort_y(), sort_z(), X, Y, and Z.
Referenced by _do_partition().
|
staticinherited |
These functions assign processor IDs to newly-created elements (in parallel) which are currently assigned to processor 0.
Definition at line 344 of file partitioner.C.
References mesh, and libMesh::ParallelObject::n_processors().
Referenced by libMesh::Partitioner::partition(), and libMesh::Partitioner::repartition().
|
staticinherited |
Definition at line 351 of file partitioner.C.
References libMesh::as_range(), libMesh::ParallelObject::comm(), libMesh::MeshTools::create_bounding_box(), distance(), libMesh::MeshCommunication::find_global_indices(), libMesh::make_range(), mesh, libMesh::MeshTools::n_elem(), and libMesh::ParallelObject::n_processors().
|
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 578 of file partitioner.C.
References libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), mesh, 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().
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 262 of file partitioner.C.
References libMesh::Partitioner::_do_repartition(), mesh, libMesh::MeshBase::n_active_elem(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::MeshBase::set_n_partitions(), 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 255 of file partitioner.C.
References mesh, libMesh::ParallelObject::n_processors(), 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 656 of file partitioner.C.
References libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::ParallelObject::comm(), libMesh::MeshTools::find_nodal_neighbors(), mesh, libMesh::MeshBase::node_ref(), libMesh::DofObject::processor_id(), 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 631 of file partitioner.C.
References libMesh::ParallelObject::comm(), mesh, libMesh::MeshBase::node_ref(), libMesh::DofObject::processor_id(), 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 737 of file partitioner.C.
References libMesh::MeshTools::build_nodes_to_elem_map(), libMesh::ParallelObject::comm(), libMesh::MeshTools::find_nodal_neighbors(), libMesh::is, libMesh::libmesh_ignore(), mesh, libMesh::MeshBase::node_ref(), libMesh::DofObject::processor_id(), 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 851 of file partitioner.C.
References libMesh::as_range(), libMesh::Node::choose_processor_id(), libMesh::ParallelObject::comm(), libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), mesh, libMesh::MeshTools::n_elem(), libMesh::MeshTools::n_levels(), libMesh::MeshBase::node_ref(), libMesh::on_command_line(), libMesh::DofObject::processor_id(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), and libMesh::Parallel::sync_node_data_by_element_id().
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 425 of file partitioner.C.
References libMesh::as_range(), libMesh::Elem::child_ref_range(), libMesh::ParallelObject::comm(), libMesh::Partitioner::communication_blocksize, libMesh::DofObject::invalid_processor_id, libMesh::DofObject::invalidate_processor_id(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::MeshBase::max_elem_id(), mesh, TIMPI::Communicator::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().
|
inline |
Setter for the current sorting method.
Definition at line 103 of file centroid_partitioner.h.
References _sort_method.
|
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.
Returns true
iff any processor id was changed.
Definition at line 297 of file partitioner.C.
References libMesh::ParallelObject::comm(), TIMPI::Communicator::max(), mesh, libMesh::MeshBase::redistribute(), and libMesh::Partitioner::single_partition_range().
Referenced by libMesh::SubdomainPartitioner::_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).
Returns true
iff any processor id was changed.
Definition at line 319 of file partitioner.C.
References libMesh::as_range(), and libMesh::DofObject::processor_id().
Referenced by libMesh::LinearPartitioner::partition_range(), libMesh::MetisPartitioner::partition_range(), libMesh::SFCPartitioner::partition_range(), libMesh::MappedSubdomainPartitioner::partition_range(), partition_range(), and libMesh::Partitioner::single_partition().
|
inline |
Getter for the current sorting method.
Definition at line 98 of file centroid_partitioner.h.
References _sort_method.
Referenced by partition_range().
|
staticprivate |
Helper function which sorts by the vertex averages's distance from the origin in the internal std::sort call.
Definition at line 179 of file centroid_partitioner.C.
Referenced by partition_range().
|
staticprivate |
Helper function which sorts by the vertex average's x-coordinate in the internal std::sort call.
Definition at line 152 of file centroid_partitioner.C.
Referenced by partition_range().
|
staticprivate |
Helper function which sorts by the vertex average's y-coordinate in the internal std::sort call.
Definition at line 161 of file centroid_partitioner.C.
Referenced by partition_range().
|
staticprivate |
Helper function which sorts by the vertex average's z-coordinate in the internal std::sort call.
Definition at line 171 of file centroid_partitioner.C.
Referenced by partition_range().
|
overridevirtual |
Reimplemented from libMesh::Partitioner.
Definition at line 31 of file centroid_partitioner.C.
References libMesh::CENTROID_PARTITIONER.
|
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 302 of file partitioner.h.
Referenced by libMesh::Partitioner::build_graph().
Vector which holds pairs of vertex averages and their respective element pointers.
Definition at line 166 of file centroid_partitioner.h.
Referenced by compute_vertex_avgs(), and partition_range().
|
protectedinherited |
Maps active element ids into a contiguous range, as needed by parallel partitioner.
Definition at line 286 of file partitioner.h.
Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::Partitioner::assign_partitioning(), and libMesh::Partitioner::build_graph().
|
protectedinherited |
Definition at line 305 of file partitioner.h.
Referenced by libMesh::Partitioner::build_graph().
|
protectedinherited |
The number of active elements on each processor.
Definition at line 295 of file partitioner.h.
Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::Partitioner::assign_partitioning(), and libMesh::Partitioner::build_graph().
|
private |
Flag indicating the type of sort method we are using.
Definition at line 160 of file centroid_partitioner.h.
Referenced by set_sort_method(), and sort_method().
|
protectedinherited |
The weights that might be used for partitioning.
Definition at line 281 of file partitioner.h.
Referenced by libMesh::MetisPartitioner::attach_weights(), and libMesh::MetisPartitioner::partition_range().
|
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 258 of file partitioner.h.
Referenced by libMesh::Partitioner::set_parent_processor_ids().