# Presentation: 430433

## Solvers Made Easy (to use and use together)Thyra, Stratimikos, Handles and More...

**Roscoe A. Bartlett **
**Department of Optimization & Uncertainty Estimation**
**Sandia National Laboratories**
**Trilinos Users Group Meeting, November 7****th****, 2006**

- Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company,for the United States Department of Energy under contract DE-AC04-94AL85000.

## Outline

- Overview of Thyra
- “Why should anyone care about Thyra”
- Stratimikos (unified access to linear solvers & algebraic preconditioners)
- Wrapping it up

## Outline

- Overview of Thyra
- “Why should anyone care about Thyra”
- Stratimikos (unified access to linear solvers & algebraic preconditioners)
- Wrapping it up

## Categories of Abstract Problems and Abstract Algorithms

- Linear Problems:
- Linear equations:
- Eigen problems:
- Preconditioners:

- Nonlinear Problems:
- Nonlinear equations:
- Stability analysis:

- Transient Nonlinear Problems:
- DAEs/ODEs:

- Optimization Problems:
- Unconstrained:
- Constrained:

- _Trilinos Packages_

- Belos

- Anasazi

- NOX

- LOCA

- MOOCHO
- Aristos

**Categories of Abstract Problems and Abstract Algorithms**

- Meros

- Rythmos

**Notes:**
Here are some of the different types of abstract problems and the Trilinos packages implementing abstract numerical algorithms for solving these problems.

## Introducing Abstract Numerical Algorithms

- An ANA is a numerical algorithm that can be expressed abstractly solely in terms of vectors, vector spaces, linear operators, and other abstractions built on top of these without general direct data access or any general assumptions about data locality

_**Example : Linear Conjugate Gradients**_

_**Types of operations**_

_**Types of objects**_

- What is an abstract numerical algorithm (ANA)?

_**Linear Conjugate Gradient Algorithm**_

**Introducing Abstract Numerical Algorithms**

**Key Points**
- ANAs can be very mathematically sophisticated!
- ANAs can be extremely reusable!
- Flexibility needed to achieve high performance!

**Notes:**
So what is an abstract numerical algorithm, or an ANA for short?

## Trilinos Strategic Goals

**Scalable Solvers**: As problem size and processor counts increase, the cost of the solver will remain a nearly fixed percentage of the total solution time.
**Hardened Solvers**: Never fail unless problem essentially unsolvable, in which case we diagnose and inform the user why the problem fails and provide a reliable measure of error.
**Full Vertical Coverage**: Provide leading edge capabilities from basic linear algebra to transient and optimization solvers.
***Grand***** Universal Interoperability**: All Trilinos packages will be interoperable, so that any combination of solver packages that makes sense algorithmically will be possible within Trilinos.
**Universal Solver RAS**: Trilinos will be:
- _R_eliable: Leading edge hardened, scalable solutions for each of these applications
- _A_vailable: Integrated into every major application at Sandia
- _S_erviceable: Easy to maintain and upgrade within the application environment.

**Courtesy of Mike Heroux, Trilinos Project Leader**

**Thyra** is being developed to address this issue

## Interoperability is Especially Important to Optimization

- Numerous interactions exist between layered abstract numerical algorithms (ANAs) in a transient optimization problem

**Iterative Linear Solver**
**AztecOO, Amesos, Belos, ???**

**Operators and Vectors**
**Epetra, Tpetra, PETSc, ???**

**Nonlinear Solver**
**NOX, PETSc, ???**

**Nonlinear Optimizer**
**MOOCHO, ???**

**Key Points**
- Higher level algorithms, like optimization, require a lot of interoperability
- Interoperability and layering must be “easy” or these configurations will not be achieved in practice

- What is needed to solve problem?
- Standard interfaces to break O(*N**2*) 1-to-1 couplings
- Operators/vectors
- Linear Solvers
- Nonlinear solvers
- Transient solvers
- etc.

**Application**
**Charon, Aria, ???**

