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// Version 1.0; svn revision $LastChangedRevision$
7 //LIC//
8 //LIC// $LastChangedDate$
9 //LIC//
10 //LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11 //LIC//
12 //LIC// This library is free software; you can redistribute it and/or
13 //LIC// modify it under the terms of the GNU Lesser General Public
14 //LIC// License as published by the Free Software Foundation; either
15 //LIC// version 2.1 of the License, or (at your option) any later version.
16 //LIC//
17 //LIC// This library is distributed in the hope that it will be useful,
18 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 //LIC// Lesser General Public License for more details.
21 //LIC//
22 //LIC// You should have received a copy of the GNU Lesser General Public
23 //LIC// License along with this library; if not, write to the Free Software
24 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 //LIC// 02110-1301 USA.
26 //LIC//
27 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28 //LIC//
29 //LIC//====================================================================
30 // Domain partitioning
31 
32 #ifndef OOMPH_PARTITIONING_HEADER
33 #define OOMPH_PARTITIONING_HEADER
34 
35 
36 // Config header generated by autoconfig
37 #ifdef HAVE_CONFIG_H
38  #include <oomph-lib-config.h>
39 #endif
40 
41 #ifdef OOMPH_HAS_MPI
42 #include "mpi.h"
43 #endif
44 
45 // ooomph-lib includes
46 #include "Vector.h"
47 #include "problem.h"
48 
49 
50 namespace oomph
51 {
52 
53 //==================================================================
54 // Interfaces to METIS functions
55 //==================================================================
56 extern "C"
57 {
58 /// \short Metis graph partitioning function -- decomposes
59 /// nodal graph based on minimum edgecut
60  void METIS_PartGraphKway(int *, int *, int *, int *, int *,
61  int *, int *, int *, int *, int *, int *);
62 
63 /// \short Metis graph partitioning function -- decomposes
64 /// nodal graph based on minimum communication volume
65 void METIS_PartGraphVKway(int *, int *, int *, int *, int *,
66  int *, int *, int *, int *, int *, int *);
67 }
68 
69 
70 
71 
72 
73 
74 
75 
76 //====================================================================
77 /// Namespace for METIS graph partitioning routines
78 //====================================================================
79 namespace METIS
80 {
81 
82 
83 
84  /// \short Default function that translates spatial
85  /// error into weight for METIS partitioning (unit weight regardless
86  /// of input)
87  extern void default_error_to_weight_fct(const double& spatial_error,
88  const double& max_error,
89  const double& min_error,
90  int& weight);
91 
92  /// \short Typedef for function pointer to to function that translates spatial
93  /// error into weight for METIS partitioning.
94  typedef void (*ErrorToWeightFctPt)(const double& spatial_error,
95  const double& max_error,
96  const double& min_error,
97  int& weight);
98 
99  /// \short Function pointer to to function that translates spatial
100  /// error into weight for METIS partitioning.
102 
103  /// \short Partition mesh uniformly by dividing elements
104  /// equally over the partitions, in the order
105  /// in which they are returned by problem.
106  /// On return, element_domain[ielem] contains the number
107  /// of the domain [0,1,...,ndomain-1] to which
108  /// element ielem has been assigned.
109  extern void uniform_partition_mesh(Problem* problem_pt,
110  const unsigned& ndomain,
111  Vector<unsigned>& element_domain);
112 
113 
114  /// \short Use METIS to assign each element to a domain.
115  /// On return, element_domain[ielem] contains the number
116  /// of the domain [0,1,...,ndomain-1] to which
117  /// element ielem has been assigned.
118  /// - objective=0: minimise edgecut.
119  /// - objective=1: minimise total communications volume.
120  /// .
121  /// Partioning is based on nodal graph of mesh.
122  extern void partition_mesh(Problem* problem_pt,
123  const unsigned& ndomain,
124  const unsigned& objective,
125  Vector<unsigned>& element_domain);
126 
127 
128  /// \short Use METIS to assign each element to a domain.
129  /// On return, element_domain[ielem] contains the number
130  /// of the domain [0,1,...,ndomain-1] to which
131  /// element ielem has been assigned.
132  /// - objective=0: minimise edgecut.
133  /// - objective=1: minimise total communications volume.
134  /// .
135  /// Partioning is based on nodal graph of mesh.
136  extern void partition_mesh(OomphCommunicator* comm_pt,
137  Mesh* mesh_pt,
138  const unsigned& ndomain,
139  const unsigned& objective,
140  Vector<unsigned>& element_domain);
141 
142 // /// \short Use METIS to assign each element to a domain.
143 // /// On return, element_domain[ielem] contains the number
144 // /// of the domain [0,1,...,ndomain-1] to which
145 // /// element ielem has been assigned.
146 // /// - objective=0: minimise edgecut.
147 // /// - objective=1: minimise total communications volume.
148 // /// .
149 // /// Partioning is based on "Data" graph of mesh.
150 // extern void partition_mesh_data(Problem* problem_pt,
151 // const unsigned& ndomain,
152 // const unsigned& objective,
153 // Vector<unsigned>& element_domain);
154 
155 #ifdef OOMPH_HAS_MPI
156 
157 
158  /// \short Use METIS to assign each element in an already-distributed mesh to
159  /// a domain. On return, element_domain_on_this_proc[e] contains the number
160  /// of the domain [0,1,...,ndomain-1] to which non-halo element e on THE
161  /// CURRENT PROCESSOR ONLY has been assigned. The order of the non-halo
162  /// elements is the same as in the Problem's mesh, with the halo
163  /// elements being skipped.
164  ///
165  /// Objective:
166  /// - objective=0: minimise edgecut.
167  /// - objective=1: minimise total communications volume.
168  /// .
169  /// The partioning is based on the dof graph of the complete mesh by
170  /// taking into
171  /// account which global equation numbers are affected by each element and
172  /// connecting elements which affect the same global equation number.
173  /// Partitioning is done such that all elements associated with the
174  /// same tree root move together. Non-refineable elements are
175  /// treated as their own root elements. If the optional boolean
176  /// flag is set to true (it defaults to false) each processor
177  /// assigns a dumb-but-repeatable equidistribution of its non-halo
178  /// elements over the domains and outputs the input that would have
179  /// gone into METIS in the file metis_input_for_validation.dat
180  extern void partition_distributed_mesh
181  (Problem* problem_pt,const unsigned& objective,
182  Vector<unsigned>& element_domain_on_this_proc,
183  const bool& bypass_metis=false);
184 
185 #endif
186 
187 }
188 
189 
190 }
191 
192 #endif
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, element_domain_on_this_proc[e] contains the number of the domain [0,1,...,ndomain-1] to which non-halo element e on THE CURRENT PROCESSOR ONLY has been assigned. The order of the non-halo elements is the same as in the Problem&#39;s mesh, with the halo elements being skipped.
void METIS_PartGraphVKway(int *, int *, int *, int *, int *, int *, int *, int *, int *, int *, int *)
Metis graph partitioning function – decomposes nodal graph based on minimum communication volume...
The Problem class.
Definition: problem.h:152
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...
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:53
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:94
void METIS_PartGraphKway(int *, int *, int *, int *, int *, int *, int *, int *, int *, int *, int *)
Metis graph partitioning function – decomposes nodal graph based on minimum edgecut.
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:78
ErrorToWeightFctPt Error_to_weight_fct_pt
Function pointer to to function that translates spatial error into weight for METIS partitioning...
Definition: partitioning.cc:63
A general mesh class.
Definition: mesh.h:74
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
Definition: communicator.h:57