Browse Source

Merge branch 'master' of https://lemma.codes/Lemma

master
John Daily 4 years ago
parent
commit
a31f1538ae

+ 8
- 4
CMake/SuperBuild.cmake View File

6
 else()
6
 else()
7
     message( STATUS "Eigen WAS NOT FOUND ${eigen_DIR}" )
7
     message( STATUS "Eigen WAS NOT FOUND ${eigen_DIR}" )
8
         ExternalProject_Add(EIGEN
8
         ExternalProject_Add(EIGEN
9
-	    GIT_REPOSITORY "https://github.com/eigenteam/eigen-git-mirror.git"
10
-	    UPDATE_COMMAND "" 
9
+	    GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
10
+        UPDATE_COMMAND "" 
11
 	    GIT_TAG "3.3.7" #"default"
11
 	    GIT_TAG "3.3.7" #"default"
12
    	    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
12
    	    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
13
    	    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
13
    	    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
21
     message( STATUS "YAML-CPP was found ${yaml-cpp_FOUND}" )
21
     message( STATUS "YAML-CPP was found ${yaml-cpp_FOUND}" )
22
 else()
22
 else()
23
     message( STATUS "YAML-CPP WAS NOT FOUND, BUILDING" )
23
     message( STATUS "YAML-CPP WAS NOT FOUND, BUILDING" )
24
+
24
     ExternalProject_Add(YAML_CPP
25
     ExternalProject_Add(YAML_CPP
25
-        GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git"
26
-        GIT_TAG "master" # "yaml-cpp-0.6.2", # "master" 
26
+        GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git" 
27
+        GIT_TAG  "yaml-cpp-0.6.2"  # "master" 
27
         UPDATE_COMMAND ""
28
         UPDATE_COMMAND ""
28
         PATCH_COMMAND ""
29
         PATCH_COMMAND ""
29
         PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
30
         PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
34
                    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
35
                    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
35
                    -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} 
36
                    -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} 
36
                    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 
37
                    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 
38
+                   -DCMAKE_CXX_STANDARD=14
39
+                   -DCMAKE_CXX_STANDARD_REQUIRED=ON
40
+                   -DCMAKE_CXX_EXTENSIONS=OFF
37
     )
41
     )
38
 endif()
42
 endif()
39
 
43
 

+ 22
- 22
CMakeLists.txt View File

70
 #            "Please create a separate binary directory and run CMake there.")
70
 #            "Please create a separate binary directory and run CMake there.")
71
 #    endif()
71
 #    endif()
72
 
72
 
73
-    find_package (yaml-cpp 0.6         PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH) # Serialisation of classes 
74
-    find_package (Eigen3   3.3         PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH) # Matrix/Vector & Math
73
+    find_package (yaml-cpp 0.6    PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH) # Serialisation of classes 
74
+    find_package (Eigen3   3.3    PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH) # Matrix/Vector & Math
75
 
75
 
76
     if (LEMMA_PYTHON3_BINDINGS)
76
     if (LEMMA_PYTHON3_BINDINGS)
77
         find_package(pybind11 PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH)           # Python 3 bindings
77
         find_package(pybind11 PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH)           # Python 3 bindings
165
     message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
165
     message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
166
     message ( STATUS "This necessitates a two step build." )
166
     message ( STATUS "This necessitates a two step build." )
167
     message ( STATUS "Build these packages first...THEN RERUN CMAKE!" )
167
     message ( STATUS "Build these packages first...THEN RERUN CMAKE!" )
168
-    project (SUPERBUILD NONE)
168
+    project (SUPERBUILD NONE) 
169
   	# execute the superbuild (this script will be invoked again without the
169
   	# execute the superbuild (this script will be invoked again without the
170
-  	# USE_SUPERBUILD option this time)
171
-  	include (CMake/SuperBuild.cmake)
170
+  	# USE_SUPERBUILD option this time) 
171
+    include (CMake/SuperBuild.cmake)
172
   	return()                      # stop processing this file further
172
   	return()                      # stop processing this file further
173
 else()
173
 else()
174
 	#project (Blah)               # <-- YOUR PROJECT NAME HERE
174
 	#project (Blah)               # <-- YOUR PROJECT NAME HERE
