A level set based flamelet model for the prediction of combustion in homogeneous charge and direct injection spark ignition engines