//============================================================================ Epetra_CrsMatrix* Ifpack_CreateOverlappingCrsMatrix(const Epetra_RowMatrix* Matrix, const int OverlappingLevel) { if (OverlappingLevel == 0) return(0); // All done if (Matrix->Comm().NumProc() == 1) return(0); // All done Epetra_CrsMatrix* OverlappingMatrix; OverlappingMatrix = 0; Epetra_Map* OverlappingMap; OverlappingMap = (Epetra_Map*)&(Matrix->RowMatrixRowMap()); const Epetra_RowMatrix* OldMatrix; const Epetra_Map* DomainMap = &(Matrix->OperatorDomainMap()); const Epetra_Map* RangeMap = &(Matrix->OperatorRangeMap()); for (int level = 1; level <= OverlappingLevel ; ++level) { if (OverlappingMatrix) OldMatrix = OverlappingMatrix; else OldMatrix = Matrix; Epetra_Import* OverlappingImporter; OverlappingImporter = (Epetra_Import*)OldMatrix->RowMatrixImporter(); int NumMyElements = OverlappingImporter->TargetMap().NumMyElements(); // need to build an Epetra_Map in this way because Epetra_CrsMatrix // requires Epetra_Map and not Epetra_BlockMap #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES if(OverlappingImporter->TargetMap().GlobalIndicesInt()) { int* MyGlobalElements = OverlappingImporter->TargetMap().MyGlobalElements(); OverlappingMap = new Epetra_Map(-1,NumMyElements,MyGlobalElements, 0, Matrix->Comm()); } else #endif #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES if(OverlappingImporter->TargetMap().GlobalIndicesLongLong()) { long long* MyGlobalElements = OverlappingImporter->TargetMap().MyGlobalElements64(); OverlappingMap = new Epetra_Map((long long) -1,NumMyElements,MyGlobalElements, 0, Matrix->Comm()); } else #endif throw "Ifpack_CreateOverlappingCrsMatrix: GlobalIndices type unknown"; if (level < OverlappingLevel) OverlappingMatrix = new Epetra_CrsMatrix(Copy, *OverlappingMap, 0); else // On last iteration, we want to filter out all columns except // those that correspond // to rows in the graph. This assures that our matrix is square OverlappingMatrix = new Epetra_CrsMatrix(Copy, *OverlappingMap, *OverlappingMap, 0); OverlappingMatrix->Import(*OldMatrix, *OverlappingImporter, Insert); if (level < OverlappingLevel) { OverlappingMatrix->FillComplete(*DomainMap, *RangeMap); } else { OverlappingMatrix->FillComplete(*DomainMap, *RangeMap); } delete OverlappingMap; if (level > 1) { delete OldMatrix; } OverlappingMatrix->FillComplete(); } return(OverlappingMatrix); }