Browse Source

Bug fix for Anderson lagged solution which would occasionally result in NaN due to array index overrun in spline. Also work towards grounding points in wire antenna.

master
Trevor Irons 4 years ago
parent
commit
32f3339fff

+ 4
- 4
CMake/SuperBuild.cmake View File

41
     )
41
     )
42
 endif()
42
 endif()
43
 
43
 
44
-if ( LEMMA_VTK8_SUPPORT )
45
-    if ( NOT VTK_FOUND OR  VTK_VERSION VERSION_GREATER "8.2.0" )
44
+if ( LEMMA_VTK9_SUPPORT )
45
+    if ( NOT VTK_FOUND OR  VTK_VERSION VERSION_LESS "9.0.0" )
46
         message( STATUS "VTK > 8.20.0 was found! Version found: " ${VTK_VERSION}, ${VTK_USE_FILE} )
46
         message( STATUS "VTK > 8.20.0 was found! Version found: " ${VTK_VERSION}, ${VTK_USE_FILE} )
47
         message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
47
         message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
48
-        ExternalProject_Add(VTK8
48
+        ExternalProject_Add(VTK9
49
         GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
49
         GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
50
-        GIT_TAG  "v8.2.0"
50
+        GIT_TAG  "v9.0.1"
51
         PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
51
         PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
52
         CMAKE_ARGS
52
         CMAKE_ARGS
53
             -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
53
             -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}

+ 33
- 10
CMakeLists.txt View File

47
 option ( LEMMA_USE_OPENMP           "Use OpenMP in Lemma" OFF )
47
 option ( LEMMA_USE_OPENMP           "Use OpenMP in Lemma" OFF )
48
 option ( LEMMA_BUILD_DOCUMENTATION  "Build Doxygen man pages" OFF )
48
 option ( LEMMA_BUILD_DOCUMENTATION  "Build Doxygen man pages" OFF )
49
 option ( LEMMA_VTK8_SUPPORT         "VTK 8.x library for visualisation and grids" OFF )
49
 option ( LEMMA_VTK8_SUPPORT         "VTK 8.x library for visualisation and grids" OFF )
50
+option ( LEMMA_VTK9_SUPPORT         "VTK 9.x library for visualisation and grids" OFF )
50
 option ( LEMMA_PYTHON3_BINDINGS     "Compile Python 3 bindings" OFF )
51
 option ( LEMMA_PYTHON3_BINDINGS     "Compile Python 3 bindings" OFF )
51
 
52
 
52
 # We end up using this for all builds, TODO remove this variable but follow same path
53
 # We end up using this for all builds, TODO remove this variable but follow same path
99
         QUIET
100
         QUIET
100
         ) 
101
         ) 
101
     endif()
102
     endif()
103
+    if (LEMMA_VTK9_SUPPORT)                                                            # Visualisation 
104
+        find_package (VTK  9.0.1      
105
+        COMPONENTS 
106
+        CommonCore 
107
+        RenderingCore 
108
+        FiltersCore 
109
+        FiltersSources 
110
+        CommonDataModel 
111
+        FiltersHyperTree 
112
+        IOXML 
113
+        IOImage 
114
+        IOLegacy 
115
+        IOGeometry 
116
+        InteractionStyle 
117
+        RenderingAnnotation 
118
+        FiltersHybrid 
119
+        FiltersModeling 
120
+        RenderingVolumeOpenGL2
121
+        QUIET
122
+        ) 
123
+    endif()
102
 else()
124
 else()
103
     find_package (Eigen3   3.3 QUIET )  # Matrix/Vector & Math
125
     find_package (Eigen3   3.3 QUIET )  # Matrix/Vector & Math
104
     find_package (yaml-cpp 0.6 QUIET )  # Serialisation of classes 
126
     find_package (yaml-cpp 0.6 QUIET )  # Serialisation of classes 
105
-    if (LEMMA_VTK8_SUPPORT)
106
-        find_package (VTK  8.2.0 COMPONENTS
127
+    if (LEMMA_VTK9_SUPPORT)
128
+        find_package (VTK  9.0.1 COMPONENTS
107
         vtkCommonCore 
129
         vtkCommonCore 
108
         vtkRenderingCore 
130
         vtkRenderingCore 
109
         vtkFiltersCore 
131
         vtkFiltersCore 
125
 
147
 
126
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
148
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
127
 
149
 
128
-if (VTK_VERSION VERSION_GREATER "8.2.0")
129
-    message( STATUS "${VTK_VERSION} is compatible: ${VTK_VERSION_COMPATIBLE} exact? ${VTK_VERSION_EXACT}" )
130
-    set (VTK_FOUND False) 
131
-endif()
150
+#if (VTK_VERSION VERSION_GREATER "8.2.0")
151
+#    message( STATUS "${VTK_VERSION} is compatible: ${VTK_VERSION_COMPATIBLE} exact? ${VTK_VERSION_EXACT}" )
152
+#    set (VTK_FOUND False) 
153
+#endif()
132
 
154
 
133
 if (VTK_FOUND)
155
 if (VTK_FOUND)
134
     set(volumeRenderer volumerenderer.cxx)
156
     set(volumeRenderer volumerenderer.cxx)
160
 if ( NOT Eigen3_FOUND OR 
182
 if ( NOT Eigen3_FOUND OR 
161
      NOT yaml-cpp_FOUND OR 
183
      NOT yaml-cpp_FOUND OR 
162
      (LEMMA_PYTHON3_BINDINGS AND NOT pybind11_FOUND) OR 
184
      (LEMMA_PYTHON3_BINDINGS AND NOT pybind11_FOUND) OR 
163
-     (LEMMA_VTK8_SUPPORT AND NOT VTK_FOUND) OR
185
+     (LEMMA_VTK9_SUPPORT AND NOT VTK_FOUND) OR
164
      (LEMMA_ENABLE_TESTING AND NOT CxxTest_FOUND) )
186
      (LEMMA_ENABLE_TESTING AND NOT CxxTest_FOUND) )
165
     message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
187
     message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
166
     message ( STATUS "This necessitates a two step build." )
188
     message ( STATUS "This necessitates a two step build." )
354
 ########################################################################
376
 ########################################################################
355
 # add a target to generate API documentation with Doxyfile.in 
377
 # add a target to generate API documentation with Doxyfile.in 
356
 # ALL make documentation build by default if possible
378
 # ALL make documentation build by default if possible
357
-find_package(Doxygen)
379
+if (LEMMA_BUILD_DOCUMENTATION)
380
+    find_package(Doxygen)
358
 	if(DOXYGEN_FOUND)
381
 	if(DOXYGEN_FOUND)
359
-	if (LEMMA_BUILD_DOCUMENTATION)
382
+    message( STATUS "LEMMA_BUILD_DOCUMENTATION must be positive" )
360
 # Custom header and footer option, enable in Doxygen 
383
 # Custom header and footer option, enable in Doxygen 
361
 #	file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/header.html
384
 #	file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/header.html
362
 #        DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/header.html
385
 #        DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/header.html
371
 			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
394
 			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
372
 			COMMENT "Generating API documentation with Doxygen" VERBATIM
395
 			COMMENT "Generating API documentation with Doxygen" VERBATIM
373
 		)
396
 		)
