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;
152 rv=
A->Import(SourceMatrix, RowImporter,
Insert);
153 if(rv) {cerr<<
"build_matrix_unfused: Import failed"<<endl;
return rv;}
161 rv=
A->Export(SourceMatrix, RowExporter,
Insert);
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;
230 A->InsertGlobalValues(MyGlobalElements[i], NumEntries, Values, Indices);
231 A->InsertGlobalValues(MyGlobalElements[i], 1, &two, MyGlobalElements+i);
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
303 long long num_global =
A->RowMap().NumGlobalElements64();
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;
342 int num_local =
A->RowMap().NumMyElements();
344 std::vector<long long> MyGIDS(num_local);
345 for(
int i=0; i<num_local; i++)
346 MyGIDS[i] =
A->RowMap().GID64(num_local-i-1);
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;
383 int num_local =
A->RowMap().NumMyElements();
384 long long num_global =
A->RowMap().NumGlobalElements64();
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;
430 int num_local =
A->NumMyCols()-
A->NumMyRows();
431 std::vector<long long> MyGIDS(num_local);
433 for(
int i=0, idx=0; i<
A->NumMyCols(); i++)
434 if(
A->LRID(
A->GCID64(i)) == -1){
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;
480 long long num_global =
A->RowMap().NumGlobalElements64();
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;
519 long long num_global =
A->RowMap().NumGlobalElements64();
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;