xc
Metis.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 /* ****************************************************************** **
29 ** OpenSees - Open System for Earthquake Engineering Simulation **
30 ** Pacific Earthquake Engineering Research Center **
31 ** **
32 ** **
33 ** (C) Copyright 1999, The Regents of the University of California **
34 ** All Rights Reserved. **
35 ** **
36 ** Commercial use of this program without express permission of the **
37 ** University of California, Berkeley, is strictly prohibited. See **
38 ** file 'COPYRIGHT' in main directory for information on usage and **
39 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
40 ** **
41 ** Developed by: **
42 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
43 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
44 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
45 ** **
46 ** ****************************************************************** */
47 
48 // $Revision: 1.2 $
49 // $Date: 2006/01/12 23:37:19 $
50 // $Source: /usr/local/cvs/OpenSees/SRC/graph/partitioner/Metis.h,v $
51 
52 
53 // Written: fmk
54 //
55 // Description: This file contains the class definition for Metis.
56 // Metis is a type of GraphPartitioner which uses 'METIS - Unstructured
57 // Graph Partitioning And Sparse Matrix Ordering System', developed by
58 // G. Karypis and V. Kumar at the University of Minnesota. The metis
59 // files are found in metis-2.0 which were downloaded.
60 // This class provides the C++ interface for metis which will allow
61 // it to fit seamlessly into our system.
62 //
63 // What: "@(#) Metis.h, revA"
64 
65 #ifndef Metis_h
66 #define Metis_h
67 
68 #include "solution/graph/partitioner/GraphPartitioner.h"
69 #include "solution/graph/numberer/GraphNumberer.h"
70 
71 namespace XC {
72 
140 class Metis: public GraphPartitioner, public GraphNumberer
141  {
142  private:
143  bool checkOptions(void);
144 
145  int myPtype;
146  // pmetis = 1
147  // kmetis = 2
148 
149  int myMtype;
150  // random = 1
151  // heavy edge = 2
152  // light edge = 3
153  // heavy clique = 4
154  // modified heavy edge = 5
155  // sorted random = 11
156  // sorted heavy edge =21
157  // sorted modified heavy edge = 51
158 
159  int myCoarsenTo;
160  // if pmetis default is 100
161  // if kmetis default is 2000
162 
163  int myRtype;
164  // greedy = 1
165  // kernighan-lin = 2
166  // combo greedy and K-L = 3
167  // boundary greedy = 11
168  // boundary K-L = 12
169  // combo of boundary greedy and boundary K-L = 13,
170  // no-refinement = 20
171 
172  int myIPtype;
173  // graph growing partition = 1,
174  // greedy graph growing partition = 2,
175  // spectral bisection = 3,
176  // graph growing followed by K-L = 4
177 
178  bool defaultOptions;
179 
180  int numPartitions;
181  ID theRefResult;
182 
183  Metis(int numParts =1);
184  Metis(int Ptype,
185  int Mtype,
186  int coarsenTo,
187  int Rtype,
188  int IPtype,
189  int numParts =1);
190  public:
191  bool setOptions(int Ptype,
192  int Mtype,
193  int coarsenTo,
194  int Rtype,
195  int IPtype);
196  bool setDefaultOptions(void);
197 
198  int partitionHexMesh(int* elmnts, int* epart, int* npart, int ne, int nn, int nparts, bool whichToUse);
199  int partition(Graph &theGraph, int numPart);
200  int partitionGraph(int *nvtxs, int *xadj, int *adjncy, int *vwgt,
201  int *adjwgt, int *wgtflag, int *numflag, int *nparts,
202  int *options, int *edgecut, int *part, bool whichToUse);
203 
204  // the following methods are if the object is to be used as a numberer
205  const ID &number(Graph &theGraph, int lastVertex = -1);
206  const ID &number(Graph &theGraph, const ID &lastVertices);
207 
208  int sendSelf(Communicator &);
209  int recvSelf(const Communicator &);
210  };
211 } // end of XC namespace
212 
213 #endif
214 
int sendSelf(Communicator &)
Send the object.
Definition: Metis.cpp:520
bool setOptions(int Ptype, int Mtype, int coarsenTo, int Rtype, int IPtype)
Sets the options for the partitioning to those passed as arguments.
Definition: MetisNumberer.cpp:122
int recvSelf(const Communicator &)
Receive the object.
Definition: Metis.cpp:523
int partition(Graph &theGraph, int numPart)
Method to partition the graph.
Definition: MetisNumberer.cpp:221
bool setDefaultOptions(void)
Sets the default options.
Definition: MetisNumberer.cpp:209
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
const ID & number(Graph &theGraph, int lastVertex=-1)
Graph numbering.
Definition: Metis.cpp:393