
Finite Element Method - tosh
https://en.wikipedia.org/wiki/Finite_element_method
======
mechhacker
At one point I was doing a PhD in programming a custom FEM program written in
Java. I ended up not completing that program, but have been using FEM for many
years to design things.

One of the ways I play around with programming languages is try to make a
small Finite Element solver. I think so far I've made them in Matlab, Python,
JavaScript, and Rust. Maybe I made one in C or C++ as well.

Whenever I do, I realize that a lot of the barrier is getting good Matrix
solving tools in that language. Rust was a bit difficult because I was forced
to choose between 1 or 2 main linear algebra codes. However, these codes are
not optimized and will not be as fast as the Fortran based codes that a lot of
the Python libraries now reference (LAPACK and BLAS if I rembember correctly).

It comes down to how you store the information in the Matrix. Physical
problems solvable by FEM are symmetric and linearly independent, or some
tricks are done to make them so. They also end up being quite Sparse. Those
Sparse solvers from LAPACK and BLAS, as well as all of the past optimizations
that are probably made for dealing with cache size (I'm speculating here, I
really don't know), really make a huge difference in the problem.

Last I touched the Rust libraries to make a simple code, I just stuck with
non-sparse solvers. There's an enormous difference between storage size and
computational effort to go through a non-sparse matrix in comparison,
especially when the problem is large. I think past a few million degrees of
freedom on typical mechanical engineering problems, it started to become
unmanageable on a local cpu.

~~~
InfinityByTen
There are tons of solvers, there're a lot of libraries and SciPy, Fenics, most
likely even MATLAB, Octave, FreeFEM++ all of them use LAPACK and BLAS (at
least in their most performant flavours), all calling eventually the FORTRAN
subroutines written decades ago. And yes, the tricky parts of this is also
that how Fortran and C store 2D arrays, [https://en.wikipedia.org/wiki/Row-
_and_column-major_order](https://en.wikipedia.org/wiki/Row-_and_column-
major_order).

So no one re-writes their own stuff, unless for academic purposes. I was on
the verge of trying to extend the SciPy library to support block matrices 4
years ago for my thesis, but was able to work around it because duck-typing
had generalised quite enough to encapsulate even that.

Sparse and Full matrices have a totally different data structure. hence the
difference in the solvers. Engineers and Mathematicians that want more
performant solving, rely more on the modelling of the problem (physically or
mathematically) than improving the solvers.The other option is hardware-
assisted optimization. For full solvers, I suppose the AI/ML folk have come up
with TPUs, also because they have different tolerances for floating point
calculations in classifying an image compared with launching a satellite on
Mars.

~~~
alimw
> So no one re-writes their own stuff

I have (unwillingly) had to do this. I did look at off-the-shelf solvers but
they all seemed to restrict themselves to nice domains in low dimensions.

Edit: Perhaps you are only talking about the linear algebra "stuff". I did use
SciPy for that.

------
globuous
For those interested in FEM, I found out about Fenics a few years back [1],
here's an extract from their homepage:

"FEniCS is a popular open-source (LGPLv3) computing platform for solving
partial differential equations (PDEs). FEniCS enables users to quickly
translate scientific models into efficient finite element code. With the high-
level Python and C++ interfaces to FEniCS, it is easy to get started, but
FEniCS offers also powerful capabilities for more experienced programmers.
FEniCS runs on a multitude of platforms ranging from laptops to high-
performance clusters."

I never got to use it because I've moved out of mechanical simulations a few
years ago, but it definitely looks pretty sweet ;)

