# C or fortran library to solve linear 2D/3D elliptic PDE

I am looking for a general purpose library which can solve a 2D or 3D linear elliptic PDE on a rectangular domain with mixed/Robin boundary conditions. I am a C programmer, so I would prefer a C library, but fortran is ok too since its easy to call fortran code from C. So far I have found only 1 option: MUDPACK. This is a fortran library which uses Multigrid and handles 2D and 3D elliptic PDEs.

Just wondering if there are other options out there? Unfortunately for me, many PDE libraries are written in C++ which likely cannot be interfaced with C easily.

• If you are not looking at large-scale problems, then why not implement it yourself? Since the domains are simple, I don't think it is much of an effort. You can use a third-party library, for example, PETSc, for matrix algebra. I have a Fortran code for 2D and 3D Poisson equation and elasticity using the FEM, if you want to have a look. github.com/chennachaos/PFEMFort You can update it to incorporate Robin/Mixed BCs. Nov 5 '20 at 21:42
• Discretizing the equation, implementing the BCs, and doing multigrid seems like reinventing the wheel. I would like to just specify my equation coefficients and let a nice library handle the rest.
– vibe
Nov 5 '20 at 21:47
• FEniCS does the job. Nov 5 '20 at 23:55
• You can write it fairly easily in MATLAB, and then generate C code out of it: mathworks.com/products/matlab-coder.html Nov 6 '20 at 1:28
• @Spencer: but FEniCS is written in C++. Can it be called easily from a pure C program?
– vibe
Nov 6 '20 at 6:07

extern "C" int run_fem_solver (/*possibly arguments*/) {

This function is compiled by the C++ compiler, and so can call all of the C++ FEM machinery. But because it's marked extern "C", you can call it from the C part of your application.