244
 			add_definitions(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
244
 			add_definitions(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
245
 		endif()
245
 		endif()
246
 	endif()
246
 	endif()
247
-	find_path( HAVE_BOOST_PROGRESS "boost/progress.hpp" ) 
248
-		if(HAVE_BOOST_PROGRESS)
249
-		add_definitions(-DHAVE_BOOST_PROGRESS)
250
-	endif()
251
 endif()
247
 endif()
252
 
248
 
253
 if (LEMMA_PYTHON3_BINDINGS)
249
 if (LEMMA_PYTHON3_BINDINGS)
281
 if (LEMMA_USE_OPENMP)
277
 if (LEMMA_USE_OPENMP)
282
 
278
 
283
     if(APPLE)
279
     if(APPLE)
284
-        if(CMAKE_C_COMPILER_ID MATCHES "Clang")
285
-            set(OpenMP_C "${CMAKE_C_COMPILER}")
286
-            set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
287
-            set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
288
-            set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
289
-            set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
290
-            set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
291
-        endif()
280
+        #if(CMAKE_C_COMPILER_ID MATCHES "Clang")
281
+        #    set(OpenMP_C "${CMAKE_C_COMPILER}")
282
+        #    set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
283
+        #    set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
284
+        #    set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
285
+        #    set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
286
+        #    set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
287
+        #endif()
292
         if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
288
         if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
289
+            find_library( libiomp5 NAMES  libiomp5.dylib PATHS "/anaconda3/lib/" REQUIRED )
293
             set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
290
             set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
294
-            set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
295
-            set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
296
-            set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
297
-            set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
298
-            set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
291
+            set(OpenMP_CXX_FLAGS "-fopenmp=libiomp5 -Wno-unused-command-line-argument")
292
+            set(OpenMP_CXX_LIB_NAMES "libiomp5") #"libomp" "libgomp" "libiomp5")
293
+            #set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
294
+            #set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
295
+            set(OpenMP_libiomp5_LIBRARY libiomp5 )# ${OpenMP_CXX_LIB_NAMES})
296
+            set(OpenMP_LIBRARIES  libiomp5)
297
+            link_directories("/anaconda3/lib")
298
+    #        find_package(OpenMP REQUIRED)
299
     #         set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
299
     #         set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
300
     #         " -DOpenMP_CXX_LIB_NAMES=\"omp\" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib ")
300
     #         " -DOpenMP_CXX_LIB_NAMES=\"omp\" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib ")
301
     #         set(OpenMP_CXX_LIB_NAMES "omp") # "libgomp" "libiomp5")
301
     #         set(OpenMP_CXX_LIB_NAMES "omp") # "libgomp" "libiomp5")

+ 15
- 9
Modules/DCIP/CMakeLists.txt View File

1
-# Configure EMSchur3D 
2
-set(DCIP_VERSION_MAJOR "0")
3
-set(DCIP_VERSION_MINOR "0")
4
-set(DCIP_VERSION_PATCH "1")
5
-set(DCIP_VERSION "\"${DCIP_VERSION_MAJOR}.${DCIP_VERSION_MINOR}.${DCIP_VERSION_PATCH}\"")
6
-set(DCIP_VERSION_NOQUOTES "${DCIP_VERSION_MAJOR}.${DCIP_VERSION_MINOR}.${DCIP_VERSION_PATCH}")
7
-
8
 option ( LEMMA_MODULE_DCIP TRUE )
1
 option ( LEMMA_MODULE_DCIP TRUE )
9
 
2
 
10
-configure_file (
3
+if (LEMMA_MODULE_DCIP) 
4
+
5
+	# Configure DCIP 
6
+	set(DCIP_VERSION_MAJOR "0")
7
+	set(DCIP_VERSION_MINOR "0")
8
+	set(DCIP_VERSION_PATCH "1")
9
+	set(DCIP_VERSION "\"${DCIP_VERSION_MAJOR}.${DCIP_VERSION_MINOR}.${DCIP_VERSION_PATCH}\"")
10
+	set(DCIP_VERSION_NOQUOTES "${DCIP_VERSION_MAJOR}.${DCIP_VERSION_MINOR}.${DCIP_VERSION_PATCH}")
11
+
12
+
13
+	configure_file (
11
 	"${CMAKE_CURRENT_SOURCE_DIR}/config/DCIPConfig.h.in"
14
 	"${CMAKE_CURRENT_SOURCE_DIR}/config/DCIPConfig.h.in"
12
 	"${PROJECT_BINARY_DIR}/include/DCIPConfig.h"
15
 	"${PROJECT_BINARY_DIR}/include/DCIPConfig.h"
13
 	)
16
 	)
14
-install ( FILES  ${PROJECT_BINARY_DIR}/include/DCIPConfig.h   DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
17
+
18
+	install ( FILES  ${PROJECT_BINARY_DIR}/include/DCIPConfig.h   DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
15
 
19
 
16
 	add_subdirectory("src")
20
 	add_subdirectory("src")
17
 	add_library( dcip ${DCIPSOURCE} )  
21
 	add_library( dcip ${DCIPSOURCE} )  
48
 	#if (LEMMA_BUILD_EXAMPLES)
52
 	#if (LEMMA_BUILD_EXAMPLES)
49
 	#	add_subdirectory(examples)
53
 	#	add_subdirectory(examples)
50
 	#endif()
54
 	#endif()
55
+
56
+endif()

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

12
 
12
 
13
 # Linking
13
 # Linking
14
 target_link_libraries(fdem1d "lemmacore")
14
 target_link_libraries(fdem1d "lemmacore")
15
+target_link_libraries(fdem1d ${YAML_CPP_LIBRARIES}) 
15
 
16
 
16
 if ( KIHA_EM1D )
17
 if ( KIHA_EM1D )
17
 	target_link_libraries(fdem1d "kihaem1d")
18
 	target_link_libraries(fdem1d "kihaem1d")

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

33
 #include "QWEKey.h"
33
 #include "QWEKey.h"
34
 #include "CubicSplineInterpolator.h"
34
 #include "CubicSplineInterpolator.h"
35
 
35
 
36
-#ifdef HAVE_BOOST_PROGRESS
37
-#include "boost/progress.hpp"
38
-#endif
36
+#include "ProgressBar.h"
39
 
37
 
40
 namespace Lemma {
38
 namespace Lemma {
41
 
39
 

+ 3
- 0
Modules/FDEM1D/include/FHT.h View File

185
     const Eigen::Matrix<Real, Eigen::Dynamic, 3>  FHT<FHTKONG241>::WT;
185
     const Eigen::Matrix<Real, Eigen::Dynamic, 3>  FHT<FHTKONG241>::WT;
186
     template<>
186
     template<>
187
     const Eigen::Matrix<Real, Eigen::Dynamic, 3>  FHT<IRONS>::WT;
187
     const Eigen::Matrix<Real, Eigen::Dynamic, 3>  FHT<IRONS>::WT;
188
+    // Clang wants generic declaration
189
+    template < HANKELTRANSFORMTYPE Type >
190
+    const Eigen::Matrix<Real, Eigen::Dynamic, 3>  FHT< Type >::WT;
188
 #endif
191
 #endif
189
 
192
 
190
     template < HANKELTRANSFORMTYPE Type >
193
     template < HANKELTRANSFORMTYPE Type >

+ 4
- 2
Modules/FDEM1D/python/CMakeLists.txt View File

3
 add_library(pyFDEM1D MODULE pyFDEM1D.cpp)
3
 add_library(pyFDEM1D MODULE pyFDEM1D.cpp)
4
 target_link_libraries(pyFDEM1D PRIVATE pybind11::module lemmacore fdem1d )
4
 target_link_libraries(pyFDEM1D PRIVATE pybind11::module lemmacore fdem1d )
5
 set_target_properties(pyFDEM1D PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
5
 set_target_properties(pyFDEM1D PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
6
-                                       SUFFIX "${PYTHON_MODULE_EXTENSION}"
7
-                                                      OUTPUT_NAME "FDEM1D"
6
+	SUFFIX "${PYTHON_MODULE_EXTENSION}"
7
+    OUTPUT_NAME "FDEM1D"
8
+	CXX_STANDARD 14 
9
+	CXX_STANDARD_REQUIRED ON
8
 )
10
 )
9
 
11
 
10
 install(TARGETS pyFDEM1D
12
 install(TARGETS pyFDEM1D

+ 20
- 117
Modules/FDEM1D/src/EMEarth1D.cpp View File

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)
75
             FieldsToCalculate(BOTH), HankelType(ANDERSON801), icalcinner(0), icalc(0)
76
-        //#ifdef HAVE_BOOST_PROGRESS
77
-        //    , disp(0)
78
-        //#endif
79
         {
76
         {
80
     }
77
     }
81
 
78
 
191
 
188
 
192
     void EMEarth1D::CalculateWireAntennaFields(bool progressbar) {
189
     void EMEarth1D::CalculateWireAntennaFields(bool progressbar) {
193
 
190
 
194
-        #ifdef HAVE_BOOST_PROGRESS
195
-        boost::progress_display *disp;
196
-        #endif
197
-
198
         if (Earth == nullptr) {
191
         if (Earth == nullptr) {
199
             throw NullEarth();
192
             throw NullEarth();
200
         }
193
         }
234
             if ( Antenna->IsHorizontallyPlanar() && ( HankelType == ANDERSON801 || HankelType == FHTKEY201  || HankelType==FHTKEY101 ||
227
             if ( Antenna->IsHorizontallyPlanar() && ( HankelType == ANDERSON801 || HankelType == FHTKEY201  || HankelType==FHTKEY101 ||
235
                                                       HankelType == FHTKEY51    || HankelType == FHTKONG61  || HankelType == FHTKONG121 ||
228
                                                       HankelType == FHTKEY51    || HankelType == FHTKONG61  || HankelType == FHTKONG121 ||
236
                                                       HankelType == FHTKONG241  || HankelType == IRONS )) {
229
                                                       HankelType == FHTKONG241  || HankelType == IRONS )) {
237
-                #ifdef HAVE_BOOST_PROGRESS
230
+                std::unique_ptr<ProgressBar> mdisp;
238
                 if (progressbar) {
231
                 if (progressbar) {
239
-                    disp = new boost::progress_display( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
232
+                    mdisp = std::make_unique< ProgressBar >( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
240
                 }
233
                 }
241
-                #endif
234
+
242
                 for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies();++ifreq) {
235
                 for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies();++ifreq) {
243
                     Real wavef = 2.*PI* Antenna->GetFrequency(ifreq);
236
                     Real wavef = 2.*PI* Antenna->GetFrequency(ifreq);
244
                     #ifdef LEMMAUSEOMP
237
                     #ifdef LEMMAUSEOMP
252
                     #endif
245
                     #endif
253
                     for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
246
                     for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
254
                         SolveLaggedTxRxPair(irec, Hankel.get(), wavef, ifreq, AntCopy.get());
247
                         SolveLaggedTxRxPair(irec, Hankel.get(), wavef, ifreq, AntCopy.get());
255
-                        #ifdef HAVE_BOOST_PROGRESS
256
-                        if (progressbar) ++(*disp);
257
-                        #endif
248
+                        if (progressbar) {
249
+                            ++ *mdisp;
250
+                        }
258
                     }
251
                     }
259
-                    #pragma omp barrier
260
                     #ifdef LEMMAUSEOMP
252
                     #ifdef LEMMAUSEOMP
253
+                    #pragma omp barrier
261
                     }
254
                     }
262
                     #endif
255
                     #endif
263
                 }
256
                 }
257
+
258
+
264
             } else if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
259
             } else if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
265
 
260
 
266
-                //std::cout << "freq parallel #1" << std::endl;
267
                 //** Progress display bar for long calculations */
261
                 //** Progress display bar for long calculations */
268
-                #ifdef HAVE_BOOST_PROGRESS
262
+                std::unique_ptr<ProgressBar> mdisp;
269
                 if (progressbar) {
263
                 if (progressbar) {
270
-                    disp = new boost::progress_display( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
264
+                    mdisp = std::make_unique< ProgressBar > ( Receivers->GetNumberOfPoints()*Antenna->GetNumberOfFrequencies() );
271
                 }
265
                 }
272
-                #endif
266
+
273
                 // parallelise across receivers
267
                 // parallelise across receivers
274
                 #ifdef LEMMAUSEOMP
268
                 #ifdef LEMMAUSEOMP
275
                 #pragma omp parallel
269
                 #pragma omp parallel
279
                     // thread.
273
                     // thread.
280
                     auto AntCopy = static_cast<PolygonalWireAntenna*>(Antenna.get())->ClonePA();
274
                     auto AntCopy = static_cast<PolygonalWireAntenna*>(Antenna.get())->ClonePA();
281
                     auto Hankel = HankelTransformFactory::NewSP( HankelType );
275
                     auto Hankel = HankelTransformFactory::NewSP( HankelType );
282
-/*
283
-                    std::shared_ptr<HankelTransform> Hankel;
284
-                    switch (HankelType) {
285
-                        case ANDERSON801:
286
-                            Hankel = FHTAnderson801::NewSP();
287
-                            break;
288
-                        case CHAVE:
289
-                            Hankel = GQChave::NewSP();
290
-                            break;
291
-                        case FHTKEY201:
292
-                            Hankel = FHTKey201::NewSP();
293
-                            break;
294
-                        case FHTKEY101:
295
-                            Hankel = FHTKey101::NewSP();
296
-                            break;
297
-                        case FHTKEY51:
298
-                            Hankel = FHTKey51::NewSP();
299
-                            break;
300
-                        case FHTKONG61:
301
-                            Hankel = FHT<FHTKONG61>::NewSP();
302
-                            break;
303
-                        case FHTKONG121:
304
-                            Hankel = FHT<FHTKONG121>::NewSP();
305
-                            break;
306
-                        case QWEKEY:
307
-                            std::cout << "QWEKEY" << std::endl;
308
-                            Hankel = QWEKey::NewSP();
309
-                            break;
310
-                        default:
311
-                            std::cerr << "Hankel transform cannot be created\n";
312
-                            exit(EXIT_FAILURE);
313
-                    }
314
-*/
315
-                    //for (int irec=tid; irec<Receivers->GetNumberOfPoints(); irec+=nthreads) {
276
+
316
                     #ifdef LEMMAUSEOMP
277
                     #ifdef LEMMAUSEOMP
317
                     #pragma omp for schedule(static, 1) //nowait
278
                     #pragma omp for schedule(static, 1) //nowait
318
                     #endif
279
                     #endif
336
                         //std::cout << "Normal Path\n";
297
                         //std::cout << "Normal Path\n";
337
                         //std::cout << Receivers->GetHfield(0, irec) << std::endl;
298
                         //std::cout << Receivers->GetHfield(0, irec) << std::endl;
338
                         //if (irec == 1) exit(0);
299
                         //if (irec == 1) exit(0);
339
-                        #ifdef HAVE_BOOST_PROGRESS
340
-                        if (progressbar) ++(*disp);
341
-                        #endif
300
+                        if (progressbar) {
301
+                            ++ *mdisp;
302
+                        }
342
                     } // receiver loop
303
                     } // receiver loop
343
                 } // OMP_PARALLEL BLOCK
304
                 } // OMP_PARALLEL BLOCK
344
             } else if (Antenna->GetNumberOfFrequencies() > 8) {
305
             } else if (Antenna->GetNumberOfFrequencies() > 8) {
352
                         #endif
313
                         #endif
353
                         { // OpenMP Parallel Block
314
                         { // OpenMP Parallel Block
354
 
315
 
355
-                            std::shared_ptr<HankelTransform> Hankel;
356
-                            switch (HankelType) {
357
-                                case ANDERSON801:
358
-                                    Hankel = FHTAnderson801::NewSP();
359
-                                    break;
360
-                                case CHAVE:
361
-                                    Hankel = GQChave::NewSP();
362
-                                    break;
363
-                                case FHTKEY201:
364
-                                    Hankel = FHTKey201::NewSP();
365
-                                    break;
366
-                                case FHTKEY101:
367
-                                    Hankel = FHTKey101::NewSP();
368
-                                    break;
369
-                                case FHTKEY51:
370
-                                    Hankel = FHTKey51::NewSP();
371
-                                    break;
372
-                                case QWEKEY:
373
-                                    Hankel = QWEKey::NewSP();
374
-                                    break;
375
-                                default:
376
-                                    std::cerr << "Hankel transform cannot be created\n";
377
-                                    exit(EXIT_FAILURE);
378
-                            }
316
+                            auto Hankel = HankelTransformFactory::NewSP( HankelType );
379
                             #ifdef LEMMAUSEOMP
317
                             #ifdef LEMMAUSEOMP
380
                             #pragma omp for schedule(static, 1)
318
                             #pragma omp for schedule(static, 1)
381
                             #endif
319
                             #endif
390
                             } // frequency loop
328
                             } // frequency loop
391
                         } // OMP_PARALLEL BLOCK
329
                         } // OMP_PARALLEL BLOCK
