You need to wrap the scalars as Constants
, e.g.,
for i in range(100):
c_i = Constant(c[i])
for j in range(100):
result = assemble(f[i]*f[j]*c_i*dx)
The above will avoid the JIT compiler being called more than once. You can make it even more efficient via lower-level interfaces where you pre-process the form to avoid UFL processing the form each time. To do this, you need to turn a UFL form into a DOLFIN Form
object. Something like:
# UFL form
M = fi*fj*c*dx
# Attach coefficients to form
...
# Create a DOLFIN form
M = Form(M)
Caveat: the above snippet has not been tested. See site-packages/dolfin/fem/form.py for details.