adtzlr / felupe

:mag: finite element analysis for continuum mechanics of solid bodies
https://felupe.readthedocs.io/
GNU General Public License v3.0
75 stars 11 forks source link

Define slow? #3

Closed bhaveshshrimali closed 3 years ago

bhaveshshrimali commented 3 years ago

Hi @adtzlr

Thanks for open-sourcing felupe. Looks great. I have used both FEniCS and scikit-fem and completely agree with you on native-installation of FEniCS on Windows (I use it mostly via Docker) and the the convenience of scikit-fem. For the latter, with numba even though the forms are considerably longer, the timings have been reasonable so far, especially for a pure python code.

I will try felupe for myself sometime this week. But have you observed significant differences between scikit-fem and felupe timings? Is this documented somewhere? My use cases also reside in finite incompressible elasticity so it might be worthwhile knowing it.

In any case, yet another nice tool in pure python to have at disposal.

Cheers!

adtzlr commented 3 years ago

Hi, I think it is a bit unfair to compare scikit-fem and felupe. scikit-fem is continously and quite professionally maintained by two great developers. I for myself try to handle a codebase for my PhD thesis for the calculation of elastomer components. My goal is not to cover the whole stuff what scikit-fem can handle - I just try to learn how things work. Hopefully I can contribute to scikit-fem in the future.

While felupe is still in its early days I think has some potential. Be aware that the scripts could be broken and the tests are outdated. Things can change over time - I did no feature freeze or have any intention to keep backward compatibility.

I plan to use felupe for nearly-incompressible hyperelastic materials with linear hexahedral (no tets for now!) elements for the displacements and element-wise constant fields for the pressure and volume change. Anything else (2d, linear elasticity, probably axisymmetry) will be possible but is not on my focus.

I use numba only for code-internal stuff (assembly of nodal reaction forces and stiffness matrix) - I try to keep the constitutive part 100% python. I even thought of dropping numba because np.einsum is actually quite fast if you set optimize=True for calculations with more than 2 arguments. But of course - if you would like to use numba for constitutive calculations you are free to do so.

I do have no benchmark scikit-fem vs. felupe available - but I'm quite surprised how fast felupe evaluates the sparse matrices. If you use anaconda and install pypardiso things are getting even faster for large systems. That really makes a difference. I certainly will add a benchmark table to the readme - once it makes sense for me.

Feel free to open issues if you have further questions.

adtzlr commented 3 years ago

As you wrote you are interested in incompressible elasticity - well, the code how to define mixed-field variations is not documented yet. You may find some useful snippets in the scripts but I don't think it is fun to play with felupe yet. Please give me some more time. 😄

adtzlr commented 3 years ago

I'm not sure if you found the github-pages "page" yet: https://adtzlr.github.io/felupe/ . For now this is identical to the readme but will be extended and linked in the readme in the future.

bhaveshshrimali commented 3 years ago

Wonderful. I can totally get your point. Being a graduate student myself, I haven't organized half my codes either. Kudos to you for felupe. Will follow the progress along. Thanks

adtzlr commented 3 years ago

I added two benchmarks to the documentation - one for the poisson problem and another one for the linear solution (first Newton-Rhapson iteration) of a simple hyperelastic cube under uniaxial compression. Assembly times are more or less the same compared to scikit-fem. felupe uses pypardiso as linear solver which seems to be considerably faster than the one from scipy.sparse.linalg.spsolve.

adtzlr commented 3 years ago

Poisson-Problem:

DOF Assembly Linear solve
5000 0.1 s 0.2 s
10082 0.2 s 0.1 s
20000 0.4 s 0.1 s
49928 0.9 s 0.3 s
100352 1.9 s 0.6 s
199712 3.9 s 1.3 s
500000 9.0 s 3.5 s
999698 18.3 s 8.6 s
adtzlr commented 3 years ago

quarter-model of a Neo-Hookean rubber block - see here:

DOF Assembly Linear solve
5184 0.2 s 0.5 s
10125 0.5 s 0.2 s
20577 0.9 s 0.6 s
52728 2.3 s 3.2 s
98304 4.8 s 10.0 s
206763 10.4 s 42.5 s
499125 28.1 s 313.1 s
adtzlr commented 3 years ago

I'll close this issue again as things should be cleared out now.

bhaveshshrimali commented 3 years ago

Thanks @adtzlr

I briefly took a look at https://github.com/adtzlr/felupe/blob/main/felupe/element.py

Do you think that the assembly pipeline is tailored for n-cubes, i.e. lines/quads/hexes? If it's just the basis functions and their derivatives then this should be generalizable for simplices too, right?

adtzlr commented 3 years ago

I did another benchmark with a (u,p,J) - Three-Field variation. For details please have a look at the documentation (section performance). The result is quite impressive!