Browse Source

Fix bug in QWEKey related to array bounds

add-code-of-conduct-1
Trevor Irons 6 years ago
parent
commit
d4eba3abbe
3 changed files with 16 additions and 9 deletions
  1. 1
    1
      CMakeLists.txt
  2. 11
    6
      Modules/FDEM1D/src/EMEarth1D.cpp
  3. 4
    2
      Modules/FDEM1D/src/QWEKey.cpp

+ 1
- 1
CMakeLists.txt View File

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

+ 11
- 6
Modules/FDEM1D/src/EMEarth1D.cpp View File

@@ -232,7 +232,8 @@ namespace Lemma {
232 232
             icalc += 1;
233 233
             // Check to see if they are all on a plane? If so we can do this fast
234 234
             if (Antenna->IsHorizontallyPlanar() && ( HankelType == ANDERSON801 || HankelType== FHTKEY201 || HankelType==FHTKEY101 ||
235
-                                                     HankelType == FHTKEY51 || HankelType == FHTKONG61 || FHTKONG121 || FHTKONG241 || IRONS )) {
235
+                                                     HankelType == FHTKEY51 || HankelType == FHTKONG61 || HankelType == FHTKONG121 ||
236
+                                                     HankelType == FHTKONG241 || HankelType == IRONS )) {
236 237
                 #ifdef HAVE_BOOST_PROGRESS
237 238
                 if (progressbar) {
238 239
                     disp = new boost::progress_display( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
@@ -260,10 +261,9 @@ namespace Lemma {
260 261
                     }
261 262
                     #endif
262 263
                 }
263
-            } else
264
-            if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
264
+            } else if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
265 265
 
266
-                //std::cout << "freq parallel #1" << std::endl;
266
+                std::cout << "freq parallel #1" << std::endl;
267 267
                 //** Progress display bar for long calculations */
268 268
                 #ifdef HAVE_BOOST_PROGRESS
269 269
                 if (progressbar) {
@@ -279,7 +279,8 @@ namespace Lemma {
279 279
                     // Since these antennas change we need a local copy for each
280 280
                     // thread.
281 281
                     auto AntCopy = static_cast<PolygonalWireAntenna*>(Antenna.get())->ClonePA();
282
-
282
+                    auto Hankel = HankelTransformFactory::NewSP( HankelType );
283
+/*
283 284
                     std::shared_ptr<HankelTransform> Hankel;
284 285
                     switch (HankelType) {
285 286
                         case ANDERSON801:
@@ -304,13 +305,14 @@ namespace Lemma {
304 305
                             Hankel = FHT<FHTKONG121>::NewSP();
305 306
                             break;
306 307
                         case QWEKEY:
308
+                            std::cout << "QWEKEY" << std::endl;
307 309
                             Hankel = QWEKey::NewSP();
308 310
                             break;
309 311
                         default:
310 312
                             std::cerr << "Hankel transform cannot be created\n";
311 313
                             exit(EXIT_FAILURE);
312 314
                     }
313
-
315
+*/
314 316
                     //for (int irec=tid; irec<Receivers->GetNumberOfPoints(); irec+=nthreads) {
315 317
                     #ifdef LEMMAUSEOMP
316 318
                     #pragma omp for schedule(static, 1) //nowait
@@ -753,6 +755,7 @@ namespace Lemma {
753 755
 
754 756
     void EMEarth1D::SolveSingleTxRxPair (const int &irec, HankelTransform *Hankel, const Real &wavef, const int &ifreq,
755 757
                    DipoleSource *tDipole) {
758
+        //std::cout << "SolveSingleTxRxPair" << std::endl;
756 759
         ++icalcinner;
757 760
         Real rho = (Receivers->GetLocation(irec).head<2>() - tDipole->GetLocation().head<2>()).norm();
758 761
         tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
@@ -772,6 +775,8 @@ namespace Lemma {
772 775
     void EMEarth1D::SolveLaggedTxRxPair(const int &irec, HankelTransform* Hankel,
773 776
                     const Real &wavef, const int &ifreq, PolygonalWireAntenna* antenna) {
774 777
 
778
+        //std::cout << "SolveLaggedTxRxPair" << std::endl;
779
+
775 780
         antenna->ApproximateWithElectricDipoles(Receivers->GetLocation(irec));
776 781
 
777 782
         // Determine the min and max arguments

+ 4
- 2
Modules/FDEM1D/src/QWEKey.cpp View File

@@ -141,7 +141,6 @@ namespace Lemma {
141 141
     //--------------------------------------------------------------------------------------
142 142
     void QWEKey::ComputeRelated ( const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManagerIn ) {
143 143
         KernelManager = KernelManagerIn;  // OK becauase this is internal and we know what we are doing
144
-
145 144
         Lambda = Bx.array()/rho;
146 145
         Intervals = xInt.array()/rho;
147 146
         int nrel = (int)(KernelManager->GetSTLVector().size());
@@ -270,7 +269,10 @@ namespace Lemma {
270 269
                     }
271 270
 
272 271
                     // The extrapolated result plus the prev integration term:
273
-                    Textrap(j,n) = TS(j, (n-1)%2)+prev(0, j);
272
+                    if (n>0) {
273
+                        Textrap(j,n) = TS(j, (n-1)%2)+prev(0, j); // WAS  BUG
274
+                    }
275
+                    //Textrap(j,n) = TS(j, (n-1)%2 + 1)+prev(0, j);
274 276
                     //Textrap(j,n) = TS(j, n%2 + 1)+prev(0, j);
275 277
 
276 278
                     // Step 3: Analyze for convergence:

Loading…
Cancel
Save