An adjoint equation is a linear differential equation, usually derived from its primal equation using integration by parts. Gradient values with respect to a particular quantity of interest can be efficiently calculated by solving the adjoint equation. Methods based on solution of adjoint equations are used in wing shape optimization, fluid flow control and uncertainty quantification.
Consider the following linear, scalar advection-diffusion equation for the primal solution
u(\vec{x})
\Omega
\begin{align} \nabla ⋅ \left(\vec{c}u-\mu\nablau\right)&=f, \vec{x}\in\Omega,\\ u&=b, \vec{x}\in\partial\Omega. \end{align}
Let the output of interest be the following linear functional:
J(u)=\int\Omegagu dV.
Derive the weak form by multiplying the primal equation with a weighting function
w(\vec{x})
\begin{align} B(u,w)&=L(w), \end{align}
where,
\begin{align} B(u,w)&=\int\Omegaw\nabla ⋅ \left(\vec{c}u-\mu\nablau\right)dV\\ &=\int\partialw\left(\vec{c}u-\mu\nablau\right) ⋅ \vec{n}dA-\int\Omega\nablaw ⋅ \left(\vec{c}u-\mu\nablau\right)dV, (Integrationbyparts)\\ L(w)&=\int\Omegawf dV. \end{align}
Then, consider an infinitesimal perturbation to
L(w)
u
\begin{align} B(u+u',w)&=L(w)+L'(w)\\ B(u',w)&=L'(w). \end{align}
u'
\partial\Omega
Using the weak form above and the definition of the adjoint
\psi(\vec{x})
\begin{align} L'(\psi)&=J(u')\\ B(u',\psi)&=J(u'), \end{align}
we obtain:
\begin{align} \int\partial\psi\left(\vec{c}u'-\mu\nablau'\right) ⋅ \vec{n}dA-\int\Omega\nabla\psi ⋅ \left(\vec{c}u'-\mu\nablau'\right)dV&=\int\Omegagu' dV. \end{align}
Next, use integration by parts to transfer derivatives of
u'
\psi
\begin{align} \int\partial\psi\left(\vec{c}u'-\mu\nablau'\right) ⋅ \vec{n}dA-\int\Omega\nabla\psi ⋅ \left(\vec{c}u'-\mu\nablau'\right)dV-\int\Omegagu' dV&=0\\ \int\partial\psi\left(\vec{c}u'-\mu\nablau'\right) ⋅ \vec{n}dA+\int\Omegau'\left(-\vec{c} ⋅ \nabla\psi\right)dV+\int\Omega\nablau' ⋅ \left(\mu\nabla\psi\right)dV-\int\Omegagu' dV&=0\\ \int\partial\psi\left(\vec{c}u'-\mu\nablau'\right) ⋅ \vec{n}dA+\int\Omegau'\left(-\vec{c} ⋅ \nabla\psi\right)dV+\int\partialu'\left(\mu\nabla\psi\right) ⋅ \vec{n}dA-\int\Omegau'\nabla ⋅ \left(\mu\nabla\psi\right)dV-\int\Omegagu' dV&=0 (Repeatingintegrationbypartsondiffusionvolumeterm)\\ \int\Omegau'\left[-\vec{c} ⋅ \nabla\psi-\nabla ⋅ \left(\mu\nabla\psi\right)-g\right]dV+\int\partial\psi\left(\vec{c}u'-\mu\nablau'\right) ⋅ \vec{n}dA+\int\partialu'\left(\mu\nabla\psi\right) ⋅ \vec{n}dA&=0. \end{align}
The adjoint PDE and its boundary conditions can be deduced from the last equation above. Since
u'
\Omega
\left[-\vec{c} ⋅ \nabla\psi-\nabla ⋅ \left(\mu\nabla\psi\right)-g\right]
\Omega
\left(\vec{c}u'-\mu\nablau'\right) ⋅ \vec{n}
\psi
u'=0
Therefore, the adjoint problem is given by:
\begin{align} -\vec{c} ⋅ \nabla\psi-\nabla ⋅ \left(\mu\nabla\psi\right)&=g, \vec{x}\in\Omega,\\ \psi&=0, \vec{x}\in\partial\Omega. \end{align}
Note that the advection term reverses the sign of the convective velocity
\vec{c}