[petsc-users] confusion about VecGetArray on a sequential vec

Dave May dave.mayhem23 at gmail.com
Thu Aug 1 06:18:46 CDT 2013


You should be pass the same communicator into VecView() as was used when
you created the vector.
Do this
ierr = VecView(seqx,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);


On 1 August 2013 13:08, 丁老师 <ztdepyahoo at 163.com> wrote:

> but when we use vecveiw to veiw the seqx, it gives value only with 1
> process
>
>
>
>
>
>
> At 2013-08-01 18:36:09,"Dave May" <dave.mayhem23 at gmail.com> wrote:
>
> When you called
>   VecCreateSeq(PETSC_COMM_SELF,5,&seqx);
> you created a sequential vector on each process - not just on rank 0.
>
>
> On 1 August 2013 12:11, 丁老师 <ztdepyahoo at 163.com> wrote:
>
>> I create a sequential vec seqx, and i get it value with VecGetArrary,
>> since seqx is created  only in process 0, why every process can output the
>> value of the seqx.
>>
>>
>>  VecCreateSeq(PETSC_COMM_SELF,5,&seqx);
>>  VecView(seqx,PETSC_VIEWER_STDOUT_WORLD);
>>  double *seqarry;
>>  VecGetArray(seqx,&seqarry);
>>
>>  for(int i=0;i<n;i++)
>>    cout<<MyRank<<"  seqarry "<<s eqarry[i]<<endl;
>>
>>
>>
>>
>>
>>
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130801/c62f7130/attachment-0001.html>


More information about the petsc-users mailing list