81 NumMyRows_ = Graph.NumMyRows();
82 Reorder_.resize(NumMyRows_);
83 InvReorder_.resize(NumMyRows_);
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
105 if (UseSymmetricGraph_) {
107#if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
112 SymMap = Teuchos::rcp(
new Epetra_Map(NumMyRows_,0,Graph.Comm()) );
116#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
117 if(SymGraph->RowMap().GlobalIndicesInt()) {
118 for (
int i = 0; i < NumMyRows_ ; ++i) {
120 ierr = Graph.ExtractMyRowCopy(i, Length, NumIndices,
122 IFPACK_CHK_ERR(ierr);
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()) {
138 for (
int i = 0; i < NumMyRows_ ; ++i) {
141 ierr = Graph.ExtractMyRowCopy(i, Length, NumIndices,
143 IFPACK_CHK_ERR(ierr);
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";
159 IFPACK_CHK_ERR(SymGraph->OptimizeStorage());
160 IFPACK_CHK_ERR(SymGraph->FillComplete());
162 IFPACKGraph = SymIFPACKGraph;
166 std::vector<idxtype> xadj;
167 xadj.resize(NumMyRows_ + 1);
169 std::vector<idxtype> adjncy;
170 adjncy.resize(Graph.NumMyNonzeros());
176 for (
int i = 0; i < NumMyRows_ ; ++i) {
178 xadj[count2+1] = xadj[count2];
180 ierr = IFPACKGraph->ExtractMyRowCopy(i, Length, NumIndices, &Indices[0]);
181 IFPACK_CHK_ERR(ierr);
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],
202 &InvReorder_[0], &Reorder_[0]);
207 cerr <<
"Please configure with --enable-ifpack-metis" << endl;
208 cerr <<
"to use METIS Reordering." << endl;