I'm currently working on this project and I have a basic structural analyzer that uses the finite element method. Essentially, I turn each block into a set of trusses, construct a stiffness matrix relating each truss's force to each other, and feed it into Matlab.

The next task is for me to speed it up, ideally by using some GPU acceleration. Since Matlab does not yet support spare matrix computations in the GPU, I'm looking into the other libraries available. One approach I'm considering taking is to use CULA Sparse's solvers to speed things up. But there are also a multitude of finite element software packages that may do a better job, and save me the performance overhead of constructing matrices and retrieving results.

What I'm wondering is, which of these finite element software packages is right for me? That's a hard question, so here are a few qualifiers, in order of importance:

  • It's part of a program, so a library is preferred over a complete modelling package.
  • Established and well-documented
  • GPU acceleration
  • Easy-to-use
  • It should quickly compute results for relatively small data sets (solve a 10,000 element system in about a second)
  • The price for a student should be under $300.
  • An interface in both Java and C.

Does anyone have a recommendation? Or would it be better to go forward with my CULA idea?

Edit: Jed Brown requested that I give the computation I'm making in more detail. I am not a civil engineer, but I spoke with one about the possibility of a making a structural analysis system that would look and feel good. I already have a prototype. Here's how it works.

  1. Within the setting of a game like Minecraft, a subroutine targets some contiguous region of blocks R to be tested. The program creates a truss mesh out of the region of blocks, and assigns a weight to each node in the mesh (based on how heavy the blocks would be). There are base nodes bordering the region.
  2. From this mesh, the program makes a wide stiffness matrix T and a weight vector w. From there, it needs to solve the equation Tf = w, where f, the unknown, is a vector indicating the forces exerted by each truss and base node. In other words, a row of T dictates how the truss and base forces add up to counteract the weights of the nodes.
  3. Currently, my program solves this by solving the equation TT'u=b using a conjugate gradient solver, then getting f = T'u.
  4. Once I have the forces on each of the trusses, I can determine which blocks break under the strain. Rather than using a detailed deformation model, I just have each block if one of its comprising trusses exerts a force beyond a threshold.

Because my structural analysis system is to be used in a game, and not a serious engineering context, speed is much more important than accuracy. A lot of the work in making this will consist of tweaking variables in order to give the game a good feel.

  • $\begingroup$ There are a great many finite element libraries out there, and any number of them are in fact open source and free. However, most of them are written in C++ (some have Python interfaces) and only a very small number have GPU acceleration. Can you rank how important each of your requirements are to you? $\endgroup$ Apr 7, 2014 at 0:20
  • $\begingroup$ Edited my post. $\endgroup$ Apr 7, 2014 at 1:03
  • 3
    $\begingroup$ Why is "GPU acceleration" on your list? If a CPU-only version can solve 1M elements in under a second, would it matter that it doesn't need a GPU to do that? Would you rather have a "GPU accelerated" package that solves your problems much slower than a CPU-only version? (This is not a contrived question; you usually need quite large problem sizes before a GPU has a chance of being faster than a similar class CPU.) What kind of problems do you intend to solve (poisson, elasticity, CFD)? What solvers (e.g., multigrid) would you like to use? Unstructured grids? Adaptivity? $\endgroup$
    – Jed Brown
    Apr 7, 2014 at 5:36
  • $\begingroup$ I'm pretty inexperienced with scientific computation, but I edited my post to give some details. I tried to give as good of an answer as I could. I think it's an elasticity problem... Why GPU? Because I am doing something akin to a real-time simulation, so it's always better if I can do larger/faster computations. I found that my problem can be expressed as a sparse linear algebra problem, which can be more quickly solved with a GPU. Do FEM problems benefit from a specialized solver? I doubt that I'll need to use multigrid or anything that breaks the problem down into smaller chunks. $\endgroup$ Apr 7, 2014 at 20:09

5 Answers 5


