Use mesh.n_elem() instead of whatever the Exodus writer has for num_elem.