libMesh
Loading...
Searching...
No Matches
parmetis_partitioner.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
33namespace libMesh
34{
35
36// Forward declarations
37class ParmetisHelper;
38
48{
49public:
50
56
62
69
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
87protected:
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
108 virtual void build_graph (const MeshBase & mesh) override;
109
110private:
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
This is the MeshBase class.
Definition mesh_base.h:81
The ParmetisPartitioner uses the Parmetis graph partitioner to partition the elements.
ParmetisPartitioner()
Default and copy ctors.
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
Partition the MeshBase into n subdomains.
ParmetisPartitioner & operator=(const ParmetisPartitioner &)=delete
This class contains a unique_ptr member, so it can't be default copy assigned.
std::unique_ptr< ParmetisHelper > _pmetis
Pointer to the Parmetis-specific data structures.
virtual ~ParmetisPartitioner()
The destructor is out-of-line-defaulted to play nice with forward declarations.
virtual PartitionerType type() const override
virtual void build_graph(const MeshBase &mesh) override
Build the graph.
ParmetisPartitioner(const ParmetisPartitioner &other)
virtual std::unique_ptr< Partitioner > clone() const override
void initialize(const MeshBase &mesh, const unsigned int n_sbdmns)
Initialize data structures.
ParmetisPartitioner(ParmetisPartitioner &&)=default
Move ctor, move assignment operator, and destructor are all explicitly inline-defaulted for this clas...
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...
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition partitioner.h:52
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
PartitionerType
Defines an enum for mesh partitioner types.