# Interior Control of the Poisson Equation with the Steepest Descent Method in OpenFOAM

Authors: - 29 June 2018

In this work we solve the optimal control problem

$\min _{u \in L^2 \left( \Omega \right)} \mathcal{J}\left( u\right) = \min _{u \in L^2 \left( \Omega \right)} \frac{1}{2} \int_{\Omega} \left( y - y_d \right) ^2 \mathrm{d} \Omega + \frac{\beta}{2} \int_{\Omega} u ^2 \mathrm{d} \Omega,$

where $u$ is the control variable, $y$ the state variable and $y_d$ a target function. The minimization problem is subject to the elliptic partial differential equation

$\begin{cases} -\Delta y = f + u & \text{in } \Omega, \\ y = 0 & \text{on } \Gamma. \end{cases}$

We use the steepest descent method based on the adjoint methodology. The corresponding adjoint system writes as

$\begin{cases} - \Delta \lambda = y - y_d & \text{in } \Omega, \\ \lambda = 0 & \text{on } \Gamma. \end{cases}$

The directional derivative of the cost function is given by

$\mathcal{D}_{ \delta u} \mathcal{J} \left( u \right) = \int_{\Omega} \left( \lambda + \beta u \right) \delta u \, \mathrm{d} \Omega,$

and the control variable is updated according to

$u^{\left( n + 1 \right)} = u^{\left( n \right)} - \epsilon \left( \lambda^{\left( n \right)} + \beta u^{\left( n \right)} \right),$

for some value of $\epsilon$.

## Getting Started

The solver must be compiled in the terminal. It is advisable to first clean previous compilations with

wclean


and then use

wmake


### Prerequisites

OpenFOAM C++ library must be installed in order to compile the code.

The OpenFOAM distribution provided by the OpenFOAM Foundation was used.

## Running a Case

In order to run the solver move to the case folder poissonAdjoinFoamCase and type in the command line

./Allprepare



The poissonAdjointFoam solver has been tested in a square domain $[0, 1] \times [0, 1]$ with zero Dirichlet boundary conditions and $\beta = 10^{-3},10^{-4},10^{-5},10^{-6}$. The target function is $y_d = xy \sin \left( \pi x \right) \sin \left( \pi y \right)$.

### Warning

It might be needed to use

sed -i -e 's/\r\$//' filename


and

chmod +x filename


in order to be able to execute

./filename


## References

• F. Tröltzsch. Optimal control of partial differential equations: theory, methods, and applications. American Mathematical Soc., 2010.