Dear all,
I added the lines written below to the stokes-bc-control.py code from the dolphin-adjoint examples folder:
IFS = FunctionSpace(mesh, "CG", 2)
I1 = project(I1, IFS)
I2 = project(I2, IFS)
IGFS = VectorFunctionSpace(mesh, "CG", 2)
gradI2 = project(gradI2, IGFS)
and changed J accordingly:
J = Functional(1./2 * inner(grad(u), grad(u))*dx + alpha/2.*inner(g, g)*ds(2)
+ (1./2.*pow(inner(gradI2, u) + I2 - I1, 2)*dx
))
m = SteadyParameter(g)
Jhat = ReducedFunctional(J, m)
When trying to run it I get the error:
File "/usr/lib/python2.7/dist-packages/dolfin/fem/form.py", line 95, in init
assert form.domains(), "Expecting a completed form with domains at this point."
AssertionError: Expecting a completed form with domains at this point.
However, if I do not project any of them it actually runs, but it doesn't do what I want it to. The I1 (and similarly I2) is defined as:
VI = FunctionSpace(mesh, "DG", 0)
A = Function(VI)
A.vector()[:] = a.flatten().repeat(2).astype(np.float32)
I would be very grateful if you could help me sort it out.
Thank you for your consideration!