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:
https://bitbucket.org/fenics-project/dolfin/src/3eacdb46ed4e6dcdcbfb3b2f5eefa73f32e1b8a8/dolfin/fem/DirichletBC.h?at=master#DirichletBC.h-328

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:
https://bitbucket.org/dolfin-adjoint/dolfin-adjoint/src/286fc31bd06634d4d3f2941aa16328fd4ac58e3d/dolfin_adjoint/utils.py#lines-40
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