392
                     } // mask loop
330
                     } // mask loop
393
-                    #ifdef HAVE_BOOST_PROGRESS
394
                     //if (Receivers->GetNumberOfPoints() > 100) {
331
                     //if (Receivers->GetNumberOfPoints() > 100) {
395
-                    //    ++ disp;
332
+                    //    ++ mdisp;
396
                     //}
333
                     //}
397
-                    #endif
398
                 } // receiver loop
334
                 } // receiver loop
399
-                //std::cout << "End freq parallel " << std::endl;
400
             } // Frequency Parallel
335
             } // Frequency Parallel
401
               else {
336
               else {
402
-                //std::cout << "parallel across #3 " << std::endl;
337
+                //std::cout << "parallel across transmitter dipoles " << std::endl;
403
                 for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
338
                 for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
404
                     if (!Receivers->GetMask(irec)) {
339
                     if (!Receivers->GetMask(irec)) {
405
-
406
                         static_cast<PolygonalWireAntenna*>(Antenna.get())->ApproximateWithElectricDipoles(Receivers->GetLocation(irec));
340
                         static_cast<PolygonalWireAntenna*>(Antenna.get())->ApproximateWithElectricDipoles(Receivers->GetLocation(irec));
407
 //                         std::cout << "Not Masked " << std::endl;
341
 //                         std::cout << "Not Masked " << std::endl;
408
 //                         std::cout << "n Freqs " << Antenna->GetNumberOfFrequencies() << std::endl;
342
 //                         std::cout << "n Freqs " << Antenna->GetNumberOfFrequencies() << std::endl;
411
 //                             std::cout << "NO DIPOLES!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
345
 //                             std::cout << "NO DIPOLES!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
412
 // //                            std::cout << "rec location " << Receivers->GetLocation(irec) << std::endl;
346
 // //                            std::cout << "rec location " << Receivers->GetLocation(irec) << std::endl;
413
 // //                        }
347
 // //                        }
414
-
415
                         #ifdef LEMMAUSEOMP
348
                         #ifdef LEMMAUSEOMP
416
                         #pragma omp parallel
349
                         #pragma omp parallel
417
                         #endif
350
                         #endif
418
                         { // OpenMP Parallel Block
351
                         { // OpenMP Parallel Block
419
-                            std::shared_ptr<HankelTransform> Hankel;
420
-                            switch (HankelType) {
421
-                                case ANDERSON801:
422
-                                    Hankel = FHTAnderson801::NewSP();
423
-                                    break;
424
-                                case CHAVE:
425
-                                    Hankel = GQChave::NewSP();
426
-                                    break;
427
-                                case FHTKEY201:
428
-                                    Hankel = FHTKey201::NewSP();
429
-                                    break;
430
-                                case FHTKEY101:
431
-                                    Hankel = FHTKey101::NewSP();
432
-                                    break;
433
-                                case FHTKEY51:
434
-                                    Hankel = FHTKey51::NewSP();
435
-                                    break;
436
-                                case QWEKEY:
437
-                                    Hankel = QWEKey::NewSP();
438
-                                    break;
439
-                                default:
440
-                                    std::cerr << "Hankel transform cannot be created\n";
441
-                                    exit(EXIT_FAILURE);
442
-                            }
352
+                            auto Hankel = HankelTransformFactory::NewSP( HankelType );
443
                             for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies(); ++ifreq) {
353
                             for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies(); ++ifreq) {
444
                                 #ifdef LEMMAUSEOMP
354
                                 #ifdef LEMMAUSEOMP
445
                                 #pragma omp for schedule(static, 1)
355
                                 #pragma omp for schedule(static, 1)
457
                             } // frequency loop
367
                             } // frequency loop
458
                         } // OMP_PARALLEL BLOCK
368
                         } // OMP_PARALLEL BLOCK
459
                     } // mask loop
369
                     } // mask loop
