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

Matthew Knepley knepley at gmail.com
Thu Jun 11 08:44:30 CDT 2015

On Thu, 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
>
> 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?
>

The way that periodicity works in PETSc right now for DMDA is that values
are copied into the halo
region from the other part of the mesh. Thus, you can just choose to add
your delta at the right boundary
and not at the left. The mechanics would be the same as now. Does that make
sense?

Thanks,

Matt

> 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
>
>
>
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their