Numerical simulation of crack propagation in layered formations