61 int* numIndicesPerRow,
62 bool ignoreNonLocalEntries,
63 bool buildNonlocalGraph)
67 ignoreNonLocalEntries_(ignoreNonLocalEntries),
68 nonlocalGraph_ (NULL),
69 buildNonlocalGraph_ (buildNonlocalGraph)
77 bool ignoreNonLocalEntries,
78 bool buildNonlocalGraph)
82 ignoreNonLocalEntries_(ignoreNonLocalEntries),
83 nonlocalGraph_ (NULL),
84 buildNonlocalGraph_ (buildNonlocalGraph)
94 int* numIndicesPerRow,
95 bool ignoreNonLocalEntries,
96 bool buildNonlocalGraph)
100 ignoreNonLocalEntries_(ignoreNonLocalEntries),
101 nonlocalGraph_ (NULL),
102 buildNonlocalGraph_ (buildNonlocalGraph)
112 int numIndicesPerRow,
113 bool ignoreNonLocalEntries,
114 bool buildNonlocalGraph)
118 ignoreNonLocalEntries_(ignoreNonLocalEntries),
119 nonlocalGraph_ (NULL),
120 buildNonlocalGraph_ (buildNonlocalGraph)
142 template<
typename int_type>
144 int numCols,
const int_type* cols)
151 for(
int i=0; i<numRows; ++i) {
152 const int LID = thisgraph->
LRID(rows[i]);
156 const_cast<int_type*>(cols));
159 nonlocalRowData<int_type>()[rows[i]].AddEntries(numCols,cols);
162 if (err < 0)
return (err);
163 if (err > 0) returncode = err;
168 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 171 if(
RowMap().GlobalIndicesInt())
172 return InsertGlobalIndices<int>(numRows, rows, numCols, cols);
174 throw ReportError(
"Epetra_FECrsGraph::InsertGlobalIndices int version called for a matrix that is not int.", -1);
177 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 180 if(
RowMap().GlobalIndicesLongLong())
181 return InsertGlobalIndices<long long>(numRows, rows, numCols, cols);
183 throw ReportError(
"Epetra_FECrsGraph::InsertGlobalIndices long long version called for a matrix that is not long long.", -1);
191 static_cast<Epetra_Map&>(this->CrsGraphData_->RowMap_),
196 template<
typename int_type>
199 bool callFillComplete)
202 if (callFillComplete) {
217 std::map<int_type,Epetra_CrsGraphData::EntriesInOneRow<int_type> >& nonlocalRowData_var = nonlocalRowData<int_type>();
219 const int numRows = (int) nonlocalRowData_var.size();
220 int_type * presentRowIndices =
new int_type[numRows];
221 typename std::map<int_type,Epetra_CrsGraphData::EntriesInOneRow<int_type> >::iterator nonlocalRows
222 = nonlocalRowData<int_type>().begin();
223 for (
int i=0 ; nonlocalRows != nonlocalRowData_var.end(); ++nonlocalRows, ++i)
224 presentRowIndices[i] = (int_type) nonlocalRows->first;
233 if (callFillComplete) {
236 delete [] presentRowIndices;
246 for (nonlocalRows = nonlocalRowData_var.begin();
247 nonlocalRows != nonlocalRowData_var.end(); ++nonlocalRows)
248 allColumns.
AddEntries((
int) nonlocalRows->second.entries_.size(),
249 nonlocalRows->second.entries_.size() ? &nonlocalRows->second.entries_[0] : 0);
258 int * rowLengths =
new int[numRows];
261 for (nonlocalRows = nonlocalRowData_var.begin();
262 nonlocalRows != nonlocalRowData_var.end() ; ++nonlocalRows, ++i)
263 rowLengths[i] = (
int) nonlocalRows->second.entries_.size();
280 for (nonlocalRows = nonlocalRowData_var.begin();
281 nonlocalRows != nonlocalRowData_var.end(); ++nonlocalRows)
283 (
int) nonlocalRows->second.entries_.size(),
284 nonlocalRows->second.entries_.size() ? &nonlocalRows->second.entries_[0] : 0) );
299 if(callFillComplete) {
304 for (nonlocalRows = nonlocalRowData_var.begin();
305 nonlocalRows != nonlocalRowData_var.end(); ++nonlocalRows)
306 nonlocalRows->second.entries_.clear();
307 nonlocalRowData_var.clear();
309 delete [] rowLengths;
310 delete [] presentRowIndices;
322 bool callFillComplete)
325 throw ReportError(
"Epetra_FECrsGraph::GlobalAssemble: cannot be called with different indices types for domainMap and rangeMap", -1);
328 throw ReportError(
"Epetra_FECrsGraph::GlobalAssemble: cannot be called with different indices types for row map and incoming rangeMap", -1);
331 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
332 return GlobalAssemble<int>(domain_map, range_map, callFillComplete);
334 throw ReportError(
"Epetra_FECrsGraph::GlobalAssemble: ERROR, GlobalIndicesInt but no API for it.",-1);
337 if(
RowMap().GlobalIndicesLongLong())
338 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 339 return GlobalAssemble<long long>(domain_map, range_map, callFillComplete);
341 throw ReportError(
"Epetra_FECrsGraph::GlobalAssemble: ERROR, GlobalIndicesLongLong but no API for it.",-1);
344 throw ReportError(
"Epetra_FECrsGraph::GlobalAssemble: cannot determine global index type", -1);
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.
Epetra_Map: A class for partitioning vectors and matrices.
int InsertGlobalIndices(int numRows, const int *rows, int numCols, const int *cols)
Insert a rectangular, dense 'submatrix' of entries (matrix nonzero positions) into the graph...
int FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
Store some data for each row describing which entries of this row are nonzero.
Epetra_CrsGraph * nonlocalGraph_
A CrsGraph holding non-local data in case the respective flag is set in the constructor.
long long MinMyGID64() const
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this graph.
long long IndexBase64() const
#define EPETRA_CHK_ERR(a)
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
int GlobalAssemble(bool callFillComplete=true)
Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was ...
Epetra_FECrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap &RowMap, int *NumIndicesPerRow, bool ignoreNonLocalEntries=false, bool buildNonlocalGraph=false)
Constructor.
virtual ~Epetra_FECrsGraph()
Constructor.
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
long long NumGlobalElements64() const
const Epetra_BlockMap & RowMap() const
Returns the RowMap associated with this graph.
Epetra_CrsGraphData * CrsGraphData_
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Exports an Epetra_DistObject using the Epetra_Import object.
Epetra_CrsGraph(Epetra_DataAccess CV, const Epetra_BlockMap &RowMap, const int *NumIndicesPerRow, bool StaticProfile=false)
Epetra_CrsGraph constuctor with variable number of indices per row.
void SetIndicesAreGlobal(bool Flag)
int OptimizeStorage()
Make consecutive row index sections contiguous, minimize internal storage used for constructing graph...
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
int NumMyElements() const
Number of elements on the calling processor.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
std::vector< int_type > entries_
Storage for the column indices of this row.
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified global row of the graph.
void AddEntries(const int n_cols, const int_type *col_nums)
Add many entries to one row.
long long IndexBase64() const
bool GlobalIndicesTypeMatch(const Epetra_BlockMap &other) const
int InsertIndicesIntoSorted(int Row, int NumIndices, int *Indices)
int LRID(int GRID_in) const
Returns the local row index for given global row index, returns -1 if no local row for this global ro...
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
bool ignoreNonLocalEntries_