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