Nanomechanics of flexoelectric switching