Thyra Package Browser (Single Doxygen Collection) Version of the Day
Classes
Templated SPMD Implementation of the CG Method
CG Examples

Here is an example program that shows the use of the example SPMD templated matrix class ExampleTridiagSpmdLinearOp with the example linear ANA implementation sillyCgSolve() or silliestCgSolve(). More...

Collaboration diagram for Templated SPMD Implementation of the CG Method:

Classes

class  ExampleTridiagSpmdLinearOp< Scalar >
 Simple example subclass for Spmd tridiagonal matrices. More...

Detailed Description

Here is an example program that shows the use of the example SPMD templated matrix class ExampleTridiagSpmdLinearOp with the example linear ANA implementation sillyCgSolve() or silliestCgSolve().

The class ExampleTridiagSpmdLinearOp that derives from the base class Thyra::SpmdLinearOpBase is quite simple and its implementation (minus the communication() function) looks like:

The above SPMD matrix class is used in an example program (see runCgSolveExample() below) that calls sillyCgSolve() or silliestCgSolve(). In this example program, the matrix constructed and used is 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 CG method is then run on the matrix $A$ for a number of iterations or until convergence to some tolerance is achieved.

The following templated function runCgSolveExample() implements the example described above:

The above templated function runCgSolveExample() is then instantiated with the following scalar types:

and is called multiple times from within the following main() program function:

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

./example/operator_vector/sillyCgSolve_mpi.exe 

where ./ is the base build directory for Thyra (e.g. $TRILINOS_BUILD_DIR/packages/thyra).

This example program should run successfully with no arguments for any number of processors and for one processor 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_mpi.exe --echo-command-line --help are:

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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines