I’m doing some multimesh shape-optimization and I would like to use/extend dolfin_adjoint. The trouble is: it seems that dolfin’s assemble is overloaded in dolfin_adjoint, but assemble_multimesh is not. Do you know if there is an example use-case for dolfin_adjoint with MultiMesh, or is this still not supported as stated here 5 years ago? Would I have to overload assemble_multimesh, along with other multimesh-functions I use, with pyadjoint or do you suggest another way?
We never got around to add multimesh to pyadjoint, mostly due to limited time during my PhD.
Multi-mesh is no longer developed, and since dolfin hasn’t really evolved since 2019 (as development has moved to dolfinx) it is not a priority to work on.
Note that you can use ufl.derivative as described in:
ie.
V = MultiMeshFunctionSpace(multimesh, "Lagrange", 1)
uh = MultiMeshFunction(V)
J = uh**2*dX
Q = MultiMeshVectorFunctionSpace(multimesh, "Lagrange", 1)
s = MultiMeshFunction(Q)
x = SpatialCoordinate(multimesh)
dJdx = derivative(J, x)
Thanks, Jørgen. The UFL shape-differentiation book seems very helpful so far. Your work on dolfin(,x), dolfin_adjoint and MultiMesh* is also very helpful.
Re. using your suggestion for my purpose: it seems that the derivative that is imported with
from dolfin import *
is a dolfin.fem.formmanipulations function. In some cursory tests, this seems to work for me as expected. The ufl.derivative seems to be a function from ufl.formoperators, and doesn’t work for my present purpose since I use indexed-coefficients. I will have to tinker with both a bit more.
P.S. I reverted to using dolfin after starting with dolfinx since neither MultiMesh* nor *_adjoint seems to be (fully) developed in dolfinx. I look forward to being able to use both if/when they are developed.