[petsc-users] How to set up an interface-type problem

Jed Brown jed at jedbrown.org
Thu Oct 20 10:55:43 CDT 2016


"Safin, Artur" <aks084000 at utdallas.edu> writes:

> Matt,
>
>
> You use
>
>   http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html
>   http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetSubVector.html
>
> to put values directly into the subvectors and submatrices. This interacts well with MatNest, so it
> can be optimized after you get it working.
>
>
> Thanks, MatNest and VecNest is what I was looking for.
>
> I have a one more question: if I generate a vector with VecCreateNest, will it be allocated separately, or does it somehow reuse the space from the original subvectors?

It references the vectors that you pass in.

But you almost certainly should not hard-code to use VecNest.  Almost
all operations are less efficient and most preconditioners cannot use
VecNest.  Similarly, you should assembly your matrix using
MatGetLocalSubMatrix(), setting values into the blocks using
MatSetValuesLocal().  You can reuse code you currently have for building
the blocks separately.  See src/snes/examples/tutorials/ex28.c for an
example.  If you do it this way, then using MatNest or VecNest is a
run-time flag that is a possible optimization for *some specific*
algorithms.  (VecNest is almost always a pessimization.  You can use
MatNest without VecNest.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161020/3297342a/attachment.pgp>


More information about the petsc-users mailing list