Micromechanics of deformation and stress evolution in thin films and patterned lines on substrates