46 #include <Epetra_CrsMatrix.h> 47 #include <Epetra_Map.h> 48 #include <Epetra_IntVector.h> 50 #include <Epetra_Export.h> 51 #include <Epetra_Import.h> 59 if( NewColMap_ )
delete NewColMap_;
70 Epetra_Map & OldDomainMap =
const_cast<Epetra_Map&
>(orig.OperatorDomainMap());
71 Epetra_Map & OldColMap =
const_cast<Epetra_Map&
>(orig.ColMap());
72 int NumMyElements = OldDomainMap.NumMyElements();
73 int NumGlobalElements = OldDomainMap.NumGlobalElements();
74 assert( orig.RowMap().NumMyElements() == NewRowMap_.NumMyElements() );
76 if (NumGlobalElements == 0 && orig.RowMap().NumGlobalElements() == 0 )
79 Epetra_CrsMatrix * NewMatrix =
new Epetra_CrsMatrix( View, orig.RowMap(), orig.ColMap(), 0 );
85 Epetra_IntVector Cols( OldDomainMap );
86 Epetra_IntVector NewCols( OldColMap );
87 Epetra_Import Importer( OldColMap, OldDomainMap );
89 Epetra_Map tmpColMap( NumGlobalElements, NumMyElements, 0, OldDomainMap.Comm() );
91 for(
int i = 0; i < NumMyElements; ++i )
92 Cols[i] = tmpColMap.GID(i);
94 NewCols.Import( Cols, Importer, Insert );
96 std::vector<int*> NewColIndices(1);
97 NewCols.ExtractView( &NewColIndices[0] );
99 int NumMyColElements = OldColMap.NumMyElements();
100 int NumGlobalColElements = OldColMap.NumGlobalElements();
102 NewColMap_ =
new Epetra_Map( NumGlobalColElements, NumMyColElements, NewColIndices[0], OldColMap.IndexBase(), OldColMap.Comm() );
105 Epetra_CrsMatrix * NewMatrix =
new Epetra_CrsMatrix( View, NewRowMap_, *NewColMap_, 0 );
111 int numMyRows = NewMatrix->NumMyRows();
112 for(
int i = 0; i < numMyRows; ++i )
114 orig.ExtractMyRowView( i, indicesCnt, myValues, myIndices );
115 NewMatrix->InsertMyValues( i, indicesCnt, myValues, myIndices );
118 NewMatrix->FillComplete();
~CrsMatrix_Reindex()
Destructor.
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
NewTypeRef operator()(OriginalTypeRef orig)
Constructs "reindexed" Matrix.