The discrete adjoint method is our preferred method for calculating sensitivities of an objective function with respect to design variables, dJ/dX. See Section 3.3 of Nemec's thesis for a description of its implementation in Optima2D. For some historical background, checkout Pironneau's seminal paper (Pironneau, 1974) which laid the mathematical foundation for Jameson's later work demonstrating the practical application of the method to aerodynamic shape optimization problems within a CFD context.