|
Epetra Package Browser (Single Doxygen Collection)
Development
|
Go to the documentation of this file.
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;
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);
284 int ierr0 = resid.
Norm2(&residual);
286 if (verbose) cout <<
"Norm of b1 - b2 = " << residual << endl;
290 if (residual > 1.0e-10) ierr++;
292 if (ierr!=0 && verbose) {
293 cerr <<
"Status: Test failed" << endl;
295 else if (verbose) cerr <<
"Status: Test passed" << endl;
301 int * xoff,
int * yoff,
int nrhs,
310 int numGlobalEquations = nx*ny;
311 map =
new Epetra_Map(numGlobalEquations, 0, comm);
317 int * indices =
new int[npoints];
318 double * values =
new double[npoints];
320 double dnpoints = (double) npoints;
322 for (
int i=0; i<numMyEquations; i++) {
324 int rowID = map->
GID(i);
327 for (
int j=0; j<npoints; j++) {
328 int colID = rowID + xoff[j] + nx*yoff[j];
329 if (colID>-1 && colID<numGlobalEquations) {
330 indices[numIndices] = colID;
331 double value = - ((double) rand())/ ((
double) RAND_MAX);
333 values[numIndices++] = dnpoints - value;
335 values[numIndices++] = -value;
366 int nsizes,
int * sizes,
int nrhs,
377 int numGlobalEquations = nx*ny;
378 Epetra_Map ptMap(numGlobalEquations, 0, comm);
383 for (i=0; i<numMyElements; i++)
384 elementSizes[i] = sizes[ptMap.
GID(i)%nsizes];
391 int * indices =
new int[npoints];
396 int maxElementSize = 0;
397 for (i=0; i< nsizes; i++) maxElementSize =
EPETRA_MAX(maxElementSize, sizes[i]);
405 for (i=0; i<numMyElements; i++) {
406 int rowID = map->
GID(i);
408 int rowDim = sizes[rowID%nsizes];
409 for (j=0; j<npoints; j++) {
410 int colID = rowID + xoff[j] + nx*yoff[j];
411 if (colID>-1 && colID<numGlobalEquations)
412 indices[numIndices++] = colID;
417 for (j=0; j < numIndices; j++) {
418 int colDim = sizes[indices[j]%nsizes];
435 int numBlockDiagonalEntries;
439 for (i=0; i< numBlockDiagonalEntries; i++) {
444 for (j=0; j<rowDim; j++) diagVals[j+j*diagLDA] = rowSums[diagoffsets[i]+j];
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.
int BeginInsertGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices)
Initiate insertion of a list of elements in a given global row of the matrix, values are inserted via...
int FillComplete()
Signal that data entry is complete, perform transformations to local index space.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
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.
int NumMyElements() const
Number of elements on the calling processor.
int checkResults(Epetra_RowMatrix *A, Epetra_CrsMatrix *transA, Epetra_MultiVector *xexact, bool verbose)
int ElementSize() const
Returns the size of elements in the map; only valid if map has constant element size.
virtual int NumGlobalRows() const =0
Returns the number of global matrix rows.
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.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator.
const Epetra_BlockMap & RowMap() const
Returns the RowMap object as an Epetra_BlockMap (the Epetra_Map base class) needed for implementing E...
Epetra_IntVector: A class for constructing and using dense integer vectors on a parallel computer.
Epetra_Comm: The Epetra Communication Abstract Base Class.
int MyPID() const
Return my process ID.
std::string Epetra_Version()
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 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 NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_VbrMatrix multiplied by a Epetra_MultiVector X in Y.
int GID(int LID) const
Returns global ID of local ID, return IndexBase-1 if not found on this processor.
int Scale(double ScalarValue)
Scale the current values of a multi-vector, this = ScalarValue*this.
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices.
int Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
int SubmitBlockEntry(double *Values, int LDA, int NumRows, int NumCols)
Submit a block entry to the indicated block row and column specified in the Begin routine.
Epetra_MpiComm: The Epetra MPI Communication Class.
Epetra_SerialComm: The Epetra Serial Communication Class.
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space.
int EndSubmitEntries()
Completes processing of all data passed in for the current block row.
void GenerateCrsProblem(int nx, int ny, int npoints, int *xoff, int *yoff, int nrhs, const Epetra_Comm &comm, Epetra_Map *&map, Epetra_CrsMatrix *&A, Epetra_MultiVector *&x, Epetra_MultiVector *&b, Epetra_MultiVector *&xexact)
Epetra_Time: The Epetra Timing Class.
int Reciprocal(const Epetra_MultiVector &A)
Puts element-wise reciprocal values of input Multi-vector in target.
int * Values() const
Returns a pointer to an array containing the values of this vector.
int * FirstPointInElementList() const
Pointer to internal array containing a mapping between the local elements and the first local point n...
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int main(int argc, char *argv[])
virtual const Epetra_Map & OperatorRangeMap() const =0
Returns the Epetra_Map object associated with the range of this operator.
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.
double ElapsedTime(void) const
Epetra_Time elapsed time function.
int LeftScale(const Epetra_Vector &x)
Scales the Epetra_VbrMatrix on the left with a Epetra_Vector x.
int IndexBase() const
Index base for this map.
int InvRowSums(Epetra_Vector &x) const
Computes the sum of absolute values of the rows of the Epetra_VbrMatrix, results returned in x.
virtual int SetUseTranspose(bool UseTranspose)=0
If set true, transpose of this operator will be applied.
int ExtractBlockDiagonalEntryView(double *&Values, int &LDA) const
Extract a view of a block diagonal entry from the matrix.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Epetra_VbrMatrix: A class for the construction and use of real-valued double-precision variable block...
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
virtual const Epetra_Map & OperatorDomainMap() const =0
Returns the Epetra_Map object associated with the domain of this operator.
Epetra_RowMatrixTransposer: A class for transposing an Epetra_RowMatrix object.
Epetra_Map: A class for partitioning vectors and matrices.
void GenerateVbrProblem(int nx, int ny, int npoints, int *xoff, int *yoff, int nsizes, int *sizes, int nrhs, const Epetra_Comm &comm, Epetra_BlockMap *&map, Epetra_VbrMatrix *&A, Epetra_MultiVector *&x, Epetra_MultiVector *&b, Epetra_MultiVector *&xexact)
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.
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_SerialComm Broadcast function.
int BeginExtractBlockDiagonalView(int &NumBlockDiagonalEntries, int *&RowColDims) const
Initiates a view of the block diagonal entries.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.