A new method is described for an electron beam analysis in a three-dimensional self-consistent field. The method has been developed based on a boundary-fitted coordinate transformation. The scheme also used the technique of decomposing the domain surrounded by electrodes into several hexahedrons and then overlapping neighboring hexahedrons. The computer code developed for the method can treat electron beam optics in complicated electrode shapes with a practicably sized CPU memory. Numerical results for an axisymmetric electron gun verified the code capability and feasibility.