コード例 #1
0
ファイル: Giem2gGreenTensor.cs プロジェクト: prisae/extreme
        //	public static ForwardSolver current_solver;

        public static GreenTensor CalcAtoATensor(ForwardSolver solver, GreenTensor gt)
        {
            var giem2g_ie_op = new giem2g_data();
            var bkg          = new giem2g_background();
            var anomaly      = new giem2g_anomaly();

            GreenTensor gt_new;

            //	current_solver = solver;


            PrepareBkgAndAnomaly(solver, ref bkg, ref anomaly);



            //giem2g_set_logger(GIEM2G_LOGGER);

            IntPtr ie_op_ptr;

            if (gt == null || !gt.Has("giem2g"))
            {
                gt_new    = PrepareGIEM2GTensor(solver, ref giem2g_ie_op, anomaly);
                ie_op_ptr = giem2g_ie_op.giem2g_tensor;
            }
            else
            {
                ie_op_ptr = new IntPtr(gt ["giem2g"].Ptr);
                gt_new    = gt;
            }



            var omega = solver.Model.Omega;

            giem2g_calc_ie_kernel(ie_op_ptr, bkg, anomaly, omega);

            solver.MemoryProvider.Release((void *)bkg.csigb);
            solver.MemoryProvider.Release((void *)bkg.thickness);
            solver.MemoryProvider.Release((void *)anomaly.z);
            solver.MemoryProvider.Release((void *)anomaly.dz);



            return(gt_new);
        }
コード例 #2
0
ファイル: Giem2gGreenTensor.cs プロジェクト: prisae/extreme
        static GreenTensor PrepareGIEM2GTensor(ForwardSolver solver, ref giem2g_data giem2g_ie_op, giem2g_anomaly anomaly)
        {
            int nz = solver.Model.Nz;
            int nx = solver.Model.Nx;
            int ny = solver.Model.Ny;

            giem2g_ie_op.comm = solver.Mpi.CommunicatorC2Fortran();
            giem2g_calc_data_sizes(anomaly, ref giem2g_ie_op);



            var buff = FftBuffersPool.GetBuffer(solver.Model);

            if (buff.Plan3Nz.BufferLength >= giem2g_ie_op.fft_buffers_length)
            {
                giem2g_ie_op.fft_buffer_in  = buff.Plan3Nz.Buffer1Ptr;
                giem2g_ie_op.fft_buffer_out = buff.Plan3Nz.Buffer2Ptr;
            }
            else
            {
                var len = giem2g_ie_op.fft_buffers_length;
                giem2g_ie_op.fft_buffer_in  = solver.MemoryProvider.AllocateComplex(len);
                giem2g_ie_op.fft_buffer_out = solver.MemoryProvider.AllocateComplex(len);
                solver.Logger.WriteError("Allocate additional memory for FFT inside GIEM2G!!");
            }
            var giem2g_ptrs = AllocateGiem2gDataBuffers(solver.MemoryProvider, ref giem2g_ie_op, nz);


            giem2g_prepare_ie_kernel(anomaly, giem2g_ie_op);



            var gt = GreenTensor.CreateGiem2gTensor(solver.MemoryProvider, nx, ny, nz, nz, giem2g_ptrs);

            return(gt);
        }
コード例 #3
0
ファイル: Giem2gGreenTensor.cs プロジェクト: prisae/extreme
 private static extern void giem2g_prepare_ie_kernel(giem2g_anomaly anomaly, giem2g_data giem2g_ie_op);
コード例 #4
0
ファイル: Giem2gGreenTensor.cs プロジェクト: prisae/extreme
 private static extern void  giem2g_calc_data_sizes(giem2g_anomaly anomaly, ref giem2g_data giem2g_op);
コード例 #5
0
ファイル: Giem2gGreenTensor.cs プロジェクト: prisae/extreme
        private static List <IntPtr> AllocateGiem2gDataBuffers(INativeMemoryProvider memoryProvider, ref giem2g_data giem2g_ie_op, int nz)
        {
            var giem2g_ptrs = new List <IntPtr> ();

//			var tmp1=(memoryProvider.AllocateBytes(giem2g_ie_op.tensor_size));
//			giem2g_ie_op.giem2g_tensor=tmp1;
            var tmp1 = giem2g_ie_op.giem2g_tensor;

            giem2g_ptrs.Add(tmp1);

            var tmp2 = (memoryProvider.AllocateComplex(giem2g_ie_op.ie_kernel_buffer_length));

            giem2g_ptrs.Add(new IntPtr(tmp2));
            giem2g_ie_op.kernel_buffer = tmp2;

            var dz = (memoryProvider.AllocateDouble(nz));

            giem2g_ie_op.dz = dz;
            giem2g_ptrs.Add(new IntPtr(dz));

            var sqsigb = (memoryProvider.AllocateDouble(nz));

            giem2g_ie_op.sqsigb = sqsigb;
            giem2g_ptrs.Add(new IntPtr(sqsigb));

            var csigb = (memoryProvider.AllocateComplex(nz));

            giem2g_ie_op.csigb = csigb;
            giem2g_ptrs.Add(new IntPtr(csigb));
            return(giem2g_ptrs);
        }