"Safin, Artur" <[email protected]> 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.)

Attachment: signature.asc
Description: PGP signature

Reply via email to