Browse Source

Beginning work on adding lagged convolution to Key FHT classes.

lagkey
Trevor Irons 6 years ago
parent
commit
7d1e64b6c8

+ 3
- 1
Modules/FDEM1D/examples/Hantenna.cpp View File

202
 	for (int iy=0; iy<ny; ++iy) {
202
 	for (int iy=0; iy<ny; ++iy) {
203
 	for (int ix=0; ix<nx; ++ix) {
203
 	for (int ix=0; ix<nx; ++ix) {
204
         hreal << receivers->GetLocation(i).transpose() << "\t";
204
         hreal << receivers->GetLocation(i).transpose() << "\t";
205
- 		hreal << receivers->GetHfield(0, i).transpose() << "\n";
205
+ 		//hreal << receivers->GetHfield(0, i).transpose() << "\n"; ( complex, notation )
206
+ 		hreal << receivers->GetHfield(0, i).transpose().real() << "\t";
207
+ 		hreal << receivers->GetHfield(0, i).transpose().imag() << "\n";
206
         ++i;
208
         ++i;
207
     }
209
     }
208
     }
210
     }

+ 15
- 2
Modules/FDEM1D/include/FHTKey201.h View File

20
 #define  FHTKEY201_INC
20
 #define  FHTKEY201_INC
21
 
21
 
22
 #include "HankelTransform.h"
22
 #include "HankelTransform.h"
23
+#include "CubicSplineInterpolator.h"
23
 
24
 
