Hi, I have an objective f(b) + |\nabla b| where b is the control variable which is defined in DG0 function space. Is there a function in fenics adjoint which is a smooth approximation of the TV norm such that the gradients w.r.t. b can also be tracked.
For example, consider this:
’’’
n = 250
mesh = UnitSquareMesh(n, n)
A = FunctionSpace(mesh, "CG", 1) # function space for control
P = FunctionSpace(mesh, "CG", 1) # function space for solution
.......
J = assemble(f * T * dx + alpha * inner(grad(a), grad(a)) * dx)
m = Control(a)
Jhat = ReducedFunctional(J, m, eval_cb_post=eval_cb)
What should I use in place of : inner(grad(a), grad(a))
as described by @dokken, it is not possible to compute a real gradient, because our objective is not differentiable. There are specialized algorithms to solve such non-smooth problems. Some of them require generalized gradients of the objective, which could be computed using dolfin-adjoint.
One problem you might face (and this might be you actual question) is that you represent the euclidean norm, a Lipschitz continious function, by a composition using sqrt, which is not Lipschitz. This can lead to instablility in the numerical computation. I think you could fix this by adding the euclidean norm as a custom function. Then you can specify the derivative you want to use at 0.