Compaction and plasticity in nanofoams induced by shock waves: A molecular dynamics study