460
-                    #ifdef HAVE_BOOST_PROGRESS
461
                     //if (Receivers->GetNumberOfPoints() > 100) {
370
                     //if (Receivers->GetNumberOfPoints() > 100) {
462
                     //    ++ disp;
371
                     //    ++ disp;
463
                     //}
372
                     //}
464
-                    #endif
465
                 } // receiver loop
373
                 } // receiver loop
466
            } // Polygonal parallel logic
374
            } // Polygonal parallel logic
467
         } else {
375
         } else {
479
             this->Dipole = nullptr;
387
             this->Dipole = nullptr;
480
         }
388
         }
481
 
389
 
482
-        #ifdef HAVE_BOOST_PROGRESS
483
-        if (progressbar) {
484
-            delete disp;
485
-        }
486
-        #endif
487
     }
390
     }
488
 
391
 
489
     #ifdef KIHALEE_EM1D
392
     #ifdef KIHALEE_EM1D

+ 964
- 803
Modules/FDEM1D/src/FHT.cpp
File diff suppressed because it is too large
View File


+ 9
- 1
Modules/FDEM1D/src/PolygonalWireAntenna.cpp View File

126
 		    std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
126
 		    std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
127
 
127
 
128
 		    // loop over all segments
128
 		    // loop over all segments
129
-		    for (int iseg=0; iseg<NumberOfPoints-1; ++iseg) {
129
+		    int iseg;
130
+            for (iseg=0; iseg<NumberOfPoints-1; ++iseg) {
130
 			    InterpolateLineSegment(Points.col(iseg), Points.col(iseg+1), rp, xDipoles);
131
 			    InterpolateLineSegment(Points.col(iseg), Points.col(iseg+1), rp, xDipoles);
131
 		    }
132
 		    }
