FEniCS / ufl

UFL - Unified Form Language
https://fenicsproject.org
GNU Lesser General Public License v3.0
104 stars 64 forks source link

Possible fix for taking scalar derivatives of vector coefficients using coefficient derivative maps #124

Closed cianwilson closed 1 year ago

cianwilson commented 2 years ago

If the argument v is scalar then len(v.ufl_shape) = 0 and choosing the indices based on:

oi1 = oi[:-rv]
oi2 = oi[-rv:]

is not valid. Specifically v[oi2] will produce the error (see #123):

Component and shape length don't match.

This PR makes scalar v a special case so that the product can be evaluated as a tensor scalar product.

It also adds a unit test for this case, which fails with current main.