Port getgravc.js and tests

Refs #162