69 #include "Trilinos_Util.h"
70 #ifdef HAVE_COMM_ASSERT_EQUAL
71 #include "Comm_assert_equal.h"
80 int main(
int argc,
char *argv[]) {
87 MPI_Init(&argc,&argv);
96 bool veryVerbose =
false;
99 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
103 if (verbose) cout << comm << endl << flush;
105 bool verbose1 = verbose;
106 if (verbose) verbose = (comm.
MyPID()==0);
119 int xoff[] = {-1, 0, 1, -1, 0, 1, 0};
120 int yoff[] = {-1, -1, -1, 0, 0, 0, 1};
126 Trilinos_Util_GenerateCrsProblem(nx, ny, npoints, xoff, yoff, comm, map, A, x, b, xexact);
129 cout <<
"npoints = " << npoints <<
" nx = " << nx <<
" ny = " << ny << endl ;
131 if (verbose && nx<6 ) {
133 cout <<
"B = " << endl << *b << endl;
146 if (verbose) cout <<
"\nTime to construct redistor = "
149 bool ConstructTranspose =
true;
150 bool MakeDataContiguous =
true;
155 #define CREATEREDISTPROBLEM
156 #ifdef CREATEREDISTPROBLEM
158 redistor.CreateRedistProblem(ConstructTranspose, MakeDataContiguous, redistProblem);
159 if (verbose) cout <<
"\nTime to create redistributed problem = "
167 ierr +=
checkResults( ConstructTranspose, &redistor, &origProblem,
168 redistProblem, verbose);
170 cout <<
" Here we are just before the return() " << endl ;
200 assert( matrixA != 0 ) ;
210 double *val, *rhs, *lhs;
211 int Nrhs, ldrhs, ldlhs;
214 val, Nrhs, rhs, ldrhs,
219 cout <<
" iam = " << iam
220 <<
" m = " << m <<
" n = " << n <<
" M = " << M << endl ;
222 cout <<
" iam = " << iam <<
" ptr = " << ptr[0] <<
" " << ptr[1] <<
" " << ptr[2] <<
" " << ptr[3] <<
" " << ptr[4] <<
" " << ptr[5] << endl ;
224 cout <<
" iam = " << iam <<
" ind = " << ind[0] <<
" " << ind[1] <<
" " << ind[2] <<
" " << ind[3] <<
" " << ind[4] <<
" " << ind[5] << endl ;
226 cout <<
" iam = " << iam <<
" val = " << val[0] <<
" " << val[1] <<
" " << val[2] <<
" " << val[3] <<
" " << val[4] <<
" " << val[5] << endl ;
231 int NumMyElements_ = 0 ;
232 if (matrixA->
Comm().
MyPID()==0) NumMyElements_ = n;
246 for (
int k = 0 ; k < Nrhs; k ++ ) {
247 for (
int i = 0 ; i < M ; i ++ ) {
248 lhs[ i + k * ldlhs ] = 0.0;
250 for (
int i = 0 ; i < M ; i++ ) {
251 for (
int l = ptr[i]; l < ptr[i+1]; l++ ) {
253 if ( verbose && N < 40 ) {
254 cout <<
" i = " << i <<
" j = " << j ;
255 cout <<
" l = " << l <<
" val[l] = " << val[l] ;
256 cout <<
" rhs = " << rhs[ j + k * ldrhs ] << endl ;
258 lhs[ i + k * ldrhs ] += val[l] * rhs[ j + k * ldrhs ] ;
262 if ( verbose && N < 40 ) {
264 for (
int j = 0 ; j < N ; j++ ) cout <<
" " << lhs[j] ;
267 for (
int j = 0 ; j < N ; j++ ) cout <<
" " << rhs[j] ;
272 #ifdef HAVE_COMM_ASSERT_EQUAL
277 for (
int j = 0 ; j < N ; j++ ) {
278 assert( Comm_assert_equal( &comm, lhs[ j + k * ldrhs ] ) ) ;
279 assert( Comm_assert_equal( &comm, rhs[ j + k * ldrhs ] ) ) ;
294 double Norm_x1, Norm_diff ;
300 x1.
Update( -1.0, *x, 1.0 ) ;
308 cout <<
" Norm_diff = " << Norm_diff << endl ;
309 cout <<
" Norm_x1 = " << Norm_x1 << endl ;
314 if (ierr!=0 && verbose) cerr <<
"Status: Test failed" << endl;
315 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.
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 NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_SerialComm: The Epetra Serial Communication Class.
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