Replies: 1 comment 2 replies
-
I think I might've tested something similar and eventually settled to the current approach in scikit-fem. However, numpy has improved a lot and most likely the conclusions I have made from the performance are not valid anymore. As it might interest you as a FEM developer, I have lately done some experiments by dynamically compiling FEM assembly routines using gcc/clang from Python. In particular, I have written some multithreaded assembly routine templates in C and the relevant parts of the routine are replaced with basis function expressions and weak form expressions by some simple Python code. The resulting C code gets written into /tmp/foo.c, compiled using gcc/clang and then imported into Python dynamically. This is all done within Python by a simple call such as form = BilinearForm("ux * vx + uy * vy + uz * vz", ElemTetP1()) # the string is written directly into the C source code template
form.compile() # this will call gcc/clang and afterwards form.assemble() works as usual The template C source code is programmed carefully to not depend on any C level packages/libraries so the only true dependency is a standard C compiler such as gcc/clang. It uses There are at least three reasons for these experiments. For instance,
Even in some simple cases (e.g., 3D tetrahedral MINI element) I have gotten 100x improvement in assembly time. I currently cannot foresee this work becoming part of scikit-fem due to backward incompabilities. It would most likely be another package which is very close to scikit-fem in its API and even more focused to assembly only. |
Beta Was this translation helpful? Give feedback.
-
Hi @kinnala !
Have you ever considered to treat the data of the bases (e.g. the gradient data) simply as additional trailing axes in addition to the cells and quadrature-points axes? Recently, I tried to outline the assembly in minimal scripts and this seemed like an obvious choice for me (at least for an isoparametric hexahedron).
The snippet is undocumented (yet), but I'm sure you get the idea in
SolidBody()
immediately.3D Hyperelastic Finite Element Analysis in 150 Lines of Python Code
(
dhdX
are the basis function gradients andF
is the deformation gradient withδF
(orgrad(v)
) andΔF
(orgrad(u)
in scikit-fem notation).Thank you for your constant improvements to scikit-fem!
Beta Was this translation helpful? Give feedback.
All reactions