133
+
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);
138
+            }
139
+
132
             Dipoles = std::move(xDipoles);
140
             Dipoles = std::move(xDipoles);
133
             rRepeat = rp;
141
             rRepeat = rp;
134
 
142
 

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

24
 target_link_libraries (lemmacore Eigen3::Eigen)
24
 target_link_libraries (lemmacore Eigen3::Eigen)
25
 #target_link_libraries (lemmacore CxxTest)
25
 #target_link_libraries (lemmacore CxxTest)
26
 target_link_libraries (lemmacore ${YAML_CPP_LIBRARIES}) 
26
 target_link_libraries (lemmacore ${YAML_CPP_LIBRARIES}) 
27
+target_link_libraries (lemmacore ${YAML_CPP_LIBRARY}) 
27
 
28
 
28
 # Linking
29
 # Linking
29
 if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT ) 
30
 if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT ) 

+ 67
- 0
Modules/LemmaCore/include/ProgressBar.h View File

1
+#ifndef PROGRESS_BAR_H
2
+#define PROGRESS_BAR_H
3
+
4
+#include <string>
5
+
6
+/**
7
+ * RAII implementation of a progress bar.
8
+ * available from https://stackoverflow.com/questions/46717885/make-boostprogress-display-work-when-more-information-is-being-printed-to-the
9
+ */
10
+class ProgressBar
11
+{
12
+public:
13
+    /**
14
+     * Constructor.
15
+     * It takes two values: the expected number of iterations whose progress we
16
+     * want to monitor and an initial message to be displayed on top of the bar
17
+     * (which can be updated with updateLastPrintedMessage()).
18
+     */
19
+    ProgressBar(
20
+            uint32_t expectedIterations, const std::string& initialMessage="");
21
+
22
+    /**
23
+     * Destructor to guarantee RAII.
24
+     */
25
+    ~ProgressBar();
26
+
27
+    // Make the object non-copyable
28
+    ProgressBar(const ProgressBar& o) = delete;
29
+    ProgressBar& operator=(const ProgressBar& o) = delete;
30
+
31
+    /**
32
+     * Must be invoked when the progress bar is no longer needed to restore the
33
+     * position of the cursor to the end of the output.
34
+     * It is automatically invoked when the object is destroyed.
35
+     */
36
+    void endProgressBar();
37
+
38
+    /**
39
+     * Prints a new message under the last printed message, without overwriting
40
+     * it. This moves the progress bar down to be placed under the newly
41
+     * written message.
42
+     */
43
+    void printNewMessage(const std::string& message);
44
+
45
+    /**
46
+     * Prints a message while the progress bar is on the screen on top on the
47
+     * last printed message. Since the cursor is right at the beginning of the
48
+     * progress bar, it moves the cursor up by one line before printing, and
49
+     * then returns it to its original position.
50
+     */
51
+    void updateLastPrintedMessage(const std::string& message);
52
+
53
+    /**
54
+     * Overloaded prefix operator, used to indicate that the has been a new
55
+     * iteration.
56
+     */
57
+    void operator++();
58
+
59
+private:
60
+    unsigned int mTotalIterations;
61
+    unsigned int mNumberOfTicks;
62
+    bool mEnded;
63
+    size_t mLengthOfLastPrintedMessage;
64
+};
65
+
66
+#endif /* PROGRESS_BAR_H */
67
+

