getFieldInElement() and getFieldInFieldElement() don't check validity of element index. Please upgrade to the latest release of Simcenter MAGNET to avoid this issue altogether.
Workaround: We don't recommend trying to recognize an output array of very low values. Avoid the issue at the source by using the command Mesh.getNumberOfElements() to deduce the valid range of element indices. The minimum value is zero, and the maximum value is one less than the number of elements.