<br><br><div class="gmail_quote">2010/2/25 Jed Brown <span dir="ltr">&lt;<a href="mailto:jed@59a2.org">jed@59a2.org</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Thu, 25 Feb 2010 13:37:21 -0300, Pedro Torres &lt;<a href="mailto:torres.pedrozpk@gmail.com">torres.pedrozpk@gmail.com</a>&gt; wrote:<br>
&gt; Well, in my case I have a sequential vector and I&#39;m trying to append one<br>
&gt; element at the end of the array, without the need of destroy this.<br>
<br>
</div>PETSc Vec doesn&#39;t work this way.  Use whatever data structure you like<br>
to put this thing together, then give it to PETSc once you know what you<br>
have.<br>
<div class="im"><br>
&gt; - Create a new vector with size+1<br>
&gt; - copy old array in the new array and append the element,<br>
<br>
</div>This is what dynamically sized array containers (e.g. std::vector) do<br>
internally, but they guess at how much extra will be needed (usually<br>
increasing the allocated size by a geometric factor).<br>
<br>
(When I asked what you are trying to do, I was looking for a higher<br>
level description of what you wanted to achieve, and why you thought<br>
appending to a Vec was a desirable thing.)<br></blockquote><div><br>The things is that I don&#39;t have the final dimension of the vector, because it depends of mesh size, boundary conditions,etc. But I think that I can do the following,<br>
<br>- use std::vector<br>- when I get final size, I create a Vec with<font size="2"> VecCreateSeqWithArray and Petsc will use the array in std::vector.<br><br>Is that right? <br><br>Thanks a lot!<br><br></font>Pedro<br> </div>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888"><br>
Jed<br>
</font></blockquote></div><br>