374
-	endif (LEMMA_BUILD_DOCUMENTATION)
375
 	endif(DOXYGEN_FOUND)
397
 	endif(DOXYGEN_FOUND)
398
+endif (LEMMA_BUILD_DOCUMENTATION)
376
 
399
 
377
 # vim: set tabstop=4 shiftwidth=4 expandtab: 
400
 # vim: set tabstop=4 shiftwidth=4 expandtab: 

+ 5
- 0
Modules/FDEM1D/CMakeLists.txt View File

10
     CXX_STANDARD_REQUIRED ON
10
     CXX_STANDARD_REQUIRED ON
11
 )
11
 )
12
 
12
 
13
+if ( LEMMA_VTK9_SUPPORT ) 
14
+	target_link_libraries(fdem1d ${visibility}VTK::RenderingCore VTK::CommonDataModel)
15
+	vtk_module_autoinit(TARGETS fdem1d MODULES VTK::RenderingCore)
16
+endif()
17
+
13
 # Linking
18
 # Linking
14
 target_link_libraries(fdem1d "lemmacore")
19
 target_link_libraries(fdem1d "lemmacore")
15
 target_link_libraries(fdem1d ${YAML_CPP_LIBRARIES}) 
20
 target_link_libraries(fdem1d ${YAML_CPP_LIBRARIES}) 

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

1338
         static bool called = false;
1338
         static bool called = false;
1339
         if (!called) {
1339
         if (!called) {
1340
             std::cout << "WARNING\n";
1340
             std::cout << "WARNING\n";
1341
-            std::cout << "Unspecialised PotentialBelowSourceLayer <" << Mode << " " << Ikernel << " "
1341
+            std::cout << "Unspecialised RelPotentialBelowSourceLayer <" << Mode << " " << Ikernel << " "
1342
                   << Isource << " " << Irecv << ">...this function will be slow\n\n";
1342
                   << Isource << " " << Irecv << ">...this function will be slow\n\n";
1343
             called = true;
1343
             called = true;
1344
         }
1344
         }

+ 6
- 0
Modules/FDEM1D/include/PolygonalWireAntenna.h View File

118
             /// Maximum dipole moment allowed
118
             /// Maximum dipole moment allowed
119
             Real maxDipoleMoment;
119
             Real maxDipoleMoment;
120
 
120
 
121
+            /// Adds grounding point to non-closed wire loop
122
+            void AddGroundingPoint(
123
+                            const Vector3r &cp,
124
+                            const Vector3r &dir,
125
+                            std::vector< std::shared_ptr<DipoleSource> > &Dipoles );
126
+
121
             /// appends
127
             /// appends
122
             void PushXYZDipoles( const Vector3r &step, const Vector3r &cp,
128
             void PushXYZDipoles( const Vector3r &step, const Vector3r &cp,
123
                             const Vector3r &dir,
129
                             const Vector3r &dir,

+ 2
- 2
Modules/FDEM1D/python/pyFDEM1D.cpp View File

249
         // modifiers
249
         // modifiers
250
         .def("AttachWireAntenna", &Lemma::EMEarth1D::AttachWireAntenna,
250
         .def("AttachWireAntenna", &Lemma::EMEarth1D::AttachWireAntenna,
251
             "Sets the wire antenna to use for calculations")
251
             "Sets the wire antenna to use for calculations")
252
-        .def("AttachDipoleSOurce", &Lemma::EMEarth1D::AttachDipoleSource,
252
+        .def("AttachDipoleSource", &Lemma::EMEarth1D::AttachDipoleSource,
253
             "Sets a DipoleSource to use for calculations")
253
             "Sets a DipoleSource to use for calculations")
254
         .def("AttachFieldPoints", &Lemma::EMEarth1D::AttachFieldPoints,
254
         .def("AttachFieldPoints", &Lemma::EMEarth1D::AttachFieldPoints,
255
             "Sets the FieldPoints to use for calculations")
255
             "Sets the FieldPoints to use for calculations")
256
         .def("AttachLayeredEarthEM", &Lemma::EMEarth1D::AttachLayeredEarthEM,
256
         .def("AttachLayeredEarthEM", &Lemma::EMEarth1D::AttachLayeredEarthEM,
257
             "Sets the LayeredEarthEM to use for calculations")
257
             "Sets the LayeredEarthEM to use for calculations")
258
 
258
 
259
-        .def("SetFieldToCalculate", &Lemma::EMEarth1D::SetFieldsToCalculate,
259
+        .def("SetFieldsToCalculate", &Lemma::EMEarth1D::SetFieldsToCalculate,
260
             "Sets which fields to calculate")
260
             "Sets which fields to calculate")
261
         .def("SetHankelTransformMethod", &Lemma::EMEarth1D::SetHankelTransformMethod,
261
         .def("SetHankelTransformMethod", &Lemma::EMEarth1D::SetHankelTransformMethod,
262
             "Sets which Hankel transform to use")
262
             "Sets which Hankel transform to use")

+ 301
- 7
Modules/FDEM1D/src/DipoleSource.cpp View File

183
             case (UNGROUNDEDELECTRICDIPOLE):
183
             case (UNGROUNDEDELECTRICDIPOLE):
184
                 this->Type = stype;
184
                 this->Type = stype;
185
                 break;
185
                 break;
186
+            case (GROUNDINGPOINT):
187
+                this->Type = stype;
188
+                break;
186
             case (MAGNETICDIPOLE):
189
             case (MAGNETICDIPOLE):
187
                 this->Type = stype;
190
                 this->Type = stype;
188
                 break;
191
                 break;
485
                     }
488
                     }
