Magnetohydrodynamics, magnetogenesis, and magnetorotational instabilities with adaptive mesh refinement