Speed up expression evaluations with vectorized functions
Hi,
I would like to speed up the evaluation of my Expression implementation (which I can not express as an JIT-compiled expression).
My current code overloads the Expression class and implements the eval function. However, the main computational cost is
caused by the overhead of calling the eval function for each DOF. The attached Python code takes about 110s to interpolate a
simple Expression onto a 1000201 DOFs.
One easy way to speed up such loops is to use vectorized Python functions (a speed up of 10x - 200x is expected,
see e.g. http://
I was wondering if there is a way if/how I can make use such vectorized functions in Expressions. For that, the
Expression class would need an evaluation function which evaluates at a whole list of (x, y) coordinates. I imagine this to
look like:
class Turbines(
def eval_all(self, values, x, y):
# x = [x0, x1, x2, ...])
# y = [y0, y1, y2, ...]
values[0] = exp(-1.
I am happy for any hints.
Thanks very much,
Simon
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Simon Funke
- Solved:
- Last query:
- Last reply: