42 #include <Epetra_ConfigDefs.h> 47 #include <Epetra_CrsMatrix.h> 48 #include <Epetra_Map.h> 49 #include <Epetra_GIDTypeVector.h> 51 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 52 #include <Epetra_LongLongVector.h> 55 #include <Epetra_Export.h> 56 #include <Epetra_Import.h> 64 if( NewColMap_ )
delete NewColMap_;
67 template<
typename int_type>
70 Toperator( OriginalTypeRef orig )
76 Epetra_Map & OldDomainMap =
const_cast<Epetra_Map&
>(orig.OperatorDomainMap());
77 Epetra_Map & OldColMap =
const_cast<Epetra_Map&
>(orig.ColMap());
78 int NumMyElements = OldDomainMap.NumMyElements();
79 int_type NumGlobalElements = (int_type) OldDomainMap.NumGlobalElements64();
80 assert( orig.RowMap().NumMyElements() == NewRowMap_.NumMyElements() );
82 if (NumGlobalElements == 0 && orig.RowMap().NumGlobalElements64() == 0 )
85 Epetra_CrsMatrix * NewMatrix =
new Epetra_CrsMatrix( View, orig.RowMap(), orig.ColMap(), 0 );
91 typename Epetra_GIDTypeVector<int_type>::impl Cols( OldDomainMap );
92 typename Epetra_GIDTypeVector<int_type>::impl NewCols( OldColMap );
93 Epetra_Import Importer( OldColMap, OldDomainMap );
95 Epetra_Map tmpColMap( NumGlobalElements, NumMyElements, 0, OldDomainMap.Comm() );
97 for(
int i = 0; i < NumMyElements; ++i )
98 Cols[i] = (int_type) tmpColMap.GID64(i);
100 NewCols.Import( Cols, Importer, Insert );
102 std::vector<int_type*> NewColIndices(1);
103 NewCols.ExtractView( &NewColIndices[0] );
105 int NumMyColElements = OldColMap.NumMyElements();
106 int_type NumGlobalColElements = (int_type) OldColMap.NumGlobalElements64();
108 NewColMap_ =
new Epetra_Map( NumGlobalColElements, NumMyColElements, NewColIndices[0], (int_type) OldColMap.IndexBase64(), OldColMap.Comm() );
111 Epetra_CrsMatrix * NewMatrix =
new Epetra_CrsMatrix( View, NewRowMap_, *NewColMap_, 0 );
117 int numMyRows = NewMatrix->NumMyRows();
118 for(
int i = 0; i < numMyRows; ++i )
120 orig.ExtractMyRowView( i, indicesCnt, myValues, myIndices );
121 NewMatrix->InsertMyValues( i, indicesCnt, myValues, myIndices );
124 NewMatrix->FillComplete();
137 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 138 if(orig.RowMatrixRowMap().GlobalIndicesInt())
139 return Toperator<int>(orig);
142 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 143 if(orig.RowMatrixRowMap().GlobalIndicesLongLong())
144 return Toperator<long long>(orig);
147 throw "EpetraExt::CrsMatrix_Reindex::operator(): Global indices unknown.";
~CrsMatrix_Reindex()
Destructor.
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
NewTypeRef operator()(OriginalTypeRef orig)
Constructs "reindexed" Matrix.