[petsc-users] MATNEST with shell matrices

Jed Brown jedbrown at mcs.anl.gov
Thu Feb 21 14:57:06 CST 2013


What you describe will basically work, but it won't give you
preconditioning. I would NOT recommend using MatNest or VecNest until you
have a fully-implemented algorithm that you're happy with and that performs
well with fieldsplit or custom preconditioning that will be amenable to
your MatShells, AND for which you have systematically demonstrated that
those operations that are comparatively expensive when using monolithic
formats are actually bottlenecks for your application. If you write
assembly using MatGetLocalSubMatrix [1] and MatSetValuesLocal, then adding
in (optional) support for MatNest later will involve only a small amount of
setup code and zero modifications to your assembly routines.

Even then, I would not use VecNest. In fact, VecNest should pretty much
never be used. It demonstrates a concept and may occasionally be useful,
but that occurrence is so rare that you shouldn't even consider it for a
new code.

[1]
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html


On Thu, Feb 21, 2013 at 2:44 PM, Amneet Bhalla <mail2amneet at gmail.com>wrote:

> Hi All,
>
> I want to solve a system of equations which looks like
>
>              A x  +  Bu  = f1
>              C x  +  Du  = f2
>
> A, B, C, and D as shell operators and {x , u, f1, and f2} are non-native
> PETSc vectors.
>
> This is how I am thinking of solving it in PETSc
>
> 1)  Define shell operators which define Matrix-vector multiplication
>      routines {Ax,Bu, Cx, Du}.
>
> 2) Define a composite Matrix MAT_COMP as
>     Mat mat_array[ ] = {A,B,C,D};
>     Mat MAT_COMP;
>     MatCreateNest(PETSC_COMM_WORLD, 2, PETSC_NULL, 2, PETSC_NULL,
> mat_array, &MAT_COMP);
>
> 3) Define a composite Vector VEC_COMP as
>     Vec vec_array[ ] = {f1,f2};
>     Vec VEC_COMP;
>     VecCreateNest(PETSC_COMM_WORLD, 2, PETSC_NULL, vec_array, &VEC_COMP);
>
> 4) Create a shell matrix for composite matrix (MAT_COMP) which defines the
> action
>      f1 = Ax + Bu;
>      f2 = Cx + Du;
>
>    i.e MATOP_MULT, MATOP_MULT_ADD,  and MATOP_GET_VECS to duplicate vectors
>
>
> Does this sound like a reasonable approach?
>
> --
> Amneet
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130221/270c3e39/attachment.html>


More information about the petsc-users mailing list