libMesh
parmetis_partitioner.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 
27 // C++ Includes
28 #include <cstddef>
29 #include <memory>
30 #include <unordered_map>
31 #include <vector>
32 
33 namespace libMesh
34 {
35 
36 // Forward declarations
37 class ParmetisHelper;
38 
48 {
49 public:
50 
56 
62 
69 
74  virtual ~ParmetisPartitioner();
75 
76  virtual PartitionerType type () const override;
77 
81  virtual std::unique_ptr<Partitioner> clone () const override
82  {
83  return std::make_unique<ParmetisPartitioner>(*this);
84  }
85 
86 
87 protected:
88 
95  virtual void _do_repartition (MeshBase & mesh,
96  const unsigned int n) override;
97 
101  virtual void _do_partition (MeshBase & mesh,
102  const unsigned int n) override;
103 
104 #ifdef LIBMESH_HAVE_PARMETIS
105 
108  virtual void build_graph (const MeshBase & mesh) override;
109 
110 private:
111 
112  // These methods and data only need to be available if the
113  // ParMETIS library is available.
114 
118  void initialize (const MeshBase & mesh, const unsigned int n_sbdmns);
119 
124  std::unique_ptr<ParmetisHelper> _pmetis;
125 
126 #endif
127 };
128 
129 } // namespace libMesh
130 
131 #endif // LIBMESH_PARMETIS_PARTITIONER_H
std::unique_ptr< ParmetisHelper > _pmetis
Pointer to the Parmetis-specific data structures.
ParmetisPartitioner & operator=(const ParmetisPartitioner &)=delete
This class contains a unique_ptr member, so it can&#39;t be default copy assigned.
virtual PartitionerType type() const override
void initialize(const MeshBase &mesh, const unsigned int n_sbdmns)
Initialize data structures.
virtual void _do_repartition(MeshBase &mesh, const unsigned int n) override
Parmetis can handle dynamically repartitioning a mesh such that the redistribution costs are minimize...
MeshBase & mesh
virtual void build_graph(const MeshBase &mesh) override
Build the graph.
ParmetisPartitioner()
Default and copy ctors.
The libMesh namespace provides an interface to certain functionality in the library.
The ParmetisPartitioner uses the Parmetis graph partitioner to partition the elements.
virtual std::unique_ptr< Partitioner > clone() const override
virtual ~ParmetisPartitioner()
The destructor is out-of-line-defaulted to play nice with forward declarations.
This is the MeshBase class.
Definition: mesh_base.h:74
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition: partitioner.h:51
PartitionerType
Defines an enum for mesh partitioner types.
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
Partition the MeshBase into n subdomains.