How to impose boundary conditions in finite difference methods

I have a problem when I want to use the high order center difference approximation:

$$\left(\frac{-u_{i+2,j}+16u_{i+1,j}-30u_{i,j}+16u_{i-1,j}-u_{i-2,j}}{12}\right)$$

for the Poisson equation

$$(u_{xx}+u_{yy}=0)$$ in a square domain in which the boundary conditions are:

$$u(0,y)=u(x,0)=u(x,1)=0,u(1,y)=\sin \pi y$$ $$\Delta{x}=\Delta{y}=0.1$$

When I want to obtain the value of inside points of domain, considering this approximation some points depend on the outside points of boundary. For example, $u_{1,1}$ needs to have the value of $u_{i-2,j}=u_{-1,0}$ a point which is outside of boundary. Can anybody please help me in this case?

• I presume you are using dirichlet boundary conditions, correct?
– Paul
Feb 25, 2012 at 15:56
• Please state the boundary conditions that you would like to impose. Feb 25, 2012 at 18:01
• Maybe the key is in the use of boundary conditions to obtain constraints involving those values. I cannot expand as I have never tried to solve numerically a PDE, but this idea works for ODEs. Can anybody confirm this? Feb 25, 2012 at 18:03
• With high-order methods it can be difficult to ensure stability of the method by filling ghost cells this way. That said, elliptic problems are typically more forgiving from my experience, so you might be able to get away with it. Feb 25, 2012 at 18:10
• liona, you can edit your question and add the boundary conditions there, which is much better than putting them in comments. Feb 26, 2012 at 7:32

There are other stencils that you can use to obtain a high order accuracy near the boundary points. Your current stencil is of the form:

$Au_{i+2,j} + Bu_{i+1,j} + Cu_{i,j}+Du_{i-1,j}+Eu_{i-2,j}$

But, you can also use a different stencil near the boundary like this:

$Au_{i+3,j} + Bu_{i+2,j}+Cu_{i+1,j}+Du_{i,j} +Eu_{i-1,j}$

to compute the value at $u_{1,1}$. Note that the coefficients in the second stencil will be different from the ones in the first formula.

Similarly, you can approximate the value at the opposite boundary by a similar formula.

• Thank you for your answer, however how I can compute the value at $u_{1,1}$ when I use only one type of difference approximation method? (i.e. Can it be correct that it is used different approximation types in different places?) Feb 25, 2012 at 19:55
• How can I obtain the coefficients? Feb 26, 2012 at 7:10
• To understand how to derive finite difference formulas, a good reference is Chapter 1 of Leveque's book: faculty.washington.edu/rjl/fdmbook. It amounts to Taylor series and a bit of algebra. Feb 26, 2012 at 7:32
• @liona: Yes, you can use different approximation formulas at different locations... Generally, it is more important to ensure that all of your formulas adhere to the order of truncation that you desire. That is, if you want your numerical solution to be of order $O(h^2)$, then all of your finite difference approximations must also have a truncation error of $O(h^2)$
– Paul
Feb 26, 2012 at 17:01
• @liona: The book that David Ketcheson is referring to is one of the best books on the subject of finite difference method (in my honest opinion). As he states, we simply need to sum the taylor expansions for the expressions $AU(x+h)$, $BU(x)$, $CU(x-h)$, $DU(x-2h)$, and $EU(x-3h)$. Then, ensure that all the coefficients of the second derivative terms $U_{xx}$ sum to 1, and as many other terms as possible sum to zero.
– Paul
Feb 26, 2012 at 17:06

You may want to look into summation-by-parts (SBP) finite difference methods. Ken Mattsson has done a lot of work on these methods. Good place to start is here (constant coefficients) and here (variable coefficients).

Basically the way these methods work is they are the standard central methods in the interior and transition to one sided near the boundary. An important part of the SBP technology, is that the transition to one-sided is such that stability of the method for time dependent problems can be proven even after the inclusion of boundary conditions. (This is possible because the operators themselves "define" a norm, which mimics discretely integration by parts.)

You say that you are looking at Poisson's equation, I am not totally sure how boundary conditions are stably included with SBP operators and elliptic equations. I have a colleague who has played with these for elliptic problems and seems to indicate it doesn't really matter what you do.

please see my fdm paper which you can locate in researchgate under my name david Edwards jr. if you have questions I would be glad to help.

david

• Simply giving instructions for people to search elsewhere is not a useful answer. At a minimum, you should provide a summary of the answer here and provide a link to more details. Furthermore, many of us disagree with the way ResearchGate is run and therefore avoid all interactions with that site, making it impossible to see your paper with your suggested method. Jul 12, 2015 at 14:24
• Please revise your answer to include a summary of whatever background you think is needed to answer the question. Answers are meant to be relatively self-contained; referring a reader to search for one's paper is not self-contained, and is far less helpful than providing a summary of its contents. Jul 12, 2015 at 16:44