<div>Hi,</div>
<div> </div>
<div>I've the sequential version of PETSc working and I have some questions about the parallel implementation.</div>
<div> </div>
<div>My code is to solve the NS eqn. Mainly it has to solve 2 linear eqns - momentum & poisson. The poisson eqn solving takes the most % of time so it going to be solved in parallel. Most likely the momentum eqn 'll be as well. The other parts of the code may be parallelized later using MPI.
</div>
<div> </div>
<div> </div>
<div> </div>
<div>The parallel part is coded as follows:</div>
<div> </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> </div>
<div>call MatGetOwnershipRange(A,Istart,Iend,ierr)</div>
<div> </div>
<div>call VecCreateMPI(PETSC_COMM_WORLD,PETSC_DECIDE,m*n,b,ierr)</div>
<div> </div>
<div>call VecSetFromOptions(b,ierr)</div>
<div> </div>
<div>call VecDuplicate(b,x,ierr)</div>
<div> </div>
<div>... insert matrix in parallel making use of Istart,Iend.</div>
<div> </div>
<div>... assembly</div>
<div> </div>
<div>... solve</div>
<div> </div>
<div> Since I've used PETSC_DECIDE, PETSc will determine the local dimension of A and b and x automatically.</div>
<div> </div>
<div> Is the no. of rows of A and b and x (Iend-Istart+1) locally?</div>
<div> </div>
<div>After the eqn is solved, I need to obtain the answer x</div>
<div> </div>
<div>I've used:</div>
<div> </div>
<div>
<p>call VecGetArray(x,ppv,i_vec,ierr)</p>
<p> do j=1,size_y</p>
<p> do i=1,size_x</p>
<p> k=(j-1)*size_x+i</p>
<p> p(i,j)=ppv(k+i_vec)</p>
<p> end do<br> <br> end do</p>
<p> call VecRestoreArray(x,ppv,i_vec,ierr)</p>
<p>I'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 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>