Modelling of isolated radio pulsars and magnetars on the fossil field hypothesis