Commit 190d5b42ff7427e0de32215ca150d847a1f245eb
1 parent
f28a7240
Updated for changes in STIM and CMake
Showing
3 changed files
with
33 additions
and
15 deletions
Show diff stats
CMakeLists.txt
1 | #Specify the version being used aswell as the language | 1 | #Specify the version being used aswell as the language |
2 | -cmake_minimum_required(VERSION 2.8) | 2 | +cmake_minimum_required(VERSION 3.19) |
3 | #Name your project here | 3 | #Name your project here |
4 | project(bimsim) | 4 | project(bimsim) |
5 | 5 | ||
@@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") | @@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") | ||
10 | find_package(CUDA) | 10 | find_package(CUDA) |
11 | 11 | ||
12 | #find OpenCV | 12 | #find OpenCV |
13 | -find_package(OpenCV REQUIRED ) | 13 | +#find_package(OpenCV REQUIRED ) |
14 | 14 | ||
15 | find_package(Boost REQUIRED) | 15 | find_package(Boost REQUIRED) |
16 | 16 |
FindSTIM.cmake
1 | +# finds the STIM library (downloads it if it isn't present) | ||
2 | +# set STIMLIB_PATH to the directory containing the stim subdirectory (the stim repository) | ||
3 | + | ||
1 | include(FindPackageHandleStandardArgs) | 4 | include(FindPackageHandleStandardArgs) |
2 | 5 | ||
3 | -set(STIM_INCLUDE_DIR $ENV{STIMLIB_PATH}) | 6 | +set(STIM_ROOT $ENV{STIM_ROOT}) |
7 | + | ||
8 | +IF(NOT UNIX) | ||
9 | + IF(NOT STIM_ROOT) | ||
10 | + MESSAGE("ERROR: STIM_ROOT environment variable must be set!") | ||
11 | + ENDIF(NOT STIM_ROOT) | ||
4 | 12 | ||
5 | -find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIR) | 13 | + FIND_PATH(STIM_INCLUDE_DIRS DOC "Path to GLFW include directory." |
14 | + NAMES stim/image/image.h | ||
15 | + PATHS ${STIM_ROOT}) | ||
16 | +ENDIF(NOT UNIX) | ||
17 | + | ||
18 | +find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS) | ||
6 | 19 | ||
7 | if(STIM_FOUND) | 20 | if(STIM_FOUND) |
8 | - set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIR}) | ||
9 | -endif() | 21 | + set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIRS}) |
22 | +elseif(STIM_FOUND) | ||
23 | + message("STIM library not found. Set the STIM_ROOT environment variable to the STIM location.") | ||
24 | + message("STIMLIB can be found here: https://git.stim.ee.uh.edu/codebase/stimlib") | ||
25 | +endif(STIM_FOUND) | ||
26 | + | ||
27 | +find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS) |
bimsim.cu
@@ -356,7 +356,7 @@ int main(int argc, char* argv[]){ | @@ -356,7 +356,7 @@ int main(int argc, char* argv[]){ | ||
356 | beam.eval(E0, g_Nl); //evaluate the incident field | 356 | beam.eval(E0, g_Nl); //evaluate the incident field |
357 | 357 | ||
358 | if(g_debug_images && s == 0){ | 358 | if(g_debug_images && s == 0){ |
359 | - stim::filename incident_file = outfile.prefix(outfile.prefix() + "_0_nfi"); | 359 | + stim::filename incident_file = outfile.with_prefix(outfile.prefix() + "_0_nfi"); |
360 | E0.image(incident_file.str(), stim::complexMag); | 360 | E0.image(incident_file.str(), stim::complexMag); |
361 | } | 361 | } |
362 | E0.lowpass(stim::TAU / g_lambda * g_NA_obj[1]); //apply the objective cut-off filter to generate the far-field image | 362 | E0.lowpass(stim::TAU / g_lambda * g_NA_obj[1]); //apply the objective cut-off filter to generate the far-field image |
@@ -366,14 +366,14 @@ int main(int argc, char* argv[]){ | @@ -366,14 +366,14 @@ int main(int argc, char* argv[]){ | ||
366 | spheres.eval(E, beam, g_Nl, g_MC); | 366 | spheres.eval(E, beam, g_Nl, g_MC); |
367 | 367 | ||
368 | if(g_debug_images && s == 0){ | 368 | if(g_debug_images && s == 0){ |
369 | - stim::filename nf_file = outfile.prefix(outfile.prefix() + "_1_nfs"); | 369 | + stim::filename nf_file = outfile.with_prefix(outfile.prefix() + "_1_nfs"); |
370 | E.image(nf_file.str(), stim::complexMag); | 370 | E.image(nf_file.str(), stim::complexMag); |
371 | } | 371 | } |
372 | 372 | ||
373 | E.propagate(g_backprop, stim::TAU / g_lambda); //propagate the field back to the origin | 373 | E.propagate(g_backprop, stim::TAU / g_lambda); //propagate the field back to the origin |
374 | 374 | ||
375 | if(g_debug_images && s == 0){ | 375 | if(g_debug_images && s == 0){ |
376 | - stim::filename propagate_file = outfile.prefix(outfile.prefix()+"_2_nfprop"); | 376 | + stim::filename propagate_file = outfile.with_prefix(outfile.prefix()+"_2_nfprop"); |
377 | E.image(propagate_file.str(), stim::complexMag); | 377 | E.image(propagate_file.str(), stim::complexMag); |
378 | } | 378 | } |
379 | 379 | ||
@@ -382,7 +382,7 @@ int main(int argc, char* argv[]){ | @@ -382,7 +382,7 @@ int main(int argc, char* argv[]){ | ||
382 | Eff.intensity(I); //calculate the far field intensity and add it to the single-beam image | 382 | Eff.intensity(I); //calculate the far field intensity and add it to the single-beam image |
383 | 383 | ||
384 | if(g_debug_images && s == 0){ | 384 | if(g_debug_images && s == 0){ |
385 | - stim::filename cropped_file = outfile.prefix(outfile.prefix() + "_3_cropped"); | 385 | + stim::filename cropped_file = outfile.with_prefix(outfile.prefix() + "_3_cropped"); |
386 | Eff.image(cropped_file.str(), stim::complexMag); | 386 | Eff.image(cropped_file.str(), stim::complexMag); |
387 | } | 387 | } |
388 | P = (double)(s + 1) / (double)g_sources.size() * 100; | 388 | P = (double)(s + 1) / (double)g_sources.size() * 100; |
@@ -396,15 +396,15 @@ int main(int argc, char* argv[]){ | @@ -396,15 +396,15 @@ int main(int argc, char* argv[]){ | ||
396 | 396 | ||
397 | //save the near-field image | 397 | //save the near-field image |
398 | if (g_debug_images) { | 398 | if (g_debug_images) { |
399 | - stim::filename nearfield_real_file = outfile.prefix(outfile.prefix() + "_3_detector_real"); | 399 | + stim::filename nearfield_real_file = outfile.with_prefix(outfile.prefix() + "_3_detector_real"); |
400 | E.image(nearfield_real_file.str(), stim::complexReal); | 400 | E.image(nearfield_real_file.str(), stim::complexReal); |
401 | - stim::filename nearfield_imag_file = outfile.prefix(outfile.prefix() + "_3_detector_imag"); | 401 | + stim::filename nearfield_imag_file = outfile.with_prefix(outfile.prefix() + "_3_detector_imag"); |
402 | E.image(nearfield_imag_file.str(), stim::complexImaginary); | 402 | E.image(nearfield_imag_file.str(), stim::complexImaginary); |
403 | } | 403 | } |
404 | 404 | ||
405 | //save the background and single-beam images | 405 | //save the background and single-beam images |
406 | - stim::filename background_file = outfile.prefix(outfile.prefix() + "background"); | ||
407 | - stim::filename intensity_file = outfile.prefix(outfile.prefix() + "intensity"); | 406 | + stim::filename background_file = outfile.with_prefix(outfile.prefix() + "background"); |
407 | + stim::filename intensity_file = outfile.with_prefix(outfile.prefix() + "intensity"); | ||
408 | 408 | ||
409 | if (use_cuda) { | 409 | if (use_cuda) { |
410 | stim::gpu2image<float>(I0, background_file.str(), g_R_ff, g_R_ff, stim::cmBrewer); | 410 | stim::gpu2image<float>(I0, background_file.str(), g_R_ff, g_R_ff, stim::cmBrewer); |
@@ -419,6 +419,6 @@ int main(int argc, char* argv[]){ | @@ -419,6 +419,6 @@ int main(int argc, char* argv[]){ | ||
419 | float* A; | 419 | float* A; |
420 | HANDLE_ERROR( cudaMalloc(&A, sizeof(float) * g_R_ff * g_R_ff) ); | 420 | HANDLE_ERROR( cudaMalloc(&A, sizeof(float) * g_R_ff * g_R_ff) ); |
421 | gpu_absorbance(A, I, I0, g_R_ff * g_R_ff); | 421 | gpu_absorbance(A, I, I0, g_R_ff * g_R_ff); |
422 | - stim::filename absorbance_file = outfile.prefix(outfile.prefix() + "absorbance"); | 422 | + stim::filename absorbance_file = outfile.with_prefix(outfile.prefix() + "absorbance"); |
423 | stim::gpu2image<float>(A, absorbance_file.str(), g_R_ff, g_R_ff, stim::cmBrewer); | 423 | stim::gpu2image<float>(A, absorbance_file.str(), g_R_ff, g_R_ff, stim::cmBrewer); |
424 | } | 424 | } |
425 | \ No newline at end of file | 425 | \ No newline at end of file |