56 #include "../epetra_test_err.h" 62 int NumGlobalNonzeros1,
int * MyGlobalElements,
bool verbose);
68 double * lambda,
int niters,
double tolerance,
80 Epetra_Vector Xa(Xamap), Xb(Xbmap), Ya(Yamap), Yb(Ybmap), Diff(Yamap);
88 Xb.Import(Xa,Ximport,
Insert);
132 Xb_alias.Import(Xa,Ximport,
Insert);
136 if(Bmap)
B.Apply(*Xb,*Yb);
147 delete Xb;
delete Yb;
155 rv=
A->Import(SourceMatrix, RowImporter,
Insert);
156 if(rv) {cerr<<
"build_matrix_unfused: Import failed"<<endl;
return rv;}
164 rv=
A->Export(SourceMatrix, RowExporter,
Insert);
165 if(rv) {cerr<<
"build_matrix_unfused: Export failed"<<endl;
return rv;}
175 int MyPID = Comm.
MyPID();
179 int NumMyEquations = 100;
181 int NumGlobalEquations = (NumMyEquations * NumProc) +
EPETRA_MIN(NumProc,3);
182 if(MyPID < 3) NumMyEquations++;
185 Epetra_Map Map(NumGlobalEquations, NumMyEquations, 0, Comm);
194 int* NumNz =
new int[NumMyEquations];
199 for (
int i = 0; i < NumMyEquations; i++)
200 if((MyGlobalElements[i] == 0) || (MyGlobalElements[i] == NumGlobalEquations - 1))
212 double* Values =
new double[2];
215 int* Indices =
new int[2];
219 for (
int i = 0; i < NumMyEquations; i++) {
220 if(MyGlobalElements[i] == 0) {
224 else if (MyGlobalElements[i] == NumGlobalEquations-1) {
225 Indices[0] = NumGlobalEquations-2;
229 Indices[0] = MyGlobalElements[i]-1;
230 Indices[1] = MyGlobalElements[i]+1;
233 A->InsertGlobalValues(MyGlobalElements[i], NumEntries, Values, Indices);
234 A->InsertGlobalValues(MyGlobalElements[i], 1, &two, MyGlobalElements+i);
240 delete [] MyGlobalElements;
256 int num_local = MyPID==0 ? num_global : 0;
262 if(MyPID==0) num_local = num_global/2;
263 else if(MyPID==2) num_local = num_global - ((int)num_global/2);
269 int main(
int argc,
char *argv[])
275 MPI_Init(&argc,&argv);
278 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
281 bool verbose =
false;
284 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
286 int verbose_int = verbose ? 1 : 0;
288 verbose = verbose_int==1 ? true :
false;
291 int MyPID = Comm.
MyPID();
294 if(verbose && MyPID==0)
297 if (verbose) cout <<
"Processor "<<MyPID<<
" of "<< NumProc
298 <<
" is alive."<<endl;
301 if(verbose && rank!=0) verbose =
false;
308 double diff_tol=1e-12;
310 #define ENABLE_TEST_1 311 #define ENABLE_TEST_2 312 #define ENABLE_TEST_3 313 #define ENABLE_TEST_4 314 #define ENABLE_TEST_5 315 #define ENABLE_TEST_6 324 int num_global =
A->RowMap().NumGlobalElements();
327 if(MyPID==0) Map1=
new Epetra_Map(num_global,num_global,0,Comm);
328 else Map1=
new Epetra_Map(num_global,0,0,Comm);
336 if(MyPID==0) cout<<
"FusedImport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
347 if(MyPID==0) cout<<
"FusedExport: Test #1 FAILED with norm diff = "<<diff<<
"."<<endl;
351 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
363 int num_local =
A->RowMap().NumMyElements();
365 std::vector<int> MyGIDS(num_local);
366 for(
int i=0; i<num_local; i++)
367 MyGIDS[i] =
A->RowMap().GID(num_local-i-1);
370 Map1=
new Epetra_Map(-1,num_local,&MyGIDS[0],0,Comm);
378 if(MyPID==0) cout<<
"FusedImport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
389 if(MyPID==0) cout<<
"FusedExport: Test #2 FAILED with norm diff = "<<diff<<
"."<<endl;
393 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
404 int num_local =
A->RowMap().NumMyElements();
405 int num_global =
A->RowMap().NumGlobalElements();
408 Comm.
ScanSum(&num_local,&num_scansum,1);
411 std::vector<int> MyGIDS(num_local);
412 for(
int i=0; i<num_local; i++)
413 MyGIDS[i] = num_global - num_scansum + num_local - i - 1;
414 Map1=
new Epetra_Map(-1,num_local,&MyGIDS[0],0,Comm);
423 if(MyPID==0) cout<<
"FusedImport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
434 if(MyPID==0) cout<<
"FusedExport: Test #3 FAILED with norm diff = "<<diff<<
"."<<endl;
438 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
452 int num_local =
A->NumMyCols()-
A->NumMyRows();
453 std::vector<int> MyGIDS(num_local);
455 for(
int i=0, idx=0; i<
A->NumMyCols(); i++)
456 if(
A->LRID(
A->GCID(i)) == -1){
457 MyGIDS[idx] =
A->GCID(i);
463 Map1=
new Epetra_Map(-1,num_local,MyGIDS_ptr,0,Comm);
476 if(MyPID==0) cout<<
"FusedImport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
487 if(MyPID==0) cout<<
"FusedExport: Test #4 FAILED with norm diff = "<<diff<<
"."<<endl;
491 delete A;
delete B;
delete C;
delete Map1;
delete Import1;
delete Export1;
513 if(MyPID==0) cout<<
"FusedImport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
524 if(MyPID==0) cout<<
"FusedExport: Test #5 FAILED with norm diff = "<<diff<<
"."<<endl;
528 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
550 if(MyPID==0) cout<<
"FusedImport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
561 if(MyPID==0) cout<<
"FusedExport: Test #6 FAILED with norm diff = "<<diff<<
"."<<endl;
565 delete A;
delete B;
delete Map1;
delete Import1;
delete Export1;
571 if(MyPID==0 && total_err==0)
572 cout<<
"FusedImportExport: All tests PASSED."<<endl;
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 check_graph_sharing(Epetra_Comm &Comm)
bool SameAs(const Epetra_BlockMap &Map) const
Returns true if this and Map are identical maps.
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 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 build_matrix_unfused(const Epetra_CrsMatrix &SourceMatrix, Epetra_Import &RowImporter, Epetra_CrsMatrix *&A)
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 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 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.
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.