Er… maybe I should add one more multidimensional sample?:
ie = 100; je = 100;
c = 1/Sqrt[2];
ez = ConstantArray[0., {ie + 1, je + 1}];
hx = ConstantArray[0., {ie + 1, je}];
hy = ConstantArray[0., {ie, je + 1}];
(* Notice the following function hasn't been fixed yet *)
fdtd2d = Compile[{{steps}},
Module[{ez = ez, hx = hx, hy = hy, ie = ie, je = je, c = c},
Do[
ez[[2 ;; ie, 2 ;; je]] +=
c (hx[[2 ;; ie, 1 ;; je - 1]] - hx[[2 ;; ie, 2 ;; je]] +
hy[[2 ;; ie, 2 ;; je]] - hy[[1 ;; ie - 1, 2 ;; je]]);
ez[[Floor[ie/2], Floor[je/2]]] = Sin[n/10];
hx += c (ez[[All, 1 ;; je]] - ez[[All, 2 ;; je + 1]]);
hy += c (ez[[2 ;; ie + 1, All]] - ez[[1 ;; ie, All]]),
{n, steps}];
{ez, hx, hy}]];
AbsoluteTiming[dat = fdtd2d[1000];]
ArrayPlot /@ {ez2, hx2, hy2}