49#include "Epetra_Comm.h"
50#include "Epetra_MultiVector.h"
51#include "Epetra_CrsGraph.h"
52#include "Epetra_Map.h"
53#include "Teuchos_ParameterList.hpp"
56#ifdef HAVE_IFPACK_METIS
59 int *numflag,
int *options,
int *perm,
int *iperm);
65 UseSymmetricGraph_(
false),
87 Teuchos::RefCountPtr<Epetra_CrsGraph> SymGraph;
88 Teuchos::RefCountPtr<Epetra_Map> SymMap;
89 Teuchos::RefCountPtr<Ifpack_Graph_Epetra_CrsGraph> SymIFPACKGraph;
90 Teuchos::RefCountPtr<Ifpack_Graph> IFPACKGraph = Teuchos::rcp( (
Ifpack_Graph*)&
Graph,
false );
92 int Length = 2 *
Graph.MaxMyNumEntries();
94 std::vector<int> Indices;
95 Indices.resize(Length);
97 std::vector<int> options;
101#ifdef HAVE_IFPACK_METIS
107#if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
116#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
117 if(SymGraph->RowMap().GlobalIndicesInt()) {
120 ierr =
Graph.ExtractMyRowCopy(i, Length, NumIndices,
124 for (
int j = 0 ; j < NumIndices ; ++j) {
128 SymGraph->InsertGlobalIndices(i,1,&jj);
129 SymGraph->InsertGlobalIndices(jj,1,&i);
136#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
137 if(SymGraph->RowMap().GlobalIndicesLongLong()) {
141 ierr =
Graph.ExtractMyRowCopy(i, Length, NumIndices,
145 for (
int j = 0 ; j < NumIndices ; ++j) {
146 long long jj = Indices[j];
149 SymGraph->InsertGlobalIndices(i_LL,1,&jj);
150 SymGraph->InsertGlobalIndices(jj,1,&i_LL);
157 throw "Ifpack_METISReordering::Compute: GlobalIndices type unknown";
162 IFPACKGraph = SymIFPACKGraph;
166 std::vector<idxtype> xadj;
169 std::vector<idxtype> adjncy;
170 adjncy.resize(
Graph.NumMyNonzeros());
178 xadj[count2+1] = xadj[count2];
180 ierr = IFPACKGraph->ExtractMyRowCopy(i, Length, NumIndices, &Indices[0]);
183 for (
int j = 0 ; j < NumIndices ; ++j) {
186 adjncy[count++] = jj;
193#ifdef HAVE_IFPACK_METIS
200 METIS_NodeND(&
NumMyRows_, &xadj[0], &adjncy[0],
201 &numflag, &options[0],
207 cerr <<
"Please configure with --enable-ifpack-metis" << endl;
208 cerr <<
"to use METIS Reordering." << endl;
259 X[j][np] = Xorig[j][i];
275 X[j][i] = Xorig[j][np];
287 os <<
"*** Ifpack_METISReordering" << endl << endl;
289 os <<
"*** Reordering not yet computed." << endl;
291 os <<
"*** Number of local rows = " <<
NumMyRows_ << endl;
292 os <<
"Local Row\tReorder[i]\tInvReorder[i]" << endl;
#define IFPACK_CHK_ERR(ifpack_err)
adjacency_list< vecS, vecS, undirectedS, no_property, property< edge_weight_t, double > > Graph
Ifpack_Graph_Epetra_CrsGraph: a class to define Ifpack_Graph as a light-weight conversion of Epetra_C...
Ifpack_Graph_Epetra_RowMatrix: a class to define Ifpack_Graph as a light-weight conversion of Epetra_...
Ifpack_Graph: a pure virtual class that defines graphs for IFPACK.
Ifpack_METISReordering()
Constructor.
virtual int Pinv(const Epetra_MultiVector &Xorig, Epetra_MultiVector &X) const
Applies inverse reordering to multivector Xorig, whose local length equals the number of local rows,...
virtual int InvReorder(const int i) const
Returns the inverse reordered index of row i.
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
bool UseSymmetricGraph_
If true, the graph has to be symmetrized before calling METIS.
virtual int P(const Epetra_MultiVector &Xorig, Epetra_MultiVector &X) const
Applies reordering to multivector Xorig, whose local length equals the number of local rows,...
virtual bool IsComputed() const
Returns true is the reordering object has been successfully initialized, false otherwise.
virtual int Compute(const Ifpack_Graph &Graph)
Computes all it is necessary to initialize the reordering object.
std::vector< int > Reorder_
Contains the reordering.
virtual int Reorder(const int i) const
Returns the reordered index of row i.
int NumMyRows_
Number of local rows in the graph.
std::vector< int > InvReorder_
Contains the inverse reordering.