Seems I was not clear enough. I have my pointer to the local vector values obtained witth VecGetArray. This function is called only once at the beginning of the program and VecRestoreArray is called at the end. The pointer is only used to read the values. I am doing an iterative scheme whereby I change the vector values (VecSetValues, i.e., cross-process) and subsequent VecAssemblyBegin/End. All I want to know is if I need to VecRestoreArray and VecGetArray again, of if it remains valid throughout the scheme.
Many thanks and sorry for the confusion, Dominik On Mon, Oct 31, 2011 at 4:19 PM, Satish Balay <balay at mcs.anl.gov> wrote: > On Mon, 31 Oct 2011, Dominik Szczerba wrote: > >> In the documentation of VecGetArray I read that it returns a pointer >> to the local data array and does not use any copies. Does this mean, >> that changing the values of the vector followed by >> VecAssemblyBegin/End does NOT invalidate the pointer? In other words, >> do I need to re-get the array when vec's values are changed? > > For one - you don't need VecAssemblyBegin/End if you obtain the array > with VecGetArray() - and change values there. > > Also - after you are done using the array - you should call > VecRestoreArray(). ?And you should be changing the values only between > these two calls. [i.e do not stash the pointer for later use - and > keep changing values with this pointer - after the call to > VecRestroeArray()]. ?If you need to change the vec again - call > VecGetArray() again. > > > Note: With VecGetArray() - you get access to local array - so can > modify only local values. If you have to set values that might go to a > different processor - then VecSetValues() - with > VecAssemblyBegin/End() - is the correct thing to do. > > Satish > >
