<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 9, 2013 at 3:13 PM, Christophe Ortiz <span dir="ltr"><<a href="mailto:christophe.ortiz@ciemat.es" target="_blank">christophe.ortiz@ciemat.es</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">
<div class="im">On Wed, Oct 9, 2013 at 2:56 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Christophe Ortiz <<a href="mailto:christophe.ortiz@ciemat.es" target="_blank">christophe.ortiz@ciemat.es</a>> writes:<br>


<br>
> Hi,<br>
><br>
> I am building my Jacobian (IJacobian) with dof > 1 and I am considering to<br>
> use either MatSetValuesLocal (what you did in ex10.c from<br>
> advection-diffusion) or MatSetValuesBlocked.<br>
><br>
> Which one do you recommend ?<br>
<br>
</div>MatSetValuesBlocked or MatSetValuesBlockedLocal.<br></blockquote><div><br></div></div><div>Ok.</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div><br>
> For the moment I am trying to understand how MatSetValuesBlocked works from<br>
> the various examples given in ts tutorials, but there is a mistery for<br>
> me...In these examples, the block size is not set. So when m and idxm[] (n<br>
> and idxn[]) are passed in, how does PETSc know the correspondance with<br>
> global row and column indices in the matrix ?<br>
><br>
> For instance, ex22.c<br>
><br>
> for (i=info.xs; i<info.xs+info.xm; i++) {<br>
> const PetscReal *k = user->k;<br>
> PetscScalar     v[2][2];<br>
><br>
> v[0][0] = a + k[0]; v[0][1] =  -k[1];<br>
> v[1][0] =    -k[0]; v[1][1] = a+k[1];<br>
> MatSetValuesBlocked(*Jpre,1,&i,1,&i,&v[0][0],INSERT_VALUES);<br>
> }<br>
><br>
> Here 4 terms due to chemical reactions are passed to the matrix at once.<br>
> &i is passed for indice of row and column, which is supposed to be the<br>
> indice of the block. But if the blocksize is not set, how PETSc knows to<br>
> which row/colum it really corresponds in the matrix ?<br>
<br>
</div>DMCreateMatrix() set the block size to match the "dof" argument to DMDACreate1d.<br></blockquote><div><br></div></div><div>I suspected it ! It's smart !</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div><br>
> For instance, if we take the example from petsc (MatSetValuesBlocked page),<br>
> what should I do to pass the block of values 3, 4, 7 and 8 with<br>
> MatSetValuesBlocked ?<br>
><br>
>   1  2  | 3  4<br>
>   5  6  | 7  8<br>
>     - - - | - - -<br>
>  9  10 | 11 12<br>
> 13 14 | 15 16<br>
<br>
</div>Block row 0, block column 1.  (Count from 0.)<br></blockquote><div><br></div></div><div></div></div><br></div></div></blockquote><div><br></div><div>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] ?</div>
<div><br></div><div>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:</div><div><br></div><div>indices of block rows and block columns:</div>
<div>row = 0</div><div>col[0]=0; col[1]=1</div></div><span style="color:rgb(80,0,80)">MatSetValuesBlocked(*Jpre,1,&row</span><span style="color:rgb(80,0,80)">,2,&col,&v[0][0],INSERT_VALUES)</span><span style="color:rgb(80,0,80)">;</span><br>
</div><div class="gmail_extra"><span style="color:rgb(80,0,80)"><br></span></div><div class="gmail_extra"><span style="color:rgb(80,0,80)">Is it correct ? Is the matrix val correct ?</span></div><div class="gmail_extra"><span style="color:rgb(80,0,80)"><br>
</span></div><div class="gmail_extra"><span style="color:rgb(80,0,80)">Christophe</span></div><div class="gmail_extra"><span style="color:rgb(80,0,80)"><br></span></div></div>