libMesh
parmetis_helper.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 #ifndef LIBMESH_PARMETIS_HELPER_H
19 #define LIBMESH_PARMETIS_HELPER_H
20 
21 // Local Includes
22 #include "libmesh/libmesh_config.h"
23 
24 // C++ Includes
25 #include <vector>
26 
27 #ifdef LIBMESH_HAVE_PARMETIS
28 
29 #include "libmesh/id_types.h"
30 
31 // Before we include a header wrapped in a namespace, we'd better make
32 // sure none of its dependencies end up in that namespace
33 #include <mpi.h>
34 
35 // Include the ParMETIS header files. We need this so we can use
36 // ParMetis' idx_t and real_t types directly.
37 namespace Parmetis {
38 extern "C" {
39 # include "libmesh/ignore_warnings.h"
40 # include "parmetis.h"
41 # include "libmesh/restore_warnings.h"
42 }
43 }
44 #endif // LIBMESH_HAVE_PARMETIS
45 
46 
47 namespace libMesh
48 {
49 
62 {
63 public:
67  ParmetisHelper () = default;
68  ParmetisHelper (const ParmetisHelper &) = default;
69  ParmetisHelper (ParmetisHelper &&) = default;
70  ParmetisHelper & operator= (const ParmetisHelper &) = default;
72  ~ParmetisHelper () = default;
73 
74 #ifdef LIBMESH_HAVE_PARMETIS
75 
80  std::vector<Parmetis::idx_t> vtxdist;
81  std::vector<Parmetis::idx_t> xadj;
82  std::vector<Parmetis::idx_t> adjncy;
83 
84  // We use dof_id_type for part so we can pass it directly to
85  // Partitioner:: methods expecting that type.
86  std::vector<dof_id_type> part;
87 
88  // But we plan to pass a pointer to part as a buffer to ParMETIS, so
89  // it had better be using a simply reinterpretable type!
90  static_assert(sizeof(Parmetis::idx_t) == sizeof(dof_id_type),
91  "ParMETIS and libMesh ID sizes must match!");
92 
93  std::vector<Parmetis::real_t> tpwgts;
94  std::vector<Parmetis::real_t> ubvec;
95  std::vector<Parmetis::idx_t> options;
96  std::vector<Parmetis::idx_t> vwgt;
97 
98  Parmetis::idx_t wgtflag;
99  Parmetis::idx_t ncon;
100  Parmetis::idx_t numflag;
101  Parmetis::idx_t nparts;
102  Parmetis::idx_t edgecut;
103 
104 #endif // LIBMESH_HAVE_PARMETIS
105 };
106 
107 } // namespace libMesh
108 
109 #endif // LIBMESH_PARMETIS_HELPER_H
std::vector< Parmetis::idx_t > xadj
The ParmetisHelper class allows us to use a &#39;pimpl&#39; strategy in the ParmetisPartitioner class...
ParmetisHelper()=default
Defaulted constructors, assignment operators, and destructor.
std::vector< Parmetis::idx_t > vwgt
std::vector< dof_id_type > part
The libMesh namespace provides an interface to certain functionality in the library.
Parmetis::idx_t wgtflag
std::vector< Parmetis::idx_t > vtxdist
Data structures used by ParMETIS to describe the connectivity graph of the mesh.
std::vector< Parmetis::idx_t > options
std::vector< Parmetis::idx_t > adjncy
std::vector< Parmetis::real_t > ubvec
std::vector< Parmetis::real_t > tpwgts
ParmetisHelper & operator=(const ParmetisHelper &)=default
uint8_t dof_id_type
Definition: id_types.h:67