Thyra Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages

Here is an example program that shows the use of the Epetra adapter subclasses with the example linear ANA implementation sillyCgSolve(). More...

Collaboration diagram for Epetra Implemenation of the CG Method:

Here is an example program that shows the use of the Epetra adapter subclasses with the example linear ANA implementation sillyCgSolve().

This example program is contained in the source file

./thyra/example/sillyCgSolve_epetra.cpp 

where ./ is the base source directory for epetra (i.e. ???/Trilinos/packages/epetra).

This example program is broken down into a few pieces in an attempt to be more understandable.

The first piece of example code we show is the function Thyra::createTridiagEpetraLinearOp(). This function creates an Epetra_CrsMatrix object that represents the well-known tridiagonal matrix

\[ A= \left[\begin{array}{rrrrrrrrrr} 2 a & -1 \\ -1 & 2 a & -1 \\ & \ddots & \ddots & \ddots \\ & & -1 & 2 a & -1 \\ & & & -1 & 2 a \end{array}\right] \]

where $a$ is an adjustable diagonal scale factor that makes the matrix $A$ more or less well conditioned.

The implementation of the function Thyra::createTridiagEpetraLinearOp() is shown below:

The above matrix-building function Thyra::createTridiagEpetraLinearOp() is then called along with the sillyCgSolve() function in the following MPI-enabled main() driver program:

The above driver program should be very strightforward to follow and generates the exact same numerical results as in the double case in the tempalted serial version.

The above example program is built as part of the epetra package (unless examples where disabled at configure time) and the executable can be found at:

./thyra/example/sillyCgSolve_epetra.exe 

where ./ is the base build directory for epetra (e.g. ???/Trilinos/$BUILD_DIR/packages/epetra).

This example program should run successfully with no arguments and produces the following output:

This example program also takes a number of command-line options. To see what the command-line options are, use the –help option. The command-line options returned from ./sillyCgSolve_epetra.exe –echo-command-line –help are:

To see the full listing of this example program click: sillyCgSolve_epetra.cpp