Comment 2 for bug 1177383

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :

The background is that coefficients of a form must have a deterministic ordering in the ufc interface.

When ufl Coefficients are created, they get assigned a running counter, which is used to determine their ordering in generated code.

Consider some coefficients constructed in this ordering:

    f = Coefficient(V)
    g = Coefficient(V)
    h = Coefficient(V)

And the following forms:

    a = f * g**2 * dx
    b = f * h**2 * dx
    c = g * f**2 * dx
    d = h * f**2 * dx

Here the forms a and b should have the same signature and produce the same ufc code because they are the product of the first coefficient in the form and the square of the second coefficient in the form.

Similarly the forms c and d should have the same signature and produce the same ufc code because they are the product of the second coefficient in the form and the square of the first coefficient in the form.

At best, dolfin-adjoint might reduce the impact of this at the cost of some complexity, but I don't think you can get around this issue completely. If we had a more sophisticated algorithm for ordering of coefficients in ufl, all four forms above could be mapped to the same ufc code.