[petsc-users] MATNEST with shell matrices

Amneet Bhalla mail2amneet at gmail.com
Thu Feb 21 14:44:00 CST 2013


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/422c1c95/attachment.html>


More information about the petsc-users mailing list