public static void Propagation(WaveField1D _wf1, ref WaveField1D _wf2, MODE _MODE = MODE.CPU, DIRECTION _DIRECTION = DIRECTION.FORWARD) { switch(_MODE) { case MODE.CPU: ClsNac.WaveOpticsCLR.Prop1D( _wf1.lambda, (int)_DIRECTION, _wf1.x, _wf1.y, _wf1.u, _wf2.x, _wf2.y, _wf2.u); break; case MODE.CUDA: PropFw1dCuda(_wf1, ref _wf2); break; } }
public static void PropFw1DAf(WaveField1D wfs1,ref WaveField1D wfs2) { IntPtr ptr_u2re = IntPtr.Zero; IntPtr ptr_u2im = IntPtr.Zero; PropFw1DAf(wfs1.lambda, wfs1.div, wfs1.x, wfs1.y, wfs1.re, wfs1.im, wfs2.div, wfs2.x, wfs2.y, ref ptr_u2re, ref ptr_u2im); Marshal.Copy(ptr_u2re, wfs2.re, 0, wfs2.div); Marshal.Copy(ptr_u2im, wfs2.im, 0, wfs2.div); for (int i = 0; i < wfs2.div;i++) { wfs2.u[i] = new Complex(wfs2.re[i], wfs2.im[i]); } Marshal.FreeHGlobal(ptr_u2re); Marshal.FreeHGlobal(ptr_u2im); }
public FresnelKirchhoff1D(ref WaveField1D[] _wfs) { wfs = _wfs; n_wfs = wfs.Length; }
public static void PropFw1dCuda(WaveField1D wfs1, ref WaveField1D wfs2) { IntPtr ptr_u2re =new IntPtr(); ptr_u2re = Marshal.AllocHGlobal(wfs2.div * sizeof(double)); IntPtr ptr_u2im = new IntPtr(); ptr_u2im = Marshal.AllocHGlobal(wfs2.div * sizeof(double)); PropFw1dCuda(wfs1.lambda, wfs1.div, wfs1.x, wfs1.y, wfs1.re, wfs1.im, wfs2.div, wfs2.x, wfs2.y, ref ptr_u2re, ref ptr_u2im); Marshal.Copy(ptr_u2re, wfs2.re, 0, wfs2.div); Marshal.Copy(ptr_u2im, wfs2.im, 0, wfs2.div); Marshal.FreeHGlobal(ptr_u2re); Marshal.FreeHGlobal(ptr_u2im); for (int i = 0; i < wfs2.div; i++) { wfs2.u[i] = new Complex(wfs2.re[i], wfs2.im[i]); } }