Ejemplo n.º 1
0
        private void CalculateAnomalyField(AnomalyCurrent src, AnomalyCurrent dst, GreenTensor gt, bool electric)
        {
            var forward  = src.Nz == 1 ? Pool.Plan3 : Pool.Plan3Nz;
            var backward = dst.Nz == 1 ? Pool.Plan3 : Pool.Plan3Nz;


            UNF.ClearBuffer(forward.Buffer1Ptr, forward.BufferLength);
            PrepareForForwardFft(src, forward.Buffer1Ptr);
            Pool.ExecuteForward(forward);


            //Clear(backward.Input);
            if (electric)
            {
                ApplyGreenTensorAlongZForE(gt, forward.Buffer1Ptr, backward.Buffer2Ptr);
            }
            else
            {
                ApplyGreenTensorAlongZForH(gt, forward.Buffer1Ptr, backward.Buffer2Ptr);
            }

            Pool.ExecuteBackward(backward);

            var scalar = new Complex(1 / ((double)Model.Nx * (double)Model.Ny * 4), 0);
            var len    = backward.BufferLength;

            Zscal(len, scalar, backward.Buffer2Ptr);

            ExtractData(backward.Buffer2Ptr, dst);
        }
Ejemplo n.º 2
0
        public static GreenTensor AllocateNew(INativeMemoryProvider memoryProvider,
                                              int nx, int ny, int nTr, int nRc, long compSize, params string[] components)
        {
            var gt       = new GreenTensor(memoryProvider, nx, ny, nTr, nRc);
            var fullSize = compSize * components.Length;

            var ptr = memoryProvider.AllocateComplex(fullSize);

            UNM.ClearBuffer(ptr, fullSize);


            var dict = new Dictionary <string, Component>();

            for (int i = 0; i < components.Length; i++)
            {
                var nextPtr = ptr + i * compSize;
                dict.Add(components[i], new Component(gt, nextPtr));
            }

            gt._basePtrs.Add(new IntPtr(ptr));
            gt._components = dict;

            return(gt);
        }
Ejemplo n.º 3
0
        private void PrepareForForwardFft()
        {
            var inputPtr = Pool.Plan3Nz.Buffer1Ptr;

            UNM.ClearBuffer(inputPtr, Pool.Plan3Nz.BufferLength);

            int nx = _rx.Nx;
            int ny = _rx.Ny;
            int nz = Model.Nz;

            Iterate(nx, i => //for (int i = 0; i < nx; i++)
            {
                for (int j = 0; j < ny; j++)
                {
                    long shiftSrc = (i * ny + j) * 3L * nz;
                    long shiftDst = (i * ny * 2 + j) * 3L * nz;

                    UNM.MultiplyElementwise(nz, _forwardFactors, _rx.Ptr + shiftSrc, inputPtr + shiftDst);
                    UNM.MultiplyElementwise(nz, _forwardFactors, _rx.Ptr + shiftSrc + nz, inputPtr + shiftDst + nz);
                    UNM.MultiplyElementwise(nz, _forwardFactors, _rx.Ptr + shiftSrc + nz + nz,
                                            inputPtr + shiftDst + nz + nz);
                }
            });
        }