**Transient Solver**
**Rythmos, CVODES, IDAS, ???**

**Interoperability is Especially Important to Optimization**

**Thyra** is being developed to address interoperability of ANAs

## Examples of ANA Interoperability and Layering : Rythmos

**Examples of ANA Interoperability and Layering : Rythmos**

- Time Stepper

- Implicit Backward Euler method

- Nonlinear equations

- Newton’s method (e.g. NOX)

- Linear equations

- Preconditioned GMRES

- Operator and Preconditioner
- applications

- Preconditioners can be defined in many different ways

- Matrix-free or Matrix?

**Notes:**
Now lets look at a couple of examples of nonlinear ANAs

  ANAs build on top of one another
  One should be able to easily swap in and out linear solvers and nonlinear solvers
  Abstract interfaces between different categories of ANAs is in its infancy

## Fundamental Thyra ANA Operator/Vector Interfaces

**The Key to success!**
**    ****Reduction/Transformation Operators**** **
- Supports all needed element-wise vector operations
- Data/parallel independence
- Optimal performance

- R. A. Bartlett, B. G. van Bloemen Waanders and M. A. Heroux. *Vector Reduction/Transformation Operators*, ACM TOMS, March 2004

**A Few Quick Facts about Thyra Interfaces**
- All interfaces are expressed as abstract C++ base classes            (i.e. object-oriented)
- All interfaces are templated on a Scalar data                                         (i.e. generic)

## Preconditioners and Preconditioner Factories

- Create preconditioner prec with preconditioner operators *P**L* and/or *P**R* such that *P**L**A*, or *AP**R*, or *P**L**AP**R* is “easier” to solve than unpreconditioned *A*.

***PreconditionerFactoryBase***

- createPrec() : PreconditionerBase
- initializePrec( in fwdOpSrc, inout prec )

**PreconditionerFactoryBase** : Creates and initializes **PrecondtionerBase** objects

- <<create>>

- prec

- Allows unlimited creation/reuse of preconditioner objects
- Supports reuse of factorization structures
- Adapters currently available for Ifpack and ML
- New Stratimikos package provides a singe parameter-driver wrapper for all of these

***PreconditionerBase***

- getLeftPrecOp() : LinearOpBase
- getRightPrecOp() : LinearOpBase
- getUnspecifiedPrecOp() : LinearOpBase

## Linear Operator With Solve and Factories

**Linear Operator With Solve and Factories**

***LinearOpBase***

***LinearOpWithSolveBase***

- solve( in B, inout X, ... )

- Appropriate for both direct and iterative solvers
- Supports multiple simultaneous solutions as multi-vectors
- Allows targeting of different solution criteria to different RHSs
- Supports a “default” solve

***LinearOpWithSolveFactoryBase***

*createOp() : LinearOpWithSolveBase*
*initializeOp( in fwdOpSrc, inout Op )*
*initializePreconditionedOp( in fwdOpSrc, in prec,*
*   **inout Op)*

**LinearOpWithSolveBase** : Combines a linear operator and a linear solver

**LinearOpWithSolveFactoryBase** :  Uses LinearOpBase objects to initialize LOWSB objects

***LinearOpWithSolveBase***

- <<create>>

- Allows unlimited creation/reuse of LinearOpWithSolveBase objects
- Supports reuse of factorizations/preconditioners
- Supports client-created external preconditioners (which are ignored by direct solvers)
- Appropriate for both direct and iterative solvers
- Concrete adaptors for Amesos, AztecOO, and Belos (not released) are available
- New Stratimikos package provides a single parameter-driven wrapper to all of these!

## Introducing Stratimikos

