44 #include <Epetra_CrsGraph.h>
45 #include <Epetra_CrsMatrix.h>
46 #include <Epetra_Map.h>
47 #include <Epetra_Comm.h>
57 if( NewGraph_ )
delete NewGraph_;
58 if( NewColMap_ )
delete NewColMap_;
67 assert( !orig.IndicesAreGlobal() );
70 const Epetra_Map & RowMap = orig.RowMap();
71 const Epetra_Map & DomainMap = orig.DomainMap();
72 const Epetra_Map & ColMap = orig.ColMap();
73 const Epetra_Comm & Comm = RowMap.Comm();
74 int NumMyRows = RowMap.NumMyElements();
75 int NumCols = DomainMap.NumMyElements();
77 for(
int i = 0; i < NumCols; ++i )
78 if( DomainMap.GID(i) != ColMap.GID(i) )
85 Comm.SumAll( &Match, &MatchAll, 1 );
94 std::vector<int> Cols(NumCols);
96 for(
int i = 0; i < NumCols; ++i )
97 Cols[i] = DomainMap.GID(i);
100 int NumMyCols = ColMap.NumMyElements();
101 for(
int i = 0; i < NumMyCols; ++i )
102 if( !DomainMap.MyGID( ColMap.GID(i) ) ) Cols.push_back( ColMap.GID(i) );
104 int NewNumMyCols = Cols.size();
105 int NewNumGlobalCols;
106 Comm.SumAll( &NewNumMyCols, &NewNumGlobalCols, 1 );
108 NewColMap_ =
new Epetra_Map( NewNumGlobalCols, NewNumMyCols,&Cols[0], DomainMap.IndexBase(), Comm );
111 std::vector<int> NumIndicesPerRow( NumMyRows );
112 for(
int i = 0; i < NumMyRows; ++i )
113 NumIndicesPerRow[i] = orig.NumMyEntries(i);
114 NewGraph_ =
new Epetra_CrsGraph( Copy, RowMap, *NewColMap_, &NumIndicesPerRow[0] );
116 int MaxNumEntries = orig.MaxNumEntries();
118 std::vector<int> Indices( MaxNumEntries );
119 for(
int i = 0; i < NumMyRows; ++i )
121 int RowGID = RowMap.GID(i);
122 orig.Graph().ExtractGlobalRowCopy( RowGID, MaxNumEntries, NumEntries, &Indices[0] );
123 NewGraph_->InsertGlobalIndices( RowGID, NumEntries, &Indices[0] );
125 const Epetra_Map & RangeMap = orig.RangeMap();
126 NewGraph_->FillComplete(DomainMap,RangeMap);
129 Epetra_CrsMatrix * NewMatrix =
new Epetra_CrsMatrix( View, *NewGraph_ );
135 int numMyRows = NewMatrix->NumMyRows();
136 for(
int i = 0; i < numMyRows; ++i )
138 orig.ExtractMyRowView( i, indicesCnt, myValues, myIndices );
139 NewGraph_->ExtractMyRowView( i, indicesCnt, myIndices );
141 NewMatrix->InsertMyValues( i, indicesCnt, myValues, myIndices );
144 NewMatrix->FillComplete(DomainMap,RangeMap);
NewTypeRef operator()(OriginalTypeRef orig)
Constructs fixed view of Epetra_CrsMatrix as necessary.
~CrsMatrix_SolverMap()
Destructor.