[petsc-users] Suggestions for code with dof >> 1 ?

Barry Smith bsmith at mcs.anl.gov
Wed Oct 9 15:51:40 CDT 2013


On Oct 9, 2013, at 2:04 PM, Christophe Ortiz <christophe.ortiz at ciemat.es> wrote:

> 
> On Wed, Oct 9, 2013 at 3:13 PM, Christophe Ortiz <christophe.ortiz at ciemat.es> wrote:
> 
> > 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.)
> 
> 
> 
> And if with the previous case I would like to pass the values 1, 2, 3, 4, 5, 6, 7 and 8 (the two first rows) what is the matrix val[ ] that I should pass ? Should it be a matrix val[2][4] ?

   It takes a one dimensional array as input; by default the values should be ordered by row so you would pass in the numerical values 1, 2, 3, 4,5, 6,7,8 in that order. If you wish to have the values ordered by column then you would pass 1 5 2 6 3 7 4 8 after calling MatSetOptions(mat,MAT_ROW_ORIENTED,PETSC_FALSE).

   Note that the ordering you use on the numerical values is the same for both MatSetValues() and MatSetValuesBlocked().

   Barry

> 
> If I understand correctly it would be 1 block row, the block row indice being 0; 2 block columns, the column block indices being 0 and 1:
> 
> indices of block rows and block columns:
> row = 0
> col[0]=0; col[1]=1
> MatSetValuesBlocked(*Jpre,1,&row,2,&col,&v[0][0],INSERT_VALUES);
> 
> Is it correct ? Is the matrix val correct ?
> 
> Christophe
> 



More information about the petsc-users mailing list