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_;
61 template<
typename int_type>
68 assert( !orig.IndicesAreGlobal() );
71 const Epetra_Map & RowMap = orig.RowMap();
72 const Epetra_Map & DomainMap = orig.DomainMap();
73 const Epetra_Map & ColMap = orig.ColMap();
74 const Epetra_Comm & Comm = RowMap.Comm();
75 int NumMyRows = RowMap.NumMyElements();
76 int NumCols = DomainMap.NumMyElements();
78 for(
int i = 0; i < NumCols; ++i )
79 if( DomainMap.GID64(i) != ColMap.GID64(i) )
86 Comm.SumAll( &Match, &MatchAll, 1 );
95 std::vector<int_type> Cols(NumCols);
97 for(
int i = 0; i < NumCols; ++i )
98 Cols[i] = (int_type) DomainMap.GID64(i);
101 int NumMyCols = ColMap.NumMyElements();
102 for(
int i = 0; i < NumMyCols; ++i )
103 if( !DomainMap.MyGID( ColMap.GID64(i) ) ) Cols.push_back( (int_type) ColMap.GID64(i) );
105 int NewNumMyCols = Cols.size();
106 int NewNumGlobalCols;
107 Comm.SumAll( &NewNumMyCols, &NewNumGlobalCols, 1 );
109 NewColMap_ =
new Epetra_Map( NewNumGlobalCols, NewNumMyCols,&Cols[0], DomainMap.IndexBase64(), Comm );
112 std::vector<int> NumIndicesPerRow( NumMyRows );
113 for(
int i = 0; i < NumMyRows; ++i )
114 NumIndicesPerRow[i] = orig.NumMyEntries(i);
115 NewGraph_ =
new Epetra_CrsGraph( Copy, RowMap, *NewColMap_, &NumIndicesPerRow[0] );
117 int MaxNumEntries = orig.MaxNumEntries();
119 std::vector<int_type> Indices( MaxNumEntries );
120 for(
int i = 0; i < NumMyRows; ++i )
122 int_type RowGID = (int_type) RowMap.GID64(i);
123 orig.Graph().ExtractGlobalRowCopy( RowGID, MaxNumEntries, NumEntries, &Indices[0] );
124 NewGraph_->InsertGlobalIndices( RowGID, NumEntries, &Indices[0] );
126 const Epetra_Map & RangeMap = orig.RangeMap();
127 NewGraph_->FillComplete(DomainMap,RangeMap);
130 Epetra_CrsMatrix * NewMatrix =
new Epetra_CrsMatrix( View, *NewGraph_ );
136 int numMyRows = NewMatrix->NumMyRows();
137 for(
int i = 0; i < numMyRows; ++i )
139 orig.ExtractMyRowView( i, indicesCnt, myValues, myIndices );
140 NewGraph_->ExtractMyRowView( i, indicesCnt, myIndices );
142 NewMatrix->InsertMyValues( i, indicesCnt, myValues, myIndices );
145 NewMatrix->FillComplete(DomainMap,RangeMap);
157 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 158 if(orig.RowMap().GlobalIndicesInt()) {
159 return construct<int>(orig);
163 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 164 if(orig.RowMap().GlobalIndicesLongLong()) {
165 return construct<long long>(orig);
169 throw "CrsMatrix_SolverMap::operator(): GlobalIndices type unknown";
NewTypeRef operator()(OriginalTypeRef orig)
Constructs fixed view of Epetra_CrsMatrix as necessary.
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
~CrsMatrix_SolverMap()
Destructor.