A director-field model of DNA packaging in viral capsids