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);
122 Epetra_Vector *Yb = Bmap ?
new Epetra_Vector(*Bmap) : 0;
124 Epetra_Vector Xb_alias(
View,Bfullmap, Bmap ? Xb->
Values(): 0);
125 Epetra_Vector Yb_alias(
View,Bfullmap, Bmap ? Yb->
Values(): 0);
132 Xb_alias.Import(Xa,Ximport,
Insert);
136 if(Bmap) B.
Apply(*Xb,*Yb);
147 delete Xb;
delete Yb;
156 if(rv) {cerr<<
"build_matrix_unfused: Import failed"<<endl;
return rv;}
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;
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
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;
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;
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;
453 std::vector<int> MyGIDS(num_local);
455 for(
int i=0, idx=0; i<A->
NumMyCols(); i++)
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 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 NumGlobalElements() const
Number of elements across all processors.
Epetra_Map: A class for partitioning vectors and matrices.
double test_with_matvec(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B)
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
bool SameAs(const Epetra_BlockMap &Map) const
Returns true if this and Map are identical maps.
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
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.
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.
int NumProc() const
Returns total number of processes.
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...
double test_with_matvec_reduced_maps(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B, const Epetra_Map &Bfullmap)
int power_method(Epetra_CrsMatrix &A, double &lambda, int niters, double tolerance, bool verbose)
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...
int check(Epetra_CrsGraph &A, int NumMyRows1, int NumGlobalRows1, int NumMyNonzeros1, int NumGlobalNonzeros1, int *MyGlobalElements, bool verbose)
int ScanSum(double *MyVals, double *ScanSums, int Count) const
Epetra_MpiComm Scan Sum function.
virtual int MyPID() const =0
Return my process ID.
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)
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
int NumMyElements() const
Number of elements on the calling processor.
int NumMyCols() const
Returns the number of entries in the set of column-indices that appear on this processor.
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.
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_MpiComm Broadcast function.
void build_test_matrix(Epetra_MpiComm &Comm, int test_number, Epetra_CrsMatrix *&A)
int GID(int LID) const
Returns global ID of local ID, return IndexBase-1 if not found on this processor. ...
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
double * Values() const
Get pointer to MultiVector values.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
int check_graph_sharing(Epetra_Comm &Comm)
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 Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
int main(int argc, char *argv[])
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.
int MyPID() const
Return my process ID.
int GCID(int LCID_in) const
Returns the global column index for give local column index, returns IndexBase-1 if we don't have thi...
void build_test_map(const Epetra_Map &oldMap, Epetra_Map *&newMap)