There are plenty of finite element libraries out there that satisfy most of your criteria. In no particular order, I would mention deal.II (my own project), libMesh, and FEniCS. All three are large, are libraries, are well documented, are well established with large user bases. All three are actively maintained and are about as fast as you would a general purpose library to be. All will solve elasticity equations. All are free of charge.

The criteria you probably won't be able to meet using any of the established projects (the three above as well as the second tier ones) are:

  • In scientific computing, we have been using C++ for quite a long time. All three of the libraries above are written in C++ (though FEniCS has a Python interface) and this is generally true for many of the other libraries as well.

  • They do not directly use GPUs. Some of them have interfaces to solver libraries that can use GPUs to accelerate computations, but even in those cases, the evidence that doing this on GPUs is faster is not really conclusive. The evidence that it is incredibly more difficult and non-portable is very conclusive, though.

  • $\begingroup$ This is a very helpful answer. C++ is no problem. Now, what's the advantage of using this over a linear algebra library? I have already written code that constructs my matrices. $\endgroup$ Apr 8, 2014 at 7:55
  • $\begingroup$ The advantage with finite element libraries is not that they make the first implementation of the very simplest problems easier. It is that the effort to go from the very simplest problems to very complex ones (nonlinear, large scale, higher order finite elements, adaptive meshes) is barely higher than doing the first implementation. So it boils down to where you want to go from here. $\endgroup$ Apr 9, 2014 at 10:49

Since you want your program to be embedded in a game, something like a physics engine for structures, a good idea is to use an explicit FEM. Something similar to this simulations done with Verlet algorithm.

The explicit FEM can be really fast if you can have a structured mesh, because in that way all the stiffness matrices for the elements are the same (you can compute it once). You can, actually, compute it analytically and hard code it in the program. The reason for the speed is that you don't need to solve a system of equations. Using the Verlet integration --and lumped mass matrices-- you just have to compute

$$u^{(t+1)}_i = 2 u^{(t)}_i - u^{(t-1)}_i + \frac{F_i \Delta t^2}{M_{ii}} \enspace .$$


Your target size of 10,000 degrees of freedom should be easy to meet without embedding an entire FEM library (which may anyway be hard to do, as others have pointed out), and in much less than a second. Assuming that solving the system is your current bottleneck and not assembling it (check this first), I would recommend you to use any of the existing and free direct solvers for large sparse systems. Some pointers:

Also, if you use, say, the Eigen linear algebra library, it comes with some sparse direct solvers already built-in, so you wouldn't even need to link to an external library. These may be a bit slower than the specialized libraries linked to above, but easier and faster to get started with.


I'll suggest an FE library that is less well known than those previously mentioned. It is not as sophisticated as those but may satisfy your requirements. It is reasonably well documented and because it is simple, it is also easier to use, modify, and understand.

The library/code is FeaTure


You say you are more interested in speed than accuracy. However, as a long-time stress analyst, I can say that it is not straightforward to represent a solid continuum (like a concrete wall) as a collection of truss elements. So I think you are on the right track in looking for an FE library that includes continuum elasticity elements rather than trying to build your own from low-level linear algebra components.


Sparselizard (www.sparselizard.org) is new but robust, rather general and can solve easily your elasticity problems with millions of unknown in 2D and hundreds of thousands in 3D on your laptop in two or three minutes (it is openmp parallelised). You can also use high order interolations for accurate mechanical computations at a low computational cost. The documentation is also up to date and convenient. From my (of course subjective) point of view it is the most concise and user friendly library I have found.

  • 1
    $\begingroup$ Welcome to SciComp.SE! You could be more explicit about disclosing your affiliation as one of the developers and address in more details how your library addresses the OPs requirements (integrability into a game, GPU support); otherwise your answer might be mistaken for spam. (I assume that's what the downvote is for.) $\endgroup$ Dec 19, 2017 at 18:49

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.