Ok, I really apreciate your help. Thanks Jed and Barry.<br><br>Regards<br><br>Pedro<br><br><div class="gmail_quote">2010/2/25 Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></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><div></div><div class="h5"><br>
On Feb 25, 2010, at 7:50 PM, Pedro Torres wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<br>
2010/2/25 Jed Brown <<a href="mailto:jed@59a2.org" target="_blank">jed@59a2.org</a>><br>
On Thu, 25 Feb 2010 13:37:21 -0300, Pedro Torres <<a href="mailto:torres.pedrozpk@gmail.com" target="_blank">torres.pedrozpk@gmail.com</a>> wrote:<br>
> Well, in my case I have a sequential vector and I'm trying to append one<br>
> element at the end of the array, without the need of destroy this.<br>
<br>
PETSc Vec doesn'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>
<br>
> - Create a new vector with size+1<br>
> - copy old array in the new array and append the element,<br>
<br>
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>
<br>
The things is that I don'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 VecCreateSeqWithArray and Petsc will use the array in std::vector.<br>
</blockquote>
<br></div></div>
You could do this. In general what we do is to "process" the mesh, boundary conditions etc to determine the needed size, set the vector size, then go back and compute the vector/matrix entries.<br><font color="#888888">
<br>
Barry</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Is that right?<br>
<br>
Thanks a lot!<br>
<br>
Pedro<br>
<br>
<br>
Jed<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br>