Coupled reservoir flow and geomechanics has numerous important applications in the oil & gas industry, such as land subsidence, hydraulic fracturing, fault reaction and hydrocarbon recovery etc. High fidelity numerical schemes and multiphysics models must be coupled in order to simulate these processes and their interactions accurately and efficiently. Specifically, in the applications of CO2 sequestration, the effect of geomechanics on carbon storage estimation is not negligible. However, coupled flow-geomechanics simulations are very computationally expensive and most of the computational time is usually spent for geomechanics calculations. This paper investigates a three-way coupling algorithm that uses an error indicator to determine when displacement must be updated and whether fixed-stress iterative coupling technique is required. Numerical experiments with coupled nonlinear single-phase flow and linear poromechanics shows that the three-way coupling algorithm can speed up 4 times comparing to fixed-stress iterative coupling algorithm. Extensions to coupled compositional flow with poromechanics also shows a speed-up for 5 times for continuous CO2 sequestration applications and 2 times for surfactant-alternating-gas applications (SAG). The substantial speed up makes the three-way coupling algorithm of flow and geomechanics feasible in the large-scale optimizations. Based on the three-way coupling of compositional flow and geomechanics, we experimented two black box optimization algorithms, covariance-matrix adaptation evolution strategy (CMA-ES) and genetic algorithm (GA), for the optimization of well controls during SAG process to maximize CO2 storage volume. CMA-ES outperforms GA in that it is more robust, and it achieves higher objective function value in less simulation runs. The optimized SAG process achieves 27.55% more CO2 storage volume and reduces water and surfactant consumption by 54.84%.