[Trilinos-Users] Custom preconditioner with Tpetra
MHeroux at CSBSJU.EDU
Mon Jan 4 14:50:10 EST 2016
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:
I hope this helps.
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:
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
I would like to build a custom preconditioner for a linear system using
Tpetra matrix/vector and linear solvers provided by Belos. Could you
tell me where to start? Is there some basic example showing how to do
Yes, Tpetra has an example showing how to define a custom
Tpetra::Operator. Please refer to
Belos also has examples showing how to use preconditioners.
The matrix I would like to use for preconditioning is P^(-1), so I
simple way of applying the preconditioner would be to assemble P, invert
(or compute cheap approximation of P^(-1)) and then multiply my lhs and
P^(-1), but perhaps there's a more proper way of applying the
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.
Trilinos-Users mailing list
Trilinos-Users at trilinos.org<mailto:Trilinos-Users at trilinos.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Trilinos-Users