486
                 break;
489
                 break;
487
 
490
 
491
+            case (GROUNDINGPOINT):
492
+
493
+                if (std::abs(Pol[2]) > 0) { // z dipole
494
+
495
+                    switch(FieldsToCalculate) {
496
+
497
+                        case E:
498
+                            if (lays == 0 && layr == 0) {
499
+                                ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INAIR>( );
500
+                                ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INAIR>( );
501
+                            } else if (lays == 0 && layr > 0) {
502
+                                ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INGROUND>( );
503
+                                ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INGROUND>( );
504
+                            } else if (lays > 0 && layr == 0) {
505
+                                ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INAIR>( );
506
+                                ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INAIR>( );
507
+                            } else {
508
+                                ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INGROUND>( );
509
+                                ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INGROUND>( );
510
+                            }
511
+                            break;
512
+
513
+                        case H:
514
+                            if (lays == 0 && layr == 0) {
515
+                                ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INAIR>( );
516
+                            } else if (lays == 0 && layr > 0) {
517
+                                ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INGROUND>( );
518
+                            } else if (lays > 0 && layr == 0) {
519
+                                ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INAIR>( );
520
+                            } else {
521
+                                ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INGROUND>( );
522
+                            }
523
+                            break;
524
+
525
+
526
+                        case BOTH:
527
+                            if ( lays == 0 && layr == 0) {
528
+                                ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INAIR>( );
529
+                                ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INAIR>( );
530
+                                ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INAIR>( );
531
+                            } else if (lays == 0 && layr > 0) {
532
+                                ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INGROUND>( );
533
+                                ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INGROUND>( );
534
+                                ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INGROUND>( );
535
+                            } else if (lays > 0 && layr == 0) {
536
+                                ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INAIR>( );
537
+                                ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INAIR>( );
538
+                                ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INAIR>( );
539
+                            } else {
540
+                                ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INGROUND>( );
541
+                                ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INGROUND>( );
542
+                                ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INGROUND>( );
543
+                            }
544
+                        }
545
+                }
546
+                if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y grounded HED dipole
547
+
548
+                    switch(FieldsToCalculate) {
549
+
550
+                        case E:
551
+                            if ( lays == 0 && layr == 0) {
552
+                                ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INAIR>( );
553
+                                ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INAIR>( );
554
+                                ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INAIR>( );
555
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INAIR>( );
556
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INAIR>( );
557
+                            } else if (lays == 0 && layr > 0) {
558
+                                ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INGROUND>( );
559
+                                ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INGROUND>( );
560
+                                ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INGROUND>( );
561
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INGROUND>( );
562
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INGROUND>( );
563
+                            } else if (lays > 0 && layr == 0) {
564
+                                ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INAIR>( );
565
+                                ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INAIR>( );
566
+                                ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INAIR>( );
567
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INAIR>( );
568
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INAIR>( );
569
+                            } else {
570
+                                ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INGROUND>( );
571
+                                ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INGROUND>( );
572
+                                ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INGROUND>( );
573
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INGROUND>( );
574
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INGROUND>( );
575
+                            }
576
+                            break;
577
+
578
+                        case H:
579
+                            if (lays == 0 && layr == 0) {
580
+                                ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INAIR>( );
581
+                                ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INAIR>( );
582
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INAIR>( );
583
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INAIR>( );
584
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INAIR>( );
585
+                            } else if (lays == 0 && layr > 0) {
586
+                                ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INGROUND>( );
587
+                                ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INGROUND>( );
588
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INGROUND>( );
589
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INGROUND>( );
590
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INGROUND>( );
591
+                            } else if (lays > 0 && layr == 0) {
592
+                                ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INAIR>( );
593
+                                ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INAIR>( );
594
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INAIR>( );
595
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INAIR>( );
596
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INAIR>( );
597
+                            } else {
598
+                                ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INGROUND>( );
599
+                                ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INGROUND>( );
600
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INGROUND>( );
601
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INGROUND>( );
602
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INGROUND>( );
603
+                            }
604
+                            break;
605
+
606
+                        case BOTH:
607
+                            if (lays == 0 && layr == 0) {
608
+                                ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INAIR>( );
609
+                                ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INAIR>( );
610
+                                ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INAIR>( );
611
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INAIR>( );
612
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INAIR>( );
613
+                                ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INAIR>( );
614
+                                ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INAIR>( );
615
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INAIR>( );
616
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INAIR>( );
617
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INAIR>( );
618
+                            } else if (lays == 0 && layr > 0) {
619
+                                ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INGROUND>( );
620
+                                ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INGROUND>( );
621
+                                ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INGROUND>( );
622
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INGROUND>( );
623
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INGROUND>( );
624
+                                ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INGROUND>( );
625
+                                ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INGROUND>( );
626
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INGROUND>( );
627
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INGROUND>( );
628
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INGROUND>( );
629
+                            } else if (lays > 0 && layr == 0) {
630
+                                ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INAIR>( );
631
+                                ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INAIR>( );
632
+                                ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INAIR>( );
633
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INAIR>( );
634
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INAIR>( );
635
+                                ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INAIR>( );
636
+                                ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INAIR>( );
637
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INAIR>( );
638
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INAIR>( );
639
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INAIR>( );
640
+                            } else {
641
+                                ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INGROUND>( );
642
+                                ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INGROUND>( );
643
+                                ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INGROUND>( );
644
+                                //ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INGROUND>( );
645
+                                //ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INGROUND>( );
646
+                                ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INGROUND>( );
647
+                                ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INGROUND>( );
648
+                                //ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INGROUND>( );
649
+                                //ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INGROUND>( );
650
+                                //ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INGROUND>( );
651
+                            }
652
+                            break;
653
+                        }
654
+                    }
655
+                break;
656
+
488
             case (UNGROUNDEDELECTRICDIPOLE):
657
             case (UNGROUNDEDELECTRICDIPOLE):
489
 
658
 
490
                 if (std::abs(Pol[2]) > 0) { // z dipole
659
                 if (std::abs(Pol[2]) > 0) { // z dipole
786
                 exit(EXIT_FAILURE);
955
                 exit(EXIT_FAILURE);
787
 
956
 
788
         }
957
         }
789
-
790
-
791
     }
958
     }
792
 
959
 
