Mechanics of nanoelectromechanical systems