Browse Source

Fix to Boost in CMake to throw error when not found but requested. Also fixed bench kiha test

master
Trevor Irons 3 years ago
parent
commit
7f0b056cf9
2 changed files with 125 additions and 22 deletions
  1. 2
    0
      CMakeLists.txt
  2. 123
    22
      Modules/FDEM1D/testing/BenchKiHa.h

+ 2
- 0
CMakeLists.txt View File

@@ -270,6 +270,8 @@ if (LEMMA_USE_BOOST)
270 270
 		if(HAVE_BOOST_SPECIAL_FUNCTIONS)
271 271
 			add_definitions(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
272 272
 		endif()
273
+    else()
274
+        message(FATAL_ERROR "Boost was not found, but was requested in CMake.")
273 275
 	endif()
274 276
 endif()
275 277
 

+ 123
- 22
Modules/FDEM1D/testing/BenchKiHa.h View File

@@ -80,10 +80,10 @@ public:
80 80
 		Real dy = 20;
81 81
 		Real dz = 20;
82 82
 
83
-		int  nx = 13;
84
-		int  ny = 13;
85
-		int  nz = 13;
86
-        Delta = nx*ny*nz*1e-10;
83
+		int  nx = 5;  //13
84
+		int  ny = 5;  //13
85
+		int  nz = 5;  //13
86
+        Delta = nx*ny*nz*1e-9;
87 87
 
88 88
 		receivers->SetNumberOfPoints(nx*ny*nz);
89 89
 		int ir = 0;
@@ -119,29 +119,35 @@ public:
119 119
 
120 120
         // Put in a unit test that will be slow.
121 121
         std::cout << "MAGNETICDIPOLE Z polarisation" << std::endl;
122
-	    std::cout << "C++\n";
122
+        std::cout << "=====================================\n";
123
+	    std::cout << "Lemma/C++: ";
124
+        std::cout.flush();
123 125
 
124 126
   	    timer.begin();
125 127
 	    EmEarth->MakeCalc3();
126 128
 	    Real lemmaTime = timer.end();
129
+        std::cout << lemmaTime << " [s]" << std::endl;
127 130
 
128 131
         auto lc = receivers->GetEfield( 0 );
129 132
 
130 133
         #ifdef KIHALEE_EM1D
131 134
 	    receivers->ClearFields();
132
-        std::cout << "\nFORTRAN KiHa\n";
135
+        std::cout << "FORTRAN KiHa: ";
136
+        std::cout.flush();
137
+
133 138
   	    timer.begin();
134 139
  	    EmEarth->MakeCalc();
135 140
 	    Real kihaTime = timer.end();
136 141
 
137
-        auto fc = receivers->GetEfield( 0 ); //0,0);
142
+        std::cout << kihaTime << " [s]" << std::endl;
138 143
 
139
-        std::cout << "Lemma time:" << lemmaTime << "\tKiHa time:" << kihaTime << std::endl;
144
+        auto fc = receivers->GetEfield( 0 ); //0,0);
140 145
 
141 146
         std::cout.precision(16);
142 147
         std::cout << "Lemma norm |" << (lc).norm() << "|" << std::endl;
143 148
         std::cout << "KiHa norm  |" << (fc).norm() << "|" << std::endl;
144
-        std::cout << "Difference norm |" << (lc - fc).norm() << "|" << std::endl;
149
+        std::cout << "Difference norm |" << (lc - fc).norm() << "|\n";
150
+        std::cout << "Speedup:" << kihaTime/lemmaTime << "\n" << std::endl;
145 151
 
146 152
         TS_ASSERT_DELTA((lc-fc).norm(), 0.0, Delta);
147 153
         #endif
@@ -153,30 +159,33 @@ public:
153 159
 		dipole->SetPolarisation(XPOLARISATION);
154 160
 
155 161
         // Put in a unit test that will be slow.
156
-	    std::cout << "C++\n";
157 162
         std::cout << "MAGNETICDIPOLE X polarisation" << std::endl;
163
+        std::cout << "=====================================\n";
164
+	    std::cout << "Lemma/C++: ";
165
+        std::cout.flush();
158 166
 
159 167
   	    timer.begin();
160 168
 	    EmEarth->MakeCalc3();
161 169
 	    Real lemmaTime = timer.end();
170
+        std::cout << lemmaTime << " [s]" << std::endl;
162 171
 
163 172
         auto lc = receivers->GetEfield( 0 );
164 173
 
165 174
         #ifdef KIHALEE_EM1D
166 175
 	    receivers->ClearFields();
167
-        std::cout << "\nFORTRAN KiHa\n";
176
+        std::cout << "FORTRAN KiHa: ";
168 177
   	    timer.begin();
169 178
  	    EmEarth->MakeCalc();
170 179
 	    Real kihaTime = timer.end();
180
+        std::cout << kihaTime << " [s]" << std::endl;
171 181
 
172 182
         auto fc = receivers->GetEfield( 0 ); //0,0);
173 183
 
174
-        std::cout << "Lemma time:" << lemmaTime << "\tKiHa time:" << kihaTime << std::endl;
175
-
176 184
         std::cout.precision(16);
177 185
         std::cout << "Lemma norm |" << (lc).norm() << "|" << std::endl;
178 186
         std::cout << "KiHa norm  |" << (fc).norm() << "|" << std::endl;
179
-        std::cout << "Difference norm |" << (lc - fc).norm() << "|" << std::endl;
187
+        std::cout << "Difference norm |" << (lc - fc).norm() << "|\n";
188
+        std::cout << "Speedup:" << kihaTime/lemmaTime << "\n" << std::endl;
180 189
 
181 190
         TS_ASSERT_DELTA((lc-fc).norm(), 0.0, Delta);
182 191
         #endif
@@ -188,30 +197,34 @@ public:
188 197
 		dipole->SetPolarisation(YPOLARISATION);
189 198
 
190 199
         // Put in a unit test that will be slow.
191
-	    std::cout << "C++\n";
192 200
         std::cout << "MAGNETICDIPOLE Y polarisation" << std::endl;
201
+        std::cout << "=====================================\n";
202
+	    std::cout << "Lemma/C++: ";
203
+        std::cout.flush();
193 204
 
194 205
   	    timer.begin();
195 206
 	    EmEarth->MakeCalc3();
196 207
 	    Real lemmaTime = timer.end();
208
+        std::cout << lemmaTime << " [s]" << std::endl;
197 209
 
198 210
         auto lc = receivers->GetEfield( 0 );
199 211
 
200 212
         #ifdef KIHALEE_EM1D
201 213
 	    receivers->ClearFields();
202
-        std::cout << "\nFORTRAN KiHa\n";
214
+        std::cout << "FORTRAN KiHa: ";
215
+        std::cout.flush();
203 216
   	    timer.begin();
204 217
  	    EmEarth->MakeCalc();
205 218
 	    Real kihaTime = timer.end();
219
+        std::cout << kihaTime << " [s]" << std::endl;
206 220
 
207 221
         auto fc = receivers->GetEfield( 0 ); //0,0);
208 222
 
209
-        std::cout << "Lemma time:" << lemmaTime << "\tKiHa time:" << kihaTime << std::endl;
210
-
211 223
         std::cout.precision(16);
212 224
         std::cout << "Lemma norm |" << (lc).norm() << "|" << std::endl;
213 225
         std::cout << "KiHa norm  |" << (fc).norm() << "|" << std::endl;
214
-        std::cout << "Difference norm |" << (lc - fc).norm() << "|" << std::endl;
226
+        std::cout << "Difference norm |" << (lc - fc).norm() << "|\n";
227
+        std::cout << "Speedup:" << kihaTime/lemmaTime << "\n" << std::endl;
215 228
 
216 229
         TS_ASSERT_DELTA((lc-fc).norm(), 0.0, Delta);
217 230
         #endif
@@ -223,21 +236,108 @@ public:
223 236
 		dipole->SetPolarisation(XPOLARISATION);
224 237
 
225 238
         // Put in a unit test that will be slow.
226
-	    std::cout << "C++\n";
227 239
         std::cout << "GROUNDEDELECTRICDIPOLE X polarisation" << std::endl;
240
+        std::cout << "=====================================\n";
241
+	    std::cout << "Lemma/C++: ";
242
+        std::cout.flush();
243
+
244
+  	    timer.begin();
245
+	    EmEarth->MakeCalc3();
246
+	    Real lemmaTime = timer.end();
247
+        std::cout << lemmaTime << " [s]" << std::endl;
248
+
249
+        auto lc = receivers->GetEfield( 0 );
250
+
251
+        #ifdef KIHALEE_EM1D
252
+	    receivers->ClearFields();
253
+        std::cout << "FORTRAN KiHa: ";
254
+        std::cout.flush();
255
+  	    timer.begin();
256
+ 	    EmEarth->MakeCalc();
257
+	    Real kihaTime = timer.end();
258
+        std::cout << kihaTime << " [s]" << std::endl;
259
+
260
+        auto fc = receivers->GetEfield( 0 ); //0,0);
261
+
262
+        std::cout.precision(16);
263
+        std::cout << "Lemma norm |" << (lc).norm() << "|" << std::endl;
264
+        std::cout << "KiHa norm  |" << (fc).norm() << "|" << std::endl;
265
+        std::cout << "Difference norm |" << (lc - fc).norm() << "|\n";
266
+        std::cout << "Speedup:" << kihaTime/lemmaTime << "\n" << std::endl;
267
+
268
+        TS_ASSERT_DELTA((lc-fc).norm(), 0.0, Delta);
269
+        #endif
270
+   }
271
+
272
+   void test_Ey() {
273
+
274
+        dipole->SetType(GROUNDEDELECTRICDIPOLE);
275
+		dipole->SetPolarisation(YPOLARISATION);
276
+
277
+        // Put in a unit test that will be slow.
278
+        std::cout << "GROUNDEDELECTRICDIPOLE Y polarisation" << std::endl;
279
+        std::cout << "=====================================\n";
280
+	    std::cout << "Lemma/C++: ";
281
+        std::cout.flush();
228 282
 
229 283
   	    timer.begin();
230 284
 	    EmEarth->MakeCalc3();
231 285
 	    Real lemmaTime = timer.end();
286
+        std::cout << lemmaTime << " [s]" << std::endl;
232 287
 
233 288
         auto lc = receivers->GetEfield( 0 );
234 289
 
235 290
         #ifdef KIHALEE_EM1D
236 291
 	    receivers->ClearFields();
237
-        std::cout << "\nFORTRAN KiHa\n";
292
+        std::cout << "KiHa/FORTRAN: ";
293
+        std::cout.flush();
294
+
295
+        timer.begin();
296
+ 	    EmEarth->MakeCalc();
297
+	    Real kihaTime = timer.end();
298
+        std::cout << kihaTime << " [s]" << std::endl;
299
+
300
+        auto fc = receivers->GetEfield( 0 ); //0,0);
301
+
302
+        std::cout << "Lemma time:" << lemmaTime << "\tKiHa time:" << kihaTime << std::endl;
303
+
304
+        std::cout.precision(16);
305
+        std::cout << "Lemma norm |" << (lc).norm() << "|" << std::endl;
306
+        std::cout << "KiHa norm  |" << (fc).norm() << "|" << std::endl;
307
+        std::cout << "Difference norm |" << (lc - fc).norm() << "|\n";
308
+        std::cout << "Speedup:" << kihaTime/lemmaTime << "\n" << std::endl;
309
+
310
+        TS_ASSERT_DELTA((lc-fc).norm(), 0.0, Delta);
311
+        #endif
312
+   }
313
+
314
+   void test_Ez() {
315
+
316
+        dipole->SetType(GROUNDEDELECTRICDIPOLE);
317
+		dipole->SetPolarisation(ZPOLARISATION);
318
+
319
+        // Put in a unit test that will be slow.
320
+        std::cout << "GROUNDEDELECTRICDIPOLE Z polarisation" << std::endl;
321
+        std::cout << "=====================================\n";
322
+	    std::cout << "Lemma/C++: ";
323
+        std::cout.flush();
324
+
238 325
   	    timer.begin();
326
+	    EmEarth->MakeCalc3();
327
+	    Real lemmaTime = timer.end();
328
+        std::cout << lemmaTime << " [s]" << std::endl;
329
+
330
+        auto lc = receivers->GetEfield( 0 );
331
+
332
+        #ifdef KIHALEE_EM1D
333
+	    receivers->ClearFields();
334
+        std::cout << "KiHa/FORTRAN: ";
335
+        std::cout.flush();
336
+
337
+        timer.begin();
239 338
  	    EmEarth->MakeCalc();
240 339
 	    Real kihaTime = timer.end();
340
+        std::cout << kihaTime << " [s]" << std::endl;
241 341
 
242 342
         auto fc = receivers->GetEfield( 0 ); //0,0);
243 343
 
@@ -246,7 +346,8 @@ public:
246 346
         std::cout.precision(16);
247 347
         std::cout << "Lemma norm |" << (lc).norm() << "|" << std::endl;
248 348
         std::cout << "KiHa norm  |" << (fc).norm() << "|" << std::endl;
249
-        std::cout << "Difference norm |" << (lc - fc).norm() << "|" << std::endl;
349
+        std::cout << "Difference norm |" << (lc - fc).norm() << "|\n";
350
+        std::cout << "Speedup:" << kihaTime/lemmaTime << "\n" << std::endl;
250 351
 
251 352
         TS_ASSERT_DELTA((lc-fc).norm(), 0.0, Delta);
252 353
         #endif

Loading…
Cancel
Save