793
     void DipoleSource::UpdateFields( const int& ifreq, HankelTransform* Hankel, const Real& wavef) {
960
     void DipoleSource::UpdateFields( const int& ifreq, HankelTransform* Hankel, const Real& wavef) {
874
                                     Pol[0]*Moment*QPI*sp*f(9) );
1041
                                     Pol[0]*Moment*QPI*sp*f(9) );
875
                             }
1042
                             }
876
                             break;
1043
                             break;
1044
+
877
                         case BOTH:
1045
                         case BOTH:
878
                             f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
1046
                             f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
879
                             f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
1047
                             f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
913
                 }
1081
                 }
914
                 break; // GROUNDEDELECTRICDIPOLE
1082
                 break; // GROUNDEDELECTRICDIPOLE
915
 
1083
 
1084
+            case (GROUNDINGPOINT):
1085
+                if (std::abs(Pol[2]) > 0) { // z dipole
1086
+                    switch(FieldsToCalculate) {
1087
+                        case E:
1088
+                            f(10) = Hankel->Zgauss(10, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10])) / KernelManager->GetRAWKernel(ik[10])->GetYm();
1089
+                            f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
1090
+                            this->Receivers->AppendEfield(ifreq, irec,
1091
+                                -Pol[2]*QPI*cp*f(10)*Moment,
1092
+                                -Pol[2]*QPI*sp*f(10)*Moment,
1093
+                                 Pol[2]*QPI*f(11)*Moment);
1094
+                            break;
1095
+
1096
+                        case H:
1097
+                            f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
1098
+                            this->Receivers->AppendHfield(ifreq, irec,
1099
+                                -Pol[2]*QPI*sp*f(12)*Moment,
1100
+                                 Pol[2]*QPI*cp*f(12)*Moment,
1101
+                                 0. );
1102
+                            break;
1103
+
1104
+                        case BOTH:
1105
+                            f(10) = Hankel->Zgauss(10, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10])) / KernelManager->GetRAWKernel(ik[10])->GetYm();
1106
+                            f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
1107
+                            this->Receivers->AppendEfield(ifreq, irec,
1108
+                                    -Pol[2]*QPI*cp*f(10)*Moment,
1109
+                                    -Pol[2]*QPI*sp*f(10)*Moment,
1110
+                                     Pol[2]*QPI*f(11)*Moment   );
1111
+
1112
+                            f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
1113
+                            this->Receivers->AppendHfield(ifreq, irec,
1114
+                                    -Pol[2]*QPI*sp*f(12)*Moment,
1115
+                                     Pol[2]*QPI*cp*f(12)*Moment,
1116
+                                     0. );
1117
+                    } // Fields to calculate Z polarity Electric dipole
1118
+                }
1119
+                if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y dipole
1120
+                    switch(FieldsToCalculate) {
1121
+                        case E:
1122
+                            f(2) = 0;//Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
1123
+                            f(3) = 0;//Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
1124
+                            f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
1125
+                            f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
1126
+                            f(4) = Hankel->Zgauss(4, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4])) / KernelManager->GetRAWKernel(ik[4])->GetYm();
1127
+                            if (std::abs(Pol[1]) > 0) {
1128
+                                this->Receivers->AppendEfield(ifreq, irec,
1129
+                                    0,0,0);
1130
+                                    //Pol[1]*QPI*Moment*scp*(f(0)+f(2)),
1131
+                                    //Pol[1]*QPI*Moment*((sps*f(0)+c2p*f(1)/rho)),
1132
+                                    //Pol[1]*QPI*Moment*(f(0)+f(2)),
1133
+                                    //Pol[1]*QPI*Moment*((f(0)+f(1)/rho)),
1134
+                                    //Pol[1]*QPI*sp*f(4)*Moment);
1135
+                                    // std dipole
1136
+                                    //Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment ,
1137
+                                    //Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
1138
+                                    //Pol[1]*QPI*sp*f(4)*Moment);
1139
+                            }
1140
+                            if (std::abs(Pol[0]) > 0) {
1141
+                                this->Receivers->AppendEfield(ifreq, irec,
1142
+                                    Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)),          //-(sps*f(2)+c2p*f(3)/rho)),
1143
+                                    Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)),   //+(f(2)-(Real)(2.)*f(3)/rho)),
1144
+                                    Pol[0]*Moment*QPI*cp*f(4) );
1145
+                            }
1146
+                            break;
1147
+                        case H:
1148
+                            f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
1149
+                            f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
1150
+                            f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
1151
+                            f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
1152
+                            f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
1153
+                            if (std::abs(Pol[1]) > 0) {
1154
+                                this->Receivers->AppendHfield(ifreq, irec,
1155
+                                        Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
1156
+                                        Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
1157
+                                        -Pol[1]*QPI*cp*f(9)*Moment );
1158
+                            }
1159
+                            if (std::abs(Pol[0]) > 0) {
1160
+                                this->Receivers->AppendHfield(ifreq, irec,
1161
+                                    Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
1162
+                                    Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
1163
+                                    Pol[0]*Moment*QPI*sp*f(9) );
1164
+                            }
1165
+                            break;
1166
+
1167
+                        case BOTH:
1168
+                            f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
1169
+                            f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
1170
+                            f(4) = Hankel->Zgauss(4, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4])) / KernelManager->GetRAWKernel(ik[4])->GetYm();
1171
+                            f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
1172
+                            f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
1173
+                            f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
1174
+                            f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
1175
+                            f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
1176
+                            f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
1177
+                            f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
1178
+
1179
+                            if (std::abs(Pol[1]) > 0) {
1180
+                                this->Receivers->AppendEfield(ifreq, irec,
1181
+                                        Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment ,
1182
+                                        Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
1183
+                                        Pol[1]*QPI*sp*f(4)*Moment);
1184
+
1185
+                                this->Receivers->AppendHfield(ifreq, irec,
1186
+                                        Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
1187
+                                        Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
1188
+                                       -Pol[1]*QPI*cp*f(9)*Moment );
1189
+                            }
1190
+                            if (std::abs(Pol[0]) > 0) {
1191
+                                this->Receivers->AppendEfield(ifreq, irec,
1192
+                                    Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
1193
+                                    Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
1194
+                                    Pol[0]*Moment*QPI*cp*f(4) );
1195
+
1196
+                                this->Receivers->AppendHfield(ifreq, irec,
1197
+                                    Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
1198
+                                    Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
1199
+                                    Pol[0]*Moment*QPI*sp*f(9) );
1200
+                            }
1201
+                            break;
1202
+                    }
1203
+                }
1204
+                break; // GROUNDINGPOINT
1205
+
916
 
