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 long long indexBase = 0;
121 long long myNodes[4];
135 if (localProc == 0) {
144 Epetra_Map Map((
long long)-1, numMyNodes, myNodes, indexBase, map.
Comm());
148 if (localProc == 0) {
163 numMyNodes, myNodes, values,
210 if (numProcs != 2)
return(0);
212 long long indexBase = 0;
215 double* values =
new double[9];
226 if (localProc == 0) {
228 long long* myNodes =
new long long[numMyNodes];
233 Epetra_Map Map((
long long)-1, numMyNodes, myNodes, indexBase, map.
Comm());
254 if (verbose&&localProc==0) {
255 cout <<
"y = A*x, x=1.0's"<<endl;
267 long long* myNodes =
new long long[numMyNodes];
270 Epetra_Map Map((
long long)-1, numMyNodes, myNodes, indexBase, map.
Comm());
277 myNodes =
new long long[numMyNodes];
316 int MyPID = Comm.
MyPID();
318 if (Numprocs != 2)
return(0);
320 long long NumGlobalRows = 4;
321 long long IndexBase = 0;
322 Epetra_Map Map(NumGlobalRows, IndexBase, Comm);
326 int NumEntriesPerRow = 3;
330 double ElementArea = 0.5;
333 long long* Indices =
new long long[NumCols];
348 double* Values =
new double[NumCols*NumCols];
351 Values[0] = 2*ElementArea/12.;
352 Values[1] = 1*ElementArea/12.;
353 Values[2] = 1*ElementArea/12.;
354 Values[3] = 1*ElementArea/12.;
355 Values[4] = 2*ElementArea/12.;
356 Values[5] = 1*ElementArea/12.;
357 Values[6] = 1*ElementArea/12.;
358 Values[7] = 1*ElementArea/12.;
359 Values[8] = 2*ElementArea/12.;
403 if (verbose&&MyPID==0) cout <<
"b:" << endl;
410 if (verbose&&MyPID==0) {
430 cout <<
"******************* four_quads ***********************"<<endl;
460 long long numNodes = 9;
462 int numNodesPerElem = 4;
464 long long indexBase = 0;
471 long long* nodes =
new long long[numNodesPerElem];
474 if (preconstruct_graph) {
480 for(i=0; i<numElems; ++i) {
483 nodes[0] = 0; nodes[1] = 1; nodes[2] = 4; nodes[3] = 3;
486 nodes[0] = 1; nodes[1] = 2; nodes[2] = 5; nodes[3] = 4;
489 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
492 nodes[0] = 4; nodes[1] = 5; nodes[2] = 8; nodes[3] = 7;
496 for(j=0; j<numNodesPerElem; ++j) {
497 if (map.
MyGID(nodes[j])) {
500 if (err<0)
return(err);
510 if (preconstruct_graph) {
519 double* values_1d =
new double[numNodesPerElem*numNodesPerElem];
520 double** values_2d =
new double*[numNodesPerElem];
522 for(i=0; i<numNodesPerElem*numNodesPerElem; ++i) values_1d[i] = 1.0;
525 for(i=0; i<numNodesPerElem; ++i) {
526 values_2d[i] = &(values_1d[offset]);
527 offset += numNodesPerElem;
533 numNodesPerElem, numNodesPerElem);
535 for(i=0; i<numElems; ++i) {
538 nodes[0] = 0; nodes[1] = 1; nodes[2] = 4; nodes[3] = 3;
539 if (preconstruct_graph) {
541 epetra_values, format);
542 if (err<0)
return(err);
546 epetra_values, format);
547 if (err<0)
return(err);
552 nodes[0] = 1; nodes[1] = 2; nodes[2] = 5; nodes[3] = 4;
553 if (preconstruct_graph) {
562 if (err<0)
return(err);
567 if (err<0)
return(err);
572 nodes[0] = 3; nodes[1] = 4; nodes[2] = 7; nodes[3] = 6;
573 if (preconstruct_graph) {
575 numNodesPerElem, nodes,
577 if (err<0)
return(err);
581 numNodesPerElem, nodes,
583 if (err<0)
return(err);
588 nodes[0] = 4; nodes[1] = 5; nodes[2] = 8; nodes[3] = 7;
589 if (preconstruct_graph) {
591 numNodesPerElem, nodes,
593 if (err<0)
return(err);
597 numNodesPerElem, nodes,
599 if (err<0)
return(err);
636 long long* indices =
new long long[len];
637 double* values =
new double[len];
643 if (numIndices != 4) {
646 if (indices[0] != 0) {
650 if (values[0] != 1.0*numProcs) {
651 cout <<
"ERROR: values[0] ("<<values[0]<<
") should be "<<numProcs<<endl;
660 if (numIndices != 9) {
663 int lcid = A->
LCID(4);
667 if (values[lcid] != 4.0*numProcs) {
668 cout <<
"ERROR: values["<<lcid<<
"] ("<<values[lcid]<<
") should be "
693 int myPID = Comm.
MyPID();
695 int numLocalElements = 3;
696 long long numGlobalElements = numLocalElements*numProcs;
697 long long indexBase = 0;
699 Epetra_Map map(numGlobalElements, numLocalElements, indexBase, Comm);
705 long long firstGlobalElement = numLocalElements*myPID;
708 for(i=0; i<numLocalElements; ++i) {
709 epetra_indices[i] = firstGlobalElement+i;
714 for(i=0; i<numLocalElements; ++i) {
715 for(j=0; j<numLocalElements; ++j) {
716 submatrix(i,j) = 1.0*(firstGlobalElement+i);
727 long long* indices =
new long long[len];
728 double* coefs =
new double[len];
730 for(i=0; i<numLocalElements; ++i) {
731 long long row = firstGlobalElement+i;
736 for(j=0; j<numIndices; ++j) {
737 if (coefs[j] != 1.0*row) {
745 for(i=0; i<numLocalElements; ++i) {
746 for(j=0; j<numLocalElements; ++j) {
747 submatrix(j,i) = 1.0*(firstGlobalElement+i);
759 for(i=0; i<numLocalElements; ++i) {
760 long long row = firstGlobalElement+i;
765 for(j=0; j<numIndices; ++j) {
766 if (coefs[j] != 2.0*row) {
782 int localproc = Comm.
MyPID();
784 long long numGlobalRows = numprocs*numMyRows;
785 long long* myrows =
new long long[numMyRows];
787 long long myFirstRow = ((
long long)localproc)*numMyRows;
789 for(i=0; i<numMyRows; ++i) {
790 myrows[i] = myFirstRow+i;
793 Epetra_Map map(numGlobalRows, numMyRows, myrows, 0LL, Comm);
797 long long numcols = 20;
798 long long* cols =
new long long[(std::size_t) numcols];
799 for(i=0; i<numcols; ++i) {
803 double* coefs =
new double[(std::size_t) (numGlobalRows*numcols)];
805 for(
int j=0; j<numcols; ++j) {
806 for(i=0; i<numGlobalRows; ++i) {
807 coefs[offset++] = 1.0*i;
811 long long* globalRows =
new long long[(std::size_t) numGlobalRows];
812 for(i=0; i<numGlobalRows; ++i) globalRows[i] = i;
815 numcols, cols, coefs,
818 delete [] globalRows;
825 int numMyCols = (int) numcols/numprocs;
826 int rem = (int) (numcols%numprocs);
827 if (localproc<rem) ++numMyCols;
828 Epetra_Map domainmap(numcols, numMyCols, 0LL, Comm);
835 if (numGlobalCols != numcols ||
836 numGlobalNNZ != numGlobalRows*numcols) {
Epetra_Map: A class for partitioning vectors and matrices.
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)
long long NumGlobalCols64() const
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.
long long NumGlobalNonzeros64() const
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
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 ...
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
virtual void Print(std::ostream &os) const
Print method.
bool MyGID(int GID_in) const
Returns true if the GID passed in belongs to the calling processor in this map, otherwise returns fal...
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...