Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test/Bugs/Bug_5988_FECrs_buildNonlocalGraph/cxx_main.cpp
Go to the documentation of this file.
1 #include <Epetra_FECrsGraph.h>
2 #include <Epetra_FECrsMatrix.h>
3 #include <Epetra_MpiComm.h>
4 
5 
6 int main(int argc, char**argv)
7 {
8  MPI_Init(&argc,&argv);
9  int rank; // My process ID
10 
11  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
12  Epetra_MpiComm Comm( MPI_COMM_WORLD );
13 
14  int NumMyEquations = 2;
15  Epetra_Map Map(-1, NumMyEquations, 0, Comm);
16 
17  Epetra_FECrsGraph graph(Copy, Map, 0, false, true);
18  for (int i=0; i<NumMyEquations; ++i)
19  {
20  int entry = i+rank*2;
21  graph.InsertGlobalIndices(i+rank*2, 1, &entry);
22  }
23  {
24  int row = 0;
25  int col = 1;
26  if (rank == 1)
27  graph.InsertGlobalIndices(1, &row, 1, &col);
28  }
29  graph.GlobalAssemble();
30  graph.FillComplete();
31  graph.OptimizeStorage();
32 
33  Epetra_FECrsMatrix matrix(Copy, graph);
34  {
35  int row = 0;
36  int col = 1;
37  double value = 1;
38  if (rank == 1)
39  matrix.SumIntoGlobalValues(1, &row, 1, &col, &value);
40  }
41  matrix.GlobalAssemble();
42  matrix.FillComplete();
43  double norm = matrix.NormFrobenius();
44  if (rank == 0) {
45  std::cout << "Frobenius norm (should be 1 with 2 or more processors): "
46  << norm << std::endl;
47  if(norm != 1)
48  std::cout << "tests FAILED" << std::endl;
49  }
50  MPI_Finalize();
51 }
52 
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:127
int InsertGlobalIndices(int numRows, const int *rows, int numCols, const int *cols)
Insert a rectangular, dense &#39;submatrix&#39; of entries (matrix nonzero positions) into the graph...
int FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
Epetra Finite-Element CrsGraph.
int GlobalAssemble(bool callFillComplete=true)
Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was ...
Epetra_MpiComm: The Epetra MPI Communication Class.
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
Epetra Finite-Element CrsMatrix.
int OptimizeStorage()
Make consecutive row index sections contiguous, minimize internal storage used for constructing graph...
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 ...
double NormFrobenius() const
Returns the frobenius norm of the global matrix.
int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::SumIntoGlobalValues method
int main(int argc, char *argv[])