You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.7 KiB
107 lines
3.7 KiB
cmake_minimum_required(VERSION 3.22)
|
|
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.6/bin/nvcc")
|
|
project(top3d LANGUAGES CUDA CXX)
|
|
#option(PROJECT_WITH_SIMD "Enable SIMD" ON)
|
|
option(VERBOSE "Show more infos" ON)
|
|
# choose linear solver
|
|
option(ENABLE_AMGCL "Use AMGCL" ON)
|
|
option(ENABLE_AMGCL_CUDA "use Cuda to speed up AMGCL" ON)
|
|
option(ENABLE_SUITESPARSE "Use SuiteSparse" OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/find)
|
|
|
|
if (ENABLE_AMGCL AND ENABLE_AMGCL_CUDA)
|
|
configure_file(
|
|
${CMAKE_SOURCE_DIR}/src/ThermoelasticTop3d.cpp
|
|
${CMAKE_SOURCE_DIR}/src/ThermoelasticTop3d.cu
|
|
COPYONLY
|
|
)
|
|
configure_file(
|
|
${CMAKE_SOURCE_DIR}/src/Top3d.cpp
|
|
${CMAKE_SOURCE_DIR}/src/Top3d.cu
|
|
COPYONLY
|
|
)
|
|
|
|
File(GLOB CPP_FILES
|
|
src/Boundary.cpp
|
|
src/Timer.cpp
|
|
src/Util.cpp
|
|
src/*/*.cpp
|
|
)
|
|
else ()
|
|
File(GLOB CPP_FILES
|
|
src/*.cpp
|
|
src/LinearSolver/Amgcl.cpp
|
|
src/FEA/*.cpp
|
|
src/Mesh/*.cpp
|
|
)
|
|
endif ()
|
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
|
add_library(${PROJECT_NAME}_lib ${CPP_FILES})
|
|
|
|
|
|
# Eigen3
|
|
add_subdirectory(3rd/eigen)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Eigen3::Eigen)
|
|
|
|
# Logger
|
|
#find_package(spdlog REQUIRED)
|
|
add_subdirectory(3rd/spdlog-1.13.0)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC spdlog::spdlog)
|
|
|
|
# nlohmann_json
|
|
#find_package(nlohmann_json REQUIRED)
|
|
add_subdirectory(3rd/json-3.11.3)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC nlohmann_json::nlohmann_json)
|
|
|
|
# igl
|
|
add_subdirectory(${LIBIGL_DIR} 3rd/libigl)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC igl::core)
|
|
|
|
# MMA
|
|
add_subdirectory(3rd/mma)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC mma::mma mma::gcmma)
|
|
|
|
if (ENABLE_SUITESPARSE)
|
|
# SuiteSparse
|
|
find_package(SuiteSparse REQUIRED)
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC USE_SUITESPARSE)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${SUITESPARSE_LIBRARIES})
|
|
target_include_directories(${PROJECT_NAME}_lib PUBLIC ${SUITESPARSE_INCLUDE_DIRS})
|
|
endif ()
|
|
|
|
if (ENABLE_AMGCL)
|
|
# AMGCL
|
|
find_package(amgcl REQUIRED)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC amgcl::amgcl)
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC USE_AMGCL)
|
|
if (ENABLE_AMGCL_CUDA)
|
|
find_package(CUDA REQUIRED)
|
|
find_package(CUDAToolkit REQUIRED)
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC CUDA::cudart cusparse)
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC USE_AMGCL_CUDA)
|
|
|
|
add_library(${PROJECT_NAME}_cuda_lib
|
|
${CMAKE_SOURCE_DIR}/src/ThermoelasticTop3d.cu
|
|
${CMAKE_SOURCE_DIR}/src/Top3d.cu
|
|
)
|
|
target_link_libraries(${PROJECT_NAME}_cuda_lib PUBLIC ${PROJECT_NAME}_lib)
|
|
target_compile_options(${PROJECT_NAME}_cuda_lib PRIVATE -Xcompiler -fopenmp)
|
|
target_compile_definitions(${PROJECT_NAME}_cuda_lib PUBLIC USE_AMGCL_CUDA)
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC WRITE_TENSOR)
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC DEBUG)
|
|
|
|
# if we want to use the temperature limit
|
|
#target_compile_definitions(${PROJECT_NAME}_lib PUBLIC WITH_T_LIMIT)
|
|
#target_compile_definitions(${PROJECT_NAME}_lib PUBLIC MECH_ONLY)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC OUTPUT_DIR="${CMAKE_SOURCE_DIR}/output")
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC ASSETS_DIR="${CMAKE_SOURCE_DIR}/assets")
|
|
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)
|