Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
test/Bugs_LL/Bug_5988_FECrs_buildNonlocalGraph_LL/cxx_main.cpp
Go to the documentation of this file.
1#include <Epetra_FECrsGraph.h>
3#include <Epetra_MpiComm.h>
4
5
6int 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(-1LL, NumMyEquations, 0, Comm);
16
17 Epetra_FECrsGraph graph(Copy, Map, 0, false, true);
18 for (int i=0; i<NumMyEquations; ++i)
19 {
20 long long entry = i+rank*2;
21 graph.InsertGlobalIndices(i+rank*2, 1, &entry);
22 }
23 {
24 long long row = 0;
25 long long 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 long long row = 0;
36 long long 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
@ Copy
int FillComplete()
Tranform to local index space. Perform other operations to allow optimal matrix operations.
int OptimizeStorage()
Make consecutive row index sections contiguous, minimize internal storage used for constructing graph...
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space.
double NormFrobenius() const
Returns the frobenius norm of the global matrix.
Epetra Finite-Element CrsGraph.
int InsertGlobalIndices(int numRows, const int *rows, int numCols, const int *cols)
Insert a rectangular, dense 'submatrix' of entries (matrix nonzero positions) into the graph.
int GlobalAssemble(bool callFillComplete=true)
Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was ...
Epetra Finite-Element CrsMatrix.
int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::SumIntoGlobalValues method
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_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
Epetra_MpiComm: The Epetra MPI Communication Class.