analyze preconditioned operator?

Matthew Knepley knepley at gmail.com
Thu Oct 9 18:46:26 CDT 2008


On Thu, Oct 9, 2008 at 5:58 PM, Matt Funk <mafunk at nmsu.edu> wrote:
> So then,
>
> is it then correct to say that this code "registers" this extra operation
> (i.e. applying the preconditioner) with the matrix context such that whenever
> a matrix operation involving this matrix is invoked (like MatMult for
> example) the pc-applying fcn (i.e. myApply() ) is called first?

The idea here is to replace a given matrix A, which you are passing to SLEPc,
with another matrix M, which is a shell matrix. When MatMult() is called on M,
we call MatMult on A, and then PCApply on the result.

  Matt

> matt
>
> ps: sorry for being a little slow on the uptake here ...
>
>
> On Thursday 09 October 2008, Matthew Knepley wrote:
>> On Thu, Oct 9, 2008 at 5:25 PM, Matt Funk <mafunk at nmsu.edu> wrote:
>> > Hi Matt,
>> >
>> > so, the basic idea with this code is to apply the pc to each column
>> > vector of the matrix? Is that right?
>>
>> No, that is what KSPGetExplicitOperator() does. This applies the operator
>> in a matrix-free way.
>>
>> > Also, in your example: when is myApply actually invoked? I also looked at
>> > the example listed under the MatShellSetOperation reference page.
>>
>> When MatMult(A) is called.
>>
>>   Matt
>>
>> > Is the function then actually internally called when MatShellSetOperation
>> > is called, or when KSPSetOperators is called or KSPSolve?
>> >
>> > The reason i am asking is that if it is called when KSPSolve called then
>> > there is a problem because for the analysis i never call KSPSolve
>> > directly.
>> >
>> > thanks
>> > matt
>> >
>> > On Thursday 09 October 2008, Matthew Knepley wrote:
>> >> On Thu, Oct 9, 2008 at 4:32 PM, Matt Funk <mafunk at nmsu.edu> wrote:
>> >> > mmhh,
>> >> >
>> >> > i think i am missing something. Doesn't PCApply() apply the
>> >> > preconditioner to a vector? So how would that work (easily) with a
>> >> > matrix?
>> >>
>> >> You do not apply it to the matrix. Here is a skeleton (maybe has
>> >> mistakes)
>> >>
>> >> void myApply(Mat A, Vec x, Vec y) {
>> >>   MatShellGetContext(A, &ctx);
>> >>   MatMult(ctx->M, x, ctx->work);
>> >>   PCApply(ctx->pc, ctx->work, y);
>> >> }
>> >>
>> >> MatShellSetOperation(A, MATOP_MULT, myApply)
>> >>
>> >>   Matt
>> >>
>> >> > matt
>> >> >
>> >> > On Thursday 09 October 2008, Matthew Knepley wrote:
>> >> >> CApply().
>
>
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener




More information about the petsc-users mailing list