- Stratimikos created Greek words "stratigiki“ (strategy) and "grammikos“ (linear)
- Defines class Thyra::DefaultRealLinearSolverBuilder:
- Provides common access to:
- Linear Solvers: Amesos, AztecOO, Belos (dev only), ...
- Preconditioners: Ifpack, ML, ...
- Reads in options through a parameter list (read from XML?)
- Accepts any linear system objects that provide
- Epetra_Operator / Epetra_RowMatrix view of the matrix
- SPMD vector views for the RHS and LHS (e.g. Epetra_[Multi]Vector objects)
- Provides uniform access to linear solver options that can be leveraged across multiple applications and algorithms

- Stay tuned for more detailed Stratimikos example to come later ...

## “Client Support” Software for Developing ANAs

- C++ wrapper functions for prewritten RTOpT subclasses
-     e.g.    norm_1(x), assign(&y,x), scale(alpha,&y), ...
- Composite objects:
- Product vectors, multi-vectors and vector spaces
-     e.g.   x = [ v1; v2; v3; ... ; vn ];
- Decorator and composite subclasses for building implicitly composed linear operators
- Zero operator                                e.g. M = 0
- Identity operator                            e.g.  M = I
- Implicit scaled adjoint/transpose:  e.g.   M = alpha*adjoint(A);
- Additive linear operators:              e.g.   M = A + B + C + D;
- Multiplicative linear operators:      e.g.   M = A * B * C * D;
- Block linear linear operators:        e.g.   M = [ A, B ; C, D ];
- Handle classes with operator overloading
-                e.g.    y = alpha*trans(A)*x + gamma*B*z + beta*y

## Math Notation vs. C++ Handle Code : Example, Linear CG

_**Math Notation for CG**_

**Math Notation vs. C++ Handle Code : Example, Linear CG**

- // Initialization ...
- Vector<Scalar> r = b - A*x;
- for( int iter = 0; iter <= maxNumIters; ++iter ) {
-   Scalar rho  = inner(r,r);
-   Scalar beta = (iter!=0 ? rho/rho_old : one);
-   if(iter!=0) p = r + beta*p; else copyInto(r,p);
-   q = A*p;
-   Scalar gamma = inner(p,q);
-   Scalar alpha = rho/gamma;
-   x += Scalar(+alpha)*p;
-   r += Scalar(-alpha)*q;
-   // Check convergence ...
-   rho_old = rho;
- }

_**C++ Handles Implementing CG**_

- Matlab-like notation for linear algebra!
- Template meta-program methods used to reduce operator-overloading overhead and avoid creation of temps.
- Works with any linear operator and vector implementation (e.g. Epetra, PETSc, etc.)
- Works in any computing configuration, i.e. serial, SPMD, client/server etc.!
- Works with any Scalar type (i.e. float, double, complex<double>, extended precision, etc.) that has a traits class
- Still some more work to be done: Better elimination of some temporaries, support for multi-vectors

- See silliestCgSolve(...) and Meros for other examples ...

**Notes:**
So what is an abstract numerical algorithm, or an ANA for short?

## History Behind Thyra

**Hilbert Class Library**** ****(HCL)**
**Symes et. al. 1995?**
**Rice University**
**Vector spaces, vectors, and operators**

**AbstractLinAlgPack ****(in rSQP++)**
**Bartlett, 2001**
**Sandia National Labs**
**RTOp**

**Sundance HCL**
**Long et. al., 2000**
**Sandia National Labs**
**Smart pointers, Handles ...**

**Trilinos Solver Framework (TSF)**
**Long et. al. 2001**
**Sandia National Labs**
**Renaming of Sundance HCL**

**TSFCore**
**Bartlett et. al.,  2003**
**Sandia National Labs**
**ANA Operator/Vector Interfaces**

**???**

**Thyra**
**Thyra developers et. al., 2005**
**Sandia National Labs**
**Renaming of TSFCore Operator/Vector clases****, ****LinearOpWithSolve, ModelEvaluator**

## Finding Your Way Around Thyra

