[petsc-users] Using /src/ksp/ksp/example/tutorial/ex29.c to solve Poisson Equation Twice

Alan Wei zhenglun.wei at gmail.com
Sun Oct 2 16:31:41 CDT 2011


Thanks Dr. Smith,
  I will work on DM later after I know how to do this.
  BTW, what is the DMMG interface you are talking about? is it DMMGSetKSP()?
if so, that's is my problem. At the 2nd time of using DMMGSetKSP() in the
main function, it does not call the __function__ to compute the right hand
side. >_< any suggestions on that?

best,
Alan

On Sun, Oct 2, 2011 at 3:56 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Oct 2, 2011, at 12:04 PM, Alan Wei wrote:
>
> > Dear all,
> >     I hope you're having a nice weekend. I'm still using this program to
> solve Poisson Equations. After several discussions before, I know how to use
> it in general. However, I met a problem when I want to use it twice to solve
> a same Poisson Equations with two different RHS.(same boundary conditions)
> > 1) after I've done my first computation of a Poisson equation, I use
> DMMGSetKSP() again setting up another (*rhs) .
> >     However, I found that this DMMGSetKSP does not call the function that
> makes the new (*rhs), i.e. ComputeNewRHS().
> > 2) In the first tempt to solve the Poisson equation with old RHS,
> DMMGSetKSP called the function making the old (*rhs). If I comment out the
> first DMMGSetKSP(), which creates the old (*rhs), then this DMMGSetKSP,
> which create the new (*rhs), can call the function making the new (*rhs)
> > 2) I read the manual of "DMMGSetKSP" saying For linear problems may be
> called more than once, reevaluates the matrices if it is called more than
> once. Call DMMGSolve() directly several times to solve with the same matrix
> but different right hand sides. Does this mean that I do not need to call
> DMMGSetKSP if I need to solve the same Poisson equation with another RHS? If
> so, how can I pass my new RHS to dmmg?
>
>     With the DMMG interface you provide a __function__ to compute the right
> hand side, if you want to solve with several right hand sides you just have
> the rhs function compute a different right hand side each time it is called
> corresponding to the right hand sides you want to compute
>
>    By the way the DMMG is being deprecated and will not be in the next
> PETSc release so we recommend moving away from it and just using the KSP
> linear solver interface (see the manual page for KSPSetDM() and several
> examples that us KSPSetDM() in the src/ksp/ksp/examples/tutorials directory.
>
>   Barry
>
> >
> > thanks in advance,
> > Alan
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111002/e698a2a5/attachment.htm>


More information about the petsc-users mailing list