Hi Dave, Thanks! That's what I needed to know.
Cheers, Rob From: [email protected] [mailto:petsc-users-bounces at mcs.anl.gov] On Behalf Of Dave May Sent: Tuesday, December 22, 2009 10:13 AM To: PETSc users list Subject: Re: [petsc-users] Two ways to set Vec values? Hey Rob If you are sure that you only want to insert values locally into x, then option 1 will be faster. 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. On Tue, Dec 22, 2009 at 7:04 PM, Rob Ellis <Robert.G.Ellis at shaw.ca> wrote: Hi Petsc'ers Can someone please let me know if I can set MPI vector values using either of the following methods? I wish to set the values of 'x' from the values in 'work'. Both methods operate correctly, but I would like to know which is more efficient, and/or recommended and why. 1. GetArray/RestoreArray Method: call VecGetOwnershipRange(x,imin,imax,ierr) call VecGetArray(x,x_local_v,x_local_i,ierr) do i=imin,imax-1 x_local(i-imin)=work(i+1) enddo call VecRestoreArray(x,x_local_v,x_local_i,ierr) 2. SetValues/VecAssembly Method: call VecGetOwnershipRange(x,imin,imax,ierr) nx_local = imax-imin do i=imin,imax-1 icol(i-imin+1)=i enddo call VecSetValues(x,nx_local,icol,work(imin+1),INSERT_VALUES,ierr) call VecAssemblyBegin(x,ierr) call VecAssemblyEnd(x,ierr) Method 1 is more compact and does not require the auxiliary column number vector, nor does it require the VecAssembly, however, it seems to be what is suggested by the examples. Also, is it recommended to use VecGetArrayF90? Thanks for your help, Cheers, Rob -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091222/9cfd5e25/attachment.htm>
