boschresearch / pylife

a general library for fatigue and reliability
https://pylife.readthedocs.io
Apache License 2.0
137 stars 25 forks source link

Performance profiling for Gradient3D #50

Closed johannes-mueller closed 8 months ago

johannes-mueller commented 9 months ago
maierbn commented 9 months ago

profiling: (I can't upload pictures)

number of nodes time gradient time gradient_3D
8 0.006999 0.008013
27 0.007274 0.023832
64 0.014600 0.076214
125 0.027407 0.177685
216 0.046525 0.346051
343 0.074140 0.595319
512 0.112052 1.012772
729 0.179701 1.410299
1000 0.233567 2.006580
1331 0.318788 2.828625
1728 0.506451 3.792203
2197 0.657848 4.896899
2744 0.756854 6.254709
maierbn commented 9 months ago

Runtime when running gradient_3D on a mesh with 1000 nodes:

Ordered by: cumulative time

ncalls tottime percall cumtime percall filename:lineno(function)
827/1 0.007 0.000 6.385 6.385 {built-in method builtins.exec}
1 0.000 0.000 6.385 6.385 profile_run.py:1(<module>)
1 0.001 0.001 5.885 5.885 profile_run.py:49(evaluate)
1 0.000 0.000 4.638 4.638 gradient.py:357(gradient_of)
1 0.001 0.001 4.635 4.635 groupby.py:1315(apply)
1 0.000 0.000 4.634 4.634 groupby.py:1367(_python_apply_general)
1 0.002 0.002 4.557 4.557 ops.py:750(apply)
729 0.002 0.000 4.514 0.006 gradient.py:341(_compute_gradient)
729 0.055 0.000 4.511 0.006 gradient.py:206(_compute_gradient_hexahedral)
152361 0.133 0.000 2.839 0.000 indexing.py:1089(__getitem__)
158922 0.265 0.000 2.170 0.000 indexing.py:1623(_getitem_axis)
5832 0.247 0.000 2.007 0.000 gradient.py:184(_compute_gradient_hexahedral_single_node)
maierbn commented 9 months ago

There is not really potential to optimize performance significantly (without using cython etc.) Imho the Gradient3D functionality still has its use because the calculated gradient is the mathematical correct one based on the finite element solution. The other gradient Gradient function approximates the space by a point cloud.

johannes-mueller commented 8 months ago

Let's come back to it after https://github.com/boschresearch/pylife/issues/38

maierbn commented 7 months ago

A real-world example where gradient_3D is faster:

Mesh data/Job-Kt15_Charge2_linelast_100MPa_abq2022.odb on MSO jupyterlab with 280'080 elements