Nanomechanics of defects in solids: applications to nanolayers, nanoparticles, nanocrystals and biomaterials