Are there any good books or references on implementing finite difference methods for PDEs? Specifically, I'm looking for something comparable to Gockenbach's book Understanding and Implementing the Finite Element Method. Even more specifically, I'm looking for information on

  • Appropriate data structures for regular meshes
  • Good ways to implement stencils
  • How to handle irregular boundaries
  • What order to loop over the nodes/elements

Really, I'm looking for pragmatic information on implementing the method. As to the kind of differential equation or programming language, it doesn't really matter. Mostly, I'm looking for core information that's (mostly) agnostic to the problem.

  • $\begingroup$ In general, standard FDM does not handle arbitrary boundary shapes very easily. This is one of its primary disadvantages, and why FEM is more ubiquitous for complicated geometries. $\endgroup$
    – Paul
    Aug 26, 2014 at 3:03
  • $\begingroup$ Related: scicomp.stackexchange.com/questions/668/… $\endgroup$
    – Paul
    Aug 26, 2014 at 3:12

1 Answer 1


You might take a look at Trangenstein's book, which comes with code. I'm sure there are many others.

Some quick suggestions:

  • Appropriate data structures for regular meshes: That one is simple -- n-dimensional arrays.
  • Good ways to implement stencils: I'm not sure how deep you want to dive into this. For starters, you just need to know how your array is laid out in memory and order loops accordingly. If you want to run on GPUs, blocking is important. If you're talking about cache optimization, it's an area of research and is architecture dependent. Be prepared to write assembly code.
  • How to handle irregular boundaries: This is a mathematical question more than an implementation one.
  • What order to loop over the nodes/elements: I guess I thought this was what you meant by stencils above.
  • $\begingroup$ Thanks for the reply. Why would handling irregular boundaries be more of a mathematical question than an implementation one if we're still on a regular mesh? Meaning, I can define some L-shaped region and still apply a stencil to nodes in the domain in a consistent way. However, this likely affects the order in which I want to iterate over the elements as well as how I want to handle the boundary conditions, labeling the nodes, etc. $\endgroup$
    – wyer33
    Aug 25, 2014 at 18:21
  • $\begingroup$ I thought you meant really irregular boundaries, that you can't fit your grid to. L-shaped domains would be pretty simple. $\endgroup$ Aug 25, 2014 at 18:48
  • $\begingroup$ Well, in theory, yes, but in practice it seems like there's a bunch of cases that need to be handled. For example, the inside corners. That's why I'm looking for a good reference book where all of these, ahem, corner cases have been worked out. $\endgroup$
    – wyer33
    Aug 25, 2014 at 19:03
  • $\begingroup$ I suggest that you post a new, more specific question. $\endgroup$ Oct 20, 2014 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.