On Tue, Dec 20, 2011 at 7:24 AM,  <span dir="ltr">&lt;<a href="mailto:E.T.A.vanderWeide@utwente.nl">E.T.A.vanderWeide@utwente.nl</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>






<div>


<p><font>Hi,<br>
<br>
I was wondering if it is possible to provide PETSc the matrix vector product yourself for a matrix free computation inside the SNES environment. The reason for asking is that the truncation error in the standard finite difference approach may lead to some noisy behavior for our application. We have found a nice way to get rid off the truncation error completely by using dual numbers for the creation of the Jacobian matrices. The same technique can be used for the matrix vector product inside SNES, but this means that the user has to provide this product to PETSc.<br>

<br>
To be more specific. I would like to solve the nonlinear problem F(U) = 0 via the SNES environment using the matrix free option. So similarly to the function SNESSetFunction, which sets the function evaluation routine, I&#39;m seeking for a function that sets the function to compute the matrix vector product dF/dU times V, where U and V are inputs. Is such a function available or is there a different way to provide the matrix vector product yourself?<br>
</font></p></div></blockquote><div>No need to use the matrix-free option. Just provide a MATSHELL (<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateShell.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateShell.html</a>)</div>
<div>as the Jacobian using SNESSetJacobian(). Then your FormJacobian() function will get a vector &#39;x&#39; as input. Update the context for the MATSHELL with</div><div>this vector in that function, which is all it would really do. Then when the MatMult() is called on your shell matrix, compute the action using that &#39;x&#39;</div>
<div>which is stored in the context.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><p><font>
Thanks,<br>
<br>
Edwin<br>
---------------------------------------------------<br>
Edwin van der Weide<br>
Department of Mechanical Engineering<br>
University of Twente<br>
Enschede, the Netherlands<br>
</font>
</p>

</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>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<br>