[el2p] fix the model for two-dimensional settings
At various places, the code still assumed 3d. Generalize it by replacing [2] by [dimWorld-1] or by appropriate if statements.
At various places, the code still assumed 3d. Generalize it by replacing [2] by [dimWorld-1] or by appropriate if statements.