Generalized stiffness matrix method for layered soils