libMesh
parmetis_partitioner.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #ifndef LIBMESH_PARMETIS_PARTITIONER_H
21 #define LIBMESH_PARMETIS_PARTITIONER_H
22 
23 // Local Includes
24 #include "libmesh/id_types.h"
25 #include "libmesh/partitioner.h"
26 #include "libmesh/vectormap.h"
27 
28 // C++ Includes
29 #include <cstddef>
30 #include <vector>
31 
32 namespace libMesh
33 {
34 
35 // Forward declarations
36 class ParmetisHelper;
37 
47 {
48 public:
49 
54 
59 
63  virtual UniquePtr<Partitioner> clone () const libmesh_override
64  {
66  }
67 
68 
69 protected:
70 
77  virtual void _do_repartition (MeshBase & mesh,
78  const unsigned int n) libmesh_override;
79 
83  virtual void _do_partition (MeshBase & mesh,
84  const unsigned int n) libmesh_override;
85 
86 private:
87 
88  // These methods and data only need to be available if the
89  // ParMETIS library is available.
90 #ifdef LIBMESH_HAVE_PARMETIS
91 
95  void initialize (const MeshBase & mesh, const unsigned int n_sbdmns);
96 
100  void build_graph (const MeshBase & mesh);
101 
105  void assign_partitioning (MeshBase & mesh);
106 
114  std::vector<dof_id_type> _n_active_elem_on_proc;
115 
120 
126 
127 #endif
128 };
129 
130 } // namespace libMesh
131 
132 #endif // LIBMESH_PARMETIS_PARTITIONER_H
void initialize(const MeshBase &mesh, const unsigned int n_sbdmns)
Initialize data structures.
virtual void _do_partition(MeshBase &mesh, const unsigned int n) libmesh_override
Partition the MeshBase into n subdomains.
virtual void _do_repartition(MeshBase &mesh, const unsigned int n) libmesh_override
Parmetis can handle dynamically repartitioning a mesh such that the redistribution costs are minimize...
MeshBase & mesh
std::vector< dof_id_type > _n_active_elem_on_proc
The number of active elements on each processor.
vectormap< dof_id_type, dof_id_type > _global_index_by_pid_map
Maps active element ids into a contiguous range, as needed by ParMETIS.
The libMesh namespace provides an interface to certain functionality in the library.
The ParmetisPartitioner uses the Parmetis graph partitioner to partition the elements.
This is the MeshBase class.
Definition: mesh_base.h:68
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition: partitioner.h:48
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
UniquePtr< ParmetisHelper > _pmetis
Pointer to the Parmetis-specific data structures.
void assign_partitioning(MeshBase &mesh)
Assign the computed partitioning to the mesh.
void build_graph(const MeshBase &mesh)
Build the graph.
virtual UniquePtr< Partitioner > clone() const libmesh_override
~ParmetisPartitioner()
Destructor.