24
 namespace Lemma {
25
 namespace Lemma {
25
 
26
 
27
       \ingroup FDEM1D
28
       \ingroup FDEM1D
28
       \brief   Impliments the fast Hankel transform as outlines by Key 2011
29
       \brief   Impliments the fast Hankel transform as outlines by Key 2011
29
       \details This filter uses 51, 101, or 201 filter points and supports both lagged and related
30
       \details This filter uses 51, 101, or 201 filter points and supports both lagged and related
30
-                kernel arguments. This algorithm is a port of code carrying the following copyright and
31
-                restriction:
31
+                kernel arguments. This algorithm is a port of code carrying the following copyright
32
+                and restriction:
32
                 %------------------------------------------------------------------%
33
                 %------------------------------------------------------------------%
33
                 % Copyright (c) 2012 by the Society of Exploration Geophysicists.  %
34
                 % Copyright (c) 2012 by the Society of Exploration Geophysicists.  %
34
                 % For more information, go to http://software.seg.org/2012/0003 .  %
35
                 % For more information, go to http://software.seg.org/2012/0003 .  %
83
 
84
 
84
         void ComputeRelated(const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManager);
85
         void ComputeRelated(const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManager);
85
 
86
 
87
+        void ComputeLaggedRelated(const Real& rho, const int& nlag, std::shared_ptr<KernelEM1DManager> KernelManager);
88
+
86
         // ====================  ACCESS        =======================
89
         // ====================  ACCESS        =======================
87
 
90
 
88
         // ====================  INQUIRY       =======================
91
         // ====================  INQUIRY       =======================
89
 
92
 
93
+        Real GetABSER();
94
+
95
+        void SetLaggedArg(const Real& rho);
96
+
90
         /** Returns the name of the underlying class, similiar to Python's type */
97
         /** Returns the name of the underlying class, similiar to Python's type */
91
         virtual std::string GetName() const;
98
         virtual std::string GetName() const;
92
 
99
 
101
         // Shared Filter Weights
108
         // Shared Filter Weights
102
 		static const Eigen::Matrix<Real, 201, 3>  WT201;
109
 		static const Eigen::Matrix<Real, 201, 3>  WT201;
103
 
110
 
111
+        /// Spines for lagged convolutions (real part)
112
+        std::vector <std::shared_ptr<CubicSplineInterpolator> > splineVecReal;
113
+
114
+        /// Spines for lagged convolutions (imaginary part)
115
+        std::vector < std::shared_ptr<CubicSplineInterpolator> > splineVecImag;
116
+
104
         /// Holds answer, dimensions are NumConv, and NumberRelated.
117
         /// Holds answer, dimensions are NumConv, and NumberRelated.
105
         Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic> Zans;
118
         Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic> Zans;
106
 
119
 

+ 7
- 4
Modules/FDEM1D/src/EMEarth1D.cpp View File

231
         if (Antenna->GetName() == std::string("PolygonalWireAntenna") || Antenna->GetName() == std::string("TEMTransmitter") ) {
231
         if (Antenna->GetName() == std::string("PolygonalWireAntenna") || Antenna->GetName() == std::string("TEMTransmitter") ) {
232
             icalc += 1;
232
             icalc += 1;
233
             // Check to see if they are all on a plane? If so we can do this fast
233
             // Check to see if they are all on a plane? If so we can do this fast
234
-            if (Antenna->IsHorizontallyPlanar() && HankelType == ANDERSON801) {
234
+            if (Antenna->IsHorizontallyPlanar() && 1==2 && ( HankelType == ANDERSON801 || HankelType== FHTKEY201  )) {
235
                 #ifdef HAVE_BOOST_PROGRESS
235
                 #ifdef HAVE_BOOST_PROGRESS
236
                 if (progressbar) {
236
                 if (progressbar) {
237
                     disp = new boost::progress_display( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
237
                     disp = new boost::progress_display( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
243
                     #pragma omp parallel
243
                     #pragma omp parallel
244
                     {
244
                     {
245
                     #endif
245
                     #endif
246
-                    auto Hankel = FHTAnderson801::NewSP();
246
+                    //if (HankelType == ANDERSON801) {
247
+                        auto Hankel = FHTAnderson801::NewSP();
248
+                    //}
249
+                    //else if(HankelType == FHTKEY201) {
250
+                    //    auto Hankel = FHTKey201::NewSP();
251
+                    //}
247
                     #ifdef LEMMAUSEOMP
252
                     #ifdef LEMMAUSEOMP
248
                     #pragma omp for schedule(static, 1)
253
                     #pragma omp for schedule(static, 1)
249
                     #endif
254
                     #endif
797
         //std::cout << Hankel->GetAnswer() << std::endl;
802
         //std::cout << Hankel->GetAnswer() << std::endl;
798
         //std::cout << Hankel->GetArg() << std::endl;
803
         //std::cout << Hankel->GetArg() << std::endl;
799
 
804
 
800
-
801
         // Sort the dipoles by rho
805
         // Sort the dipoles by rho
802
-
803
         for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
806
         for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
804
         //for (int idip=0; idip<1; ++idip) {
807
         //for (int idip=0; idip<1; ++idip) {
805
             auto tDipole = antenna->GetDipoleSource(idip);
808
             auto tDipole = antenna->GetDipoleSource(idip);

+ 61
- 0
Modules/FDEM1D/src/FHTKey201.cpp View File

371
         return ;
371
         return ;
372
     }		// -----  end of method FHTKey201::ComputeRelated  -----
372
     }		// -----  end of method FHTKey201::ComputeRelated  -----
373
 
373
 
374
+    //--------------------------------------------------------------------------------------
375
+    //       Class:  FHTKey201
376
+    //      Method:  ComputeLaggedRelated
377
+    //--------------------------------------------------------------------------------------
378
+    void FHTKey201::ComputeLaggedRelated ( const Real& rho, const int& nlag, std::shared_ptr<KernelEM1DManager> KernelManager ) {
379
+
380
+        int nrel = (int)(KernelManager->GetSTLVector().size());
381
+        Eigen::Matrix<Complex, 201, Eigen::Dynamic > Zwork;
382
+        Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(nlag, nrel);
383
+        Zwork.resize(201, nrel);
384
+        VectorXr lambda = WT201.col(0).array()/rho;
385
+        int NumFun = 0;
386
+        int idx = 0;
387
+
388
+        // Get Kernel values
389
+        for (int ir=0; ir<lambda.size(); ++ir) {
390
+            // irelated loop
391
+            ++NumFun;
392
+            KernelManager->ComputeReflectionCoeffs(lambda(ir), idx, rho);
393
+            for (int ir2=0; ir2<nrel; ++ir2) {
394
+                // Zwork* needed due to sign convention of filter weights
395
+ 			    Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
396
+            }
397
+
398
+        }
399
+
400
+        // We diverge slightly from Key here, each kernel is evaluated seperately, whereby instead
401
+        // they prefer to sum them. The reason is that all those terms have been removed from the kernels
402
+        // in the interests of making them as generic and reusable as possible. This approach requires slightly
403
+        // more multiplies, but the same number of kernel evaluations, which is the expensive part.
404
+        // Inner product and scale
405
+        for (int ir2=0; ir2<nrel; ++ir2) {
406
+            Zans(0, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
407
+        }
408
+
409
+        return ;
410
+    }		// -----  end of method FHTKey201::ComputeLaggedRelated  -----
411
+
412
+
413
+    //--------------------------------------------------------------------------------------
414
+    //       Class:  FHTKey201
415
+    //      Method:  GetABSER
416
+    //--------------------------------------------------------------------------------------
417
+    Real FHTKey201::GetABSER (  ) {
418
+        return WT201(1,0)/WT201(0,0);
419
+    }		// -----  end of method FHTKey201::GetABSER  -----
420
+
421
+
422
+    //--------------------------------------------------------------------------------------
423
+    //       Class:  FHTKey201
424
+    //      Method:  SetLaggedArg
425
+    //--------------------------------------------------------------------------------------
426
+    void FHTKey201::SetLaggedArg ( const Real& rho  ) {
427
+        for (int i=0; i<Zans.cols(); ++ i) {
428
+            Zans(0, i) = Complex( splineVecReal[i]->Interpolate(rho),
429
+                                  splineVecImag[i]->Interpolate(rho) );
430
+        }
431
+        return ;
432
+    }		// -----  end of method FHTKey201::SetLaggedArg  -----
433
+
434
+
374
 }		// -----  end of Lemma  name  -----
435
 }		// -----  end of Lemma  name  -----

Loading…
Cancel
Save