- Browse Thyra Doxygen documenation:
- Go to the website _[http://](http://software.sandia.gov/trilinos)__[software.sandia.gov/trilinos](http://software.sandia.gov/trilinos)_,
- Click on “Thyra” (on the right side)
- Click on “Release 7.0” or “Development” (on the left side)
- Browse the different doxygen documentation collections separately
- + You will see Thyra in small chunks!
- -  It is hard to find things you don’t know where they exist!
- Or, click on “Browse all of Thyra as a single doxygen collection” and click on “single doxygen collection”
- + You will find everything in Thyra!
- -  You will find everything in Thyra! This will not search outside of Thyra pacakge!
- Click “Other Software Related to Thyra” and click links to other collection
- Use the “Search For” box in a Doxygen documentation collection (on software!):
- Within any doxygen collection html page, at the fill in “Search For” box and hit Enter
- + You will search only that doxygen documentation collection!
- -  You will search only that doxygen documentation collection!
- Use the Google Search option on the main website:
- Go to the website _[http://](http://software.sandia.gov/trilinos)__[software.sandia.gov/trilinos](http://software.sandia.gov/trilinos)_,
- Click on “Search” (on the left side)
- Click “Google Search” (+ Search all packges, - Will search dev and all releases!)
- Do a “grep –r ‘What I want to find’ .” in your local Trilinos/packages dir.

## Outline

- Overview of Thyra
- “Why should anyone care about Thyra”
- Stratimikos (unified access to linear solvers & algebraic preconditioners)
- Wrapping it up

## Why Should Anyone Care about Thyra?

- We will look at answering this question and provide insights by asking some more questions:

- Do you just want different solvers to work together without a lot of work on your part?
- Do you need to access a solver that accepts input through Thyra?
- Do you want to implement large-scale numerical algorithms?
- Are you responsible for making sure that many different solvers all work together in a seamless and automatic way?

## Do you want different solvers to work together?

- Do you just want different solvers to work together without a lot of work on your part?

- If your answer is yes then: You should care about Thyra since it makes this possible like has never been achieved before for as many different types of numerical algorithms and software!

- What you need to know about Thyra?:
- Almost nothing! (perhaps not even the name Thyra)
- What you _do not_ need to know about Thyra?
- Almost everything about Thyra!

## Do you want different solvers to work together?

- <ParameterList>
-   ...
-   <Parameter name=“Time Stepper” type=“string” value=“Rythmos::ImplicitBDFStepper”/>
-   <ParameterList name=“Rythmos::SUNDIALS”> ... </ParameterList>
-   <ParameterList name=“**Rythmos::ImplicitBDFStepper**”>
-     <Parameter name=“Nonlinear Solver” type=“string” value=“NOX”/>
-     <ParameterList name=“TimeStepNewtonNonlinearSolver”> ... </ParameterList>
-     <ParameterList name=“**NOX**”>
-       <Parameter name=“Linear Solver” type=“string” value=“Stratimikos”/>
-       <ParameterList name=“**Stratimikos**”>
-         <Parameter name="Linear Solver Type" type="string" value=“Belos"/>
-         <ParameterList name="Linear Solver Types">
-           <ParameterList name=“Amesos”> ... </ParameterList>
-           <ParameterList name=“AztecOO”> ... </ParameterList>
-           <ParameterList name=“**Belos**”> ... </ParameterList>
-         </ParameterList>
-         <Parameter name="Preconditioner Type" type="string" value="ML"/>
-         <ParameterList name="Preconditioner Types">
-           <ParameterList name="Ifpack"> ... </ParameterList>
-           <ParameterList name="**ML**"> ... </ParameterList>
-           <ParameterList name=“Meros"> ... </ParameterList>
-         </ParameterList>
-       </ParameterList>
-     </ParameterList>
-   </ParameterList>
- </ParameterList>

**Time Stepper**

**Nonlinear Solver**

**Lin. Solver**

**Precond.**

**Linear Solver**

- In the long term, most users will form connections between different solvers by selecting options from in a parameter list!

- Example:
-        Time Stepper => Nonlinear Solver => Linear Solver => Preconditioner

- End users may not even see the name “Thyra”!

## Do you need to access a solver that accepts Thyra objects?

- What you need to know about Thyra?
- How to wrap your objects as Thyra objects
- Support already provided for your objects (e.g. Epetra, Tpetra, etc.)? => Easy!
- Support not already provided?                                                             => Harder!
- What you _do not_ need to know about Thyra?
- How interoperability works
- What utilities there are for developing algorithms (e.g. implicit ops, handles etc.)
- ...

- Do you need to be able to access a numerical solver that only accepts objects through Thyra (e.g. Stratimikos)?

- If your answer is yes then: You have no choice but to care about Thyra since that is the only way to access the solver capability!

- Stay tuned for more detailed Stratimikos example to come later ...

## Do you want to write large-scale numerical algorithms?

- Are you interested in doing algorithmic research and writing numerical algorithms that lend themselves to the ANA approach and ...

- If your answer is yes then: You should care about Thyra since it makes it relatively easy (but perhaps not by MATLAB standards) to achieve these goals and get efficient and maintainable code that will stand up over time.

- maintain a concise mathematical description/notation?
- will run in parallel out of the box?
- are completely independent of computer platform details or MPI?
- are interoperable with other numerical algorithms?
- provides a straightforward path to a production capability?
- have access to a wide range of large-scale production problems?

- What you need to know about Thyra?
- “Client support” software for developing ANAs (e.g. implicit ops, handles etc.)
- What you _do not_ need to know about Thyra?
- How interoperability works
- How to define concrete Thyra objects
- ...

## Are you responsible for ensuring different solvers work together?

- Are you responsible for making sure that different solver packages all work together in a seamless and automatic way in many different configurations?

- If your answer is yes then: you should care about Thyra since it makes this possible like no other middleware has ever done before with the range of algorithms that can and have been addressed using Thyra.

- What you need to know about Thyra?
- How interoperability works
- How to define concrete Thyra objects
- What you _do not_ need to know about Thyra?
- “Client support” software for developing ANAs (e.g. implicit ops, handles etc.)
- ...

## Why Should Anyone Care about Thyra?

- Do you just want solver A, solver B, solver C etc. to work together without a lot of work on your part?
- Do you need to access a solver that accepts input through Thyra?
- Do you want to implement large-scale numerical algorithms?
- Are you responsible for making sure that solver A, solver B, solver C etc. all work together in a seamless and automatic way?

- Note: Very few people (perhaps just me and a few other people) will answer yes to all four of these question!
- Take-home message: What you need to know about Thyra depends on how you interact with Thyra (if at all)!

## Outline

- Overview of Thyra
- “Why should anyone care about Thyra”
- Stratimikos (unified access to linear solvers & algebraic preconditioners)
- Wrapping it up

## Accessing a Solver through Thyra?  Stratimikos Example

- simple_stratimikos_example.cpp
- Demonstrates how to solve single-RHS linear systems expressed as Epetra objects
- Typical steps for “using a solver that accepts Thyra objects”:
- Setup the environment for the program
- => Read in command-line options
- Create the input objects using your data structures (independent of Thyra)
- => Read in linear system objects in terms of Epetra objects
- Wrap your objects as Thyra objects (The “glue”)
- => Use Epetra-to-Thyra wrapper functions
- Call the solver through Thyra interfaces (Thyra-specific)
- => Create the LinearOpWithSolve[Factory]Base objects and solve ...
- Post process the solution (if needed) using your objects (independent of Thyra)
- => Post process solution and check in terms of Epetra objects (Not Thyra!!!)

## A) Setup the environment for the program

-     //
-     // A) Program setup code
-     //
-     //
-     // Read options from command-line
-     //
-     std::string     matrixFile             = "";
-     ...
-     Thyra::DefaultRealLinearSolverBuilder linearSolverBuilder;
-     CommandLineProcessor  clp(false); // Don't throw exceptions
-     // Set up command-line options for the linear solver that will be used!
-     linearSolverBuilder.setupCLP(&clp);
-     clp.setOption( "matrix-file", &matrixFile
-                    ,"Defines the matrix and perhaps the RHS and LHS for a linear system to be solved." );
-      ...
-     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
-     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;

- See the file simple_stratimikos_example.cpp for more details ...

## B) Create the input objects using your data structures 

-     //
-     // B) Epetra-specific code that sets up the linear system to be solved
-     //
-     // While the below code reads in the Epetra objects from a file, you can
-     // setup the Epetra objects any way you would like.  Note that this next
-     // set of code as nothing to do with Thyra at all, and it should not.
-     //
-     *out << "\nReading linear system in Epetra format from the file \'"<<matrixFile<<"\' ...\n";
- #ifdef HAVE_MPI
-     Epetra_MpiComm comm(MPI_COMM_WORLD);
- #else
-     Epetra_SerialComm comm;
- #endif
-     RefCountPtr<Epetra_CrsMatrix> epetra_A;
-     RefCountPtr<Epetra_Vector> epetra_x, epetra_b;
-     EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A, NULL, &epetra_x, &epetra_b );
-     if(!epetra_b.get()) {
-       *out << "\nThe RHS b was not read in so generate a new random vector ...\n";
-       epetra_b = rcp(new Epetra_Vector(epetra_A->OperatorRangeMap()));
-       epetra_b->Random();
-     }
-     if(!epetra_x.get()) {
-       *out << "\nThe LHS x was not read in so generate a new zero vector ...\n";
-       epetra_x = rcp(new Epetra_Vector(epetra_A->OperatorDomainMap()));
-       epetra_x->PutScalar(0.0); // Initial guess is critical!
-     }

- Create the Epetra objects any way that you would like ...

## C) Wrap your objects as Thyra objects (The “glue”)

-     //
-     // C) The "Glue" code that takes Epetra objects and wraps them as Thyra
-     // objects
-     //
-     // This next set of code wraps the Epetra objects that define the linear
-     // system to be solved as Thyra objects so that they can be passed to the
-     // linear solver.
-     //
-     // Create RCPs that will be used to hold the Thyra wrappers
-     RefCountPtr<const Thyra::LinearOpBase<double> >    A;
-     RefCountPtr<Thyra::VectorBase<double> >            x;
-     RefCountPtr<const Thyra::VectorBase<double> >      b;
-     // Create the Thyra wrappers
-     if(1) {
-       // Create an RCP directly to the EpetraLinearOp so that we can access the
-       // right range and domains spaces to use to create the wrappers for the
-       // vector objects.
-       RefCountPtr<const Thyra::EpetraLinearOp>
-         _A = Thyra::create_LinearOp(epetra_A);
-       // Create Thyra wrappers for the vector objects that will automatically
-       // update the Epetra objects.
-       b = Thyra::create_Vector(epetra_b,_A->spmdRange());
-       x = Thyra::create_Vector(epetra_x,_A->spmdDomain());
-       // Set the RCP to the base linear operator interface
-       A = _A;
-     }

- Turning Epetra objects into Thyra objects is easy!

- Epetra-to-Thyra wrapper functions are found in Thyra_EpetraThyraWrappers.hpp

## D) Call the solver through Thyra interfaces 

-     //
-     // D) Thyra-specific code for solving the linear system
-     //
-     // Note that this code has no mention of any concrete implementation and
-     // therefore can be used in any use case.
-     //
-     // Reading in the solver parameters from the parameters file and/or from
-     // the command line.  This was setup by the command-line options
-     // set by the setupCLP(...) function above.
-     linearSolverBuilder.readParameters(out.get());
-     // Create a linear solver factory given information read from the
-     // parameter list.
-     RefCountPtr<Thyra::LinearOpWithSolveFactoryBase<double> >
-       lowsFactory = linearSolverBuilder.createLinearSolveStrategy("");
-     // Setup output stream and the verbosity level
-     lowsFactory->setOStream(out);
-     lowsFactory->setVerbLevel(Teuchos::VERB_LOW);
-     // Create a linear solver based on the forward operator A
-     RefCountPtr<Thyra::LinearOpWithSolveBase<double> >
-       lows = Thyra::linearOpWithSolve(*lowsFactory,A);
-     // Solve the linear system (note: the initial guess in 'x' is critical)
-     Thyra::SolveStatus<double>
-       status = Thyra::solve(*lows,Thyra::NOTRANS,*b,&*x);
-     *out << "\nSolve status:\n" << status;
-     // Write the linear solver parameters after they were read
-     linearSolverBuilder.writeParamsFile(*lowsFactory);

- This part of the code has nothing to do with Epetra!
- This is really only a trivial interaction with Thyra!

## E) Post process the solution (if needed) using your objects 

-     //
-     // E) Post process the solution and check the error
-     //
-     // Note that the below code is based only on the Epetra objects themselves
-     // and does not in any way depend or interact with any Thyra-based
-     // objects.  The point is that most users of Thyra can largely gloss over
-     // the fact that Thyra is really being used for anything.
-     //
-     // Wipe out the Thyra wrapper for x to guarantee that the solution will be
-     // written back to epetra_x!
-     x = Teuchos::null;
-     *out
-       << "\nSolution ||epetra_x||2 = " << epetraNorm2(*epetra_x) << "\n";
-     *out << "\nTesting the solution error ||b-A*x||/||b|| computed through the Epetra objects ...\n";
-     // r = b - A*x
-     Epetra_Vector epetra_r(*epetra_b);
-     if(1) {
-       Epetra_Vector epetra_A_x(epetra_A->OperatorRangeMap());
-       epetra_A->Apply(*epetra_x,epetra_A_x);
-       epetra_r.Update(-1.0,epetra_A_x,1.0);
-     }
-     const double
-       nrm_r = epetraNorm2(epetra_r),
-       nrm_b = epetraNorm2(*epetra_b),
-       rel_err = ( nrm_r / nrm_b );
-     const bool
-       passed = (rel_err <= tol);
-     *out
-       << "||b-A*x||/||b|| = " << nrm_r << "/" << nrm_b << " = " << rel_err
-       << " < tol = " << tol << " ? " << ( passed ? "passed" : "failed" ) << "\n";

**E) Post process the solution (if needed) using your objects **

