55 #include "../epetra_test_err.h" 61 int NumGlobalNonzeros1,
int * MyGlobalElements,
bool verbose);
67 double * lambda,
int niters,
double tolerance,
78 Epetra_Vector Xa(Xamap), Xb(Xbmap), Ya(Yamap), Yb(Ybmap), Diff(Yamap);
86 Xb.Import(Xa,Ximport,
Insert);
129 Xb_alias.Import(Xa,Ximport,
Insert);
133 if(Bmap) B.
Apply(*Xb,*Yb);
144 delete Xb;
delete Yb;
152 if(rv) {cerr<<
"build_matrix_unfused: Import failed"<<endl;
return rv;}
161 if(rv) {cerr<<
"build_matrix_unfused: Export failed"<<endl;
return rv;}
171 int MyPID = Comm.
MyPID();
175 int NumMyEquations = 100;
177 long long NumGlobalEquations = (NumMyEquations * NumProc) +
EPETRA_MIN(NumProc,3);
178 if(MyPID < 3) NumMyEquations++;
181 Epetra_Map Map(NumGlobalEquations, NumMyEquations, (
long long)0, Comm);
184 long long* MyGlobalElements =
new long long[Map.
NumMyElements()];
190 int* NumNz =
new int[NumMyEquations];
195 for (
int i = 0; i < NumMyEquations; i++)
196 if((MyGlobalElements[i] == 0) || (MyGlobalElements[i] == NumGlobalEquations - 1))
208 double* Values =
new double[2];
211 long long* Indices =
new long long[2];
215 for (
int i = 0; i < NumMyEquations; i++) {
216 if(MyGlobalElements[i] == 0) {
220 else if (MyGlobalElements[i] == NumGlobalEquations-1) {
221 Indices[0] = NumGlobalEquations-2;
225 Indices[0] = MyGlobalElements[i]-1;
226 Indices[1] = MyGlobalElements[i]+1;
236 delete [] MyGlobalElements;
247 int main(
int argc,
char *argv[])
253 MPI_Init(&argc,&argv);
256 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
259 bool verbose =
false;
262 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
264 int verbose_int = verbose ? 1 : 0;
266 verbose = verbose_int==1 ? true :
false;
269 int MyPID = Comm.
MyPID();
272 if(verbose && MyPID==0)
275 if (verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc
276 <<
" is alive."<<endl;
279 if(verbose && rank!=0) verbose =
false;
286 double diff_tol=1e-12;
288 #define ENABLE_TEST_1 289 #define ENABLE_TEST_2 290 #define ENABLE_TEST_3 291 #define ENABLE_TEST_4 292 #define ENABLE_TEST_5 293 #define ENABLE_TEST_6 305 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,(
long long) 0,Comm);
306 else Map1=
new Epetra_Map(num_global,0,(
long long)0,Comm);
314 if(MyPID==0) cout<<
"FusedImport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
325 if(MyPID==0) cout<<
"FusedExport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
329 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
343 std::vector<long long> MyGIDS(num_local);
344 for(
int i=0; i<num_local; i++)
348 Map1=
new Epetra_Map((
long long)-1,num_local,&MyGIDS[0],0,Comm);
356 if(MyPID==0) cout<<
"FusedImport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
367 if(MyPID==0) cout<<
"FusedExport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
371 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
386 Comm.
ScanSum(&num_local,&num_scansum,1);
389 std::vector<long long> MyGIDS(num_local);
390 for(
int i=0; i<num_local; i++)
391 MyGIDS[i] = num_global - num_scansum + num_local - i - 1;
392 Map1=
new Epetra_Map((
long long)-1,num_local,&MyGIDS[0],(
long long)0,Comm);
400 if(MyPID==0) cout<<
"FusedImport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
411 if(MyPID==0) cout<<
"FusedExport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
415 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
430 std::vector<long long> MyGIDS(num_local);
432 for(
int i=0, idx=0; i<A->
NumMyCols(); i++)
434 MyGIDS[idx] = A->
GCID64(i);
439 const long long * MyGIDS_ptr = MyGIDS.size() ? &MyGIDS[0] : 0;
440 Map1=
new Epetra_Map((
long long)-1,num_local,MyGIDS_ptr,(
long long)0,Comm);
452 if(MyPID==0) cout<<
"FusedImport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
463 if(MyPID==0) cout<<
"FusedExport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
467 delete A;
delete B;
delete C;
delete Map1;
delete Import1;
delete Export1;
482 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,(
long long)0,Comm);
483 else Map1=
new Epetra_Map(num_global,0,(
long long)0,Comm);
491 if(MyPID==0) cout<<
"FusedImport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
502 if(MyPID==0) cout<<
"FusedExport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
506 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
521 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,(
long long)0,Comm);
522 else Map1=
new Epetra_Map(num_global,0,(
long long)0,Comm);
530 if(MyPID==0) cout<<
"FusedImport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
541 if(MyPID==0) cout<<
"FusedExport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
545 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
551 if(MyPID==0 && total_err==0)
552 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 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.
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 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 check(Epetra_CrsMatrix &A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1, int NumGlobalNonzeros1, int *MyGlobalElements, bool verbose)
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 Broadcast(double *MyVals, int Count, int Root) const
Epetra_MpiComm Broadcast function.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
double test_with_matvec(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B)
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Epetra_MpiComm: The Epetra MPI Communication Class.
long long NumGlobalElements64() const
std::string Epetra_Version()
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
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.
long long GID64(int LID) const
int NumMyElements() const
Number of elements on the calling processor.
int MyPID() const
Return my process ID.
int main(int argc, char *argv[])
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
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)
long long GCID64(int LCID_in) const
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.
void build_test_matrix(Epetra_MpiComm &Comm, int test_number, Epetra_CrsMatrix *&A)
int check_graph_sharing(Epetra_Comm &Comm)
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.
double test_with_matvec_reduced_maps(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B, const Epetra_Map &Bfullmap)
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
int ScanSum(double *MyVals, double *ScanSums, int Count) const
Epetra_MpiComm Scan Sum function.