extracting work vectors
Barry Smith
bsmith at mcs.anl.gov
Fri Dec 4 13:37:12 CST 2009
Here is how preconditioners ALWAYS work (you are getting your
tangled round and round and making this much more complicated then it
really is).
Given a vector x any preconditioner returns a new vector y that
approximates the inv(A) x ; there are only two vectors involved and
there is NEVER "an initial guess to y" (or you can think of y as being
exactly zero). Note the x passed into PCApply() has NOTHING to do with
the current solution x in the gmres method nor is it the current
residual in the GMRES method it is just something that the Krylov
method has generated. In GMRES for example the current solution and
residual are not even computed until the GMRES restart, they are
simply not available during the running of GMRES.
So any PCApply() you provide takes x as input and computes an
approximation to y = inv(A) x; Note the variable names x and y in
PCApply are just dummy names and mean nothing, calling them x and y in
the source code and documention is probably a mistake, think of them
as input and output.
Barry
On Dec 4, 2009, at 9:47 AM, Jarunan Panyasantisuk wrote:
> I am using GMRES and BICGSTAB, not Richardson. Actually, I have never
> tried it.
>
> About PCSHELL, I am sorry if this will annoy you but please let me
> explain what I understand.
> When define a linear system Ax = b
> GMRES does Ax' = r
> where r is residual, acts as a new RHS and supposed to be minimized
> x' is a new solution vector, used in the iterations
>
> MyProcond(r, x', rtol, niter)
>
> which will solve the system Ax' = r for niter iterations
> Then, return new x' which will be the preconditioned vector or y in
>
> apply(pc,x',y)
>
> It is clear about the vector which preconditioner will be applied,
> x' here.
> In my case, I am looking for my right hand side, r, which I do not
> know
> how can I get this.
>
> If there is no way to access it, I apologize for asking several times.
>
> Regards,
> Jarunan
>
>
>
> Jed Brown wrote:
>> On Fri, 04 Dec 2009 12:51:27 +0100, jarunan at ascomp.ch wrote:
>>
>>> Hi Jed,
>>>
>>> Thanks for the advice. I took a look in PCShellSetApplyRicharson()
>>> and
>>> its apply function.
>>>
>>> PetscErrorCode apply (PC pc,Vec b,Vec x,Vec r,PetscReal
>>> rtol,PetscReal
>>> abstol,PetscReal dtol,PetscInt maxits)
>>>
>>> b - right-hand-side
>>> x - current iterate
>>> r - work space
>>>
>>> 1. Can I use PCShellSetApplyRicharson() with KSPGMRES? or it is
>>> restrict only for Richardson solver.
>>>
>>
>> Richardson only.
>>
>>
>>> 2. Is x equivalent to xin in PCShellSetApply(pc,apply(PC pc,Vec
>>> xin,Vec xout))?
>>>
>>
>> No, preconditioning Richardson is a different beast entirely.
>>
>>
>>> 3. Are b vector is the right hand side specified by user and r the
>>> work vector in the iterations?
>>>
>>
>> Yes, r is just work space, you are not required to use it.
>>
>> It's unlikely that you actually want to use Richardson, you should
>> write
>> apply(PC,Vec,Vec).
>>
>> Jed
>>
>
>
> --
> Jarunan Panyasantisuk
> Development Engineer
> ASCOMP GmbH, Technoparkstr. 1
> CH-8005 Zurich, Switzerland
> Phone : +41 44 445 4072
> Fax : +41 44 445 4075
> E-mail: jarunan at ascomp.ch
> www.ascomp.ch
>
>
More information about the petsc-users
mailing list