55 #include "../epetra_test_err.h" 61 int NumGlobalNonzeros1,
int * MyGlobalElements,
bool verbose);
67 double * lambda,
int niters,
double tolerance,
79 Epetra_Vector Xa(Xamap), Xb(Xbmap), Ya(Yamap), Yb(Ybmap), Diff(Yamap);
87 Xb.Import(Xa,Ximport,
Insert);
131 Xb_alias.Import(Xa,Ximport,
Insert);
135 if(Bmap) B.
Apply(*Xb,*Yb);
146 delete Xb;
delete Yb;
155 if(rv) {cerr<<
"build_matrix_unfused: Import failed"<<endl;
return rv;}
164 if(rv) {cerr<<
"build_matrix_unfused: Export failed"<<endl;
return rv;}
174 int MyPID = Comm.
MyPID();
178 int NumMyEquations = 100;
180 int NumGlobalEquations = (NumMyEquations * NumProc) +
EPETRA_MIN(NumProc,3);
181 if(MyPID < 3) NumMyEquations++;
184 Epetra_Map Map(NumGlobalEquations, NumMyEquations, 0, Comm);
193 int* NumNz =
new int[NumMyEquations];
198 for (
int i = 0; i < NumMyEquations; i++)
199 if((MyGlobalElements[i] == 0) || (MyGlobalElements[i] == NumGlobalEquations - 1))
211 double* Values =
new double[2];
214 int* Indices =
new int[2];
218 for (
int i = 0; i < NumMyEquations; i++) {
219 if(MyGlobalElements[i] == 0) {
223 else if (MyGlobalElements[i] == NumGlobalEquations-1) {
224 Indices[0] = NumGlobalEquations-2;
228 Indices[0] = MyGlobalElements[i]-1;
229 Indices[1] = MyGlobalElements[i]+1;
239 delete [] MyGlobalElements;
255 int num_local = MyPID==0 ? num_global : 0;
261 if(MyPID==0) num_local = num_global/2;
262 else if(MyPID==2) num_local = num_global - ((int)num_global/2);
268 int main(
int argc,
char *argv[])
274 MPI_Init(&argc,&argv);
277 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
280 bool verbose =
false;
283 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
285 int verbose_int = verbose ? 1 : 0;
287 verbose = verbose_int==1 ? true :
false;
290 int MyPID = Comm.
MyPID();
293 if(verbose && MyPID==0)
296 if (verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc
297 <<
" is alive."<<endl;
300 if(verbose && rank!=0) verbose =
false;
307 double diff_tol=1e-12;
309 #define ENABLE_TEST_1 310 #define ENABLE_TEST_2 311 #define ENABLE_TEST_3 312 #define ENABLE_TEST_4 313 #define ENABLE_TEST_5 314 #define ENABLE_TEST_6 326 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,0,Comm);
327 else Map1=
new Epetra_Map(num_global,0,0,Comm);
335 if(MyPID==0) cout<<
"FusedImport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
346 if(MyPID==0) cout<<
"FusedExport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
350 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
364 std::vector<int> MyGIDS(num_local);
365 for(
int i=0; i<num_local; i++)
366 MyGIDS[i] = A->
RowMap().
GID(num_local-i-1);
369 Map1=
new Epetra_Map(-1,num_local,&MyGIDS[0],0,Comm);
377 if(MyPID==0) cout<<
"FusedImport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
388 if(MyPID==0) cout<<
"FusedExport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
392 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
407 Comm.
ScanSum(&num_local,&num_scansum,1);
410 std::vector<int> MyGIDS(num_local);
411 for(
int i=0; i<num_local; i++)
412 MyGIDS[i] = num_global - num_scansum + num_local - i - 1;
413 Map1=
new Epetra_Map(-1,num_local,&MyGIDS[0],0,Comm);
422 if(MyPID==0) cout<<
"FusedImport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
433 if(MyPID==0) cout<<
"FusedExport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
437 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
452 std::vector<int> MyGIDS(num_local);
454 for(
int i=0, idx=0; i<A->
NumMyCols(); i++)
456 MyGIDS[idx] = A->
GCID(i);
461 const int * MyGIDS_ptr = MyGIDS.size() ? &MyGIDS[0] : 0;
462 Map1=
new Epetra_Map(-1,num_local,MyGIDS_ptr,0,Comm);
475 if(MyPID==0) cout<<
"FusedImport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
486 if(MyPID==0) cout<<
"FusedExport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
490 delete A;
delete B;
delete C;
delete Map1;
delete Import1;
delete Export1;
512 if(MyPID==0) cout<<
"FusedImport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
523 if(MyPID==0) cout<<
"FusedExport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
527 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
549 if(MyPID==0) cout<<
"FusedImport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
560 if(MyPID==0) cout<<
"FusedExport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
564 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
570 if(MyPID==0 && total_err==0)
571 cout<<
"FusedImportExport: All tests PASSED."<<endl;
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
int Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
double * Values() const
Get pointer to MultiVector values.
int NumProc() const
Returns total number of processes.
int check(Epetra_CrsMatrix &A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1, int NumGlobalNonzeros1, int *MyGlobalElements, bool verbose)
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
Epetra_Map: A class for partitioning vectors and matrices.
double test_with_matvec(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B)
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 check_graph_sharing(Epetra_Comm &Comm)
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
bool SameAs(const Epetra_BlockMap &Map) const
Returns true if this and Map are identical maps.
int NumMyCols() const
Returns the number of entries in the set of column-indices that appear on this processor.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given global row of the matrix.
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
int power_method(bool TransA, Epetra_CrsMatrix &A, Epetra_Vector &q, Epetra_Vector &z, Epetra_Vector &resid, double *lambda, int niters, double tolerance, bool verbose)
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_MpiComm Broadcast function.
double test_with_matvec_reduced_maps(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B, const Epetra_Map &Bfullmap)
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
virtual int MyPID() const =0
Return my process ID.
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
int build_matrix_unfused(const Epetra_CrsMatrix &SourceMatrix, Epetra_Import &RowImporter, Epetra_CrsMatrix *&A)
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_Comm: The Epetra Communication Abstract Base Class.
void build_test_matrix(Epetra_MpiComm &Comm, int test_number, Epetra_CrsMatrix *&A)
int NumMyElements() const
Number of elements on the calling processor.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
int main(int argc, char *argv[])
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 MyPID() const
Return my process ID.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
virtual int NumProc() const =0
Returns total number of processes.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int NumGlobalElements() const
Number of elements across all processors.
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Imports an Epetra_DistObject using the Epetra_Import object.
int GID(int LID) const
Returns global ID of local ID, return IndexBase-1 if not found on this processor. ...
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
void build_test_map(const Epetra_Map &oldMap, Epetra_Map *&newMap)
int ScanSum(double *MyVals, double *ScanSums, int Count) const
Epetra_MpiComm Scan Sum function.