## Stratimikos Parameter List and Sublists 

- <ParameterList name=“Stratimikos”>
-   <Parameter name="Linear Solver Type" type="string" value=“AztecOO"/>
-   <Parameter name="Preconditioner Type" type="string" value="Ifpack"/>
-   <ParameterList name="Linear Solver Types">
-     <ParameterList name="Amesos">
-       <Parameter name="Solver Type" type="string" value="Klu"/>
-       <ParameterList name="Amesos Settings">
-         <Parameter name="MatrixProperty" type="string" value="general"/>
-         ...
-         <ParameterList name="Mumps"> ... </ParameterList>
-         <ParameterList name="Superludist"> ... </ParameterList>
-       </ParameterList>
-     </ParameterList>
-     <ParameterList name="AztecOO">
-       <ParameterList name="Forward Solve">
-         <Parameter name="Max Iterations" type="int" value="400"/>
-         <Parameter name="Tolerance" type="double" value="1e-06"/>
-         <ParameterList name="AztecOO Settings">
-           <Parameter name="Aztec Solver" type="string" value="GMRES"/>
-           ...
-         </ParameterList>
-       </ParameterList>
-       ...
-     </ParameterList>
-     <ParameterList name="Belos"> ... </ParameterList>
-   </ParameterList>
- <ParameterList name="Preconditioner Types">
-     <ParameterList name="Ifpack">
-       <Parameter name="Prec Type" type="string" value="ILU"/>
-       <Parameter name="Overlap" type="int" value="0"/>
-       <ParameterList name="Ifpack Settings">
-         <Parameter name="fact: level-of-fill" type="int" value="0"/>
-         ...
-       </ParameterList>
-     </ParameterList>
-     <ParameterList name="ML"> ... </ParameterList>
-   </ParameterList>
- </ParameterList>

