A 3-D finite-element model for the calculation of inhomogeneous and nonisotropic rare-earth permanent magnets (REPM) is obtained by means of direct discretization. The automatic generation of the 3-D mesh is improved. The end-region magnetic fields of an 30-kVA aeronautical REPM generator, which has an additional generator in its end-region, is calculated by the front finite-element method with satisfactory results.