50 #include <../src/Epetra_matrix_data.h> 51 #include <../src/Epetra_test_functions.h> 84 if (numProcs != 2)
return(0);
110 double** coefs = matdata.
coefs();
111 coefs[0][0] = 2.0; coefs[0][1] = 1.0; coefs[0][2] = 1.0;
112 coefs[1][0] = 1.0; coefs[1][1] = 4.0; coefs[1][2] = 1.0; coefs[1][3] = 2.0;
113 coefs[2][0] = 1.0; coefs[2][1] = 2.0; coefs[2][2] = 1.0;
114 coefs[3][0] = 1.0; coefs[3][1] = 2.0; coefs[3][2] = 1.0; coefs[3][3] = 4.0;
119 int indexBase = 0, ierr = 0;
134 if (localProc == 0) {
147 if (localProc == 0) {
162 numMyNodes, myNodes, values,
209 if (numProcs != 2)
return(0);
211 int indexBase = 0, ierr = 0;
213 double* values =
new double[9];
224 if (localProc == 0) {
226 int* myNodes =
new int[numMyNodes];
252 if (verbose&&localProc==0) {
253 cout <<
"y = A*x, x=1.0's"<<endl;
265 int* myNodes =
new int[numMyNodes];
275 myNodes =
new int[numMyNodes];
314 int MyPID = Comm.
MyPID();
316 if (Numprocs != 2)
return(0);
318 int NumGlobalRows = 4;
320 Epetra_Map Map(NumGlobalRows, IndexBase, Comm);
324 int NumEntriesPerRow = 3;
328 double ElementArea = 0.5;
331 int* Indices =
new int[NumCols];
346 double* Values =
new double[NumCols*NumCols];
349 Values[0] = 2*ElementArea/12.;
350 Values[1] = 1*ElementArea/12.;
351 Values[2] = 1*ElementArea/12.;
352 Values[3] = 1*ElementArea/12.;
353 Values[4] = 2*ElementArea/12.;
354 Values[5] = 1*ElementArea/12.;
355 Values[6] = 1*ElementArea/12.;
356 Values[7] = 1*ElementArea/12.;
357 Values[8] = 2*ElementArea/12.;
359 A.InsertGlobalValues(NumCols, Indices,
401 if (verbose&&MyPID==0) cout <<
"b:" << endl;
408 if (verbose&&MyPID==0) {
428 cout <<
"******************* four_quads ***********************"<<endl;
460 int numNodesPerElem = 4;
469 int* nodes =
new int[numNodesPerElem];
472 if (preconstruct_graph) {
478 for(i=0; i<numElems; ++i) {
481 nodes[0] = 0; nodes[1] = 1; nodes[2] = 4; nodes[3] = 3;
484 nodes[0] = 1; nodes[1] = 2; nodes[2] = 5; nodes[3] = 4;
487 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
490 nodes[0] = 4; nodes[1] = 5; nodes[2] = 8; nodes[3] = 7;
494 for(j=0; j<numNodesPerElem; ++j) {
495 if (map.
MyGID(nodes[j])) {
498 if (err<0)
return(err);
508 if (preconstruct_graph) {
517 double* values_1d =
new double[numNodesPerElem*numNodesPerElem];
518 double** values_2d =
new double*[numNodesPerElem];
520 for(i=0; i<numNodesPerElem*numNodesPerElem; ++i) values_1d[i] = 1.0;
523 for(i=0; i<numNodesPerElem; ++i) {
524 values_2d[i] = &(values_1d[offset]);
525 offset += numNodesPerElem;
531 numNodesPerElem, numNodesPerElem);
533 for(i=0; i<numElems; ++i) {
536 nodes[0] = 0; nodes[1] = 1; nodes[2] = 4; nodes[3] = 3;
537 if (preconstruct_graph) {
538 err =
A->SumIntoGlobalValues(epetra_nodes,
539 epetra_values, format);
540 if (err<0)
return(err);
543 err =
A->InsertGlobalValues(epetra_nodes,
544 epetra_values, format);
545 if (err<0)
return(err);
550 nodes[0] = 1; nodes[1] = 2; nodes[2] = 5; nodes[3] = 4;
551 if (preconstruct_graph) {
552 err =
A->SumIntoGlobalValues(nodes[0], numNodesPerElem, values_2d[0],
554 err +=
A->SumIntoGlobalValues(nodes[1], numNodesPerElem, values_2d[1],
556 err +=
A->SumIntoGlobalValues(nodes[2], numNodesPerElem, values_2d[2],
558 err +=
A->SumIntoGlobalValues(nodes[3], numNodesPerElem, values_2d[3],
560 if (err<0)
return(err);
563 err =
A->InsertGlobalValues(numNodesPerElem, nodes,
565 if (err<0)
return(err);
570 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
571 if (preconstruct_graph) {
572 err =
A->SumIntoGlobalValues(numNodesPerElem, nodes,
573 numNodesPerElem, nodes,
575 if (err<0)
return(err);
578 err =
A->InsertGlobalValues(numNodesPerElem, nodes,
579 numNodesPerElem, nodes,
581 if (err<0)
return(err);
586 nodes[0] = 4; nodes[1] = 5; nodes[2] = 8; nodes[3] = 7;
587 if (preconstruct_graph) {
588 err =
A->SumIntoGlobalValues(numNodesPerElem, nodes,
589 numNodesPerElem, nodes,
591 if (err<0)
return(err);
594 err =
A->InsertGlobalValues(numNodesPerElem, nodes,
595 numNodesPerElem, nodes,
597 if (err<0)
return(err);
603 err =
A->GlobalAssemble();
634 int* indices =
new int[len];
635 double* values =
new double[len];
641 if (numIndices != 4) {
644 if (indices[0] != 0) {
648 if (values[0] != 1.0*numProcs) {
649 cout <<
"ERROR: values[0] ("<<values[0]<<
") should be "<<numProcs<<endl;
658 if (numIndices != 9) {
661 int lcid =
A->LCID(4);
665 if (values[lcid] != 4.0*numProcs) {
666 cout <<
"ERROR: values["<<lcid<<
"] ("<<values[lcid]<<
") should be " 691 int myPID = Comm.
MyPID();
693 int numLocalElements = 3;
694 int numGlobalElements = numLocalElements*numProcs;
697 Epetra_Map map(numGlobalElements, numLocalElements, indexBase, Comm);
703 int firstGlobalElement = numLocalElements*myPID;
706 for(i=0; i<numLocalElements; ++i) {
707 epetra_indices[i] = firstGlobalElement+i;
712 for(i=0; i<numLocalElements; ++i) {
713 for(j=0; j<numLocalElements; ++j) {
714 submatrix(i,j) = 1.0*(firstGlobalElement+i);
725 int* indices =
new int[len];
726 double* coefs =
new double[len];
728 for(i=0; i<numLocalElements; ++i) {
729 int row = firstGlobalElement+i;
734 for(j=0; j<numIndices; ++j) {
735 if (coefs[j] != 1.0*row) {
743 for(i=0; i<numLocalElements; ++i) {
744 for(j=0; j<numLocalElements; ++j) {
745 submatrix(j,i) = 1.0*(firstGlobalElement+i);
757 for(i=0; i<numLocalElements; ++i) {
758 int row = firstGlobalElement+i;
763 for(j=0; j<numIndices; ++j) {
764 if (coefs[j] != 2.0*row) {
780 int localproc = Comm.
MyPID();
782 int numGlobalRows = numprocs*numMyRows;
783 int* myrows =
new int[numMyRows];
785 int myFirstRow = localproc*numMyRows;
787 for(i=0; i<numMyRows; ++i) {
788 myrows[i] = myFirstRow+i;
791 Epetra_Map map(numGlobalRows, numMyRows, myrows, 0, Comm);
796 int* cols =
new int[numcols];
797 for(i=0; i<numcols; ++i) {
801 double* coefs =
new double[numGlobalRows*numcols];
803 for(
int j=0; j<numcols; ++j) {
804 for(i=0; i<numGlobalRows; ++i) {
805 coefs[offset++] = 1.0*i;
809 int* globalRows =
new int[numGlobalRows];
810 for(i=0; i<numGlobalRows; ++i) globalRows[i] = i;
813 numcols, cols, coefs,
816 delete [] globalRows;
823 int numMyCols = numcols/numprocs;
824 int rem = numcols%numprocs;
825 if (localproc<rem) ++numMyCols;
826 Epetra_Map domainmap(numcols, numMyCols, 0, Comm);
830 int numGlobalCols =
A.NumGlobalCols();
831 int numGlobalNNZ =
A.NumGlobalNonzeros();
833 if (numGlobalCols != numcols ||
834 numGlobalNNZ != numGlobalRows*numcols) {
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
int FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
int rectangular(const Epetra_Comm &Comm, bool verbose)
bool compare_local_data(const Epetra_CrsMatrix &A)
The portion of this matrix_data object's data that corresponds to the locally-owned rows of A...
int Drumm1(const Epetra_Map &map, bool verbose)
virtual void Print(std::ostream &os) const
Print method.
#define EPETRA_TEST_ERR(a, b)
int Drumm2(const Epetra_Map &map, bool verbose)
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
int Drumm3(const Epetra_Map &map, bool verbose)
#define EPETRA_CHK_ERR(a)
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
virtual int MyPID() const =0
Return my process ID.
Epetra Finite-Element CrsMatrix.
bool MyGID(int GID_in) const
Returns true if the GID passed in belongs to the calling processor in this map, otherwise returns fal...
Epetra_Comm: The Epetra Communication Abstract Base Class.
int GlobalAssemble(bool callFillComplete=true, Epetra_CombineMode combineMode=Add, bool save_off_and_reuse_map_exporter=false)
Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was ...
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
bool compare_matrices(const Epetra_CrsMatrix &A, const Epetra_CrsMatrix &B)
Check whether the two CrsMatrix arguments have the same size, structure and coefs.
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
Enter a list of elements in a specified global row of the graph.
matrix_data is a very simple data source to be used for filling test matrices.
virtual int NumProc() const =0
Returns total number of processes.
Epetra Finite-Element Vector.
int four_quads(const Epetra_Comm &Comm, bool preconstruct_graph, bool verbose)
int submatrix_formats(const Epetra_Comm &Comm, bool verbose)
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values, int vectorIndex=0)
Accumulate values into the vector, adding them to any values that already exist for the specified ind...