Adjoint - Dirichlet BC

5 months ago by

I am trying to solve an optimization problem using IPOPT. When the definition of BC is made using classes, optimiztion runs well. When the definition is made using functions, I get the following error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/", line 699, in runfile
    execfile(filename, namespace)
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/", line 81, in execfile
    builtins.execfile(filename, *where)
  File "/home/okubo/Desktop/Source_sink_tests/", line 121, in <module>
    dJdma_init = compute_gradient(J,ma)
  File "/home/okubo/.local/lib/python2.7/site-packages/pyadjoint/", line 26, in compute_gradient
  File "/home/okubo/.local/lib/python2.7/site-packages/pyadjoint/", line 106, in evaluate
  File "/home/okubo/.local/lib/python2.7/site-packages/pyadjoint/", line 41, in wrapper
    return function(*args, **kwargs)
  File "/home/okubo/.local/lib/python2.7/site-packages/fenics_adjoint/types/", line 100, in evaluate_adj
    adj_output.append(adj_value.sub(i, deepcopy=True).vector().sum())
  File "/usr/lib/python2.7/dist-packages/dolfin/functions/", line 355, in sub
    % num_sub_spaces)
RuntimeError: Can only extract subfunctions with i = 0..2​

The problem is that with the function use, I can reach convergence and, with classes, I can not make the problem converge (note that they are the same problem).

Any ideas?


Community: FEniCS Project
Please include minimal working example, see
written 5 months ago by Michal Habera  
Hi Okubo,

did you solve your problem? I have a similar problem that Dirichlet boundary in adjoint gave me same error info.
written 3 months ago by young zhou  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »