What is the best FD library (or collection of libraries) for C++ codes? I am looking for some data structure implementation that offers the possibility to do parallel computations on adaptively refined grids, Thank you

  • $\begingroup$ What have you already found out there? $\endgroup$ May 16 '20 at 15:38
  • $\begingroup$ I have been using deal.II for some projects, actually. For this reason I have some knowledge about PETSc and p4est and I am thinking about using this combination. Is it a good idea? $\endgroup$
    – omar kahol
    May 16 '20 at 16:16
  • $\begingroup$ But neither of these are Finite Difference libraries. In fact, there is not an abundance of widely used FD libraries in the same way as there are FE libraries. I couldn't even name one. $\endgroup$ May 16 '20 at 16:42
  • $\begingroup$ You are right! Perhaps what I need is a library that allows me to build a N-dimensional grid, share it among processors and be able to refine it. With this I would be able to build a fd solver on top of it. What is the best one for this purpose? $\endgroup$
    – omar kahol
    May 16 '20 at 18:00
  • $\begingroup$ p4est is certainly a good choice. But if all you care about is the grid, you can of course also use any of the FE libraries -- they can give you a grid with much more user-friendly data structures than p4est does. $\endgroup$ May 16 '20 at 18:31

There are several libraries for adaptive grids, see e.g.,


I have found Petsc to be very useful to write finite difference solvers, even if the schemes are explicit and do not require any matrix solving. The DMDA makes it easy to partition the mesh/solution data, ensure there are enough ghost points, take care of periodicity, etc. You can also benefit from TS which has a lot of time integration schemes.

Another library that I have come across for finite differences is opensbli


It is specifically designed for finite differences and seems to have lot of nice features for parallelization/HPC.

The book (open access)

has lot of python codes that could be useful.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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