51 #include "../epetra_test_err.h"
58 int localProc = Comm.
MyPID();
61 if (verbose && localProc == 0) {
62 cout <<
"====================== quad1 =============================="<<endl;
85 int myFirstNode = localProc*2;
86 int myLastNode = localProc*2+1;
87 if (localProc == numProcs-1) {
91 int numMyNodes = myLastNode - myFirstNode + 1;
92 int* myNodes =
new int[numMyNodes];
95 for(i=0; i<numMyNodes; ++i) {
96 myNodes[i] = myFirstNode + i;
115 int nodesPerElem = 4;
116 int* elemNodes =
new int[nodesPerElem];
117 for(i=0; i<nodesPerElem; ++i) elemNodes[i] = myFirstNode+i;
119 int elemMatrixDim = nodesPerElem*dofPerNode;
120 int len = elemMatrixDim*elemMatrixDim;
121 double* elemMatrix =
new double[len];
128 for(i=0; i<len; ++i) elemMatrix[i] = 1.0;
138 double* blockEntry = elemMatrix;
144 for(i=0; i<nodesPerElem; ++i) {
145 int blkrow = myFirstNode+i;
149 for(j=0; j<nodesPerElem; ++j) {
150 for(
int ii=0; ii<dofPerNode*dofPerNode; ii++) {
151 blockEntry[ii] = blkrow+elemNodes[j];
154 dofPerNode, dofPerNode), ierr);
159 cout <<
"quad1: error in A.EndSubmitEntries: "<<err<<endl;
166 if (verbose && localProc==0) {
167 cout <<
"after globalAssemble"<<endl;
174 int correct_numMyRows = dofPerNode*numMyNodes;
176 if (numMyRows != correct_numMyRows) {
177 cout <<
"proc " << localProc <<
", numMyRows("<<numMyRows<<
") doesn't match"
178 <<
" correct_numMyRows("<<correct_numMyRows<<
")."<<endl;
183 int correct_numMyNonzeros = nodesPerElem*nodesPerElem*dofPerNode*dofPerNode;
186 if (localProc == numProcs-1) {
187 correct_numMyNonzeros += dofPerNode*dofPerNode*4;
189 else if (localProc > 0) {
190 correct_numMyNonzeros -= dofPerNode*dofPerNode*4;
194 correct_numMyNonzeros -= dofPerNode*dofPerNode*8;
198 if (numMyNonzeros != correct_numMyNonzeros) {
199 cout <<
"proc " << localProc <<
", numMyNonzeros(" << numMyNonzeros
200 <<
") != correct_numMyNonzeros("<<correct_numMyNonzeros<<
")"<<endl;
205 delete [] elemMatrix;
218 int localProc = Comm.
MyPID();
220 if (verbose && localProc == 0) {
221 cout <<
"====================== quad2 =============================="<<endl;
246 int myFirstNode = localProc*4;
247 int myLastNode = localProc*4+3;
248 if (localProc == numProcs-1) {
254 int numMyNodes = myLastNode - myFirstNode + 1;
255 int* myNodes =
new int[numMyNodes];
258 for(i=0; i<numMyNodes; ++i) {
259 myNodes[i] = myFirstNode + i;
278 int nodesPerElem = 4;
279 int* elemNodes =
new int[nodesPerElem];
281 int elemMatrixDim = nodesPerElem*dofPerNode;
282 int len = elemMatrixDim*elemMatrixDim;
283 double* elemMatrix =
new double[len];
290 for(i=0; i<len; ++i) elemMatrix[i] = 1.0;
300 double* blockEntry = elemMatrix;
306 int firstNode = myFirstNode;
307 for(
int el=0; el<numMyElems; ++el) {
308 for(i=0; i<nodesPerElem; ++i) {
310 for(
int n=0;
n<nodesPerElem; ++
n) elemNodes[
n] = firstNode+
n;
312 int blkrow = firstNode+i;
316 for(j=0; j<nodesPerElem; ++j) {
318 dofPerNode, dofPerNode), ierr);
323 cerr <<
"error in quad2, A.EndSubmitEntries(): " << this_err << endl;
333 if (verbose && localProc==0) {
334 cout <<
"after globalAssemble"<<endl;
347 if (verbose && localProc==0) {
348 cout <<
"quad2, y:"<<endl;
354 delete [] elemMatrix;
368 int MyPID = Comm.
MyPID();
372 if (verbose && MyPID==0) cout <<
"constructing Epetra_FEVbrMatrix" << endl;
384 if (verbose && MyPID==0) {
385 cout <<
"calling A.InsertGlobalValues with 1-D data array"<<endl;
389 int* ptIndices =
new int[numCols];
390 for(
int k=0; k<numCols; ++k) {
391 ptIndices[k] = minLocalRow+k;
394 double* values_1d =
new double[numCols*numCols];
395 for(j=0; j<numCols*numCols; ++j) {
406 double* ptCoefs =
new double[3];
408 {
for(i=0; i<numGlobalRows; ++i) {
409 if (i>0 && i<numGlobalRows-1) {
410 ptIndices[0] = minGID+i-1;
411 ptIndices[1] = minGID+i;
412 ptIndices[2] = minGID+i+1;
419 ptIndices[0] = minGID+i;
420 ptIndices[1] = minGID+i+1;
421 ptIndices[2] = minGID+i+2;
428 ptIndices[0] = minGID+i-2;
429 ptIndices[1] = minGID+i-1;
430 ptIndices[2] = minGID+i;
441 for(j=0; j<rowLengths; ++j) {
449 if (verbose&&MyPID==0) {
450 cout <<
"calling A.GlobalAssemble()" << endl;
455 if (verbose&&MyPID==0) {
456 cout <<
"after globalAssemble"<<endl;
472 cout <<
"******************* four_quads ***********************"<<endl;
504 int numNodesPerElem = 4;
514 int* nodes =
new int[numNodesPerElem];
515 int i, j, k, err = 0;
517 if (preconstruct_graph) {
523 for(i=0; i<numElems; ++i) {
526 nodes[0] = 0; nodes[1] = 1; nodes[2] = 4; nodes[3] = 3;
529 nodes[0] = 1; nodes[1] = 2; nodes[2] = 5; nodes[3] = 4;
532 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
535 nodes[0] = 4; nodes[1] = 5; nodes[2] = 8; nodes[3] = 7;
539 for(j=0; j<numNodesPerElem; ++j) {
540 if (map.
MyGID(nodes[j])) {
543 if (err<0)
return(err);
553 if (preconstruct_graph) {
562 double* values_1d =
new double[numNodesPerElem*numNodesPerElem];
563 double** values_2d =
new double*[numNodesPerElem];
565 for(i=0; i<numNodesPerElem*numNodesPerElem; ++i) values_1d[i] = 1.0;
568 for(i=0; i<numNodesPerElem; ++i) {
569 values_2d[i] = &(values_1d[offset]);
570 offset += numNodesPerElem;
573 for(i=0; i<numElems; ++i) {
576 nodes[0] = 0; nodes[1] = 1; nodes[2] = 4; nodes[3] = 3;
580 nodes[0] = 1; nodes[1] = 2; nodes[2] = 5; nodes[3] = 4;
584 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
588 nodes[0] = 4; nodes[1] = 5; nodes[2] = 8; nodes[3] = 7;
592 for(j=0; j<numNodesPerElem; ++j) {
593 if (preconstruct_graph) {
595 if (err<0)
return(err);
599 if (err<0)
return(err);
602 for(k=0; k<numNodesPerElem; ++k) {
604 if (err<0)
return(err);
608 if (err<0)
return(err);
617 cout <<
"A:"<<*A << endl;
618 cout <<
"Acopy:"<<*Acopy<<endl;
631 Acopy->Multiply(
false, x2, y2);
633 double ynorm2, y2norm2;
637 if (ynorm2 != y2norm2) {
638 cerr <<
"norm2(A*ones) != norm2(*Acopy*ones)"<<endl;
656 if (y3norm2 != y2norm2) {
657 cerr <<
"norm2(Acopy*ones) != norm2(Acopy2*ones)"<<endl;
662 int* indices =
new int[len];
663 double* values =
new double[len];
667 int lid = map.
LID(0);
670 if (numIndices != 4) {
673 if (indices[0] != lid) {
677 if (values[0] != 1.0*numProcs) {
678 cout <<
"ERROR: values[0] ("<<values[0]<<
") should be "<<numProcs<<endl;
684 int lid = map.
LID(4);
688 if (numIndices != 9) {
691 int lcid = A->
LCID(4);
697 if (values[lcid] != 4.0*numProcs) {
698 cout <<
"ERROR: values["<<lcid<<
"] ("<<values[lcid]<<
") should be "
int NumGlobalElements() const
Number of elements across all processors.
Epetra_Map: A class for partitioning vectors and matrices.
int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
Returns a copy of the specified local row in user-provided arrays.
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 FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
int quad1(const Epetra_Map &map, bool verbose)
int GlobalAssemble(bool callFillComplete=true)
#define EPETRA_TEST_ERR(a, b)
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
const Epetra_BlockMap & ColMap() const
Returns the ColMap as an Epetra_BlockMap (the Epetra_Map base class) needed for implementing Epetra_R...
virtual void Print(std::ostream &os) const
Print method.
#define EPETRA_CHK_ERR(a)
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
virtual void Barrier() const =0
Epetra_Comm Barrier function.
virtual int MyPID() const =0
Return my process ID.
int quad2(const Epetra_Map &map, bool verbose)
int MultiVectorTests(const Epetra_Map &Map, int NumVectors, bool verbose)
Epetra_Comm: The Epetra Communication Abstract Base Class.
int NumMyNonzeros() const
Returns the number of nonzero entriesowned by the calling processor .
int BeginSumIntoGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices)
Initiate summing into current values with this list of entries for a given global row of the matrix...
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 EndSubmitEntries()
Completes processing of all data passed in for the current block row.
int MinAllGID() const
Returns the minimum global ID across the entire map.
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
bool MyGID(int GID_in) const
Returns true if the GID passed in belongs to the calling processor in this map, otherwise returns fal...
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified global row of the graph.
int MinMyGID() const
Returns the minimum global ID owned by this processor.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
int LCID(int GCID_in) const
Returns the local column index for given global column index, returns -1 if no local column for this ...
Epetra Finite-Element VbrMatrix.
virtual int NumProc() const =0
Returns total number of processes.
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 Finite-Element Vector.
virtual void Print(std::ostream &os) const
Print method.
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
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 four_quads(const Epetra_Comm &Comm, bool preconstruct_graph, bool verbose)