Initial thought: could you be generating a NaN in your own code as the mesh is refined?
E.g. if you're interpolating some expression that leads to a 0/0 at some points in the domain.
[Buesing, Henrik]
Ah, well. I was using int where I should have used float. Thus, my dz of the extruded mesh turned into zero.