South Africa opener Dean Elgar lost his wicket just before lunch, as Ben Stokes made a near-instant impact.