<div>Hi,<br></div><div><br></div><div>Manual pages for &quot;MatSetValuesStencil&quot; says that,</div><div>&quot;For periodic boundary conditions use negative indices for values to the left (below 0; that are to be obtained by wrapping values from right edge). </div>
<div> For values to the right of the last entry using that index plus one etc to obtain values that obtained by wrapping the values from the left edge.</div><div> This does not work for the DA_NONPERIODIC wrap.&quot;</div>
<div><br></div><div>According to this explanation, If I would set up a matrix for 3D periodic domain using DAs with DA_ XYZPERIODIC,</div><div>The code segment given below could handle periodicity &quot;without specifying boundary information within the loop&quot;   ?</div>
<div>                                                                                             - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </div><div><br></div><div>                                                                                        </div>
<div><br></div><div>&quot;</div><div>.</div><div>.</div><div>.</div><div><br></div><div> MatStencil      row(4),col(4,7)<br> PetscInt            i1,i7<br> PetscScalar   val(7)<br><br>      i1 = 1<br>      i7 = 7<br></div>
<div>.</div><div>.</div><div>.</div><div><br></div><div>call DACreate3d(...,DA_XYZPERIODIC,DA_STENCIL_STAR, ... ) <br></div><div><br></div><div>call DAGetMatrix(...,A,...)</div><div><br></div><div>call DAGetCorners(da,xs,ys,zs,xm,ym,zm,ierr)</div>
<div><br></div><div>do k=zs,zs+zm-1<br>   do j=ys,ys+ym-1<br>             do i=xs,xs+xm-1<br><br>             <br>            val(1) = ...<br>             col(MatStencil_i,1) = i<br>             col(MatStencil_j,1) = j<br>             col(MatStencil_k,1) = k-1<br>
<br>            val(2) = ...<br>             col(MatStencil_i,2) = i<br>             col(MatStencil_j,2) = j-1<br>             col(MatStencil_k,2) = k<br><br>            val(3) = ...<br>             col(MatStencil_i,3) = i-1 <br>
             col(MatStencil_j,3) = j<br>             col(MatStencil_k,3) = k<br><br>            val(4) = ...<br>             col(MatStencil_i,4) = i <br>             col(MatStencil_j,4) = j<br>             col(MatStencil_k,4) = k<br>
<br>            val(5) = ...<br>             col(MatStencil_i,5) = i+1 <br>             col(MatStencil_j,5) = j <br>             col(MatStencil_k,5) = k<br><br>            val(6) = ...<br>             col(MatStencil_i,6) = i <br>
             col(MatStencil_j,6) = j+1 <br>             col(MatStencil_k,6) = k<br><br>            val(7) = ...<br>             col(MatStencil_i,7) = i <br>             col(MatStencil_j,7) = j <br>             col(MatStencil_k,7) = k+1<br>
<br>              call MatSetValuesStencil(A,i1,row,i7,col,val,INSERT_VALUES,ierr)<br><br>               end do<br>    end do<br>end do<br><br><br>call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)<br>call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)<br>
</div><div><br></div><div>&quot;</div><div><br></div><div>If it is so, how PETSc does it ? By inserting cyclic contributions arising from periodicity into the correct locations within PETSc DAs matrix , as it is done serially ?</div>
<div><br></div><div><br></div><div>Thank you,</div><div>Ilyas.</div>