Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ project( Waves2AMR

message(STATUS "CMake version: ${CMAKE_VERSION}")

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

#
# Check if CMAKE_BUILD_TYPE is given. If not, use default
#
Expand Down Expand Up @@ -52,10 +54,6 @@ if (WAVES2AMR_GPU_BACKEND STREQUAL "CUDA")
include(AMReXTargetHelpers)
endif ()

# FFTW library is required
include_directories(${FFTW_DIR}/include/)
set(fftw_lib ${FFTW_DIR}/lib/libfftw3.a)

#
# Define the object library to compile
#
Expand All @@ -65,7 +63,10 @@ if (BUILD_SHARED_LIBS)
endif()
# Link required libraries
target_link_libraries(waves_2_amr PUBLIC AMReX::amrex)
target_link_libraries(waves_2_amr PRIVATE ${fftw_lib})

find_package(FFTW REQUIRED)
target_link_libraries_system(waves_2_amr PUBLIC FFTW::FFTW)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need https://github.com/Exawind/amr-wind/blob/ad22df58ba4f73af59ae4fde7842e5492461cd78/cmake/amr-wind-utils.cmake#L10-L17 to be able to use this. We can either add that or use target_link_libraries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I switched totarget_link_libraries


add_subdirectory(src)
add_subdirectory(include)

Expand Down
53 changes: 53 additions & 0 deletions cmake/FindFFTW.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# - Find the FFTW3 library
# This will define the following imported target:
#
# FFTW::FFTW - The FFTW library target
#
# and the following variables (for legacy support):
#
# FFTW_FOUND - True if FFTW was found
# FFTW_INCLUDE_DIRS - Include directories for FFTW
# FFTW_LIBRARIES - Libraries to link against

# Look for header
find_path(
FFTW_INCLUDE_DIR
NAMES fftw3.h
PATHS
${FFTW_ROOT}
/usr/include
/usr/local/include
)

# Look for library (shared or static)
find_library(
FFTW_LIBRARY
NAMES fftw3 libfftw3
PATHS
${FFTW_ROOT}
/usr/lib
/usr/local/lib
/usr/lib/x86_64-linux-gnu
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
FFTW
REQUIRED_VARS FFTW_LIBRARY FFTW_INCLUDE_DIR
VERSION_VAR FFTW_VERSION
)

if(FFTW_FOUND)
set(FFTW_LIBRARIES ${FFTW_LIBRARY})
set(FFTW_INCLUDE_DIRS ${FFTW_INCLUDE_DIR})

if(NOT TARGET FFTW::FFTW)
add_library(FFTW::FFTW UNKNOWN IMPORTED)
set_target_properties(FFTW::FFTW PROPERTIES
IMPORTED_LOCATION "${FFTW_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIR}"
)
endif()
endif()

mark_as_advanced(FFTW_INCLUDE_DIR FFTW_LIBRARY)
16 changes: 0 additions & 16 deletions src/interp_to_mfab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,6 @@ void interp_to_mfab::interp_velocity_to_field(

// Number of levels
const int nlevels = vfield.size();
// Number of heights relevant to this processor
const int nhts = indvec.size();
// Copy hvec and indvec to device
amrex::Gpu::DeviceVector<int> indvec_dvc(indvec.size());
amrex::Gpu::copy(
Expand All @@ -464,12 +462,6 @@ void interp_to_mfab::interp_velocity_to_field(
amrex::Gpu::DeviceVector<amrex::Real> hvec_dvc(hvec.size());
amrex::Gpu::copy(
amrex::Gpu::hostToDevice, hvec.begin(), hvec.end(), hvec_dvc.begin());
// Get pointers to device vectors
const auto* indvec_ptr = indvec_dvc.data();
const auto* hvec_ptr = hvec_dvc.data();
const auto* uvec_ptr = uvec.data();
const auto* vvec_ptr = vvec.data();
const auto* wvec_ptr = wvec.data();

// Loop through cells and perform interpolation
for (int nl = 0; nl < nlevels; ++nl) {
Expand Down Expand Up @@ -506,8 +498,6 @@ void interp_to_mfab::interp_velocity_to_field(

// Number of levels
const int nlevels = vfield.size();
// Number of heights relevant to this processor
const int nhts = indvec.size();
// Copy hvec and indvec to device
amrex::Gpu::DeviceVector<int> indvec_dvc(indvec.size());
amrex::Gpu::copy(
Expand All @@ -516,12 +506,6 @@ void interp_to_mfab::interp_velocity_to_field(
amrex::Gpu::DeviceVector<amrex::Real> hvec_dvc(hvec.size());
amrex::Gpu::copy(
amrex::Gpu::hostToDevice, hvec.begin(), hvec.end(), hvec_dvc.begin());
// Get pointers to device vectors
const auto* indvec_ptr = indvec_dvc.data();
const auto* hvec_ptr = hvec_dvc.data();
const auto* uvec_ptr = uvec.data();
const auto* vvec_ptr = vvec.data();
const auto* wvec_ptr = wvec.data();

// Loop through cells and perform interpolation
for (int nl = 0; nl < nlevels; ++nl) {
Expand Down