[petsc-users] Suggestions for code with dof >> 1 ?
Christophe Ortiz
christophe.ortiz at ciemat.es
Wed Oct 9 08:13:30 CDT 2013
On Wed, Oct 9, 2013 at 2:56 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> Christophe Ortiz <christophe.ortiz at ciemat.es> writes:
>
> > Hi,
> >
> > I am building my Jacobian (IJacobian) with dof > 1 and I am considering
> to
> > use either MatSetValuesLocal (what you did in ex10.c from
> > advection-diffusion) or MatSetValuesBlocked.
> >
> > Which one do you recommend ?
>
> MatSetValuesBlocked or MatSetValuesBlockedLocal.
>
Ok.
>
> > For the moment I am trying to understand how MatSetValuesBlocked works
> from
> > the various examples given in ts tutorials, but there is a mistery for
> > me...In these examples, the block size is not set. So when m and idxm[]
> (n
> > and idxn[]) are passed in, how does PETSc know the correspondance with
> > global row and column indices in the matrix ?
> >
> > For instance, ex22.c
> >
> > for (i=info.xs; i<info.xs+info.xm; i++) {
> > const PetscReal *k = user->k;
> > PetscScalar v[2][2];
> >
> > v[0][0] = a + k[0]; v[0][1] = -k[1];
> > v[1][0] = -k[0]; v[1][1] = a+k[1];
> > MatSetValuesBlocked(*Jpre,1,&i,1,&i,&v[0][0],INSERT_VALUES);
> > }
> >
> > Here 4 terms due to chemical reactions are passed to the matrix at once.
> > &i is passed for indice of row and column, which is supposed to be the
> > indice of the block. But if the blocksize is not set, how PETSc knows to
> > which row/colum it really corresponds in the matrix ?
>
> DMCreateMatrix() set the block size to match the "dof" argument to
> DMDACreate1d.
>
I suspected it ! It's smart !
>
> > For instance, if we take the example from petsc (MatSetValuesBlocked
> page),
> > what should I do to pass the block of values 3, 4, 7 and 8 with
> > MatSetValuesBlocked ?
> >
> > 1 2 | 3 4
> > 5 6 | 7 8
> > - - - | - - -
> > 9 10 | 11 12
> > 13 14 | 15 16
>
> Block row 0, block column 1. (Count from 0.)
>
Thanks !
Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131009/c1c39882/attachment.html>
More information about the petsc-users
mailing list