56 #include "../epetra_test_err.h" 62 int NumGlobalNonzeros1,
int * MyGlobalElements,
bool verbose);
68 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);
130 Xb_alias.Import(Xa,Ximport,
Insert);
134 if(Bmap) B.
Apply(*Xb,*Yb);
145 delete Xb;
delete Yb;
153 if(rv) {cerr<<
"build_matrix_unfused: Import failed"<<endl;
return rv;}
162 if(rv) {cerr<<
"build_matrix_unfused: Export failed"<<endl;
return rv;}
172 int MyPID = Comm.
MyPID();
176 int NumMyEquations = 100;
178 long long NumGlobalEquations = (NumMyEquations * NumProc) +
EPETRA_MIN(NumProc,3);
179 if(MyPID < 3) NumMyEquations++;
182 Epetra_Map Map(NumGlobalEquations, NumMyEquations, (
long long)0, Comm);
185 long long* MyGlobalElements =
new long long[Map.
NumMyElements()];
191 int* NumNz =
new int[NumMyEquations];
196 for (
int i = 0; i < NumMyEquations; i++)
197 if((MyGlobalElements[i] == 0) || (MyGlobalElements[i] == NumGlobalEquations - 1))
209 double* Values =
new double[2];
212 long long* Indices =
new long long[2];
216 for (
int i = 0; i < NumMyEquations; i++) {
217 if(MyGlobalElements[i] == 0) {
221 else if (MyGlobalElements[i] == NumGlobalEquations-1) {
222 Indices[0] = NumGlobalEquations-2;
226 Indices[0] = MyGlobalElements[i]-1;
227 Indices[1] = MyGlobalElements[i]+1;
237 delete [] MyGlobalElements;
248 int main(
int argc,
char *argv[])
254 MPI_Init(&argc,&argv);
257 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
260 bool verbose =
false;
263 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
265 int verbose_int = verbose ? 1 : 0;
267 verbose = verbose_int==1 ? true :
false;
270 int MyPID = Comm.
MyPID();
273 if(verbose && MyPID==0)
276 if (verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc
277 <<
" is alive."<<endl;
280 if(verbose && rank!=0) verbose =
false;
287 double diff_tol=1e-12;
289 #define ENABLE_TEST_1 290 #define ENABLE_TEST_2 291 #define ENABLE_TEST_3 292 #define ENABLE_TEST_4 293 #define ENABLE_TEST_5 294 #define ENABLE_TEST_6 306 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,(
long long) 0,Comm);
307 else Map1=
new Epetra_Map(num_global,0,(
long long)0,Comm);
315 if(MyPID==0) cout<<
"FusedImport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
326 if(MyPID==0) cout<<
"FusedExport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
330 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
344 std::vector<long long> MyGIDS(num_local);
345 for(
int i=0; i<num_local; i++)
349 Map1=
new Epetra_Map((
long long)-1,num_local,&MyGIDS[0],0,Comm);
357 if(MyPID==0) cout<<
"FusedImport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
368 if(MyPID==0) cout<<
"FusedExport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
372 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
387 Comm.
ScanSum(&num_local,&num_scansum,1);
390 std::vector<long long> MyGIDS(num_local);
391 for(
int i=0; i<num_local; i++)
392 MyGIDS[i] = num_global - num_scansum + num_local - i - 1;
393 Map1=
new Epetra_Map((
long long)-1,num_local,&MyGIDS[0],(
long long)0,Comm);
401 if(MyPID==0) cout<<
"FusedImport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
412 if(MyPID==0) cout<<
"FusedExport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
416 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
431 std::vector<long long> MyGIDS(num_local);
433 for(
int i=0, idx=0; i<A->
NumMyCols(); i++)
435 MyGIDS[idx] = A->
GCID64(i);
441 Map1=
new Epetra_Map((
long long)-1,num_local,MyGIDS_ptr,(
long long)0,Comm);
453 if(MyPID==0) cout<<
"FusedImport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
464 if(MyPID==0) cout<<
"FusedExport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
468 delete A;
delete B;
delete C;
delete Map1;
delete Import1;
delete Export1;
483 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,(
long long)0,Comm);
484 else Map1=
new Epetra_Map(num_global,0,(
long long)0,Comm);
492 if(MyPID==0) cout<<
"FusedImport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
503 if(MyPID==0) cout<<
"FusedExport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
507 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
522 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,(
long long)0,Comm);
523 else Map1=
new Epetra_Map(num_global,0,(
long long)0,Comm);
531 if(MyPID==0) cout<<
"FusedImport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
542 if(MyPID==0) cout<<
"FusedExport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
546 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
552 if(MyPID==0 && total_err==0)
553 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.
T * Epetra_Util_data_ptr(std::vector< T > &vec)
Function that returns either a pointer to the first entry in the vector or, if the vector is empty...
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.