103 #include "Trilinos_Util.h"
104 #ifdef HAVE_COMM_ASSERT_EQUAL
105 #include "Comm_assert_equal.h"
114 int main(
int argc,
char *argv[]) {
120 MPI_Init(&argc,&argv);
128 bool verbose =
false;
129 bool veryVerbose =
false;
132 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
136 if (verbose) cout << comm << endl << flush;
138 bool verbose1 = verbose;
139 if (verbose) verbose = (comm.
MyPID()==0);
152 int xoff[] = {-1, 0, 1, -1, 0, 1, 0};
153 int yoff[] = {-1, -1, -1, 0, 0, 0, 1};
159 Trilinos_Util_GenerateCrsProblem(nx, ny, npoints, xoff, yoff, comm, map, A, x, b, xexact);
162 cout <<
"npoints = " << npoints <<
" nx = " << nx <<
" ny = " << ny << endl ;
164 if (verbose && nx<6 ) {
166 cout <<
"B = " << endl << *b << endl;
179 if (verbose) cout <<
"\nTime to construct redistor = "
182 bool ConstructTranspose =
true;
183 bool MakeDataContiguous =
true;
186 redistor.CreateRedistProblem(ConstructTranspose, MakeDataContiguous, redistProblem);
187 if (verbose) cout <<
"\nTime to create redistributed problem = "
194 ierr +=
checkResults( ConstructTranspose, &redistor, &origProblem,
195 redistProblem, verbose);
205 redistor.UpdateRedistRHS(b);
206 if (verbose) cout <<
"\nTime to update redistributed RHS = "
210 &origProblem, redistProblem, verbose);
214 #define CREATE_CONST_MATRIX
215 #ifdef CREATE_CONST_MATRIX
226 cout <<
" i = " << i ;
233 redistor.UpdateRedistProblemValues(&origProblem);
234 if (verbose) cout <<
"\nTime to update redistributed problem = "
237 ierr +=
checkResults(ConstructTranspose, &redistor, &origProblem, redistProblem, verbose);
277 assert( matrixA != 0 ) ;
287 double *val, *rhs, *lhs;
288 int Nrhs, ldrhs, ldlhs;
291 val, Nrhs, rhs, ldrhs,
296 cout <<
" iam = " << iam
297 <<
" m = " << m <<
" n = " << n <<
" M = " << M << endl ;
299 cout <<
" iam = " << iam <<
" ptr = " << ptr[0] <<
" " << ptr[1] <<
" " << ptr[2] <<
" " << ptr[3] <<
" " << ptr[4] <<
" " << ptr[5] << endl ;
301 cout <<
" iam = " << iam <<
" ind = " << ind[0] <<
" " << ind[1] <<
" " << ind[2] <<
" " << ind[3] <<
" " << ind[4] <<
" " << ind[5] << endl ;
303 cout <<
" iam = " << iam <<
" val = " << val[0] <<
" " << val[1] <<
" " << val[2] <<
" " << val[3] <<
" " << val[4] <<
" " << val[5] << endl ;
308 int NumMyElements_ = 0 ;
309 if (matrixA->
Comm().
MyPID()==0) NumMyElements_ = n;
323 for (
int k = 0 ; k < Nrhs; k ++ ) {
324 for (
int i = 0 ; i < M ; i ++ ) {
325 lhs[ i + k * ldlhs ] = 0.0;
327 for (
int i = 0 ; i < M ; i++ ) {
328 for (
int l = ptr[i]; l < ptr[i+1]; l++ ) {
330 if ( verbose && N < 40 ) {
331 cout <<
" i = " << i <<
" j = " << j ;
332 cout <<
" l = " << l <<
" val[l] = " << val[l] ;
333 cout <<
" rhs = " << rhs[ j + k * ldrhs ] << endl ;
335 lhs[ i + k * ldrhs ] += val[l] * rhs[ j + k * ldrhs ] ;
339 if ( verbose && N < 40 ) {
341 for (
int j = 0 ; j < N ; j++ ) cout <<
" " << lhs[j] ;
344 for (
int j = 0 ; j < N ; j++ ) cout <<
" " << rhs[j] ;
349 #ifdef HAVE_COMM_ASSERT_EQUAL
354 for (
int j = 0 ; j < N ; j++ ) {
355 assert( Comm_assert_equal( &comm, lhs[ j + k * ldrhs ] ) ) ;
356 assert( Comm_assert_equal( &comm, rhs[ j + k * ldrhs ] ) ) ;
371 double Norm_x1, Norm_diff ;
377 x1.
Update( -1.0, *x, 1.0 ) ;
385 cout <<
" Norm_diff = " << Norm_diff << endl ;
386 cout <<
" Norm_x1 = " << Norm_x1 << endl ;
391 if (ierr!=0 && verbose) cerr <<
"Status: Test failed" << endl;
392 else if (verbose) cerr <<
"Status: Test passed" << endl;
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_MultiVector * GetLHS() const
Get a pointer to the left-hand-side X.
Epetra_MultiVector * GetRHS() const
Get a pointer to the right-hand-side B.
int ExtractHbData(int &M, int &N, int &nz, int *&ptr, int *&ind, double *&val, int &Nrhs, double *&rhs, int &ldrhs, double *&lhs, int &ldlhs) const
Extract the redistributed problem data in a form usable for other codes that require Harwell-Boeing f...
double ElapsedTime(void) const
Epetra_Time elapsed time function.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
#define EPETRA_CHK_ERR(a)
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Epetra_LinearProblemRedistor: A class for redistributing an Epetra_LinearProblem object.
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
virtual int MyPID() const =0
Return my process ID.
int checkResults(bool trans, Epetra_LinearProblemRedistor *redistor, Epetra_LinearProblem *OrigProb, Epetra_LinearProblem *RedistProb, bool verbose)
Epetra_Time: The Epetra Timing Class.
int PutScalar(double ScalarConstant)
Initialize all values in the matrix with constant value.
int Scale(double ScalarValue)
Scale the current values of a multi-vector, this = ScalarValue*this.
virtual const Epetra_Comm & Comm() const =0
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Epetra_Comm: The Epetra Communication Abstract Base Class.
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_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.
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns the result of a Epetra_RowMatrix multiplied by a Epetra_MultiVector X in Y.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
Epetra_RowMatrix * GetMatrix() const
Get a pointer to the matrix A.
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.
int main(int argc, char *argv[])
Epetra_LinearProblem: The Epetra Linear Problem Class.
int UpdateOriginalLHS(Epetra_MultiVector *LHS)
Update LHS of original Linear Problem object.
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices...
const double error_tolerance