Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Metis.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File Metis.hpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: wrapper of functions around METIS routines
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_BASICUTILS_METIS_HPP
37 #define NEKTAR_LIB_UTILITIES_BASICUTILS_METIS_HPP
38 
41 
42 #include "metis.h"
43 
44 namespace Metis
45 {
46  extern "C"
47  {
48  void AS_METIS_NodeND(int *nVerts, int *xadj, int *adjncy, int *vwgt,
49  int *options, int *perm, int *iperm, int *map,
50  int *mdswitch);
51  }
52 
53  inline static void as_onmetis(
54  int nVerts,
60  int mdswitch = 1)
61  {
62  ASSERTL1(xadj.num_elements() == nVerts+1,"Array xadj out of bounds");
63  ASSERTL1(perm.num_elements() == nVerts,"Array perm out of bounds");
64  ASSERTL1(iperm.num_elements() == nVerts,"Array iperm out of bounds");
65 
66  AS_METIS_NodeND(&nVerts, &xadj[0], &adjncy[0], NULL, NULL, &perm[0],
67  &iperm[0], &map[0], &mdswitch);
68  }
69 
70 
71  inline static void PartGraphVKway(
72  int& nVerts,
73  int& nVertConds,
78  int& nparts,
79  int& volume,
81  {
82  int *vwgt = 0;
83  int *vsize = 0;
84  if (vertWgt.num_elements() > 0)
85  {
86  vwgt = &vertWgt[0];
87  }
88  if (vertSize.num_elements() > 0)
89  {
90  vsize = &vertSize[0];
91  }
92  // number of balancing conditions (size of vertex multi-weight)
93  int ncon = nVertConds;
94  int options[METIS_NOPTIONS];
95  METIS_SetDefaultOptions(options);
96  METIS_PartGraphKway(&nVerts, &ncon, &xadj[0], &adjcy[0], vwgt, vsize,
97  0, &nparts, 0, 0, options, &volume, &part[0]);
98  }
99 }
100 #endif //NEKTAR_LIB_UTILITIES_BASICUTILS_METIS_HPP
static void PartGraphVKway(int &nVerts, int &nVertConds, Nektar::Array< Nektar::OneD, int > &xadj, Nektar::Array< Nektar::OneD, int > &adjcy, Nektar::Array< Nektar::OneD, int > &vertWgt, Nektar::Array< Nektar::OneD, int > &vertSize, int &nparts, int &volume, Nektar::Array< Nektar::OneD, int > &part)
Definition: Metis.hpp:71
static void as_onmetis(int nVerts, Nektar::Array< Nektar::OneD, int > xadj, Nektar::Array< Nektar::OneD, int > adjncy, Nektar::Array< Nektar::OneD, int > perm, Nektar::Array< Nektar::OneD, int > iperm, Nektar::Array< Nektar::OneD, int > map, int mdswitch=1)
Definition: Metis.hpp:53
void AS_METIS_NodeND(int *nVerts, int *xadj, int *adjncy, int *vwgt, int *options, int *perm, int *iperm, int *map, int *mdswitch)
Definition: Metis.hpp:44
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191