Hi<div><br></div><div>Is it ok, that VecView doesn't work properly with vectors, obtained with DACreateGlobalVector function, or im doing something wrong?</div><div>In my program I create 5x5 da and global vector, corresponding to this da. </div>
<div>Then each of 4 process writes its rank to its own local elements using DAVecGet(Restore)Array functions.</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Then i use VecView to <span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; ">visualize my global vector. </span></div>
<div><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; ">And i see, that each process owns elements with different values.</span></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif">Where is the mistake?</font></div>
<div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif">Thank you very much!</font></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif"><br>
</font></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif">Alexey Ryazanov.</font></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif"><br>
</font></div><div><font class="Apple-style-span" face="Arial, Helvetica, sans-serif"><br></font></div><div>CODE:</div><div><br></div><div><div><div>#include "petscksp.h"</div><div>#include "petscda.h"</div>
<div>static char help[] = "VecVeiw doesn't work properly with DAGlobalVectors";</div><div>int main(int argc,char **args)</div><div>{</div><div> Vec<span class="Apple-tab-span" style="white-space:pre">                </span>GlobalVec;</div>
<div> DA<span class="Apple-tab-span" style="white-space:pre">                </span>da;</div><div> PetscInt<span class="Apple-tab-span" style="white-space:pre">        </span>rank, dof, stencil_width, M, N, m, n, p, x, y, z, i, j;</div><div>
PetscScalar<span class="Apple-tab-span" style="white-space:pre">        </span>**array;</div><div> PetscErrorCode ierr;</div><div><br></div><div> PetscInitialize(&argc,&args,(char *)0,help);</div><div> MPI_Comm_rank(PETSC_COMM_WORLD, &rank);</div>
<div><br></div><div> M=N=5; dof=1; stencil_width=1;</div><div> ierr = DACreate2d(PETSC_COMM_WORLD, DA_NONPERIODIC, DA_STENCIL_BOX, M, N, PETSC_DECIDE, PETSC_DECIDE, dof, stencil_width, PETSC_NULL, PETSC_NULL, &da);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>CHKERRQ(ierr);</div><div> ierr = DACreateGlobalVector(da,&GlobalVec);<span class="Apple-tab-span" style="white-space:pre">                        </span>CHKERRQ(ierr);</div>
<div><br></div><div> ierr = DAGetCorners(da,&x,&y,&z,&m,&n,&p);<span class="Apple-tab-span" style="white-space:pre">                        </span>CHKERRQ(ierr);</div><div><br></div><div> ierr = DAVecGetArray(da, GlobalVec, &array);<span class="Apple-tab-span" style="white-space:pre">                        </span>CHKERRQ(ierr);</div>
<div> for(i=y; i<y+n ; i++)</div><div> for(j=x; j<x+m; j++)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>array[i][j]=rank;</div><div> ierr = DAVecRestoreArray(da, GlobalVec, &array);<span class="Apple-tab-span" style="white-space:pre">                </span>CHKERRQ(ierr);</div>
<div><br></div><div> ierr = VecView(GlobalVec, PETSC_VIEWER_STDOUT_WORLD);<span class="Apple-tab-span" style="white-space:pre">                </span>CHKERRQ(ierr);</div><div><br></div><div> ierr = VecDestroy(GlobalVec);<span class="Apple-tab-span" style="white-space:pre">                                        </span>CHKERRQ(ierr);</div>
<div> ierr = DADestroy(da);<span class="Apple-tab-span" style="white-space:pre">        </span> <span class="Apple-tab-span" style="white-space:pre">                                        </span>CHKERRQ(ierr);</div><div> ierr = PetscFinalize(); <span class="Apple-tab-span" style="white-space:pre">                                        </span>CHKERRQ(ierr);</div>
<div> return 0;</div><div>}</div></div></div><div><br></div><div><br></div><div>OUTPUT:</div><div><br></div><div><div>Process [0]</div><div>0</div><div>0</div><div>0</div><div>1</div><div>1</div><div>0</div><div>0</div><div>
0</div><div>1</div><div>Process [1]</div><div>1</div><div>0</div><div>0</div><div>0</div><div>1</div><div>1</div><div>Process [2]</div><div>2</div><div>2</div><div>2</div><div>3</div><div>3</div><div>2</div><div>Process [3]</div>
<div>2</div><div>2</div><div>3</div><div>3</div></div><div><br></div>