64 #include "../../test/epetra_test_err.h"
69 int NumGlobalNonzeros1,
int* MyGlobalElements,
bool verbose);
74 int main(
int argc,
char *argv[]) {
85 MPI_Init(&argc,&argv);
88 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
102 if(argv[1][0]==
'-' && argv[1][1]==
'v') {
107 if(verbose && rank == 0)
116 int MyPID = Comm.
MyPID();
118 if(verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc <<
" is alive." << endl;
120 bool verbose1 = verbose;
123 if(verbose && rank != 0)
126 int NumMyEquations = 5;
127 int NumGlobalEquations = NumMyEquations*NumProc+
EPETRA_MIN(NumProc,3);
142 int* NumNz =
new int[NumMyEquations];
147 for(i=0; i<NumMyEquations; i++)
148 if(MyGlobalElements[i]==0 || MyGlobalElements[i] == NumGlobalEquations-1)
163 Indices =
new int[2];
167 for(i = 0; i < NumMyEquations; i++) {
168 if(MyGlobalElements[i] == 0) {
172 else if(MyGlobalElements[i] == NumGlobalEquations-1) {
173 Indices[0] = NumGlobalEquations-2;
177 Indices[0] = MyGlobalElements[i]-1;
178 Indices[1] = MyGlobalElements[i]+1;
200 if(verbose) cout <<
"\n*****Testing variable entry constructor\n" << endl;
202 int NumMyNonzeros = 3 * NumMyEquations;
205 if(A.
LRID(NumGlobalEquations-1) >= 0)
208 EPETRA_TEST_ERR(
check(A, NumMyEquations, NumGlobalEquations, NumMyNonzeros, 3*NumGlobalEquations-2,
209 MyGlobalElements, verbose),ierr);
211 for(i = 0; i < NumMyEquations; i++)
214 for(i = 0; i < NumMyEquations; i++)
218 if(verbose) cout <<
"NumIndices function check OK" << endl;
224 if(verbose) cout <<
"\n*****Testing constant entry constructor\n" << endl;
230 for(i = 0; i < NumMyEquations; i++)
248 EPETRA_TEST_ERR(
check(AA, NumMyEquations, NumGlobalEquations, NumMyEquations, NumGlobalEquations,
249 MyGlobalElements, verbose),ierr);
254 for(i = 0; i < NumMyEquations; i++)
258 if(verbose) cout <<
"NumIndices function check OK" << endl;
262 if(verbose) cout <<
"\n*****Testing copy constructor\n" << endl;
267 EPETRA_TEST_ERR(
check(B, NumMyEquations, NumGlobalEquations, NumMyEquations, NumGlobalEquations,
268 MyGlobalElements, verbose),ierr);
271 for(i = 0; i < NumMyEquations; i++)
275 if(verbose) cout <<
"NumIndices function check OK" << endl;
279 if(verbose) cout <<
"\n*****Testing post construction modifications\n" << endl;
285 delete[] MyGlobalElements;
294 int NumMyElements1 = 4;
295 int NumMyEquations1 = NumMyElements1;
296 int NumGlobalEquations1 = NumMyEquations1*NumProc;
307 int* NumNz1 =
new int[NumMyEquations1];
312 for(i = 0; i < NumMyEquations1; i++)
313 if(MyGlobalElements1[i]==1 || MyGlobalElements1[i] == NumGlobalEquations1)
327 int* Indices1 =
new int[2];
331 for(i = 0; i < NumMyEquations1; i++) {
332 if(MyGlobalElements1[i]==1) {
336 else if(MyGlobalElements1[i] == NumGlobalEquations1) {
337 Indices1[0] = NumGlobalEquations1-1;
341 Indices1[0] = MyGlobalElements1[i]-1;
342 Indices1[1] = MyGlobalElements1[i]+1;
353 if(verbose) cout <<
"Print out tridiagonal matrix, each part on each processor. Index base is one.\n" << endl;
359 delete[] MyGlobalElements1;
367 if(verbose) cout <<
"\n*****Checking cpy ctr, op=, and reference counting." << endl;
370 if(verbose && (tempierr == 0)) cout <<
"Checked OK." << endl;
374 if(verbose) cout <<
"\n*****Checking shared-ownership tests." << endl;
377 if(verbose && (tempierr == 0)) cout <<
"Checked OK." << endl;
394 const int NumMyElements = 10;
395 const int IndexBase = 0;
396 Epetra_Map Map1(-1, NumMyElements, IndexBase, Comm);
398 const int NumIndicesPerRow = 5;
404 array1[0] = NumIndicesPerRow / 2;
405 array1[1] = array1[0] + 1;
407 for(
int i = 0; i < NumIndicesPerRow; i++)
410 int soleOutput, sharedOutput;
413 if(verbose) cout <<
"InsertMyIndices..." << endl;
418 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
439 if(verbose) cout <<
"FillComplete..." << endl;
444 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
447 if(verbose) cout <<
"OptimizeStorage..." << endl;
452 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
455 if(verbose) cout <<
"RemoveMyIndices..." << endl;
460 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
463 if(verbose) cout <<
"RemoveMyIndices(#2)..." << endl;
468 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
471 if(verbose) cout <<
"FillComplete(#2)..." << endl;
476 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
485 int GlobalRow = SoleOwnerG.
GRID(0);
488 if(verbose) cout <<
"InsertGlobalIndices..." << endl;
493 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
496 if(verbose) cout <<
"RemoveGlobalIndices..." << endl;
501 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
504 if(verbose) cout <<
"RemoveGlobalIndices(#2)..." << endl;
509 if(verbose && ierr > 0) cout <<
"soleOutput = " << soleOutput <<
" sharedOutput = " << sharedOutput << endl;
527 const int NumIndicesPerRow = 10;
528 const int NumGlobalElements = 50;
529 const int IndexBase = 0;
530 Epetra_Map Map1(NumGlobalElements, IndexBase, Comm);
535 if(verbose) cout <<
"Graph1 created (def ctr). data addr = " << g1addr <<
" ref. count = " << g1count << endl;
544 if(verbose) cout <<
"Graph2 created (cpy ctr). data addr = " << g2addr <<
" ref. count = " << g2count << endl;
550 if(verbose) cout <<
"Graph2 destroyed. Graph1 data addr = " << g1newaddr <<
" ref. count = " << g1newcount << endl;
557 if(verbose) cout <<
"Graph3 created (op= before). data addr = " << g3addr <<
" ref. count = " << g3count << endl;
563 if(verbose) cout <<
"Graph3 set equal to Graph1 (op= after). data addr = " << g3addr <<
" ref. count = " << g3count << endl;
570 int NumGlobalNonzeros1,
int* MyGlobalElements,
bool verbose)
572 (void)MyGlobalElements;
577 int NumGlobalIndices;
581 int* MyCopyIndices =
new int[MaxNumIndices];
582 int* GlobalCopyIndices =
new int[MaxNumIndices];
587 if(verbose) cout <<
"Number of local Rows = " << NumMyRows << endl;
592 if(verbose) cout <<
"Number of local Nonzero entries = " << NumMyNonzeros << endl;
597 if(verbose) cout <<
"Number of global Rows = " << NumGlobalRows << endl;
602 if(verbose) cout <<
"Number of global Nonzero entries = " << NumGlobalNonzeros << endl;
624 for(i = 0; i < NumMyRows; i++) {
628 forierr += !(NumGlobalIndices==NumMyIndices);
629 for(j = 1; j < NumMyIndices; j++)
EPETRA_TEST_ERR(!(MyViewIndices[j-1]<MyViewIndices[j]),ierr);
630 for(j = 0; j < NumGlobalIndices; j++) {
631 forierr += !(GlobalCopyIndices[j]==A.
GCID(MyViewIndices[j]));
632 forierr += !(A.
LCID(GlobalCopyIndices[j])==MyViewIndices[j]);
637 for(i = 0; i < NumMyRows; i++) {
641 forierr += !(NumGlobalIndices==NumMyIndices);
642 for(j = 1; j < NumMyIndices; j++)
644 for(j = 0; j < NumGlobalIndices; j++) {
645 forierr += !(GlobalCopyIndices[j]==A.
GCID(MyCopyIndices[j]));
646 forierr += !(A.
LCID(GlobalCopyIndices[j])==MyCopyIndices[j]);
652 delete[] MyCopyIndices;
653 delete[] GlobalCopyIndices;
655 if(verbose) cout <<
"Rows sorted check OK" << endl;
const Epetra_BlockMap & RangeMap() const
Returns the RangeMap associated with this graph.
int NumGlobalRows() const
Returns the number of matrix rows in global matrix.
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
int FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
int NumGlobalIndices(long long Row) const
Returns the current number of nonzero entries in specified global row on this processor.
#define EPETRA_TEST_ERR(a, b)
bool MyGlobalRow(int GID) const
Returns true of GID is owned by the calling processor, otherwise it returns false.
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
bool MyGRID(int GRID_in) const
Returns true if the GRID passed in belongs to the calling processor in this map, otherwise returns fa...
int InsertMyIndices(int LocalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified local row of the graph.
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
int NumMyRows() const
Returns the number of matrix rows on this processor.
const Epetra_BlockMap & DomainMap() const
Returns the DomainMap associated with this graph.
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
int check(Epetra_CrsGraph &A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1, int NumGlobalNonzeros1, int *MyGlobalElements, bool verbose)
Epetra_CrsGraphData: The Epetra CrsGraph Data Class.
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...
int RemoveGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Remove a list of elements from a specified global row of the graph.
bool MyLRID(int LRID_in) const
Returns true if the LRID passed in belongs to the calling processor in this map, otherwise returns fa...
int NumMyElements() const
Number of elements on the calling processor.
const Epetra_CrsGraphData * DataPtr() const
Returns a pointer to the CrsGraphData instance this CrsGraph uses.
int LCID(int GCID_in) const
Returns the local column index for given global column index, returns -1 if no local column for this ...
Epetra_Comm: The Epetra Communication Abstract Base Class.
int OptimizeStorage()
Make consecutive row index sections contiguous, minimize internal storage used for constructing graph...
int ExtractMyRowCopy(int LocalRow, int LenOfIndices, int &NumIndices, int *Indices) const
Extract a list of elements in a specified local row of the graph. Put into storage allocated by calli...
bool IndicesAreGlobal() const
If column indices are in global range, this query returns true, otherwise it returns false...
int GCID(int LCID_in) const
Returns the global column index for give local column index, returns IndexBase-1 if we don't have thi...
int NumGlobalNonzeros() const
Returns the number of indices in the global graph.
const Epetra_BlockMap & RowMap() const
Returns the RowMap associated with this graph.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
int ExtractGlobalRowCopy(int GlobalRow, int LenOfIndices, int &NumIndices, int *Indices) const
Extract a list of elements in a specified global row of the graph. Put into storage allocated by call...
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified global row of the graph.
int MaxMyGID() const
Returns the maximum global ID owned by this processor.
int MinMyGID() const
Returns the minimum global ID owned by this processor.
int ExtractMyRowView(int LocalRow, int &NumIndices, int *&Indices) const
Get a view of the elements in a specified local row of the graph.
Epetra_SerialComm: The Epetra Serial Communication Class.
int ReferenceCount() const
Returns the reference count of CrsGraphData.
int NumMyIndices(int Row) const
Returns the current number of nonzero entries in specified local row on this processor.
int GRID(int LRID_in) const
Returns the global row index for give local row index, returns IndexBase-1 if we don't have this loca...
bool UpperTriangular() const
If graph is upper triangular in local index space, this query returns true, otherwise it returns fals...
bool StorageOptimized() const
If OptimizeStorage() has been called, this query returns true, otherwise it returns false...
int RemoveMyIndices(int LocalRow, int NumIndices, int *Indices)
Remove a list of elements from a specified local row of the graph.
void Barrier() const
Epetra_SerialComm Barrier function.
int MaxNumIndices() const
Returns the maximum number of nonzero entries across all rows on this processor.
int main(int argc, char *argv[])
bool NoDiagonal() const
If graph has no diagonal entries in global index space, this query returns true, otherwise it returns...
int * Values()
Returns pointer to the values in vector.
int NumMyNonzeros() const
Returns the number of indices in the local graph.
int ExtractGlobalRowView(int GlobalRow, int &NumIndices, int *&Indices) const
Get a view of the elements in a specified global row of the graph.
bool LowerTriangular() const
If graph is lower triangular in local index space, this query returns true, otherwise it returns fals...
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
int checkCopyAndAssignment(Epetra_Comm &Comm, bool verbose)
bool IndicesAreLocal() const
If column indices are in local range, this query returns true, otherwise it returns false...
int checkSharedOwnership(Epetra_Comm &Comm, bool verbose)