<div>Hi,</div>
<div>&nbsp;</div>
<div>I&#39;ve the sequential version of PETSc working and I have some questions about the parallel implementation.</div>
<div>&nbsp;</div>
<div>My code is to solve the NS eqn. Mainly it has to solve 2 linear eqns - momentum &amp; poisson. The poisson eqn solving takes the most % of time so it going to be solved in parallel. Most likely the momentum eqn &#39;ll be as well. The other parts of the code may be parallelized later using MPI. 
</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>The parallel part is coded as follows:</div>
<div>&nbsp;</div>
<div>call MatCreate(PETSC_COMM_WORLD,A,ierr)</div>
<div><br>call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m*n,m*n,ierr)</div>
<div><br>call MatSetFromOptions(A,ierr)</div>
<div>&nbsp;</div>
<div>call MatGetOwnershipRange(A,Istart,Iend,ierr)</div>
<div>&nbsp;</div>
<div>call VecCreateMPI(PETSC_COMM_WORLD,PETSC_DECIDE,m*n,b,ierr)</div>
<div>&nbsp;</div>
<div>call VecSetFromOptions(b,ierr)</div>
<div>&nbsp;</div>
<div>call VecDuplicate(b,x,ierr)</div>
<div>&nbsp;</div>
<div>... insert matrix in parallel making use of Istart,Iend.</div>
<div>&nbsp;</div>
<div>... assembly</div>
<div>&nbsp;</div>
<div>... solve</div>
<div>&nbsp;</div>
<div>&nbsp;Since I&#39;ve used PETSC_DECIDE, PETSc will determine the local dimension of A and b and x&nbsp;automatically.</div>
<div>&nbsp;</div>
<div>&nbsp;Is the no. of rows of A and b and x (Iend-Istart+1) locally?</div>
<div>&nbsp;</div>
<div>After the eqn is solved, I need to obtain the answer x</div>
<div>&nbsp;</div>
<div>I&#39;ve used:</div>
<div>&nbsp;</div>
<div>
<p>call VecGetArray(x,ppv,i_vec,ierr)</p>
<p>&nbsp;do j=1,size_y</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; do i=1,size_x</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k=(j-1)*size_x+i</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i,j)=ppv(k+i_vec)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; end do<br>&nbsp;<br>&nbsp;end do</p>
<p>&nbsp;call VecRestoreArray(x,ppv,i_vec,ierr)</p>
<p>I&#39;m trying to get the address of the 1st value of x and map the values onto a rectangular grid to update p. Is this correct? </p>
<p>Or&nbsp;am I only able to get the local value, as in the local value of x. Do I need to use some MPI routines if I need to update the p values on the whole global grid?</p>
<p>thanks alot!</p></div>