[Trilinos-Users] Custom preconditioner with Tpetra

Heroux, Mike MHeroux at CSBSJU.EDU
Mon Jan 4 14:50:10 EST 2016


Martin,

To follow up on Mark's comments, Trilinos provides two paths for users to provide their own linear operators.  This is true for Tpetra and Epetra, and for all of the preconditioner and solver packages.  These APIs are:


  *   Operator: This basic interface enables users to define their own linear operator as an adaptor to the abstract interface used by Trilinos for applying the action of a linear operator on a vector (or multivector if you have more than one vector).  The example (tpetra/core/example/Lesson06-Custom-Operator/lesson06_custom_operator.cpp) that Mark points to shows how define your own Operator class that can be used with Belos.  The Operator interface is also implemented by Trilinos solvers and preconditioners, so each Trilinos solver and preconditioner "isa" Operator.  Belos permits you to register an Operator instance as the "A" in solving Ax = b or as the "P" to be used as the preconditioner.
  *   RowMatrix: This interface is related to Operator.  In fact, RowMatrix "isa" Operator in that any RowMatrix object "isa" Operator object.  RowMatrix enables you to provide matrix coefficients to Trilinos preconditioners and utility functions, in addition to the functionality needed by the Operator interface.  All Trilinos preconditioners access matrix coefficients via the RowMatrix interface, so if you define your own RowMatrix class, you can have Trilinos compute multigrid, ILU or other preconditioners for your RowMatrix object.  Since RowMatrix "isa" Operator, you can pass a RowMatrix object to Belos as the "A" or "P" needed for solving a linear system.

In addition to Mark's example, you may find the following example to be useful.  It shows how to define and  use both Operator and RowMatrix.  It is written in terms of Epetra and AztecOO, but the principles carry forward to Tpetra and Belos:

Trilinos/packages/aztecoo/example/AztecOO_UserOpUserMat

I hope this helps.

Mike


On 1/3/16, 12:49 AM, "Trilinos-Users on behalf of Hoemmen, Mark" <trilinos-users-bounces at trilinos.org<mailto:trilinos-users-bounces at trilinos.org> on behalf of mhoemme at sandia.gov<mailto:mhoemme at sandia.gov>> wrote:



On 12/28/15, 11:03 PM, "trilinos-users-request at trilinos.org<mailto:trilinos-users-request at trilinos.org>"
<trilinos-users-request at trilinos.org<mailto:trilinos-users-request at trilinos.org>> wrote:
Message: 6
Date: Mon, 28 Dec 2015 16:42:03 +0000
From: Martin Vymazal <martin.vymazal at vki.ac.be<mailto:martin.vymazal at vki.ac.be>>
To: trilinos-users at trilinos.org<mailto:trilinos-users at trilinos.org>
Subject: [Trilinos-Users] Custom preconditioner with Tpetra
Message-ID: <0982ff04998b5b3181f7c401386ec950 at vki.ac.be<mailto:0982ff04998b5b3181f7c401386ec950 at vki.ac.be>>
Content-Type: text/plain; charset=US-ASCII; format=flowed

Hello,

  I would like to build a custom preconditioner for a linear system using
Tpetra matrix/vector and linear solvers provided by Belos. Could you
please
tell me where to start? Is there some basic example showing how to do
this?

Yes, Tpetra has an example showing how to define a custom
Tpetra::Operator.  Please refer to
tpetra/core/example/Lesson06-Custom-Operator/lesson06_custom_operator.cpp.
Belos also has examples showing how to use preconditioners.

The matrix I would like to use for preconditioning is P^(-1), so I
suppose one
simple way of applying the preconditioner would be to assemble P, invert
it
(or compute cheap approximation of P^(-1)) and then multiply my lhs and
rhs by
P^(-1), but perhaps there's a more proper way of applying the
preconditioner?

Preconditioning is a whole field of study in itself.  I can't tell you
what the "proper way" to apply your preconditioner is, because that
depends on your preconditioner.  If you plan to write your own
preconditioner rather than using an existing implementation (including the
many preconditioners in various Trilinos packages), it's up to you to
decide how to apply it.

mfh

_______________________________________________
Trilinos-Users mailing list
Trilinos-Users at trilinos.org<mailto:Trilinos-Users at trilinos.org>
https://trilinos.org/mailman/listinfo/trilinos-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20160104/873d0613/attachment.html>


More information about the Trilinos-Users mailing list