<div dir="ltr"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 21, 2014 at 3:21 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</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 class="">Christophe Ortiz <<a href="mailto:christophe.ortiz@ciemat.es">christophe.ortiz@ciemat.es</a>> writes:<br>
> I tried and it works. The advantage is that it avoids setting up and<br>
> using pointers. However, I found out that it is significantly slower<br>
> than using explicit pointers of pointers **.<br>
<br>
</div>Are you creating and destroying in an inner loop? </blockquote><div><br></div><div>In some sense, yes. I create and destroy inside FormIJacobian() (my Jacobian evaluation routine). Therefore it is called at each timestep. I guess this takes time. But it is slower than doing the many malloc.</div>
<div><br></div><div>How can I create a global vector that would be passed to FormIJacobian() ? Creating it only once instead of doing it at each timestep would save time. I need to use this vector (size dof*dof) with classes and methods inside FormIJacobian() to calculate the different blocks that are passed to the Jacobian with MatSetValuesBlocked(). However, I cannot pass it as argument of FormIJacobian() since there is no room for it in the arguments.</div>
<div><br></div><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"> What gets set up is<br>
the same, and it's fewer allocations than what you were doing with many<br>
calls to malloc.<br>
</blockquote></div><br></div></div>