**Linear Solvers**

**Preconditioners**

- See Doxygen documentation for Thyra::DefaultRealLinearSolverBuilder!

**Sublists passed on to package code!**

**Top level parameters**

**Every parameter and sublist ****not in red**** is handled by Thyra code and is fully validated!**

## Automatically Generated Parameter List Documentation

- “Human readable” automatically generated documentation for Stratimikos

-  Linear Solver Type : string = Amesos
-     # Determines the type of linear solver that will be used.
-     # The parameters for each solver type are specified in the sublist "Linear Solver Types"
-     #   Valid values: "Belos", "Amesos", "AztecOO"
-   Preconditioner Type : string = ML
-     # Determines the type of preconditioner that will be used.
-     # This option is only meaningful for linear solvers that accept preconditioner factory objects!
-     # The parameters for each preconditioner are specified in the sublist "Preconditioner Types"
-     #   Valid values: "None", "Ifpack", "ML"
-   Linear Solver Types ->
-     AztecOO ->
-       Output Every RHS : bool = 0
-         # Determines if output is created for each individual RHS (true or 1) or if output
-         # is just created for an entire set of RHSs (false or 0).
-       Forward Solve ->
-         Max Iterations : int = 400
-           # The maximum number of iterations the AztecOO solver is allowed to perform.
-         Tolerance : double = 1e-06
-           # The tolerence used in the convergence check (see the convergence test
-           # in the sublist "AztecOO Settings")
-         AztecOO Settings ->
-           Aztec Solver : string = GMRES
-             # Type of linear solver algorithm to use.
-             #   Valid values: "CG", "GMRES", "CGS", "TFQMR", "BiCGStab", "LU"
-           Convergence Test : string = r0
-             # The convergence test to use for terminating the iterative solver.
-             #   Valid values: "r0", "rhs", "Anorm", "no scaling", "sol"
-           ...
-     ...

