SPMHD simulations of structure formation