  A novel adjoint-based framework oriented to optimal flow control in
compressible direct numerical simulations is presented. Also, a new formulation
of the adjoint characteristic boundary conditions is introduced, which enhances
the stability of the adjoint simulations. The flow configuration chosen as a
case study consists of a two dimensional open cavity flow with aspect ratio
$L/H=3$ and Reynolds number $Re=5000$. This flow configuration is of particular
interest, as the turbulent and chaotic nature of separated flows pushes the
adjoint approach to its limit. The target of the flow actuation, defined as
cost, is the reduction of the pressure fluctuations at the sensor location. To
exploit the advantages of the adjoint method, a large number of control
parameters is used. The control consists of an actuating sub-domain where a
two-dimensional body force is applied at every point within the sub-volume.
This results in a total of $2.256 \cdot 10^6$ control parameters. The final
actuation achieved a successful reduction of the cost of $79.6\%$, by altering
the directivity of the sound radiated by the trailing edge of the cavity and
breaking up the large shear layer instabilities into smaller structures.