1206
 
917
             case UNGROUNDEDELECTRICDIPOLE:
1207
             case UNGROUNDEDELECTRICDIPOLE:
918
 
1208
 
955
 
1245
 
956
                     switch(FieldsToCalculate) {
1246
                     switch(FieldsToCalculate) {
957
                         case E:
1247
                         case E:
958
-                            f(0) = 0;
959
-                            f(1) = 0;
1248
+                            //f(0) = 0;
1249
+                            //f(1) = 0;
1250
+                            //f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
1251
+                            //f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
1252
+                            //f(4) = 0;
960
                             f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
1253
                             f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
961
                             f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
1254
                             f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
962
-                            f(4) = 0;
1255
+                            f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
1256
+                            f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
1257
+                            f(4) = Hankel->Zgauss(4, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4])) / KernelManager->GetRAWKernel(ik[4])->GetYm();
963
                             if (std::abs(Pol[1]) > 0) {
1258
                             if (std::abs(Pol[1]) > 0) {
964
                                 this->Receivers->AppendEfield(ifreq, irec,
1259
                                 this->Receivers->AppendEfield(ifreq, irec,
965
                                     Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment,
1260
                                     Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment,
984
                                 this->Receivers->AppendHfield(ifreq, irec,
1279
                                 this->Receivers->AppendHfield(ifreq, irec,
985
                                         Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
1280
                                         Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
986
                                         Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
1281
                                         Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
987
-                                        -Pol[1]*QPI*cp*f(9)*Moment );
1282
+                                       -Pol[1]*QPI*cp*f(9)*Moment );
988
                             }
1283
                             }
989
                             if (std::abs(Pol[0]) > 0) {
1284
                             if (std::abs(Pol[0]) > 0) {
990
                                 this->Receivers->AppendHfield(ifreq, irec,
1285
                                 this->Receivers->AppendHfield(ifreq, irec,
1036
                 break; // UNGROUNDEDELECTRICDIPOLE
1331
                 break; // UNGROUNDEDELECTRICDIPOLE
1037
 
1332
 
1038
             case MAGNETICDIPOLE:
1333
             case MAGNETICDIPOLE:
1039
-
1040
                 //Hankel->ComputeRelated(rho, KernelManager);
1334
                 //Hankel->ComputeRelated(rho, KernelManager);
1041
                 if (std::abs(Pol[2]) > 0) { // z dipole
1335
                 if (std::abs(Pol[2]) > 0) { // z dipole
1042
                     switch(FieldsToCalculate) {
1336
                     switch(FieldsToCalculate) {

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

72
     // TODO init large arrays here.
72
     // TODO init large arrays here.
73
     EMEarth1D::EMEarth1D( const ctor_key& key ) : LemmaObject( key ),
73
     EMEarth1D::EMEarth1D( const ctor_key& key ) : LemmaObject( key ),
74
             Dipole(nullptr), Earth(nullptr), Receivers(nullptr), Antenna(nullptr),
74
             Dipole(nullptr), Earth(nullptr), Receivers(nullptr), Antenna(nullptr),
75
-            FieldsToCalculate(BOTH), HankelType(ANDERSON801), icalcinner(0), icalc(0)
76
-        {
75
+            FieldsToCalculate(BOTH), HankelType(ANDERSON801), icalcinner(0), icalc(0) {
77
     }
76
     }
78
 
77
 
79
     EMEarth1D::~EMEarth1D() {
78
     EMEarth1D::~EMEarth1D() {
107
     // ====================  ACCESS        ===================================
106
     // ====================  ACCESS        ===================================
108
     void EMEarth1D::AttachDipoleSource( std::shared_ptr<DipoleSource> dipoleptr) {
107
     void EMEarth1D::AttachDipoleSource( std::shared_ptr<DipoleSource> dipoleptr) {
109
         Dipole = dipoleptr;
108
         Dipole = dipoleptr;
110
-    }
111
-
112
-    void EMEarth1D::AttachLayeredEarthEM( std::shared_ptr<LayeredEarthEM> earthptr) {
113
-        Earth = earthptr;
109
+        if (Receivers != nullptr) {
110
+            // Check to make sure Receivers are set up for all calculations
111
+            switch(FieldsToCalculate) {
112
+                case E:
113
+                    if (Receivers->NumberOfBinsE != Dipole->GetNumberOfFrequencies())
114
+                        Receivers->SetNumberOfBinsE(Dipole->GetNumberOfFrequencies());
115
+                    break;
116
+                case H:
117
+                    if (Receivers->NumberOfBinsH != Dipole->GetNumberOfFrequencies())
118
+                        Receivers->SetNumberOfBinsH(Dipole->GetNumberOfFrequencies());
119
+                    break;
120
+                case BOTH:
121
+                    if (Receivers->NumberOfBinsH != Dipole->GetNumberOfFrequencies())
122
+                        Receivers->SetNumberOfBinsH(Dipole->GetNumberOfFrequencies());
123
+                    if (Receivers->NumberOfBinsE != Dipole->GetNumberOfFrequencies())
124
+                        Receivers->SetNumberOfBinsE(Dipole->GetNumberOfFrequencies());
125
+                    break;
126
+            }
127
+        }
114
     }
128
     }
115
 
129
 
116
     void EMEarth1D::AttachFieldPoints( std::shared_ptr<FieldPoints> recptr) {
130
     void EMEarth1D::AttachFieldPoints( std::shared_ptr<FieldPoints> recptr) {
117
 
131
 
118
         Receivers = recptr;
132
         Receivers = recptr;
119
         if (Receivers == nullptr) {
133
         if (Receivers == nullptr) {
120
-            std::cout << "nullptr Receivers in emearth1d.cpp " << std::endl;
134
+            std::cerr << "nullptr Receivers in emearth1d.cpp " << std::endl;
121
             return;
135
             return;
122
         }
136
         }
123
 
137
 
124
-        // This has an implicid need to first set a source before receivers, users
138
+        // This has an implicit need to first set a source before receivers, users
125
         // will not expect this. Fix
139
         // will not expect this. Fix
126
         if (Dipole != nullptr) {
140
         if (Dipole != nullptr) {
127
             switch (FieldsToCalculate) {
141
             switch (FieldsToCalculate) {
152
         }
166
         }
153
     }
167
     }
154
 
168
 
169
+    void EMEarth1D::AttachLayeredEarthEM( std::shared_ptr<LayeredEarthEM> earthptr) {
170
+        Earth = earthptr;
171
+    }
172
+
155
     void EMEarth1D::AttachWireAntenna(std::shared_ptr<WireAntenna> antennae) {
173
     void EMEarth1D::AttachWireAntenna(std::shared_ptr<WireAntenna> antennae) {
156
         this->Antenna = antennae;
174
         this->Antenna = antennae;
157
     }
175
     }
227
             if ( Antenna->IsHorizontallyPlanar() && ( HankelType == ANDERSON801 || HankelType == FHTKEY201  || HankelType==FHTKEY101 ||
245
             if ( Antenna->IsHorizontallyPlanar() && ( HankelType == ANDERSON801 || HankelType == FHTKEY201  || HankelType==FHTKEY101 ||
228
                                                       HankelType == FHTKEY51    || HankelType == FHTKONG61  || HankelType == FHTKONG121 ||
246
                                                       HankelType == FHTKEY51    || HankelType == FHTKONG61  || HankelType == FHTKONG121 ||
229
                                                       HankelType == FHTKONG241  || HankelType == IRONS )) {
247
                                                       HankelType == FHTKONG241  || HankelType == IRONS )) {
248
+
230
                 std::unique_ptr<ProgressBar> mdisp;
249
                 std::unique_ptr<ProgressBar> mdisp;
231
                 if (progressbar) {
250
                 if (progressbar) {
232
                     mdisp = std::make_unique< ProgressBar >( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
251
                     mdisp = std::make_unique< ProgressBar >( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
255
                     #endif
274
                     #endif
256
                 }
275
                 }
257
 
276
 
258
-
259
             } else if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
277
             } else if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
260
 
278
 
261
                 //** Progress display bar for long calculations */
279
                 //** Progress display bar for long calculations */

+ 2
- 3
Modules/FDEM1D/src/FHTAnderson801.cpp View File

940
         icount = 0;
940
         icount = 0;
941
         Manager = KernelManager;
941
         Manager = KernelManager;
942
         this->kernelVec = KernelManager->GetSTLVector();
942
         this->kernelVec = KernelManager->GetSTLVector();
943
-        this->SetNumConv(nlag);
943
+        this->SetNumConv(nlag+1);
944
+
944
 #ifdef LEMMA_SINGLE_PRECISION
945
 #ifdef LEMMA_SINGLE_PRECISION
945
  		Compute(rho, 1, 1e-8);
946
  		Compute(rho, 1, 1e-8);
946
 #else
947
 #else
958
             SplineI->SetKnots( Arg, Zans.col(ii).imag() );
959
             SplineI->SetKnots( Arg, Zans.col(ii).imag() );
959
             splineVecImag.push_back(SplineI);
960
             splineVecImag.push_back(SplineI);
960
         }
961
         }
961
-
962
     }
962
     }
963
 
963
 
964
     void FHTAnderson801::SetLaggedArg(const Real& rho) {
964
     void FHTAnderson801::SetLaggedArg(const Real& rho) {
998
         // in release.
998
         // in release.
999
         #ifndef NDEBUG
999
         #ifndef NDEBUG
1000
 		if (rho<=0) {
1000
 		if (rho<=0) {
1001
-            //std::cout << "rho= " << rho << std::endl;
1002
 			throw std::runtime_error("In Hankel 2 Argument rho <= 0; rho=" + to_string(rho) );
1001
 			throw std::runtime_error("In Hankel 2 Argument rho <= 0; rho=" + to_string(rho) );
1003
 		}
1002
 		}
1004
 
1003
 

+ 42
- 7
Modules/FDEM1D/src/PolygonalWireAntenna.cpp View File

117
 	// ====================  OPERATIONS    =======================
117
 	// ====================  OPERATIONS    =======================
118
 
118
 
119
 	void PolygonalWireAntenna::ApproximateWithElectricDipoles(const Vector3r &rp) {
119
 	void PolygonalWireAntenna::ApproximateWithElectricDipoles(const Vector3r &rp) {
120
+
120
         // Only resplit if necessary. Save a few cycles if repeated
121
         // Only resplit if necessary. Save a few cycles if repeated
121
         if ( (rRepeat-rp).norm() > 1e-16 ) {
122
         if ( (rRepeat-rp).norm() > 1e-16 ) {
122
-		    Dipoles.clear();
123
+
124
+            Dipoles.clear();
123
 
125
 
124
             ///////////////////
126
             ///////////////////
125
 		    // dipole array, this has impoved performance over directly pushing
127
 		    // dipole array, this has impoved performance over directly pushing
126
 		    std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
128
 		    std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
127
 
129
 
128
-		    // loop over all segments
130
+            // check to see if loop is closed
131
+            /*
132
+            int lastPoint = Points.cols()-1;
133
+            if ( (Points.col(0) - Points.col(lastPoint)).norm() > 1e-3 ) {
134
+                AddGroundingPoint( Points.col(0), Points.col(1)-Points.col(0), xDipoles );
135
+            }
136
+            */
137
+
138
+		    // loop over all segments, TODO fix for closed loops
129
 		    int iseg;
139
 		    int iseg;
130
-            for (iseg=0; iseg<NumberOfPoints-1; ++iseg) {
140
+            for (iseg=0; iseg<NumberOfPoints-1; ++iseg) { // closed loop
141
+            //for (iseg=1; iseg<NumberOfPoints-2; ++iseg) { // grounded wire
131
 			    InterpolateLineSegment(Points.col(iseg), Points.col(iseg+1), rp, xDipoles);
142
 			    InterpolateLineSegment(Points.col(iseg), Points.col(iseg+1), rp, xDipoles);
132
 		    }
143
 		    }
133
 
144
 
134
-            // Check to see if the loop is closed, if not, assume its grounded on ends,
135
-            if ( (Points.col(0)-Points.col(iseg)).norm() > 1e-3 ) {
136
-                xDipoles[0]->SetType(GROUNDEDELECTRICDIPOLE);
137
-                xDipoles.back()->SetType(GROUNDEDELECTRICDIPOLE);
145
+            // check to see if loop is closed
146
+            /*
147
+            if ( (Points.col(lastPoint)-Points.col( lastPoint-1 )).norm() > 1e-3 ) {
148
+                AddGroundingPoint( Points.col(lastPoint), Points.col(lastPoint)-Points.col(lastPoint-1), xDipoles );
138
             }
149
             }
150
+            */
151
+
152
+            // Check to see if the loop is closed, if not, assume its grounded on ends,
153
+            //if ( (Points.col(0)-Points.col(iseg)).norm() > 1e-3 ) {
154
+            //    xDipoles[0]->SetType(GROUNDEDELECTRICDIPOLE);
155
+            //    xDipoles.back()->SetType(GROUNDEDELECTRICDIPOLE);
156
+            //}
139
 
157
 
140
             Dipoles = std::move(xDipoles);
158
             Dipoles = std::move(xDipoles);
141
             rRepeat = rp;
159
             rRepeat = rp;
147
         }
165
         }
148
 	}
166
 	}
149
 
167
 
168
+    void PolygonalWireAntenna::AddGroundingPoint( const Vector3r &cp, const Vector3r& dir,
169
+                                std::vector< std::shared_ptr<DipoleSource> > &xDipoles) {
170
+		Real scale = (Real)(NumberOfTurns)*Current;
171
+        auto tx = DipoleSource::NewSP();
172
+		    tx->SetLocation(cp);
173
+		    tx->SetType(GROUNDINGPOINT);
174
+		    //tx->SetType(GROUNDEDELECTRICDIPOLE);
175
+		    //tx->SetType(MAGNETICDIPOLE);
176
+			tx->SetPolarisation(dir.array()); //dir.norm());
177
+			tx->SetFrequencies(Freqs);
178
+			tx->SetMoment(scale);
179
+			xDipoles.push_back(tx);
180
+        //std::cout << "cp " << cp.transpose() << std::endl;
181
+        //std::cout << "pol " << tx->GetPolarisation().transpose() << std::endl;
182
+        //std::cout << "moment " << tx->GetMoment() << std::endl;
183
+    }
184
+
150
 	Vector3r PolygonalWireAntenna::ClosestPointOnLine(const Vector3r &p1,
185
 	Vector3r PolygonalWireAntenna::ClosestPointOnLine(const Vector3r &p1,
151
 					const Vector3r &p2, const Vector3r &tp) {
186
 					const Vector3r &p2, const Vector3r &tp) {
152
 
187
 

+ 6
- 0
Modules/LemmaCore/CMakeLists.txt View File

33
 #	target_link_libraries(lemmacore "matplot")
33
 #	target_link_libraries(lemmacore "matplot")
34
 endif()
34
 endif()
35
 
35
 
36
+
37
+if ( LEMMA_VTK9_SUPPORT ) 
38
+	target_link_libraries(lemmacore ${visibility}VTK::CommonCore VTK::IOXML VTK::FiltersHyperTree)
39
+	vtk_module_autoinit(TARGETS lemmacore MODULES VTK::CommonCore VTK::IOXML VTK::FiltersHyperTree)
40
+endif()
41
+
36
 # find_package(yaml-cpp) does not seem to properly define library names...
42
 # find_package(yaml-cpp) does not seem to properly define library names...
37
 # a better solution than this is welcome 
43
 # a better solution than this is welcome 
38
 
44
 

+ 1
- 1
Modules/LemmaCore/include/RectilinearGridVTKExporter.h View File

26
 #include "LemmaObject.h"
26
 #include "LemmaObject.h"
27
 #include "RectilinearGrid.h"
27
 #include "RectilinearGrid.h"
28
 
28
 
29
-#include <vtkSmartPointer.h>
29
+#include "vtkSmartPointer.h"
30
 #include "vtkXMLRectilinearGridWriter.h"
30
 #include "vtkXMLRectilinearGridWriter.h"
31
 #include "vtkRectilinearGrid.h"
31
 #include "vtkRectilinearGrid.h"
32
 #include "vtkDoubleArray.h"
32
 #include "vtkDoubleArray.h"

+ 2
- 1
Modules/LemmaCore/include/lemma.h View File

301
          @param NOSOURCETYPE is default.
301
          @param NOSOURCETYPE is default.
302
          @param GROUNDEDELECTRICDIPOLE is an grounded electric dipole
302
          @param GROUNDEDELECTRICDIPOLE is an grounded electric dipole
303
          @param UNGROUNDEDELECTRICDIPOLE is an ungrounded electric dipole
303
          @param UNGROUNDEDELECTRICDIPOLE is an ungrounded electric dipole
304
+         @param GROUNDINGPOINT is a point of grounding in a bipole (or similiar) transmitter
304
          @param MAGNETICDIPOLE is a magnetic dipole
305
          @param MAGNETICDIPOLE is a magnetic dipole
305
         */
306
         */
306
-        enum DIPOLESOURCETYPE {NOSOURCETYPE, GROUNDEDELECTRICDIPOLE, UNGROUNDEDELECTRICDIPOLE, MAGNETICDIPOLE};
307
+        enum DIPOLESOURCETYPE {NOSOURCETYPE, GROUNDEDELECTRICDIPOLE, UNGROUNDEDELECTRICDIPOLE, GROUNDINGPOINT, MAGNETICDIPOLE};
307
 
308
 
308
         /// Only three polarizations are supported. They may be summed to
309
         /// Only three polarizations are supported. They may be summed to
309
         /// approximate others
310
         /// approximate others

+ 7
- 3
Modules/LemmaCore/src/CubicSplineInterpolator.cpp View File

173
     //      Method:  Interpolate
173
     //      Method:  Interpolate
174
     //--------------------------------------------------------------------------------------
174
     //--------------------------------------------------------------------------------------
175
     Real CubicSplineInterpolator::Interpolate ( const Real& x, int& i) {
175
     Real CubicSplineInterpolator::Interpolate ( const Real& x, int& i) {
176
+
176
         // O(n) search, could do bisection, but if these are sorted, then this is quick
177
         // O(n) search, could do bisection, but if these are sorted, then this is quick
177
-        while(Spline.x[i] < x && i<Spline.x.size()) {
178
+        while(Spline.x[i] < x && i<Spline.x.size()-1) {
178
             ++i;
179
             ++i;
179
         }
180
         }
180
         --i;
181
         --i;
181
 
182
 
182
 //         if ( x > Spline.x[i] ) {
183
 //         if ( x > Spline.x[i] ) {
183
-//             std::cout << "DOOM\t" << x << "\t" << i << "\t" << Spline.x[i];
184
-//             throw std::runtime_error("CubicSplineInterpolator::Interpolate ATTEMPT TO INTERPOLATE PAST LAST KNOT");
184
+//             std::cout << "DOOM in interplate\t x=" <<  x << "\ti=" << i << "\tSpline.x[i]=" << Spline.x[i] << std::endl;
185
+//             std::cout <<"Spline.x.size()" << Spline.x.size() << std::endl;
186
+//             std::cout << "Spline.x" << Spline.x.transpose() << std::endl;
187
+//             //throw std::runtime_error("CubicSplineInterpolator::Interpolate ATTEMPT TO INTERPOLATE PAST LAST KNOT");
185
 //         }
188
 //         }
186
 
189
 
190
+
187
         return Spline.a[i] + Spline.b[i]*(x-Spline.x[i]) + Spline.c[i]*((x-Spline.x[i])*(x-Spline.x[i])) +
191
         return Spline.a[i] + Spline.b[i]*(x-Spline.x[i]) + Spline.c[i]*((x-Spline.x[i])*(x-Spline.x[i])) +
188
                Spline.d[i]*((x-Spline.x[i])*(x-Spline.x[i])*(x-Spline.x[i]) );
192
                Spline.d[i]*((x-Spline.x[i])*(x-Spline.x[i])*(x-Spline.x[i]) );
189
     }		// -----  end of method CubicSplineInterpolator::Interpolate  -----
193
     }		// -----  end of method CubicSplineInterpolator::Interpolate  -----

+ 3
- 0
Modules/LemmaCore/src/helper.cpp View File

185
             return std::string("GROUNDEDELECTRICDIPOLE");
185
             return std::string("GROUNDEDELECTRICDIPOLE");
186
         case UNGROUNDEDELECTRICDIPOLE:
186
         case UNGROUNDEDELECTRICDIPOLE:
187
             return std::string("UNGROUNDEDELECTRICDIPOLE");
187
             return std::string("UNGROUNDEDELECTRICDIPOLE");
188
+        case GROUNDINGPOINT:
189
+            return std::string("GROUNDINGPOINT");
188
         case MAGNETICDIPOLE:
190
         case MAGNETICDIPOLE:
189
             return std::string("MAGNETICDIPOLE");
191
             return std::string("MAGNETICDIPOLE");
190
         default:
192
         default:
258
     if      (str == "NOSOURCETYPE")              return NOSOURCETYPE;
260
     if      (str == "NOSOURCETYPE")              return NOSOURCETYPE;
259
     if      (str == "GROUNDEDELECTRICDIPOLE")    return GROUNDEDELECTRICDIPOLE;
261
     if      (str == "GROUNDEDELECTRICDIPOLE")    return GROUNDEDELECTRICDIPOLE;
260
     if      (str == "UNGROUNDEDELECTRICDIPOLE")  return UNGROUNDEDELECTRICDIPOLE;
262
     if      (str == "UNGROUNDEDELECTRICDIPOLE")  return UNGROUNDEDELECTRICDIPOLE;
263
+    if      (str == "GROUNDINGPOINT")            return GROUNDINGPOINT;
261
     if      (str == "MAGNETICDIPOLE")            return MAGNETICDIPOLE;
264
     if      (str == "MAGNETICDIPOLE")            return MAGNETICDIPOLE;
262
     else {
265
     else {
263
         throw std::runtime_error("string not recognized as DipoleSource");
266
         throw std::runtime_error("string not recognized as DipoleSource");

+ 1
- 1
vim/c.vim View File

9
 syn keyword eType  MAGUNITS  TEMPUNITS  TIMEUNITS FREQUENCYUNITS FEMCOILORIENTATION ORIENTATION FIELDTYPE FIELDCOMPONENT SPATIALCOORDINANT HANKELTRANSFORMTYPE FIELDCALCULATIONS WINDOWTYPE DIPOLESOURCETYPE 
9
 syn keyword eType  MAGUNITS  TEMPUNITS  TIMEUNITS FREQUENCYUNITS FEMCOILORIENTATION ORIENTATION FIELDTYPE FIELDCOMPONENT SPATIALCOORDINANT HANKELTRANSFORMTYPE FIELDCALCULATIONS WINDOWTYPE DIPOLESOURCETYPE 
10
 
10
 
11
 highlight eeType ctermfg=Cyan guifg=Cyan
11
 highlight eeType ctermfg=Cyan guifg=Cyan
12
-syn keyword eeType  TESLA NANOTESLA GAUSS CELCIUS KELVIN SEC MILLISEC MICROSEC NANOSEC PICOSEC HZ KHZ MHZ GHZ COAXIAL COPLANAR HFIELDREAL HFIELDIMAG EFIELDREAL EFIELDIMAG XCOMPONENT YCOMPONENT ZCOMPONENT XCOORD YCOORD ZCOORD X Y Z NX  NY  NZ ANDERSON801 CHAVE FHTKEY201 FHTKEY101 FHTKEY51 FHTKONG241 FHTKONG121 FHTKONG61 QWEKEY E H BOTH HAMMING HANNING RECTANGULAR NOSOURCETYPE GROUNDEDELECTRICDIPOLE UNGROUNDEDELECTRICDIPOLE MAGNETICDIPOLE
12
+syn keyword eeType  TESLA NANOTESLA GAUSS CELCIUS KELVIN SEC MILLISEC MICROSEC NANOSEC PICOSEC HZ KHZ MHZ GHZ COAXIAL COPLANAR HFIELDREAL HFIELDIMAG EFIELDREAL EFIELDIMAG XCOMPONENT YCOMPONENT ZCOMPONENT XCOORD YCOORD ZCOORD X Y Z NX  NY  NZ ANDERSON801 CHAVE FHTKEY201 FHTKEY101 FHTKEY51 FHTKONG241 FHTKONG121 FHTKONG61 QWEKEY E H BOTH HAMMING HANNING RECTANGULAR NOSOURCETYPE GROUNDEDELECTRICDIPOLE GROUNDINGPOINT UNGROUNDEDELECTRICDIPOLE MAGNETICDIPOLE
13
 
13
 
14
 " Namespaces
14
 " Namespaces
15
 highlight nspace ctermfg=Red guifg=Red
15
 highlight nspace ctermfg=Red guifg=Red

Loading…
Cancel
Save