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,8 +6,8 @@ if (Eigen3_FOUND)
6 6
 else()
7 7
     message( STATUS "Eigen WAS NOT FOUND ${eigen_DIR}" )
8 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 11
 	    GIT_TAG "3.3.7" #"default"
12 12
    	    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
13 13
    	    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
@@ -21,9 +21,10 @@ if (yaml-cpp_FOUND)
21 21
     message( STATUS "YAML-CPP was found ${yaml-cpp_FOUND}" )
22 22
 else()
23 23
     message( STATUS "YAML-CPP WAS NOT FOUND, BUILDING" )
24
+
24 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 28
         UPDATE_COMMAND ""
28 29
         PATCH_COMMAND ""
29 30
         PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
@@ -34,6 +35,9 @@ else()
34 35
                    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
35 36
                    -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} 
36 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 42
 endif()
39 43
 

+ 22
- 22
CMakeLists.txt View File

@@ -70,8 +70,8 @@ if (CMAKE_CROSSCOMPILING)
70 70
 #            "Please create a separate binary directory and run CMake there.")
71 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 76
     if (LEMMA_PYTHON3_BINDINGS)
77 77
         find_package(pybind11 PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH)           # Python 3 bindings
@@ -165,10 +165,10 @@ if ( NOT Eigen3_FOUND OR
165 165
     message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
166 166
     message ( STATUS "This necessitates a two step build." )
167 167
     message ( STATUS "Build these packages first...THEN RERUN CMAKE!" )
168
-    project (SUPERBUILD NONE)
168
+    project (SUPERBUILD NONE) 
169 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 172
   	return()                      # stop processing this file further
173 173
 else()
174 174
 	#project (Blah)               # <-- YOUR PROJECT NAME HERE
@@ -244,10 +244,6 @@ if (LEMMA_USE_BOOST)
244 244
 			add_definitions(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
245 245
 		endif()
246 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 247
 endif()
252 248
 
253 249
 if (LEMMA_PYTHON3_BINDINGS)
@@ -281,21 +277,25 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
281 277
 if (LEMMA_USE_OPENMP)
282 278
 
283 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 288
         if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
289
+            find_library( libiomp5 NAMES  libiomp5.dylib PATHS "/anaconda3/lib/" REQUIRED )
293 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 299
     #         set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
300 300
     #         " -DOpenMP_CXX_LIB_NAMES=\"omp\" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib ")
301 301
     #         set(OpenMP_CXX_LIB_NAMES "omp") # "libgomp" "libiomp5")

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

@@ -1,17 +1,21 @@
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 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 14
 	"${CMAKE_CURRENT_SOURCE_DIR}/config/DCIPConfig.h.in"
12 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 20
 	add_subdirectory("src")
17 21
 	add_library( dcip ${DCIPSOURCE} )  
@@ -48,3 +52,5 @@ install ( FILES  ${PROJECT_BINARY_DIR}/include/DCIPConfig.h   DESTINATION ${CMAK
48 52
 	#if (LEMMA_BUILD_EXAMPLES)
49 53
 	#	add_subdirectory(examples)
50 54
 	#endif()
55
+
56
+endif()

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

@@ -12,6 +12,7 @@ set_target_properties(fdem1d PROPERTIES
12 12
 
13 13
 # Linking
14 14
 target_link_libraries(fdem1d "lemmacore")
15
+target_link_libraries(fdem1d ${YAML_CPP_LIBRARIES}) 
15 16
 
16 17
 if ( KIHA_EM1D )
17 18
 	target_link_libraries(fdem1d "kihaem1d")

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

@@ -33,9 +33,7 @@
33 33
 #include "QWEKey.h"
34 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 38
 namespace Lemma {
41 39
 

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

@@ -185,6 +185,9 @@ namespace Lemma {
185 185
     const Eigen::Matrix<Real, Eigen::Dynamic, 3>  FHT<FHTKONG241>::WT;
186 186
     template<>
187 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 191
 #endif
189 192
 
190 193
     template < HANKELTRANSFORMTYPE Type >

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

@@ -3,8 +3,10 @@
3 3
 add_library(pyFDEM1D MODULE pyFDEM1D.cpp)
4 4
 target_link_libraries(pyFDEM1D PRIVATE pybind11::module lemmacore fdem1d )
5 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 12
 install(TARGETS pyFDEM1D

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

@@ -73,9 +73,6 @@ namespace Lemma {
73 73
     EMEarth1D::EMEarth1D( const ctor_key& key ) : LemmaObject( key ),
74 74
             Dipole(nullptr), Earth(nullptr), Receivers(nullptr), Antenna(nullptr),
75 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,10 +188,6 @@ namespace Lemma {
191 188
 
192 189
     void EMEarth1D::CalculateWireAntennaFields(bool progressbar) {
193 190
 
194
-        #ifdef HAVE_BOOST_PROGRESS
195
-        boost::progress_display *disp;
196
-        #endif
197
-
198 191
         if (Earth == nullptr) {
199 192
             throw NullEarth();
200 193
         }
@@ -234,11 +227,11 @@ namespace Lemma {
234 227
             if ( Antenna->IsHorizontallyPlanar() && ( HankelType == ANDERSON801 || HankelType == FHTKEY201  || HankelType==FHTKEY101 ||
235 228
                                                       HankelType == FHTKEY51    || HankelType == FHTKONG61  || HankelType == FHTKONG121 ||
236 229
                                                       HankelType == FHTKONG241  || HankelType == IRONS )) {
237
-                #ifdef HAVE_BOOST_PROGRESS
230
+                std::unique_ptr<ProgressBar> mdisp;
238 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 235
                 for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies();++ifreq) {
243 236
                     Real wavef = 2.*PI* Antenna->GetFrequency(ifreq);
244 237
                     #ifdef LEMMAUSEOMP
@@ -252,24 +245,25 @@ namespace Lemma {
252 245
                     #endif
253 246
                     for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
254 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 252
                     #ifdef LEMMAUSEOMP
253
+                    #pragma omp barrier
261 254
                     }
262 255
                     #endif
263 256
                 }
257
+
258
+
264 259
             } else if (Receivers->GetNumberOfPoints() > Antenna->GetNumberOfFrequencies()) {
265 260
 
266
-                //std::cout << "freq parallel #1" << std::endl;
267 261
                 //** Progress display bar for long calculations */
268
-                #ifdef HAVE_BOOST_PROGRESS
262
+                std::unique_ptr<ProgressBar> mdisp;
269 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 267
                 // parallelise across receivers
274 268
                 #ifdef LEMMAUSEOMP
275 269
                 #pragma omp parallel
@@ -279,40 +273,7 @@ namespace Lemma {
279 273
                     // thread.
280 274
                     auto AntCopy = static_cast<PolygonalWireAntenna*>(Antenna.get())->ClonePA();
281 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 277
                     #ifdef LEMMAUSEOMP
317 278
                     #pragma omp for schedule(static, 1) //nowait
318 279
                     #endif
@@ -336,9 +297,9 @@ namespace Lemma {
336 297
                         //std::cout << "Normal Path\n";
337 298
                         //std::cout << Receivers->GetHfield(0, irec) << std::endl;
338 299
                         //if (irec == 1) exit(0);
339
-                        #ifdef HAVE_BOOST_PROGRESS
340
-                        if (progressbar) ++(*disp);
341
-                        #endif
300
+                        if (progressbar) {
301
+                            ++ *mdisp;
302
+                        }
342 303
                     } // receiver loop
343 304
                 } // OMP_PARALLEL BLOCK
344 305
             } else if (Antenna->GetNumberOfFrequencies() > 8) {
@@ -352,30 +313,7 @@ namespace Lemma {
352 313
                         #endif
353 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 317
                             #ifdef LEMMAUSEOMP
380 318
                             #pragma omp for schedule(static, 1)
381 319
                             #endif
@@ -390,19 +328,15 @@ namespace Lemma {
390 328
                             } // frequency loop
391 329
                         } // OMP_PARALLEL BLOCK
392 330
                     } // mask loop
393
-                    #ifdef HAVE_BOOST_PROGRESS
394 331
                     //if (Receivers->GetNumberOfPoints() > 100) {
395
-                    //    ++ disp;
332
+                    //    ++ mdisp;
396 333
                     //}
397
-                    #endif
398 334
                 } // receiver loop
399
-                //std::cout << "End freq parallel " << std::endl;
400 335
             } // Frequency Parallel
401 336
               else {
402
-                //std::cout << "parallel across #3 " << std::endl;
337
+                //std::cout << "parallel across transmitter dipoles " << std::endl;
403 338
                 for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
404 339
                     if (!Receivers->GetMask(irec)) {
405
-
406 340
                         static_cast<PolygonalWireAntenna*>(Antenna.get())->ApproximateWithElectricDipoles(Receivers->GetLocation(irec));
407 341
 //                         std::cout << "Not Masked " << std::endl;
408 342
 //                         std::cout << "n Freqs " << Antenna->GetNumberOfFrequencies() << std::endl;
@@ -411,35 +345,11 @@ namespace Lemma {
411 345
 //                             std::cout << "NO DIPOLES!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
412 346
 // //                            std::cout << "rec location " << Receivers->GetLocation(irec) << std::endl;
413 347
 // //                        }
414
-
415 348
                         #ifdef LEMMAUSEOMP
416 349
                         #pragma omp parallel
417 350
                         #endif
418 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 353
                             for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies(); ++ifreq) {
444 354
                                 #ifdef LEMMAUSEOMP
445 355
                                 #pragma omp for schedule(static, 1)
@@ -457,11 +367,9 @@ namespace Lemma {
457 367
                             } // frequency loop
458 368
                         } // OMP_PARALLEL BLOCK
459 369
                     } // mask loop
460
-                    #ifdef HAVE_BOOST_PROGRESS
461 370
                     //if (Receivers->GetNumberOfPoints() > 100) {
462 371
                     //    ++ disp;
463 372
                     //}
464
-                    #endif
465 373
                 } // receiver loop
466 374
            } // Polygonal parallel logic
467 375
         } else {
@@ -479,11 +387,6 @@ namespace Lemma {
479 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 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,9 +126,17 @@ namespace Lemma {
126 126
 		    std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
127 127
 
128 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 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 140
             Dipoles = std::move(xDipoles);
133 141
             rRepeat = rp;
134 142
 

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

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

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

@@ -0,0 +1,67 @@
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,5 +1,6 @@
1 1
 set (SOURCE 
2 2
 	${SOURCE}
3
+	${CMAKE_CURRENT_SOURCE_DIR}/ProgressBar.cpp                # external to Lemma
3 4
 	${CMAKE_CURRENT_SOURCE_DIR}/helper.cpp
4 5
 	${CMAKE_CURRENT_SOURCE_DIR}/LemmaObject.cpp
5 6
 	${CMAKE_CURRENT_SOURCE_DIR}/ASCIIParser.cpp                # key 

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

@@ -0,0 +1,108 @@
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,8 +2,8 @@
2 2
 rm -rf build dist clean pyLemma.egg.info
3 3
 python setup.py build
4 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 8
 #rm -rf dist
9 9
 #python setup.py build

+ 3
- 3
python/setup.py View File

@@ -3,8 +3,8 @@ from setuptools.command.install import install
3 3
 from setuptools.dist import Distribution
4 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 9
 class BinaryDistribution(Distribution):
10 10
     """Distribution which always forces a binary package with platform name"""
@@ -21,7 +21,7 @@ class InstallPlatlib(install):
21 21
 
22 22
 setup(
23 23
   name             = 'pyLemma',
24
-  version          = '0.0.11', 
24
+  version          = '0.0.13', 
25 25
   author           = 'Trevor Irons and others',
26 26
   author_email     = 'Trevor.Irons@lemmasoftware.org',
27 27
   description      = 'A short description of the app/lib',

Loading…
Cancel
Save