+ 1
- 0
Modules/LemmaCore/src/CMakeLists.txt View File

1
 set (SOURCE 
1
 set (SOURCE 
2
 	${SOURCE}
2
 	${SOURCE}
3
+	${CMAKE_CURRENT_SOURCE_DIR}/ProgressBar.cpp                # external to Lemma
3
 	${CMAKE_CURRENT_SOURCE_DIR}/helper.cpp
4
 	${CMAKE_CURRENT_SOURCE_DIR}/helper.cpp
4
 	${CMAKE_CURRENT_SOURCE_DIR}/LemmaObject.cpp
5
 	${CMAKE_CURRENT_SOURCE_DIR}/LemmaObject.cpp
5
 	${CMAKE_CURRENT_SOURCE_DIR}/ASCIIParser.cpp                # key 
6
 	${CMAKE_CURRENT_SOURCE_DIR}/ASCIIParser.cpp                # key 

+ 108
- 0
Modules/LemmaCore/src/ProgressBar.cpp View File

1
+#include "ProgressBar.h"
2
+#include <iostream>
3
+#include <iomanip>
4
+#include <sstream>
5
+
6
+#define LENGTH_OF_PROGRESS_BAR 55
7
+#define PERCENTAGE_BIN_SIZE (100.0/LENGTH_OF_PROGRESS_BAR)
8
+
9
+namespace
10
+{
11
+    std::string generateProgressBar(unsigned int percentage)
12
+    {
13
+        const int progress = static_cast<int>(percentage/PERCENTAGE_BIN_SIZE);
14
+        std::ostringstream ss;
15
+        ss << " " << std::setw(3) << std::right << percentage << "% ";
16
+        std::string bar("[" + std::string(LENGTH_OF_PROGRESS_BAR-2, ' ') + "]");
17
+
18
+        unsigned int numberOfSymbols = std::min(
19
+                std::max(0, progress - 1),
20
+                LENGTH_OF_PROGRESS_BAR - 2);
21
+
22
+        bar.replace(1, numberOfSymbols, std::string(numberOfSymbols, '|'));
23
+
24
+        ss << bar;
25
+        return ss.str();
26
+    }
27
+}
28
+
29
+ProgressBar::ProgressBar(
30
+            uint32_t expectedIterations, const std::string& initialMessage)
31
+    : mTotalIterations(expectedIterations),
32
+      mNumberOfTicks(0),
33
+      mEnded(false)
34
+{
35
+    std::cout << initialMessage << "\n";
36
+    mLengthOfLastPrintedMessage = initialMessage.size();
37
+    std::cout << generateProgressBar(0) << "\r" << std::flush;
38
+}
39
+
40
+ProgressBar::~ProgressBar()
41
+{
42
+    endProgressBar();
43
+}
44
+
45
+void ProgressBar::operator++()
46
+{
47
+
48
+    if (mEnded)
49
+    {
50
+        throw std::runtime_error(
51
+                "Attempted to use progress bar after having terminated it");
52
+    }
53
+
54
+    mNumberOfTicks = std::min(mTotalIterations, mNumberOfTicks+1);
55
+    const unsigned int percentage = static_cast<unsigned int>(
56
+            mNumberOfTicks*100.0/mTotalIterations);
57
+
58
+    #ifdef LEMMAUSEOMP
59
+    #pragma omp critical
60
+    #endif
61
+    std::cout << generateProgressBar(percentage) << "\r" << std::flush;
62
+
63
+}
64
+
65
+void ProgressBar::printNewMessage(const std::string& message)
66
+{
67
+    if (mEnded)
68
+    {
69
+        throw std::runtime_error(
70
+                "Attempted to use progress bar after having terminated it");
71
+    }
72
+
73
+    std::cout << "\r"
74
+        << std::left
75
+        << std::setw(LENGTH_OF_PROGRESS_BAR + 6)
76
+        << message << "\n";
77
+    mLengthOfLastPrintedMessage = message.size();
78
+    const unsigned int percentage = static_cast<unsigned int>(
79
+            mNumberOfTicks*100.0/mTotalIterations);
80
+
81
+    std::cout << generateProgressBar(percentage) << "\r" << std::flush;
82
+
83
+}
84
+
85
+void ProgressBar::updateLastPrintedMessage(const std::string& message)
86
+{
87
+    if (mEnded)
88
+    {
89
+        throw std::runtime_error(
90
+                "Attempted to use progress bar after having terminated it");
91
+    }
92
+
93
+    std::cout << "\r\033[F"
94
+        << std::left
95
+        << std::setw(mLengthOfLastPrintedMessage)
96
+        << message << "\n";
97
+    mLengthOfLastPrintedMessage = message.size();
98
+}
99
+
100
+void ProgressBar::endProgressBar()
101
+{
102
+    if (!mEnded)
103
+    {
104
+        std::cout << std::string(2, '\n');
105
+    }
106
+    mEnded = true;
107
+}
108
+

+ 2
- 2
python/publish.sh View File

2
 rm -rf build dist clean pyLemma.egg.info
2
 rm -rf build dist clean pyLemma.egg.info
3
 python setup.py build
3
 python setup.py build
4
 python setup.py bdist_wheel
4
 python setup.py bdist_wheel
5
-auditwheel repair ./dist/pyLemma*.whl -w ./clean
6
-twine upload clean/*
5
+#auditwheel repair ./dist/pyLemma*.whl -w ./clean
6
+#twine upload build/* #clean/*
7
 
7
 
8
 #rm -rf dist
8
 #rm -rf dist
9
 #python setup.py build
9
 #python setup.py build

+ 3
- 3
python/setup.py View File

3
 from setuptools.dist import Distribution
3
 from setuptools.dist import Distribution
4
 import sys
4
 import sys
5
 
5
 
6
-if sys.version_info < (3,0):
7
-  sys.exit('Sorry, Python < 3.0 is not supported')
6
+if sys.version_info < (3,6):
7
+  sys.exit('Sorry, Python < 3.6 is not supported')
8
 
8
 
9
 class BinaryDistribution(Distribution):
9
 class BinaryDistribution(Distribution):
10
     """Distribution which always forces a binary package with platform name"""
10
     """Distribution which always forces a binary package with platform name"""
21
 
21
 
22
 setup(
22
 setup(
23
   name             = 'pyLemma',
23
   name             = 'pyLemma',
24
-  version          = '0.0.11', 
24
+  version          = '0.0.13', 
25
   author           = 'Trevor Irons and others',
25
   author           = 'Trevor Irons and others',
26
   author_email     = 'Trevor.Irons@lemmasoftware.org',
26
   author_email     = 'Trevor.Irons@lemmasoftware.org',
27
   description      = 'A short description of the app/lib',
27
   description      = 'A short description of the app/lib',

Loading…
Cancel
Save