<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Perhaps more simply, consider the 1D version of your problem:<br>
    <br>
    u''=0 on [0,1]   with "Boundary Conditions"  u'(0)=a and u'(1) =b<br>
    <br>
    The solution is u(x) = a x + c  (for any! value of c).<br>
    This is not going to solve happily :(<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 1/10/13 8:27 AM, Jed Brown wrote:<br>
    </div>
    <blockquote
cite="mid:CAM9tzSkzob=h85DRjtWQHv=TLNGkchivauj4ef-3-0hibvp0KQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">... and you describe a "boundary condition" as
        "second derivative is zero", which is not a boundary condition,
        making your problem ill-posed. (Indeed, consider the family of
        problems in which you extend the domain in that patch and apply
        _any_ boundary conditions in the extended domain. All of those
        solutions are also solutions of your problem with "second
        derivative is zero" on your "boundary".)</div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Thu, Jan 10, 2013 at 9:44 AM, David
          Scott <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:d.scott@ed.ac.uk" target="_blank">d.scott@ed.ac.uk</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            All right, I'll say it differently. I wish to solve<br>
              div.grad phi = 0<br>
            with the boundary conditions that I have described.
            <div class="im"><br>
              <br>
              On 10/01/2013 15:28, Jed Brown wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="im">
                Second derivative is not a boundary condition for
                Poisson; that is the<br>
                equation satisfied in the interior. Unless you are
                intentionally<br>
                attempting to apply a certain kind of outflow boundary
                condition (i.e.,<br>
                you're NOT solving Laplace) then there is a problem with
                your<br>
                formulation. I suggest you revisit the continuum problem
                and establish<br>
                that it is well-posed before concerning yourself with
                implementation<br>
                details.<br>
                <br>
                <br>
                On Thu, Jan 10, 2013 at 9:03 AM, David Scott <<a
                  moz-do-not-send="true" href="mailto:d.scott@ed.ac.uk"
                  target="_blank">d.scott@ed.ac.uk</a><br>
              </div>
              <div>
                <div class="h5">
                  <mailto:<a moz-do-not-send="true"
                    href="mailto:d.scott@ed.ac.uk" target="_blank">d.scott@ed.ac.uk</a>>>
                  wrote:<br>
                  <br>
                      Hello,<br>
                  <br>
                      I am solving Poisson's equation (actually
                  Laplace's equation in this<br>
                      simple test case) on a 3D structured grid. The
                  boundary condition in<br>
                      the first dimension is periodic. In the others
                  there are Von Neumann<br>
                      conditions except for one surface where the second
                  derivative is<br>
                      zero. I have specified DMDA_BOUNDARY_NONE in these
                  two dimensions<br>
                      and deal with the boundary conditions by
                  constructing an appropriate<br>
                      matrix. Here is an extract from the Fortran code:<br>
                  <br>
                                     if (j==0) then<br>
                                       ! Von Neumann boundary conditions
                  on y=0 boundary.<br>
                                       v(1) = 1<br>
                                         col(MatStencil_i, 1) = i<br>
                                         col(MatStencil_j, 1) = j<br>
                                         col(MatStencil_k, 1) = k<br>
                                       v(2) = -1<br>
                                         col(MatStencil_i, 2) = i<br>
                                         col(MatStencil_j, 2) = j+1<br>
                                         col(MatStencil_k, 2) = k<br>
                                       call MatSetValuesStencil(B, 1,
                  row, 2, col, v,<br>
                      INSERT_VALUES, ierr)<br>
                                     else if (j==maxl) then<br>
                                       ! Boundary condition on y=maxl
                  boundary.<br>
                                       v(1) = 1<br>
                                         col(MatStencil_i, 1) = i<br>
                                         col(MatStencil_j, 1) = j<br>
                                         col(MatStencil_k, 1) = k<br>
                                       v(2) = -2<br>
                                         col(MatStencil_i, 2) = i<br>
                                         col(MatStencil_j, 2) = j-1<br>
                                         col(MatStencil_k, 2) = k<br>
                                       v(3) = 1<br>
                                         col(MatStencil_i, 3) = i<br>
                                         col(MatStencil_j, 3) = j-2<br>
                                         col(MatStencil_k, 3) = k<br>
                                       call MatSetValuesStencil(B, 1,
                  row, 3, col, v,<br>
                      INSERT_VALUES, ierr)<br>
                                     else if (k==0) then<br>
                  <br>
                  <br>
                      Here the second clause deals with the second
                  derivative on the boundary.<br>
                  <br>
                      In order for this code to work I have to set the
                  stencil width to 2<br>
                      even though 'j-2' refers to an interior, non-halo<br>
                      point in the grid. This leads to larger halo swaps
                  than would be<br>
                      required if a stencil width of 1 could be used.<br>
                  <br>
                      Is there a better way to encode the problem?<br>
                  <br>
                      David<br>
                  <br>
                      --<br>
                      The University of Edinburgh is a charitable body,
                  registered in<br>
                      Scotland, with registration number SC005336.<br>
                  <br>
                  <br>
                </div>
              </div>
            </blockquote>
            <span class="HOEnZb"><font color="#888888">
                <br>
                <br>
                -- <br>
                Dr. D. M. Scott<br>
                Applications Consultant<br>
                Edinburgh Parallel Computing Centre<br>
                Tel. 0131 650 5921</font></span>
            <div class="HOEnZb">
              <div class="h5"><br>
                <br>
                The University of Edinburgh is a charitable body,
                registered in<br>
                Scotland, with registration number SC005336.<br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>