Christophe Ortiz <[email protected]> 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.
> 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.
> 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.)
pgpcUa4cfPs4J.pgp
Description: PGP signature
