[petsc-users] setting up DA matrix for 3D periodic domain
ilyas ilyas
ilyascfd at gmail.com
Sun Apr 24 07:31:53 CDT 2011
Hi,
Manual pages for "MatSetValuesStencil" says that,
"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).
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.
This does not work for the DA_NONPERIODIC wrap."
According to this explanation, If I would set up a matrix for 3D periodic
domain using DAs with DA_ XYZPERIODIC,
The code segment given below could handle periodicity "without specifying
boundary information within the loop" ?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
"
.
.
.
MatStencil row(4),col(4,7)
PetscInt i1,i7
PetscScalar val(7)
i1 = 1
i7 = 7
.
.
.
call DACreate3d(...,DA_XYZPERIODIC,DA_STENCIL_STAR, ... )
call DAGetMatrix(...,A,...)
call DAGetCorners(da,xs,ys,zs,xm,ym,zm,ierr)
do k=zs,zs+zm-1
do j=ys,ys+ym-1
do i=xs,xs+xm-1
val(1) = ...
col(MatStencil_i,1) = i
col(MatStencil_j,1) = j
col(MatStencil_k,1) = k-1
val(2) = ...
col(MatStencil_i,2) = i
col(MatStencil_j,2) = j-1
col(MatStencil_k,2) = k
val(3) = ...
col(MatStencil_i,3) = i-1
col(MatStencil_j,3) = j
col(MatStencil_k,3) = k
val(4) = ...
col(MatStencil_i,4) = i
col(MatStencil_j,4) = j
col(MatStencil_k,4) = k
val(5) = ...
col(MatStencil_i,5) = i+1
col(MatStencil_j,5) = j
col(MatStencil_k,5) = k
val(6) = ...
col(MatStencil_i,6) = i
col(MatStencil_j,6) = j+1
col(MatStencil_k,6) = k
val(7) = ...
col(MatStencil_i,7) = i
col(MatStencil_j,7) = j
col(MatStencil_k,7) = k+1
call MatSetValuesStencil(A,i1,row,i7,col,val,INSERT_VALUES,ierr)
end do
end do
end do
call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)
"
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 ?
Thank you,
Ilyas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110424/d8f5955d/attachment-0001.htm>
More information about the petsc-users
mailing list