[1] [https://fenicsproject.org/](https://fenicsproject.org/)

~~~
yuriko
You might also want to look at the Firedrake project [1]

[1] [https://firedrakeproject.org/](https://firedrakeproject.org/)

~~~
InfinityByTen
Oh ther're tons of those. Here's another:
[https://freefem.org/](https://freefem.org/)

Eventually all of them call LAPACK AND BLAS Fortran stuff written decades ago.
Just the problem definition syntax evolves a little in each package.

------
HPsquared
I'm a fan of Code_Aster at the moment. It has a massive amount of
documentation due to its provenance from the nuclear industry. The only
downside (for me as an exclusive English speaker) is, it's all either in
French or machine-translated (including functions and parameter names) which
adds an extra layer of difficulty.

~~~
doczoidberg
yes code aster is great. I work on a cloud based FEA SaaS based on code aster.
Besides a GUI it will also have an english API.

------
rwcarlsen
FEM is super important/useful in engineering and scientific disciplines. While
the basic concepts are quite straight forward, all the details you need for
developing useful engineering FEM tools make it really challenging. You can
read a textbook and learn a lot, but in production tools you have to figure
out how to handle things like: mesh generation, mesh adaptivity, coupled
nonlinear equation support, different time-stepping/integration schemes, 3D,
convective term stabilization, sparse matrix solvers, preconditioning,
parallelization (e.g. MPI for supercomputers), and much much more. I work on
an open source FEM framework called MOOSE
([https://mooseframework.org/](https://mooseframework.org/)) and get to enjoy
digging in this stuff every day!

------
krosaen
On a related note, I've enjoyed reading about the Lattice Boltzmann method:

[https://en.wikipedia.org/wiki/Lattice_Boltzmann_methods](https://en.wikipedia.org/wiki/Lattice_Boltzmann_methods)

~~~
chaosbutters314
Thanks, I wrote a lot of that page :)

~~~
krosaen
oh nice, thank you!

------
0x445442
In my Fluid Dynamics class we used Excel together with Finite Element Analysis
to solve all kinds of problems. It was actually pretty cool. I remember
specifically solving heat gradient problems in various shapes this way.

------
rumanator
FEM os the workhorse of pretty much any engineering field that needs to use
models expressed as partial differential equations, such as heat exchanges,
mechanics (solid and fluid statics and Dynamics), electromagnetics, etc. It's
hard to go through a day without using anything whose design process involved
FEM analysis at some point.

~~~
petschge
While FEM is (rightfully) very popular, a lot of work on electromagnetism is
done using finite-difference time-domain methods (FDTD) instead of finite-
element.

~~~
sansnomme
And there is a huge need for better open source tooling in both fields!

~~~
madengr
I don’t think that will ever happen. The knowledge to develop the tools is too
specialized and the user base too small. The same goes for any RF tools.

~~~
ofrzeta
There's a lot of open source from the academic world (e.g. SALOME, ONELAB,
FreeFEM). But maybe you think "tooling" in terms of integration in CAD
packages (which are more lacking in the open source world than FEM packages
arguably).

~~~
madengr
Yes. The integration and polish is what make all the difference. The
commercial EDA tools are light years ahead of the open source, and will
probably stay that way.

------
RhysU
libMesh is quite a tool for anyone looking for FEM software:
[http://libmesh.github.io/](http://libmesh.github.io/)

"...a framework for the numerical simulation of partial differential equations
using arbitrary unstructured discretizations on serial and parallel
platforms... support for adaptive mesh refinement... supports 1D, 2D, and 3D
steady and transient simulations on a variety of popular geometric and finite
element types."

------
hatmatrix
I've never seen a Wikipedia article on the front page of HN. Any idea why this
particular one made it?

~~~
mdszy
Are you serious? This happens every day.

~~~
IshKebab
I agree. This is also a particularly annoying example - at least some of the
niche ones are interesting. Who hasn't heard of FEA?

What next? Posting a link to
[https://en.wikipedia.org/wiki/Computer](https://en.wikipedia.org/wiki/Computer)?

~~~
mdszy
Why not see what happens[0]

0:
[https://news.ycombinator.com/item?id=22356125](https://news.ycombinator.com/item?id=22356125)

------
Ididntdothis
When I studied mechanical engineering we had one semester about finite
elements. It was really fascinating to take some simple physical rules, set up
some matrices, calculate them and have the result then be reproducible in the
real world. It drove home to me the power of computing.

