[petsc-users] DMDA questions

Jed Brown jed at jedbrown.org
Mon Mar 3 11:35:19 CST 2014


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140303/dccef61d/attachment.pgp>


More information about the petsc-users mailing list