Comment 2 for bug 1187366

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

In case someone else encounters this, handled by adding a dummy term to the form:

        # Hack: Add a zero term with a function that references the mesh
        R = FunctionSpace(mesh, "Real", 0)
        f0 = Function(R, name="dummy_zero_constant")
        J += f0**2*ds*dt[START_TIME]

The reason this was necessary is that the previous J only used Constants and so no mesh was available through the form when dolfin-adjoint assembled it.