FinalFunctional fails in

Asked by Glen D. Granzow

When running the example program from

from dolfin import *
from dolfin_adjoint import *

n = 30
mesh = UnitInterval(n)
V = FunctionSpace(mesh, "CG", 2)

ic = project(Expression("sin(2*pi*x[0])"), V)
u = Function(ic)
u_next = Function(V)
v = TestFunction(V)

nu = Constant(0.0001)

timestep = Constant(1.0/n)

F = ((u_next - u)/timestep*v
    + u_next*grad(u_next)*v
    + nu*grad(u_next)*grad(v))*dx
bc = DirichletBC(V, 0.0, "on_boundary")

t = 0.0
end = 0.2
while (t <= end):
  solve(F == 0, u_next, bc)
  t += float(timestep)

J = FinalFunctional(inner(u, u)*dx)
dJdic = compute_gradient(J, InitialConditionParameter(u), forget=False)
dJdnu = compute_gradient(J, ScalarParameter(nu))

I get the error message

NameError: name 'FinalFunctional' is not defined

Question information

English Edit question
dolfin-adjoint Edit question
No assignee Edit question
Solved by:
Glen D. Granzow
Last query:
Last reply:
Revision history for this message
Glen D. Granzow (ggranzow) said :

I see now that someone had reported this as a bug ( and there is some useful information posted in response.

Revision history for this message
Glen D. Granzow (ggranzow) said :

I made the change described at and now runs without any error messages.