Hey Rob<br> If you are sure that you only want to insert values locally into x, then option 1 will be faster.<br>Option 2 will communicate values if the inserted values live on another processor. If you don't need to send any data, use Option 1.<br>
<br><br><br><br><div class="gmail_quote">On Tue, Dec 22, 2009 at 7:04 PM, Rob Ellis <span dir="ltr"><<a href="mailto:Robert.G.Ellis@shaw.ca">Robert.G.Ellis@shaw.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Petsc'ers<br>
<br>
Can someone please let me know if I can set MPI vector values using either<br>
of the following methods? I wish to set the values of 'x' from the values in<br>
'work'. Both methods operate correctly, but I would like to know which is<br>
more efficient, and/or recommended and why.<br>
<br>
<br>
1. GetArray/RestoreArray Method:<br>
<br>
call VecGetOwnershipRange(x,imin,imax,ierr)<br>
call VecGetArray(x,x_local_v,x_local_i,ierr)<br>
do i=imin,imax-1<br>
x_local(i-imin)=work(i+1)<br>
enddo<br>
call VecRestoreArray(x,x_local_v,x_local_i,ierr)<br>
<br>
<br>
<br>
2. SetValues/VecAssembly Method:<br>
<br>
call VecGetOwnershipRange(x,imin,imax,ierr)<br>
nx_local = imax-imin<br>
do i=imin,imax-1<br>
icol(i-imin+1)=i<br>
enddo<br>
call VecSetValues(x,nx_local,icol,work(imin+1),INSERT_VALUES,ierr)<br>
call VecAssemblyBegin(x,ierr)<br>
call VecAssemblyEnd(x,ierr)<br>
<br>
<br>
Method 1 is more compact and does not require the auxiliary column number<br>
vector, nor does it require the VecAssembly, however, it seems to be what is<br>
suggested by the examples. Also, is it recommended to use VecGetArrayF90?<br>
<br>
Thanks for your help,<br>
Cheers,<br>
<font color="#888888">Rob<br>
<br>
</font></blockquote></div><br>