56 #include "../epetra_test_err.h"
68 int * xoff,
int * yoff,
int nrhs,
77 int nsizes,
int * sizes,
int nrhs,
85 int main(
int argc,
char *argv[]) {
93 MPI_Init(&argc,&argv);
103 bool verbose =
false;
106 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
108 int verbose_int = verbose ? 1 : 0;
110 verbose = verbose_int==1 ?
true :
false;
119 int MyPID = Comm.
MyPID();
122 if(verbose && MyPID==0)
136 int xoff[] = {-1, 0, 1, -1, 0, 1, 0};
137 int yoff[] = {-1, -1, -1, 0, 0, 0, 1};
143 GenerateCrsProblem(nx, ny, npoints, xoff, yoff, 1, Comm, map, A, x, b, xexact);
147 cout <<
"X exact = " << endl << *xexact << endl;
148 cout <<
"B = " << endl << *b << endl;
156 if (verbose) cout <<
"\nTime to construct transposer = "
159 bool MakeDataContiguous =
true;
164 if (verbose) cout <<
"\nTime to create transpose matrix = "
182 if (verbose) cout <<
"\nTime to update transpose matrix = "
194 if (verbose) cout << endl <<
"Checking transposer for VbrMatrix objects" << endl<< endl;
197 int sizes[] = {4, 6, 5, 3};
203 1, Comm, bmap, Avbr, x, b, xexact);
206 cout << *Avbr << endl;
207 cout <<
"X exact = " << endl << *xexact << endl;
208 cout <<
"B = " << endl << *b << endl;
213 if (verbose) cout <<
"\nTime to construct transposer = "
218 if (verbose) cout <<
"\nTime to create transpose matrix = "
235 if (verbose) cout <<
"\nTime to update transpose matrix = "
259 if (n<100) cout <<
"A transpose = " << endl << *transA << endl;
269 if (verbose) cout <<
"\nTime to compute b1: matvec with original matrix using transpose flag = " << timer.ElapsedTime() - start << endl;
271 if (n<100) cout <<
"b1 = " << endl << b1 << endl;
274 start = timer.ElapsedTime();
276 if (verbose) cout <<
"\nTime to compute b2: matvec with transpose matrix = " << timer.ElapsedTime() - start << endl;
278 if (n<100) cout <<
"b1 = " << endl << b1 << endl;
283 resid.
Update(1.0, b1, -1.0, b2, 0.0);
287 resid.Norm2(&residual);
289 if (verbose) cout <<
"Norm of b1 - b2 = " << residual << endl;
293 if (residual > 1.0e-10) ierr++;
295 if (ierr!=0 && verbose) {
296 cerr <<
"Status: Test failed" << endl;
298 else if (verbose) cerr <<
"Status: Test passed" << endl;
304 int * xoff,
int * yoff,
int nrhs,
313 int numGlobalEquations = nx*ny;
314 map =
new Epetra_Map(numGlobalEquations, 0, comm);
320 int * indices =
new int[npoints];
321 double * values =
new double[npoints];
323 double dnpoints = (double) npoints;
325 for (
int i=0; i<numMyEquations; i++) {
327 int rowID = map->
GID(i);
330 for (
int j=0; j<npoints; j++) {
331 int colID = rowID + xoff[j] + nx*yoff[j];
332 if (colID>-1 && colID<numGlobalEquations) {
333 indices[numIndices] = colID;
334 double value = - ((double) rand())/ ((
double) RAND_MAX);
336 values[numIndices++] = dnpoints - value;
338 values[numIndices++] = -value;
369 int nsizes,
int * sizes,
int nrhs,
380 int numGlobalEquations = nx*ny;
381 Epetra_Map ptMap(numGlobalEquations, 0, comm);
386 for (i=0; i<numMyElements; i++)
387 elementSizes[i] = sizes[ptMap.
GID(i)%nsizes];
394 int * indices =
new int[npoints];
399 int maxElementSize = 0;
400 for (i=0; i< nsizes; i++) maxElementSize =
EPETRA_MAX(maxElementSize, sizes[i]);
408 for (i=0; i<numMyElements; i++) {
409 int rowID = map->
GID(i);
411 int rowDim = sizes[rowID%nsizes];
412 for (j=0; j<npoints; j++) {
413 int colID = rowID + xoff[j] + nx*yoff[j];
414 if (colID>-1 && colID<numGlobalEquations)
415 indices[numIndices++] = colID;
418 A->BeginInsertGlobalValues(rowID, numIndices, indices);
420 for (j=0; j < numIndices; j++) {
421 int colDim = sizes[indices[j]%nsizes];
422 A->SubmitBlockEntry(&(randvec[0]), rowDim, rowDim, colDim);
424 A->EndSubmitEntries();
434 A->InvRowSums(invRowSums);
435 rowSums.Reciprocal(invRowSums);
438 int numBlockDiagonalEntries;
441 A->BeginExtractBlockDiagonalView(numBlockDiagonalEntries, rowColDims);
442 for (i=0; i< numBlockDiagonalEntries; i++) {
445 A->ExtractBlockDiagonalEntryView(diagVals, diagLDA);
447 for (j=0; j<rowDim; j++) diagVals[j+j*diagLDA] = rowSums[diagoffsets[i]+j];
463 A->Multiply(
false, *xexact, *b);
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int * FirstPointInElementList() const
Pointer to internal array containing a mapping between the local elements and the first local point n...
Epetra_Map: A class for partitioning vectors and matrices.
int Random()
Set multi-vector values to random numbers.
int CreateTranspose(const bool MakeDataContiguous, Epetra_CrsMatrix *&TransposeMatrix, Epetra_Map *TransposeRowMap=0)
Generate a new Epetra_CrsMatrix as the transpose of an Epetra_RowMatrix passed into the constructor...
int ElementSize() const
Returns the size of elements in the map; only valid if map has constant element size.
virtual int SetUseTranspose(bool UseTranspose)=0
If set true, transpose of this operator will be applied.
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
Returns the result of a Epetra_CrsMatrix multiplied by a Epetra_Vector x in y.
Epetra_IntVector: A class for constructing and using dense integer vectors on a parallel computer...
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
double ElapsedTime(void) const
Epetra_Time elapsed time function.
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.
void GenerateVbrProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints, int *xoff, int *yoff, int nsizes, int *sizes, const Epetra_Comm &comm, bool verbose, bool summary, Epetra_BlockMap *&map, Epetra_VbrMatrix *&A, Epetra_Vector *&b, Epetra_Vector *&bt, Epetra_Vector *&xexact, bool StaticProfile, bool MakeLocalOnly)
Epetra_VbrMatrix: A class for the construction and use of real-valued double-precision variable block...
virtual const Epetra_Map & OperatorDomainMap() const =0
Returns the Epetra_Map object associated with the domain of this operator.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
int * Values() const
Returns a pointer to an array containing the values of this vector.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
int checkResults(bool trans, Epetra_LinearProblemRedistor *redistor, Epetra_LinearProblem *OrigProb, Epetra_LinearProblem *RedistProb, bool verbose)
Epetra_Time: The Epetra Timing Class.
int IndexBase() const
Index base for this map.
int NumMyElements() const
Number of elements on the calling processor.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
virtual const Epetra_Map & OperatorRangeMap() const =0
Returns the Epetra_Map object associated with the range of this operator.
virtual const Epetra_Comm & Comm() const =0
Returns a pointer to the Epetra_Comm communicator associated with this operator.
int UpdateTransposeValues(Epetra_RowMatrix *MatrixWithNewValues)
Update the values of an already-redistributed problem.
Epetra_Comm: The Epetra Communication Abstract Base Class.
void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints, int *xoff, int *yoff, const Epetra_Comm &comm, bool verbose, bool summary, Epetra_Map *&map, Epetra_CrsMatrix *&A, Epetra_Vector *&b, Epetra_Vector *&bt, Epetra_Vector *&xexact, bool StaticProfile, bool MakeLocalOnly)
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.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
const Epetra_BlockMap & RowMap() const
Returns the RowMap object as an Epetra_BlockMap (the Epetra_Map base class) needed for implementing E...
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
Epetra_SerialComm: The Epetra Serial Communication Class.
int SumIntoMyValues(int MyRow, int NumEntries, const double *Values, const int *Indices)
Add this list of entries to existing values for a given local row of the matrix.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Epetra_RowMatrixTransposer: A class for transposing an Epetra_RowMatrix object.
int InvRowSums(Epetra_Vector &x) const
Computes the sum of absolute values of the rows of the Epetra_VbrMatrix, results returned in x...
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int main(int argc, char *argv[])
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_SerialComm Broadcast function.
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices...
virtual int NumGlobalRows() const =0
Returns the number of global matrix rows.
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.
int LeftScale(const Epetra_Vector &x)
Scales the Epetra_VbrMatrix on the left with a Epetra_Vector x.