Browse Source

Improved speed for horizontal loops, reduced initialization of unused resources

master
Trevor Irons 4 years ago
parent
commit
11967300c1

+ 1
- 1
CMakeLists.txt View File

@@ -14,7 +14,7 @@ SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
14 14
 # Lemma versioning, set Major, minor, and patch here                                               #
15 15
 set(LEMMA_VERSION_MAJOR "0")                                                                       #
16 16
 set(LEMMA_VERSION_MINOR "3")                                                                       #
17
-set(LEMMA_VERSION_PATCH "2")                                                                       #
17
+set(LEMMA_VERSION_PATCH "3")                                                                       #
18 18
 set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")      #
19 19
 set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}") #
20 20
 ####################################################################################################

+ 5
- 0
Modules/FDEM1D/include/DipoleSource.h View File

@@ -224,6 +224,11 @@ namespace Lemma {
224 224
                     std::shared_ptr<FieldPoints> Receivers, const int& irec,
225 225
                     std::shared_ptr<LayeredEarthEM> Earth );
226 226
 
227
+            /** For use in lagged calculations, this does the necessary parts to make field calculations
228
+                for a segment.
229
+             */
230
+            void SetupLight(const int& ifreq,  const FIELDCALCULATIONS&  Fields, const int& irec);
231
+
227 232
             /** resets the kernels if they cannot be reused */
228 233
             virtual void ReSetKernels(const int& ifreq,  const FIELDCALCULATIONS&  Fields,
229 234
                     std::shared_ptr<FieldPoints> Receivers,

+ 3
- 1
Modules/FDEM1D/include/KernelEM1DSpec.h View File

@@ -56,7 +56,8 @@ namespace Lemma {
56 56
                 return std::make_shared< KernelEM1DSpec > ( ctor_key() );
57 57
             }
58 58
 
59
-            static std::shared_ptr<KernelEM1DSpec> NewSP(LayeredEarthEM* Earth, std::shared_ptr<DipoleSource> Dipole,
59
+            /* Management has shifted from this approach, this will be removed
60
+            static std::shared_ptr<KernelEM1DSpec> NewSP2(LayeredEarthEM* Earth, std::shared_ptr<DipoleSource> Dipole,
60 61
                                                          const int& ifreq, const Real& rz) {
61 62
                 auto Obj = std::make_shared< KernelEM1DSpec > ( ctor_key() );
62 63
 
@@ -68,6 +69,7 @@ namespace Lemma {
68 69
 
69 70
                 return Obj;
70 71
             }
72
+            */
71 73
 
72 74
             // ====================  OPERATORS     =======================
73 75
 

+ 18
- 0
Modules/FDEM1D/src/DipoleSource.cpp View File

@@ -291,6 +291,24 @@ namespace Lemma {
291 291
         return;
292 292
     }
293 293
 
294
+    void DipoleSource::SetupLight(const int& ifreq, const FIELDCALCULATIONS&  Fields, const int& irecin) {
295
+
296
+        xxp = Receivers->GetLocation(irec)[0] - Location[0];
297
+        yyp = Receivers->GetLocation(irec)[1] - Location[1];
298
+        rho = (Receivers->GetLocation(irec).head<2>() - Location.head<2>()).norm();
299
+
300
+        sp = yyp/rho;
301
+        cp = xxp/rho;
302
+        scp = sp*cp;
303
+        sps = sp*sp;
304
+        cps = cp*cp;
305
+        c2p = cps-sps;
306
+
307
+        return;
308
+    }
309
+
310
+
311
+
294 312
     // TODO we could make the dipoles template specializations avoiding this rats nest of switch statements. Probably
295 313
     //      not the most critical piece though
296 314
     void DipoleSource::ReSetKernels(const int& ifreq, const FIELDCALCULATIONS&  Fields ,

+ 9
- 2
Modules/FDEM1D/src/EMEarth1D.cpp View File

@@ -803,8 +803,15 @@ namespace Lemma {
803 803
 
804 804
         // Sort the dipoles by rho
805 805
         for (unsigned int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
806
-            auto tDipole = antenna->GetDipoleSource(idip);
807
-            tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
806
+            // Can we avoid these two lines, and instead vary the moment of the previous tDipole?
807
+            // SetKernels is somewhat heavy
808
+            auto rDipole = antenna->GetDipoleSource(idip);
809
+            //tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth); // expensive, and not used
810
+            tDipole->SetLocation( rDipole->GetLocation() );
811
+            tDipole->SetMoment( rDipole->GetMoment() );
812
+            tDipole->SetPolarisation( rDipole->GetPolarisation() );
813
+            tDipole->SetupLight( ifreq, FieldsToCalculate, irec );
814
+
808 815
             // Pass Hankel2 a message here so it knows which one to return in Zgauss!
809 816
             Real rho = (Receivers->GetLocation(irec).head<2>() - tDipole->GetLocation().head<2>()).norm();
810 817
             Hankel->SetLaggedArg( rho );

Loading…
Cancel
Save