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 = "
195 if (verbose) cout << endl <<
"Checking transposer for VbrMatrix objects" << endl<< endl;
198 int sizes[] = {4, 6, 5, 3};
204 1, Comm, bmap, Avbr, x, b, xexact);
207 cout << *Avbr << endl;
208 cout <<
"X exact = " << endl << *xexact << endl;
209 cout <<
"B = " << endl << *b << endl;
214 if (verbose) cout <<
"\nTime to construct transposer = "
219 if (verbose) cout <<
"\nTime to create transpose matrix = "
236 if (verbose) cout <<
"\nTime to update transpose matrix = "
261 if (n<100) cout <<
"A transpose = " << endl << *transA << endl;
271 if (verbose) cout <<
"\nTime to compute b1: matvec with original matrix using transpose flag = " << timer.ElapsedTime() - start << endl;
273 if (n<100) cout <<
"b1 = " << endl << b1 << endl;
276 start = timer.ElapsedTime();
278 if (verbose) cout <<
"\nTime to compute b2: matvec with transpose matrix = " << timer.ElapsedTime() - start << endl;
280 if (n<100) cout <<
"b1 = " << endl << b1 << endl;
285 resid.
Update(1.0, b1, -1.0, b2, 0.0);
289 resid.Norm2(&residual);
291 if (verbose) cout <<
"Norm of b1 - b2 = " << residual << endl;
295 if (residual > 1.0e-10) ierr++;
297 if (ierr!=0 && verbose) {
298 cerr <<
"Status: Test failed" << endl;
300 else if (verbose) cerr <<
"Status: Test passed" << endl;
306 int * xoff,
int * yoff,
int nrhs,
315 int numGlobalEquations = nx*ny;
316 map =
new Epetra_Map(numGlobalEquations, 0, comm);
322 int * indices =
new int[npoints];
323 double * values =
new double[npoints];
325 double dnpoints = (double) npoints;
327 for (
int i=0; i<numMyEquations; i++) {
329 int rowID = map->
GID(i);
332 for (
int j=0; j<npoints; j++) {
333 int colID = rowID + xoff[j] + nx*yoff[j];
334 if (colID>-1 && colID<numGlobalEquations) {
335 indices[numIndices] = colID;
336 double value = - ((double) rand())/ ((
double) RAND_MAX);
338 values[numIndices++] = dnpoints - value;
340 values[numIndices++] = -value;
371 int nsizes,
int * sizes,
int nrhs,
382 int numGlobalEquations = nx*ny;
383 Epetra_Map ptMap(numGlobalEquations, 0, comm);
388 for (i=0; i<numMyElements; i++)
389 elementSizes[i] = sizes[ptMap.
GID(i)%nsizes];
396 int * indices =
new int[npoints];
401 int maxElementSize = 0;
402 for (i=0; i< nsizes; i++) maxElementSize =
EPETRA_MAX(maxElementSize, sizes[i]);
410 for (i=0; i<numMyElements; i++) {
411 int rowID = map->
GID(i);
413 int rowDim = sizes[rowID%nsizes];
414 for (j=0; j<npoints; j++) {
415 int colID = rowID + xoff[j] + nx*yoff[j];
416 if (colID>-1 && colID<numGlobalEquations)
417 indices[numIndices++] = colID;
420 A->BeginInsertGlobalValues(rowID, numIndices, indices);
422 for (j=0; j < numIndices; j++) {
423 int colDim = sizes[indices[j]%nsizes];
424 A->SubmitBlockEntry(&(randvec[0]), rowDim, rowDim, colDim);
426 A->EndSubmitEntries();
436 A->InvRowSums(invRowSums);
437 rowSums.Reciprocal(invRowSums);
440 int numBlockDiagonalEntries;
443 A->BeginExtractBlockDiagonalView(numBlockDiagonalEntries, rowColDims);
444 for (i=0; i< numBlockDiagonalEntries; i++) {
447 A->ExtractBlockDiagonalEntryView(diagVals, diagLDA);
449 for (j=0; j<rowDim; j++) diagVals[j+j*diagLDA] = rowSums[diagoffsets[i]+j];
465 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.