Can dolfin-adjoint calculate the gradient of the cost with respect to mesh points?

Asked by Kuan Lee

Is it possible to calculate the cost with respect to changes in the shape of the domain?
For instance, if I define some shape function that alters the points on the mesh using some parameter, P.
Can I then get dolfin-adjoint to calculate dJ/dP?

Question information

English Edit question
dolfin-adjoint Edit question
No assignee Edit question
Solved by:
Simon Funke
Last query:
Last reply:
Revision history for this message
Simon Funke (simon-funke) said :

Hi Kuan,

No, dolfin-adjoint currently has no direct way of calculating the shape gradient.

However, you can use shape differential calculus to compute these sensitivities efficiently (and doing so involves computing the adjoint which you can do with dolfin-adjoint).

Below are two references for you to get started on shape differential calculus:

KG van der Zee, Introduction to Shape Differential Calculus

S. Schmidt, Efficient Large Scale Aerodynamic Design Based on Shape Calculus

Hope this helps,


Revision history for this message
Kuan Lee (kuan133) said :

Hi Simon,

Thanks you for the links.

I have looked through the references, and from my understanding (which may be incorrect), it seems that the shape calculus is a 'post processing' step which requires the calculated solution of the forward and adjoint states, along with some other curvature information.

How do I output the adjoint states of the simulation?
Can this be done through the dolfin-adjoint API?


Revision history for this message
Best Simon Funke (simon-funke) said :

Your understanding is correct.

You have access to the adjoint solution with the function:

dolfin_adjoint.compute_adjoint(functional, forget=True, ignore=[])

I think there are some example / tests that use it.

Revision history for this message
Kuan Lee (kuan133) said :

Thanks Simon Funke, that solved my question.