probably Jafari means a non uniform cross section beam ( something like a charge density gradient along x,y,z directions) and changing as the beam is propagating . i feel that a adaptive and moving mesh tricks will do the job.
Your program will be different depending on whether you are refering simply to a changing size of the beam cross-section or also to nonuniformity within the beam cross-section.
To implement specific beam cross section into your program depends on the beam transfer procedures of the program.
If internal particle interactions(for example, space charge effects) are not included in the program, then you can do the implementation by just using specific slits or control the particle distribution generator to get specific cross section. This method is also suitable for internal interaction effects if you are using PIC method.
For some simplified model to study internal interactions, the previous method might fail to present good results.