- See Doxygen documentation for Thyra::DefaultRealLinearSolverBuilder!
- Development version of Trilinos Only!

## Open Issues for Stratimikos 

- Thyra::DefaultRealLinearSolverBuilder
- Not every parameter can be read from an XML file currently.
- Common “presolve” operations (e.g. prescaling and singleton filter removal) are not supported yet.
- Only double precision is supported currently.
- AztecOO, Amesos, Ifpack, and ML all currently require Epetra views of the objects.
-  Future needs
- Other scalar types (i.e. float, std::complex<float>, std::complex<double> ...)
- Specialized/blocked preconditioners (e.g. Meros ...)
- “Smart” solver managers (e.g. pick the best method automatically)
-  ...

## Outline

- Overview of Thyra
- “Why should anyone care about Thyra”
- Stratimikos (unified access to linear solvers & algebraic preconditioners)
- Wrapping it up

## Summary

**Thyra **interfaces provide** **minimal but efficient connectivity between ANAs and linear algebra implementations and applications
**Thyra** is the critical standard for interoperability between ANAs in Trilinos
**Thyra** can be used in Serial/SMP, SPMD, client/server and master/slave
**Thyra** provides a growing set of optional utilities for ANA development and subclass implementation support
**Thyra** support for nonlinear ANAs (i.e. the model evaluator) is being developed as well as general support for linear solvers
**Thyra** interfaces and adapters are provided for preconditioner factories and linear solver factories (Stratimikos)
**Thyra** adapters are available for Epetra, Amesos, AztecOO, Belos, Anasazi, Rythmos, and MOOCHO with others on the way (e.g. NOX,  ...)
**Python/Thyra** wrappers are on the way as well (Bill Spotz)!
_**Trilinos website**_
-    http://software.sandia.gov/trilinos