[petsc-users] segv in VecSum when using nested vec

Jed Brown jedbrown at mcs.anl.gov
Wed Mar 7 07:07:27 CST 2012


On Wed, Mar 7, 2012 at 06:53, Matthew Knepley <knepley at gmail.com> wrote:

> > Why are you using VecNest? It causes more harm than good in all but some
>> > very special circumstances.
>>
>> I'm using it to experiment with PETSc's block preconditioners. In
>> short, I have a block matrix for the 2D Stokes eqs with the
>> variables arranged as (u1,...,uN,v1,...,vN,p1,...pN). The matrix
>> has the form A = [Q G, D 0]. I'm using VecCreateNest to assemble
>> the vector x = [u p], just like I use MatCreateNest to assemble
>> the matrix A from the blocks Q, G and D. The index sets are the
>> ones you helped me with in a previous thread
>> (
>> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2012-February/012262.html
>> )
>>
>
> This is just an optimization for block PCs, and for vectors I think it
> makes almost
> no difference.
>

Agreed, I recommend using normal Vecs. You can access part of it with
VecGetSubVector() if you want to set values for each part separately (it
will be no-copy if possible). VecNest only matters if you insist on storing
the subvectors as non-contiguous parts of the composite Vec, but also
insist on not making copies. Even then, since VecScatter does not have
native support for VecNest, there will be some copies in the preconditioner
(but they could eventually be supported without copies, note that it's
mostly moot because you need a very specialized scenario to make copies
account for more than 5% of run-time). So you should basically never use
VecNest unless you are really sure that it's the right thing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120307/a9cea3d7/attachment.htm>


More information about the petsc-users mailing list