Where can I find the homogenize function?

In the project I am working on I unfortunately cannot use dolfin-adjoint and have to implement some of its features manually. I have been reading the dolfin adjoint code, in particular on resolving the adjoint equation to try and replicate it/debug my current code.

In the pyadjoint/tests/migration/manual_hessian/manual_hessian.py file dolfin adjoint uses
from dolfin_adjoint.utils import homogenize
However if I try to import this function myself I cannot. I can’t find any reference to it in the github, so I am confused as to where it is coming from.

What about bc.homogenize?

Which in turn calls:

The tests in the migration folder are taken from the old dolfin-adjoint that builds on libadjoint. Not all the tests in the migration folder have been converted to a new dolfin-adjoint/pyadjoint version, and so they are marked with an xfail in the test_*.py file. That includes the manual_hessian test.

You can find the actual function used from dolfin-adjoint/libadjoint here:
Which essentially just copies the DirichletBC (since homogenize is an in-place operation) and then homogenizes using the dolfin function as @dokken suggests above.

1 Like