libMesh
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
libMesh::ParmetisPartitioner Class Reference

The ParmetisPartitioner uses the Parmetis graph partitioner to partition the elements. More...

#include <parmetis_partitioner.h>

Inheritance diagram for libMesh::ParmetisPartitioner:
[legend]

Public Member Functions

 ParmetisPartitioner ()
 Default and copy ctors. More...
 
 ParmetisPartitioner (const ParmetisPartitioner &other)
 
ParmetisPartitioneroperator= (const ParmetisPartitioner &)=delete
 This class contains a unique_ptr member, so it can't be default copy assigned. More...
 
 ParmetisPartitioner (ParmetisPartitioner &&)=default
 Move ctor, move assignment operator, and destructor are all explicitly inline-defaulted for this class. More...
 
ParmetisPartitioneroperator= (ParmetisPartitioner &&)=default
 
virtual ~ParmetisPartitioner ()
 The destructor is out-of-line-defaulted to play nice with forward declarations. More...
 
virtual std::unique_ptr< Partitionerclone () const override
 
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...
 
virtual void partition_range (MeshBase &, MeshBase::element_iterator, MeshBase::element_iterator, const unsigned int)
 Partitions elements in the range (it, end) into n parts. 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 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_repartition (MeshBase &mesh, const unsigned int n) override
 Parmetis can handle dynamically repartitioning a mesh such that the redistribution costs are minimized. More...
 
virtual void _do_partition (MeshBase &mesh, const unsigned int n) override
 Partition the MeshBase into n subdomains. More...
 
virtual void build_graph (const MeshBase &mesh) override
 Build the graph. More...
 
void single_partition (MeshBase &mesh)
 Trivially "partitions" the mesh for one processor. More...
 
void 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 _find_global_index_by_pid_map (const MeshBase &mesh)
 Construct contiguous global indices for the current partitioning. More...
 
void assign_partitioning (const 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 initialize (const MeshBase &mesh, const unsigned int n_sbdmns)
 Initialize data structures. More...
 

Private Attributes

std::unique_ptr< ParmetisHelper_pmetis
 Pointer to the Parmetis-specific data structures. More...
 

Detailed Description

The ParmetisPartitioner uses the Parmetis graph partitioner to partition the elements.

Author
Benjamin S. Kirk
Date
2003 Partitioner which provides an interface to ParMETIS.

Definition at line 47 of file parmetis_partitioner.h.

Constructor & Destructor Documentation

◆ ParmetisPartitioner() [1/3]

libMesh::ParmetisPartitioner::ParmetisPartitioner ( )

Default and copy ctors.

◆ ParmetisPartitioner() [2/3]

libMesh::ParmetisPartitioner::ParmetisPartitioner ( const ParmetisPartitioner other)

◆ ParmetisPartitioner() [3/3]

libMesh::ParmetisPartitioner::ParmetisPartitioner ( ParmetisPartitioner &&  )
default

Move ctor, move assignment operator, and destructor are all explicitly inline-defaulted for this class.

◆ ~ParmetisPartitioner()

virtual libMesh::ParmetisPartitioner::~ParmetisPartitioner ( )
virtual

The destructor is out-of-line-defaulted to play nice with forward declarations.

Member Function Documentation

◆ _do_partition()

virtual void libMesh::ParmetisPartitioner::_do_partition ( MeshBase mesh,
const unsigned int  n 
)
overrideprotectedvirtual

Partition the MeshBase into n subdomains.

Implements libMesh::Partitioner.

◆ _do_repartition()

virtual void libMesh::ParmetisPartitioner::_do_repartition ( MeshBase mesh,
const unsigned int  n 
)
overrideprotectedvirtual

Parmetis can handle dynamically repartitioning a mesh such that the redistribution costs are minimized.

This method takes a previously partitioned mesh (which may have then been adaptively refined) and repartitions it.

Reimplemented from libMesh::Partitioner.

◆ _find_global_index_by_pid_map()

virtual void libMesh::Partitioner::_find_global_index_by_pid_map ( const MeshBase mesh)
protectedvirtualinherited

Construct contiguous global indices for the current partitioning.

The global indices are ordered part-by-part

◆ assign_partitioning()

void libMesh::Partitioner::assign_partitioning ( const MeshBase mesh,
const std::vector< dof_id_type > &  parts 
)
protectedinherited

Assign the computed partitioning to the mesh.

◆ attach_weights()

virtual void libMesh::Partitioner::attach_weights ( ErrorVector )
virtualinherited

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.

203 { libmesh_not_implemented(); }

◆ build_graph()

virtual void libMesh::ParmetisPartitioner::build_graph ( const MeshBase mesh)
overrideprotectedvirtual

Build the graph.

Reimplemented from libMesh::Partitioner.

◆ clone()

virtual std::unique_ptr<Partitioner> libMesh::ParmetisPartitioner::clone ( ) const
overridevirtual
Returns
A copy of this partitioner wrapped in a smart pointer.

Implements libMesh::Partitioner.

Definition at line 79 of file parmetis_partitioner.h.

80  {
81  return libmesh_make_unique<ParmetisPartitioner>(*this);
82  }

◆ initialize()

void libMesh::ParmetisPartitioner::initialize ( const MeshBase mesh,
const unsigned int  n_sbdmns 
)
private

Initialize data structures.

◆ operator=() [1/2]

ParmetisPartitioner& libMesh::ParmetisPartitioner::operator= ( const ParmetisPartitioner )
delete

This class contains a unique_ptr member, so it can't be default copy assigned.

◆ operator=() [2/2]

ParmetisPartitioner& libMesh::ParmetisPartitioner::operator= ( ParmetisPartitioner &&  )
default

◆ partition() [1/2]

virtual void libMesh::Partitioner::partition ( MeshBase mesh,
const unsigned int  n 
)
virtualinherited

Partitions the MeshBase into n parts by setting processor_id() on Nodes and Elems.

Note
If you are implementing a new type of Partitioner, you most likely do not want to override the partition() function, see instead the protected virtual _do_partition() method below. The partition() function is responsible for doing a lot of libmesh-internals-specific setup and finalization before and after the _do_partition() function is called. The only responsibility of the _do_partition() function, on the other hand, is to set the processor IDs of the elements according to a specific partitioning algorithm. See, e.g. MetisPartitioner for an example.

◆ partition() [2/2]

virtual void libMesh::Partitioner::partition ( MeshBase mesh)
virtualinherited

Partitions the MeshBase into mesh.n_processors() by setting processor_id() on Nodes and Elems.

Note
If you are implementing a new type of Partitioner, you most likely do not want to override the partition() function, see instead the protected virtual _do_partition() method below. The partition() function is responsible for doing a lot of libmesh-internals-specific setup and finalization before and after the _do_partition() function is called. The only responsibility of the _do_partition() function, on the other hand, is to set the processor IDs of the elements according to a specific partitioning algorithm. See, e.g. MetisPartitioner for an example.

◆ partition_range()

virtual void libMesh::Partitioner::partition_range ( MeshBase ,
MeshBase::element_iterator  ,
MeshBase::element_iterator  ,
const unsigned int   
)
virtualinherited

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.

131  { libmesh_not_implemented(); }

◆ partition_unpartitioned_elements() [1/2]

static void libMesh::Partitioner::partition_unpartitioned_elements ( MeshBase mesh)
staticinherited

These functions assign processor IDs to newly-created elements (in parallel) which are currently assigned to processor 0.

◆ partition_unpartitioned_elements() [2/2]

static void libMesh::Partitioner::partition_unpartitioned_elements ( MeshBase mesh,
const unsigned int  n 
)
staticinherited

◆ processor_pairs_to_interface_nodes()

static void libMesh::Partitioner::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 
)
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.

◆ repartition() [1/2]

void libMesh::Partitioner::repartition ( MeshBase mesh,
const unsigned int  n 
)
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).

◆ repartition() [2/2]

void libMesh::Partitioner::repartition ( MeshBase mesh)
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.

◆ set_interface_node_processor_ids_BFS()

static void libMesh::Partitioner::set_interface_node_processor_ids_BFS ( MeshBase mesh)
staticinherited

Nodes on the partitioning interface is clustered into two groups BFS (Breadth First Search)scheme for per pair of processors.

◆ set_interface_node_processor_ids_linear()

static void libMesh::Partitioner::set_interface_node_processor_ids_linear ( MeshBase mesh)
staticinherited

Nodes on the partitioning interface is linearly assigned to each pair of processors.

◆ set_interface_node_processor_ids_petscpartitioner()

static void libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner ( MeshBase mesh)
staticinherited

Nodes on the partitioning interface is partitioned into two groups using a PETSc partitioner for each pair of processors.

◆ set_node_processor_ids()

static void libMesh::Partitioner::set_node_processor_ids ( MeshBase mesh)
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.

◆ set_parent_processor_ids()

static void libMesh::Partitioner::set_parent_processor_ids ( MeshBase mesh)
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.

◆ single_partition()

void libMesh::Partitioner::single_partition ( MeshBase mesh)
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.

◆ single_partition_range()

void libMesh::Partitioner::single_partition_range ( MeshBase::element_iterator  it,
MeshBase::element_iterator  end 
)
protectedinherited

Slightly generalized version of single_partition which acts on a range of elements defined by the pair of iterators (it, end).

Member Data Documentation

◆ _dual_graph

std::vector<std::vector<dof_id_type> > libMesh::Partitioner::_dual_graph
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.

◆ _global_index_by_pid_map

std::unordered_map<dof_id_type, dof_id_type> libMesh::Partitioner::_global_index_by_pid_map
protectedinherited

Maps active element ids into a contiguous range, as needed by parallel partitioner.

Definition at line 272 of file partitioner.h.

◆ _local_id_to_elem

std::vector<Elem *> libMesh::Partitioner::_local_id_to_elem
protectedinherited

Definition at line 291 of file partitioner.h.

◆ _n_active_elem_on_proc

std::vector<dof_id_type> libMesh::Partitioner::_n_active_elem_on_proc
protectedinherited

The number of active elements on each processor.

Note
ParMETIS requires that each processor have some active elements; it will abort if any processor passes a nullptr _part array.

Definition at line 281 of file partitioner.h.

◆ _pmetis

std::unique_ptr<ParmetisHelper> libMesh::ParmetisPartitioner::_pmetis
private

Pointer to the Parmetis-specific data structures.

Lets us avoid including parmetis.h here.

Definition at line 122 of file parmetis_partitioner.h.

◆ _weights

ErrorVector* libMesh::Partitioner::_weights
protectedinherited

The weights that might be used for partitioning.

Definition at line 267 of file partitioner.h.

Referenced by libMesh::MetisPartitioner::attach_weights().

◆ communication_blocksize

const dof_id_type libMesh::Partitioner::communication_blocksize
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.


The documentation for this class was generated from the following file: