dolfin.function.expression¶
Functions
|
Decorator to create Numba JIT-compiled evaluate function. |
Classes
|
Initialise Expression |
-
dolfin.function.expression.
numba_eval
(*args, numba_jit_options: dict = {'cache': False, 'nopython': True}, numba_cfunc_options: dict = {'cache': False, 'nopython': True})[source]¶ Decorator to create Numba JIT-compiled evaluate function.
A decorator that takes an evaluation function
f
and returns the C address of the Numba JIT-ed method. The call signature off
should be:- f: Callable(None, (numpy.array, numpy.array, numpy.array))
Python function accepting parameters: values, x, cell_index, t.
For more information on
numba_jit_options
andnumba_cfunc_options
read the Numba documentation.- Parameters
numba_jit_options (dict, optional) – Options passed to
numba.jit
.nopython
must beTrue
.numba_cfunc_options (dict, optional) – Options passed to
numba.cfunc
.nopython
must beTrue
.
Example
>>> @function.expression.numba_eval >>> def expr(values, x, cell_idx): >>> values[:, 0] = x[:, 0] + x[:, 1] + x[:, 2] >>> values[:, 1] = x[:, 0] - x[:, 1] - x[:, 2] >>> values[:, 2] = x[:, 0] + x[:, 1] + x[:, 2] >>> mesh = UnitCubeMesh(MPI.comm_world, 3, 3, 3) >>> W = VectorFunctionSpace(mesh, ('CG', 1)) >>> e = Expression(expr, shape=(3,)) >>> u = Function(W) >>> u.interpolate(e)