<div dir="ltr"><div dir="ltr">On Mon, Aug 10, 2020 at 6:26 PM Nidish <<a href="mailto:nb25@rice.edu">nb25@rice.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ah I get it now, MatSetBlocked has to be set node-wise. I tried this and <br>
it works, thank you.<br>
<br>
The other question I had was why are the arguments for MatSetValues() <br>
and MatSetValuesBlocked() set to const PetscInt* and const PetscScalar* <br>
instead of just PetscInt* and PetscScalar* ? I have the typecast there <br>
so my flycheck doesn't keep throwing me warnings on emacs ;)<br></blockquote><div><br></div><div>Jed is correct that this cast is implicit. The idea here is to tell the caller that we will not change the contents of the arrays that you pass in.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thank You,<br>
Nidish<br>
<br>
On 8/10/20 5:16 PM, Jed Brown wrote:<br>
> Nidish <<a href="mailto:nb25@rice.edu" target="_blank">nb25@rice.edu</a>> writes:<br>
><br>
>> It's a 1D model with displacements and rotations as DoFs at each node.<br>
>><br>
>> I couldn't find much in the manual on MatSetBlockSize - could you<br>
>> provide some more information on its use?<br>
>><br>
>> I thought since I've setup the system using DMDACreate1d (I've given<br>
>> 2dofs per node and a stencil width of 1 there), the matrix object should<br>
>> have the nonzero elements preallocated. Here's the call to DMDACreate1d:<br>
>><br>
>> DMDACreate1d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, N, 2, 1, NULL, &mshdm);<br>
> Ah, that will set the block size, but then it'll expect elstiff to be an 8x8 matrix where you've only passed 4x4.<br>
><br>
> idx[0] = 2*e; idx[1] = 2*e+1; idx[2] = 2*e+2; idx[3] = 2*e+3;<br>
><br>
> MatSetValuesBlocked(jac, 4, (const PetscInt*)idx, 4, (const PetscInt*)idx,<br>
> (const PetscScalar*)elstiff, ADD_VALUES);<br>
><br>
> You don't need the casts in either case, BTW. You probably want something like this.<br>
><br>
> idx[0] = e; idx[1] = e + 1;<br>
><br>
> MatSetValuesBlocked(jac, 2, idx, 2, idx, elstiff, ADD_VALUES);<br>
><br>
> Also, it might be more convenient to call MatSetValuesBlockedStencil(), especially if you move to a multi-dimensional problem at some point.<br>
-- <br>
Nidish<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>