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.;
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) {
539 epetra_values, format);
540 if (err<0)
return(err);
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) {
560 if (err<0)
return(err);
565 if (err<0)
return(err);
570 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
571 if (preconstruct_graph) {
573 numNodesPerElem, nodes,
575 if (err<0)
return(err);
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) {
589 numNodesPerElem, nodes,
591 if (err<0)
return(err);
595 numNodesPerElem, nodes,
597 if (err<0)
return(err);
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);
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.
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 Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
Returns the result of a Epetra_CrsMatrix multiplied by a Epetra_Vector x in y.
#define EPETRA_TEST_ERR(a, b)
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
virtual void Print(std::ostream &os) const
Print method.
#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...
const Epetra_Map & ColMap() const
Returns the Epetra_Map object that describes the set of column-indices that appear in each processor'...
int Drumm1(const Epetra_Map &map, bool verbose)
virtual int MyPID() const =0
Return my process ID.
int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::InsertGlobalValues method
int PutScalar(double ScalarConstant)
Initialize all values in the matrix with constant value.
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
void Print(std::ostream &os) const
Print method.
Epetra Finite-Element CrsMatrix.
Epetra_Comm: The Epetra Communication Abstract Base Class.
int ExtractGlobalRowCopy(int GlobalRow, int Length, int &NumEntries, double *Values, int *Indices) const
Returns a copy of the specified global row in user-provided arrays.
int LCID(int GCID_in) const
Returns the local column index for given global column index, returns -1 if no local column for this ...
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 ...
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
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 NumGlobalCols() const
Returns the number of global matrix columns.
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.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
matrix_data is a very simple data source to be used for filling test matrices.
int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::SumIntoGlobalValues method
virtual int NumProc() const =0
Returns total number of processes.
Epetra Finite-Element Vector.
int Drumm3(const Epetra_Map &map, bool verbose)
int submatrix_formats(const Epetra_Comm &Comm, bool verbose)
int rectangular(const Epetra_Comm &Comm, bool verbose)
int Drumm2(const Epetra_Map &map, bool verbose)
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
int four_quads(const Epetra_Comm &Comm, bool preconstruct_graph, bool verbose)
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...