[petsc-users] VecSetValues

Barry Smith bsmith at mcs.anl.gov
Mon Oct 10 18:24:17 CDT 2011


  Rob,

   You can use VecGetArray() and then compute the values directly into the underlying array, this is the fastest way to change the values. If you use VecGetArray() you can only write values for THAT process into the vector and you do not need to call VecAssemblyBegin/End().

   Barry

On Oct 10, 2011, at 3:33 PM, Robert Ellis wrote:

> Hello All,
>  
> I sometimes use VecSetValues ...
>  
> PetscErrorCode  VecSetValues(Vec x,PetscInt ni,const PetscInt ix[],const PetscScalar y[],InsertMode iora)
>  
> with PetscInt ix[] increasing uniformly, in steps of 1, from 0 to ni-1, which is also the full index range of Vec x.  I do this on every rank, then use ADD_VALUES to generate the full Vec x.
>  
> Is there a PetSc method to set values without specifying PetscInt ix[] explicitly in this simple case.  I'm trying to save the memory overhead of specifying ix[]on every rank.
>  
> Any guidance will be appreciated.
>  
> Regards,
> Rob



More information about the petsc-users mailing list