When does the shock occurred? I'm between this 2 conditions that when does the shock occurred over an airfoil.


*

*When the speed of point of an airfoil reach to sonic velocity of environment.

*When the speed of point of an airfoil reach to sonic velocity of local flow over an airfoil.
Which one is correct?
 A: A compression shock at subsonic flight speed only occurs when a supersonic pocket of air collapses downstream. Neither of your options is correct, and in that shock the speed drops from mildly supersonic (typically Mach 1.25) to the inverse of that Mach number (that would then be typically Mach 0.8).
Acceleration into the supersonic regime is smooth and continuous. This is caused by the displacement effect of a body and by super velocities due to lift creation.
Only with supersonic flight speed will you see a compression shock at the tip of the aircraft and all surfaces which have less sweep than the Mach cone.
Local flow conditions should be used for all Mach numbers. Only the tip compression shock should be calculated with the environment conditions.

Isotachs on the rear upper surface of an airfoil, the picture contributed by @meisamnemati. The steep Mach gradient indicates the shock; in reality the gradient would be much steeper. I think the grid he used was much too coarse to capture the shock correctly. Modern algorithms use adaptive grids which refine the spatial resolution of their finite elements according to the local gradient. Proper use of such an algorithm should show the shock much more clearly.
The pocket of supersonic air is where all the colors from red to light green can be seen.
