Skip to content

Uniqueness of integrands after computing form data #304

@jorgensd

Description

@jorgensd

Using compute_form_data makes equal integrands un-equal in ufl.
MWE

from ufl import TestFunction, Mesh, interval, FunctionSpace
import ufl.algorithms
import ufl.classes
from ufl.finiteelement import FiniteElement
from ufl.sobolevspace import H1
from ufl.pullback import identity_pullback
cell = interval
mesh = Mesh(FiniteElement("Lagrange", cell, 1, (2, ), identity_pullback, H1))
V = FunctionSpace(mesh, FiniteElement("Lagrange", cell, 1, (), identity_pullback, H1))
u = TestFunction(V)
a0 = u.dx(0) * ufl.dx((1))
a1 = u.dx(0) * ufl.dx((2))

print(a0.integrals()[0].integrand() == a1.integrals()[0].integrand())
form_data0 = ufl.algorithms.compute_form_data(
    a0+a1,
    do_apply_function_pullbacks=True,
    do_apply_integral_scaling=True,
    do_apply_geometry_lowering=True,
    preserve_geometry_types=(ufl.classes.Jacobian,),
    do_apply_restrictions=True,
    do_append_everywhere_integrals=False)
i0 = form_data0.integral_data[0].integrals[0].integrand()
i1 = form_data0.integral_data[1].integrals[0].integrand()
print(str(i0))
print(str(i1))
print(i0 == i1)

Returning

True
({ A | A_{i_{12}} = sum_{i_{13}} ({ A | A_{i_{17}, i_{18}} = ({ A | A_{i_{15}, i_{14}} = J[i_{14}, i_{15}] })[i_{17}, i_{18}] / (sum_{i_{16}} J[i_{16}, 0] * J[i_{16}, 0] ) })[i_{13}, i_{12}] * (reference_grad(reference_value(v_0)))[i_{13}]  })[0] * weight * |(cell_orientation * sqrt(sum_{i_{10}} J[i_{10}, 0] * J[i_{10}, 0] ))|
({ A | A_{i_{12}} = sum_{i_{13}} ({ A | A_{i_{22}, i_{23}} = ({ A | A_{i_{20}, i_{19}} = J[i_{19}, i_{20}] })[i_{22}, i_{23}] / (sum_{i_{21}} J[i_{21}, 0] * J[i_{21}, 0] ) })[i_{13}, i_{12}] * (reference_grad(reference_value(v_0)))[i_{13}]  })[0] * weight * |(cell_orientation * sqrt(sum_{i_{11}} J[i_{11}, 0] * J[i_{11}, 0] ))|
False

Any idea how we can resolve this, as it results in duplicate kernels similar to what I tried to resolve with: #92

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions