[petsc-users] Accessing 'halo' matrix entries?

Barry Smith bsmith at mcs.anl.gov
Thu Jun 11 14:07:39 CDT 2015


> On Jun 11, 2015, at 8:15 AM, Oliver Henrich <ohenrich at epcc.ed.ac.uk> wrote:
> 
> Dear PETSc-Team,
> 
> I am trying to solve a Poisson equation with a mixed periodic-Dirichlet boundary condition. What I have in mind is e.g. a compressible flow with a total pressure difference imposed between the two sides of the system, but otherwise periodic, and periodic boundary conditions along the remaining two dimensions. Another example would be an electrostatic system with dielectric contrast in an external electric field / potential difference.
> 
> For clarity, if x = 0  (N+1) is the left (right) halo site at the boundary and x = 1 (N) is the leftmost (rightmost) site in the physical domain: 
> 
> psi(x = 0)  =  psi(x = N) - dpsi
> psi(x = N+1) = psi(1) + dpsi

   If I understand correctly this does't affect the MATRIX at all, since the dpsi is a constant. So aren't you just solving with a "regular periodic" matrix but a modified right hand side?

   Note in PETSc indexing which starts at 0 (not one) and ends with N-1 what you wrote above should be 

psi(x=-1) = psi(x=N-1) - dpsi
psi(x=N) = psi(0) + dpsi

Now x=-1 and x=N don't exist in the matrix (only in ghosted vectors) so b(0) = b(0) + od*dpsi   and b(N-1) = b(N-1) - od*dpsi where od is the "off diagonal" entry of the Poisson matrix and b() is the "normal" right hand side

> 
> I know it is possible to solve this with a double Poisson solve, which I try to avoid for performance reasons.
> 
> It is also possible to solve this by modifying the matrix with a master-slave approach that imposes the constraint. This requires defining a transformation matrix that acts on the matrix, the solution vector and the righthand side of the problem.
> 
> The core of the problem I have is that the pressure or potential difference should not be between the leftmost and rightmost site in the physical domain (a standard Dirichlet BC), but between the left- or rightmost site in the physical domain and the corresponding halo site at the opposite side of the system. It should be possible to do this if the entries of the transformation matrix that act on the halo sites can be accessed and modified. 
> 
> Is anything like this possible in PETSc?
> 
> Best regards and many thanks,
> Oliver
> 
> --
> Dr Oliver Henrich
> Edinburgh Parallel Computing Centre
> School of Physics and Astronomy
> University of Edinburgh
> King's Buildings, JCMB
> Edinburgh EH9 3FD
> United Kingdom
> 
> Tel: +44 (0)131 650 5818
> Fax: +44 (0)131 650 6555
> 
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336
> 
> 
> 



More information about the petsc-users mailing list