Esempio n. 1
0
        public static void Propagation(WaveField2D _wf1, ref WaveField2D _wf2, MODE _MODE = MODE.CUDA, DIRECTION _DIRECTION = DIRECTION.FORWARD)
        {
            float[] x1, y1, z1, re1, im1;
            float[] x2, y2, z2, re2, im2;
            float lambda = (float)_wf1.lambda;
            int n1 = _wf1.div;
            int n2 = _wf2.div;

            double2float(_wf1.x, out x1);
            double2float(_wf1.y, out y1);
            double2float(_wf1.z, out z1);
            double2float(_wf1.re, out re1);
            double2float(_wf1.im, out im1);
            double2float(_wf2.x, out x2);
            double2float(_wf2.y, out y2);
            double2float(_wf2.z, out z2);
            double2float(_wf2.re, out re2);
            double2float(_wf2.im, out im2);

            switch (_MODE)
            {
                case MODE.CPU:
                    ClsNac.WaveOpticsCLR.Prop2Df(
                        lambda,
                        x1, y1, z1, re1, im1,
                        x2, y2, z2, re2, im2);
                    break;
                case MODE.CUDA:
                    PropFw2dCudaf(lambda,
                        n1, x1, y1, z1, re1, im1,
                        n2, x2, y2, z2, ref re2, ref im2);
                    break;
            }

            float2double(re2, out _wf2.re);
            float2double(im2, out _wf2.im);
        }
Esempio n. 2
0
        public static void PropFw2dCuda2(WaveField2D wfs1, ref WaveField2D 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));

            PropFw2dCuda2(wfs1.lambda,
                wfs1.div1, wfs1.div2, wfs1.x, wfs1.y, wfs1.z, wfs1.re, wfs1.im,
                wfs2.div1, wfs2.div2, wfs2.x, wfs2.y, wfs2.z, 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]);
            }
        }
Esempio n. 3
0
 public static void Propagation2(WaveField2D _wf1, ref WaveField2D _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:
             PropFw2dCuda2(_wf1, ref _wf2);
             break;
     }
 }
Esempio n. 4
0
 public static void PropFw2dCLR(WaveField2D wfs1, ref WaveField2D wfs2)
 {
     ClsNac.WaveOpticsCLR.Prop2D(
         wfs1.lambda,
         wfs1.x, wfs1.y, wfs1.z, wfs1.u,
         wfs2.x, wfs2.y, wfs2.z, wfs2.u);
 }
Esempio n. 5
0
 public FresnelKirchhoff2D(ref WaveField2D[] _wfs)
 {
     wfs = _wfs;
     n_wfs = wfs.Length;
 }