Magnetic shape memory