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;