50 #include "../epetra_test_err.h"
60 #ifdef HAVE_EPETRA_TEUCHOS
65 int main(
int argc,
char *argv[]) {
73 MPI_Init(&argc,&argv);
76 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
86 #ifdef HAVE_EPETRA_TEUCHOS
88 fancyOut = Teuchos::VerboseObjectBase::getDefaultOStream();
93 std::ostream &out = *fancyOut;
95 std::ostream &out = std::cout;
102 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
109 int MyPID = Comm.
MyPID();
112 if (verbose && MyPID==0)
115 if (verbose) out << Comm <<endl;
117 bool verbose1 = verbose;
120 if (verbose && rank!=0) verbose =
false;
122 int NumMyElements = 10000;
123 int NumMyElements1 = NumMyElements;
124 int NumGlobalElements = NumMyElements*NumProc+
EPETRA_MIN(NumProc,3);
125 if (MyPID < 3) NumMyElements++;
132 if (verbose) out <<
"\n*********************************************************" << endl;
133 if (verbose) out <<
"Checking Epetra_LocalMap(NumMyElements1, IndexBase, Comm)" << endl;
134 if (verbose) out <<
" and Epetra_BlockMap(NumGlobalElements, ElementSize, IndexBase, Comm)" << endl;
135 if (verbose) out <<
"*********************************************************" << endl;
148 if (verbose) out <<
"\n*********************************************************" << endl;
149 if (verbose) out <<
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm)" << endl;
150 if (verbose) out <<
"*********************************************************" << endl;
152 BlockMap =
new Epetra_BlockMap(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm);
163 int * MyGlobalElements =
new int[NumMyElements];
164 int MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
165 if (Comm.
MyPID()>2) MaxMyGID+=3;
166 for (i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
168 if (verbose) out <<
"\n*********************************************************" << endl;
169 if (verbose) out <<
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize, IndexBase, Comm)" << endl;
170 if (verbose) out <<
"*********************************************************" << endl;
172 BlockMap =
new Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize,
180 int * ElementSizeList =
new int[NumMyElements];
181 int NumMyEquations = 0;
182 int NumGlobalEquations = 0;
183 for (i = 0; i<NumMyElements; i++)
185 ElementSizeList[i] = i%6+2;
186 NumMyEquations += ElementSizeList[i];
189 NumGlobalEquations = Comm.
NumProc()*NumMyEquations;
195 NumGlobalEquations += 3*((NumMyElements)%6+2);
197 NumGlobalEquations -= (Comm.
NumProc()-3)*((NumMyElements-1)%6+2);
200 if (verbose) out <<
"\n*********************************************************" << endl;
201 if (verbose) out <<
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSizeList, IndexBase, Comm)" << endl;
202 if (verbose) out <<
"*********************************************************" << endl;
204 BlockMap =
new Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSizeList,
212 if (verbose) out <<
"\n*********************************************************" << endl;
213 if (verbose) out <<
"Checking Epetra_BlockMap(*BlockMap)" << endl;
214 if (verbose) out <<
"*********************************************************" << endl;
222 delete [] ElementSizeList;
223 delete [] MyGlobalElements;
230 if (verbose) out <<
"\n*********************************************************" << endl;
231 if (verbose) out <<
"Checking Epetra_Map(NumGlobalElements, IndexBase, Comm)" << endl;
232 if (verbose) out <<
"*********************************************************" << endl;
243 if (verbose) out <<
"\n*********************************************************" << endl;
244 if (verbose) out <<
"Checking Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm)" << endl;
245 if (verbose) out <<
"*********************************************************" << endl;
247 Map =
new Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm);
258 MyGlobalElements =
new int[NumMyElements];
259 MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
260 if (Comm.
MyPID()>2) MaxMyGID+=3;
261 for (i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
263 if (verbose) out <<
"\n*********************************************************" << endl;
264 if (verbose) out <<
"Checking Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements, IndexBase, Comm)" << endl;
265 if (verbose) out <<
"*********************************************************" << endl;
267 Map =
new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements,
275 if (verbose) out <<
"\n*********************************************************" << endl;
276 if (verbose) out <<
"Checking Epetra_Map(*Map)" << endl;
277 if (verbose) out <<
"*********************************************************" << endl;
285 delete [] MyGlobalElements;
301 const char* VecLabel = A.
Label();
302 const char* VecLabel1 =
"Epetra::Vector";
303 if (verbose) out << endl << endl <<
"This should say " << VecLabel1 <<
": " << VecLabel << endl << endl << endl;
305 if (verbose) out <<
"Testing Assignment operator" << endl;
307 double tmp1 = 1.00001* (double) (MyPID+1);
311 out <<
"On PE "<< MyPID <<
" A[1] should equal = " << tmp1;
312 if (tmp1==tmp2) out <<
" and it does!" << endl;
313 else out <<
" but it equals " << tmp2;
317 if (verbose) out << endl << endl <<
"Testing MFLOPs" << endl;
321 C.
Multiply(
'T',
'N', 0.5, A, B, 0.0);
323 double Multiply_flops = C.
Flops();
324 if (verbose) out <<
"\n\nTotal FLOPs = " << Multiply_flops << endl;
325 if (verbose) out <<
"Total Time = " << Multiply_time << endl;
326 if (verbose) out <<
"MFLOPs = " << Multiply_flops/Multiply_time/1000000.0 << endl;
334 double * Dp =
new double[100];
335 for (i=0; i<100; i++)
339 if (verbose) out <<
"\n\nTesting ostream operator: Multivector should be 100-by-2 and print i,j indices"
343 if (verbose) out <<
"Traceback Mode value = " << D.
GetTracebackMode() << endl;
void SetFlopCounter(const Epetra_Flops &FlopCounter_in)
Set the internal Epetra_Flops() pointer.
Epetra_Map: A class for partitioning vectors and matrices.
int Random()
Set multi-vector values to random numbers.
#define EPETRA_TEST_ERR(a, b)
basic_FancyOStream & setShowProcRank(const bool showProcRank)
double ElapsedTime(void) const
Epetra_Time elapsed time function.
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
int MatrixTests(const Epetra_BlockMap &Map, const Epetra_LocalMap &LocalMap, int NumVectors, bool verbose)
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()
Epetra_Time: The Epetra Timing Class.
virtual const char * Label() const
Epetra_Object Label access funtion.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
Epetra_SerialComm: The Epetra Serial Communication Class.
Epetra_Flops: The Epetra Floating Point Operations Class.
int Multiply(char TransA, char TransB, double ScalarAB, const Epetra_MultiVector &A, const Epetra_MultiVector &B, double ScalarThis)
Matrix-Matrix multiplication, this = ScalarThis*this + ScalarAB*A*B.
void Barrier() const
Epetra_SerialComm Barrier function.
static int GetTracebackMode()
Get the value of the Epetra_Object error report mode.
double Flops() const
Returns the number of floating point operations with this multi-vector.
int main(int argc, char *argv[])
int VectorTests(const Epetra_BlockMap &Map, bool verbose)
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.