42 #ifndef EpetraExt_TCRSGRAPH_MAPCOLORINGINDEX_H 43 #define EpetraExt_TCRSGRAPH_MAPCOLORINGINDEX_H 46 #include <Epetra_GIDTypeVector.h> 47 #include <Epetra_MapColoring.h> 52 class Epetra_CrsGraph;
53 class Epetra_IntVector;
62 template<
typename int_type>
64 :
public StructuralTransform< Epetra_CrsGraph,std::vector<typename Epetra_GIDTypeVector<int_type>::impl> > {
94 template<
typename int_type>
99 if(!orig.RowMap().
template GlobalIndicesIsType<int_type>())
100 throw "EpetraExt::TCrsGraph_MapColoringIndex::operator(): Global indices mismatch.";
102 Base::origObj_ = &orig;
104 const Epetra_BlockMap & RowMap = orig.RowMap();
105 int nRows = RowMap.NumMyElements();
107 int NumColors = ColorMap_.NumColors();
108 int * ListOfColors = ColorMap_.ListOfColors();
110 std::map<int,int> MapOfColors;
111 for(
int i = 0; i < NumColors; ++i ) MapOfColors[ ListOfColors[i] ] = i;
114 std::vector<int_type> dummy( nRows, -1 );
115 typename Base::NewTypePtr IndexVec =
new typename Base::NewType( NumColors,
typename Epetra_GIDTypeVector<int_type>::impl( Copy, RowMap, &dummy[0] ) );
117 int MaxNumIndices = orig.MaxNumIndices();
119 std::vector<int_type> Indices( MaxNumIndices );
121 for(
int i = 0; i < nRows; ++i )
123 orig.ExtractGlobalRowCopy( (int_type) orig.GRID64(i), MaxNumIndices, NumIndices, &Indices[0] );
125 for(
int j = 0; j < NumIndices; ++j )
126 (*IndexVec)[ MapOfColors[ColorMap_(Indices[j])] ][i] = Indices[j];
129 Base::newObj_ = IndexVec;
136 #endif // EpetraExt_TCRSGRAPH_MAPCOLORINGINDEX_H StructuralTransform< Epetra_CrsGraph, std::vector< typename Epetra_GIDTypeVector< int_type >::impl > > Base
const Epetra_MapColoring & ColorMap_
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
Base::NewTypeRef NewTypeRef
Generates a std::vector<Epetra_IntVector> from the input Epetra_CrsGraph.
~TCrsGraph_MapColoringIndex()
Destructor.
Generates a std::vector of Epetra_IntVector's to be used to map perturbation contributions to a CrsGr...
NewTypeRef operator()(OriginalTypeRef orig)
Base::OriginalTypeRef OriginalTypeRef
TCrsGraph_MapColoringIndex(const Epetra_MapColoring &ColorMap)
Constructor input param ColorMap defines the perturbation coloring.