[petsc-users] DMDA questions

Xiangdong epscodes at gmail.com
Mon Mar 3 13:06:04 CST 2014


On Mon, Mar 3, 2014 at 12:35 PM, Jed Brown <jed at jedbrown.org> wrote:

> Xiangdong <epscodes at gmail.com> writes:
>
> > I have a question about using KSPSetComputeOperator with user provided
> > function ComputeMatrix().
> >
> > In order to use multigrid, this function ComputeMatrix() should be able
> to
> > generate the matrix for any grid level. However, the matrix I am trying
> to
> > generate depending on a vector u (the solution at previous time step). It
> > is okay for ComputeMatrix at finest level, because I have the vector u at
> > the finest level. However, if the ComputeMatrix tries to compute the
> matrix
> > at a coarse level, I do not have the vector u at the coarse level. Then I
> > see some error messages about nonconfirming sizes. Should I manually
> > restrict the vector u at a coarse level or petsc has some functions on
> this?
> >
> > In other words, there is a vector u in ctx struct passing to the
> > ComputeMatrix at finest level, how can I interpolate/restrict it to the
> > correct grid level for multigrid applications?
>
> I encourage you to use TS because it can manage this for you, but if you
> want to manage it yourself, use DMCoarsenHookAdd to set callbacks that
> are called as the coarse grids are constructed and set up and PCMG. Use
> DMGetNamedGlobalVector to store your coarsened state and access it from
> your compute matrix function.  See the TS implementations if you want an
> example to follow.
>


Could you please expand it a little more on using DMCoarsenHookAdd to
restrict a fine vector on a coarse grid? The only example I can find is
ex48 in snes. It is not clear how the coarsen vector are generated from
that example.

thank you.

Xiangdong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140303/14f7b07e/attachment.html>


More information about the petsc-users mailing list