Galeri  Development
 All Classes Files Functions Variables Pages
Creating an Epetra_CrsMatrix

This file first gives an example of how to create an Epetra_CrsMatrix object, then it details the supported matrices and gives a list of required parameters.

Given an already created Epetra_Map, Galeri can construct an Epetra_CrsMatrix object that has this Map as RowMatrixRowMap(). A simple example is as follows. Let Map be an already created Epetra_Map* object; then, a diagonal matrix with $a = 2.0$ on the diagonal can be created using the instructions

#include "Galeri_CrsMatrices.h"
using namespace Galeri;
...
string MatrixType = "Diag";
List.set("a", 2.0);
Epetra_CrsMatrix* Matrix = CreateCrsMatrix(MatrixType, Map, List);

More interesting matrices can be easily created. For example, a 2D biharmonic operator can be created like this:

List.set("nx", 10);
List.set("ny", 10);
Epetra_CrsMatrix* Matrix = Galeri.Create("Biharmonic2D", Map, List);

For matrices arising from 2D discretizations on Cartesian grids, it is possible to visualize the computational stencil at a given grid point by using function PrintStencil2D, defined in the Galeri namespace:

#include "Galeri_Utils.h"
using namespace Galeri;
...
// Matrix is an already created Epetra_CrsMatrix* object
// and nx and ny the number of nodes along the X-axis and Y-axis, 
// respectively.
PrintStencil2D(Matrix, nx, ny);

The output is:

2D computational stencil at GID 12 (grid is 5 x 5)

        0          0          1          0          0
        0          2         -8          2          0
        1         -8         20         -8          1
        0          2         -8          2          0
        0          0          1          0          0

To present the list of supported matrices we adopt the following symbols:

The list of supported matrices is now reported in alphabetical order.