On the efficiency and robustness of the adjoint method: Applications in steady and unsteady shape optimization in fluid mechanics