Toggle navigation
Documentation
Big picture
The finite element method
The data structure
Not-so-quick guide
Optimisation
Order of action functions
Example codes and tutorials
List of example codes and tutorials
Meshing
Solvers
MPI parallel processing
Post-processing/visualisation
Other
Change log
Creating documentation
Coding conventions
Index
FAQ
About
People
Contact/Get involved
Publications
Acknowledgements
Copyright
Picture show
Go
src
generic
partitioning.h
Go to the documentation of this file.
1
// LIC// ====================================================================
2
// LIC// This file forms part of oomph-lib, the object-oriented,
3
// LIC// multi-physics finite-element library, available
4
// LIC// at http://www.oomph-lib.org.
5
// LIC//
6
// LIC// Copyright (C) 2006-2025 Matthias Heil and Andrew Hazel
7
// LIC//
8
// LIC// This library is free software; you can redistribute it and/or
9
// LIC// modify it under the terms of the GNU Lesser General Public
10
// LIC// License as published by the Free Software Foundation; either
11
// LIC// version 2.1 of the License, or (at your option) any later version.
12
// LIC//
13
// LIC// This library is distributed in the hope that it will be useful,
14
// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// LIC// Lesser General Public License for more details.
17
// LIC//
18
// LIC// You should have received a copy of the GNU Lesser General Public
19
// LIC// License along with this library; if not, write to the Free Software
20
// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
// LIC// 02110-1301 USA.
22
// LIC//
23
// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24
// LIC//
25
// LIC//====================================================================
26
// Domain partitioning
27
28
#ifndef OOMPH_PARTITIONING_HEADER
29
#define OOMPH_PARTITIONING_HEADER
30
31
// Config header
32
#ifdef HAVE_CONFIG_H
33
#include <oomph-lib-config.h>
34
#endif
35
#ifdef OOMPH_HAS_MPI
36
#include "mpi.h"
37
#endif
38
39
// ooomph-lib includes
40
#include "
Vector.h
"
41
#include "
problem.h
"
42
43
// for the new METIS API, need to use symbols defined in the standard header
44
// which aren't available in the current frozen (old) version of METIS
45
// Version 3 will (presumably) have this header in the include path as standard
46
#include "metis.h"
47
48
namespace
oomph
49
{
50
//==================================================================
51
// Interfaces to METIS functions
52
//==================================================================
53
extern
"C"
54
{
55
/// Metis graph partitioning function
56
METIS_API
(
int
)
57
METIS_PartGraphKway
(
idx_t
*,
58
idx_t
*,
59
idx_t
*,
60
idx_t
*,
61
idx_t
*,
62
idx_t
*,
63
idx_t
*,
64
idx_t
*,
65
real_t
*,
66
real_t
*,
67
idx_t
*,
68
idx_t
*,
69
idx_t
*);
70
}
71
72
73
//====================================================================
74
/// Namespace for METIS graph partitioning routines
75
//====================================================================
76
namespace
METIS
77
{
78
/// Default function that translates spatial
79
/// error into weight for METIS partitioning (unit weight regardless
80
/// of input)
81
extern
void
default_error_to_weight_fct
(
const
double
& spatial_error,
82
const
double
& max_error,
83
const
double
& min_error,
84
int
& weight);
85
86
/// Typedef for function pointer to to function that translates
87
/// spatial error into weight for METIS partitioning.
88
typedef
void
(*
ErrorToWeightFctPt
)(
const
double
&
spatial_error
,
89
const
double
& max_error,
90
const
double
& min_error,
91
int
& weight);
92
93
/// Function pointer to to function that translates spatial
94
/// error into weight for METIS partitioning.
95
extern
ErrorToWeightFctPt
Error_to_weight_fct_pt
;
96
97
/// Partition mesh uniformly by dividing elements
98
/// equally over the partitions, in the order
99
/// in which they are returned by problem.
100
/// On return, element_domain[ielem] contains the number
101
/// of the domain [0,1,...,ndomain-1] to which
102
/// element ielem has been assigned.
103
extern
void
uniform_partition_mesh
(
Problem
* problem_pt,
104
const
unsigned
&
ndomain
,
105
Vector<unsigned>
&
element_domain
);
106
107
108
/// Use METIS to assign each element to a domain.
109
/// On return, element_domain[ielem] contains the number
110
/// of the domain [0,1,...,ndomain-1] to which
111
/// element ielem has been assigned.
112
/// - objective=0: minimise edgecut.
113
/// - objective=1: minimise total communications volume.
114
/// .
115
/// Partioning is based on nodal graph of mesh.
116
extern
void
partition_mesh
(
Problem
* problem_pt,
117
const
unsigned
&
ndomain
,
118
const
unsigned
&
objective
,
119
Vector<unsigned>
&
element_domain
);
120
121
122
/// Use METIS to assign each element to a domain.
123
/// On return, element_domain[ielem] contains the number
124
/// of the domain [0,1,...,ndomain-1] to which
125
/// element ielem has been assigned.
126
/// - objective=0: minimise edgecut.
127
/// - objective=1: minimise total communications volume.
128
/// .
129
/// Partioning is based on nodal graph of mesh.
130
extern
void
partition_mesh
(
OomphCommunicator
* comm_pt,
131
Mesh
* mesh_pt,
132
const
unsigned
&
ndomain
,
133
const
unsigned
&
objective
,
134
Vector<unsigned>
&
element_domain
);
135
136
// /// Use METIS to assign each element to a domain.
137
// /// On return, element_domain[ielem] contains the number
138
// /// of the domain [0,1,...,ndomain-1] to which
139
// /// element ielem has been assigned.
140
// /// - objective=0: minimise edgecut.
141
// /// - objective=1: minimise total communications volume.
142
// /// .
143
// /// Partioning is based on "Data" graph of mesh.
144
// extern void partition_mesh_data(Problem* problem_pt,
145
// const unsigned& ndomain,
146
// const unsigned& objective,
147
// Vector<unsigned>& element_domain);
148
149
#ifdef OOMPH_HAS_MPI
150
151
152
/// Use METIS to assign each element in an already-distributed mesh
153
/// to a domain. On return, element_domain_on_this_proc[e] contains the
154
/// number of the domain [0,1,...,ndomain-1] to which non-halo element e on
155
/// THE CURRENT PROCESSOR ONLY has been assigned. The order of the non-halo
156
/// elements is the same as in the Problem's mesh, with the halo
157
/// elements being skipped.
158
///
159
/// Objective:
160
/// - objective=0: minimise edgecut.
161
/// - objective=1: minimise total communications volume.
162
/// .
163
/// The partioning is based on the dof graph of the complete mesh by
164
/// taking into
165
/// account which global equation numbers are affected by each element and
166
/// connecting elements which affect the same global equation number.
167
/// Partitioning is done such that all elements associated with the
168
/// same tree root move together. Non-refineable elements are
169
/// treated as their own root elements. If the optional boolean
170
/// flag is set to true (it defaults to false) each processor
171
/// assigns a dumb-but-repeatable equidistribution of its non-halo
172
/// elements over the domains and outputs the input that would have
173
/// gone into METIS in the file metis_input_for_validation.dat
174
extern
void
partition_distributed_mesh
(
175
Problem
* problem_pt,
176
const
unsigned
&
objective
,
177
Vector<unsigned>
&
element_domain_on_this_proc
,
178
const
bool
&
bypass_metis
=
false
);
179
180
#endif
181
182
}
// namespace METIS
183
184
185
}
// namespace oomph
186
187
#endif
Vector.h
oomph::Mesh
A general mesh class.
Definition
mesh.h:67
oomph::OomphCommunicator
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
Definition
communicator.h:54
oomph::Problem
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Definition
problem.h:154
oomph::TAdvectionDiffusionReactionElement
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Definition
Tadvection_diffusion_reaction_elements.h:66
oomph::METIS::uniform_partition_mesh
void uniform_partition_mesh(Problem *problem_pt, const unsigned &ndomain, Vector< unsigned > &element_domain)
Partition mesh uniformly by dividing elements equally over the partitions, in the order in which they...
Definition
partitioning.cc:70
oomph::METIS::partition_distributed_mesh
void partition_distributed_mesh(Problem *problem_pt, const unsigned &objective, Vector< unsigned > &element_domain_on_this_proc, const bool &bypass_metis=false)
Use METIS to assign each element in an already-distributed mesh to a domain. On return,...
Definition
partitioning.cc:556
oomph::METIS::partition_mesh
void partition_mesh(Problem *problem_pt, const unsigned &ndomain, const unsigned &objective, Vector< unsigned > &element_domain)
Use METIS to assign each element to a domain. On return, element_domain[ielem] contains the number of...
Definition
partitioning.cc:110
oomph::METIS::ErrorToWeightFctPt
void(* ErrorToWeightFctPt)(const double &spatial_error, const double &max_error, const double &min_error, int &weight)
Typedef for function pointer to to function that translates spatial error into weight for METIS parti...
Definition
partitioning.h:88
oomph::METIS::Error_to_weight_fct_pt
ErrorToWeightFctPt Error_to_weight_fct_pt
Function pointer to to function that translates spatial error into weight for METIS partitioning.
Definition
partitioning.cc:57
oomph::METIS::default_error_to_weight_fct
void default_error_to_weight_fct(const double &spatial_error, const double &max_error, const double &min_error, int &weight)
Default function that translates spatial error into weight for METIS partitioning (unit weight regard...
Definition
partitioning.cc:47
oomph
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition
advection_diffusion_elements.cc:30
oomph::METIS_API
METIS_API(int) METIS_PartGraphKway(idx_t *
Metis graph partitioning function.
problem.h