diff --git a/build/build_cvode.py b/build/build_cvode.py index 4d975080..8449821f 100644 --- a/build/build_cvode.py +++ b/build/build_cvode.py @@ -19,8 +19,8 @@ ) args, _ = parser.parse_known_args() -archive = download_file('https://github.com/LLNL/sundials/releases/download/v6.4.1/cvode-6.4.1.tar.gz', - checksum='0a614e7d7d525d9ec88d5a30c887786d7c3681bd123bb6679fb9a4ec5f4609fe') +archive = download_file('https://github.com/LLNL/sundials/releases/download/v7.1.1/cvode-7.1.1.tar.gz', + checksum='36eb0ccea5e223ff4fbc528ef996bfb292ec8a1238019b929290ae5d444520ff') root = Path(__file__).parent @@ -40,8 +40,8 @@ cmake_args = [ '-G', args.cmake_generator, - '-D', 'CMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG', - '-D', 'CMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1', + '-D', 'CMAKE_POLICY_DEFAULT_CMP0091=NEW', + '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' ] if fmi_architecture == 'x86': @@ -66,11 +66,12 @@ ['cmake'] + cmake_args + ['-B', build_dir, - '-D', f'BUILD_SHARED_LIBS=OFF', - '-D', f'BUILD_TESTING=OFF', - '-D', f'EXAMPLES_INSTALL=OFF', + '-D', 'BUILD_SHARED_LIBS=OFF', + '-D', 'BUILD_TESTING=OFF', + '-D', 'EXAMPLES_INSTALL=OFF', + '-D', 'SUNDIALS_ENABLE_ERROR_CHECKS=OFF', '-D', f'CMAKE_INSTALL_PREFIX={ install_prefix }', - root / 'cvode-6.4.1'] + root / 'cvode-7.1.1'] ) check_call([ diff --git a/fmusim-gui/CMakeLists.txt b/fmusim-gui/CMakeLists.txt index f875287d..b7fc8061 100644 --- a/fmusim-gui/CMakeLists.txt +++ b/fmusim-gui/CMakeLists.txt @@ -126,7 +126,8 @@ target_link_libraries(fmusim-gui PRIVATE Qt6::WebEngineWidgets ${LIBXML2_DIR}/lib/libxml2.lib ${ZLIB_DIR}/lib/zlib.lib - ${CVODE_DIR}/lib/sundials_cvode.lib + ${CVODE_DIR}/lib/sundials_cvode_static.lib + ${CVODE_DIR}/lib/sundials_core_static.lib ) # Define target properties for Android with Qt 6 as: diff --git a/fmusim-gui/build/build_cvode.py b/fmusim-gui/build/build_cvode.py index 4b635019..d05b1aee 100644 --- a/fmusim-gui/build/build_cvode.py +++ b/fmusim-gui/build/build_cvode.py @@ -4,8 +4,8 @@ import tarfile -archive = download_file('https://github.com/LLNL/sundials/releases/download/v6.4.1/cvode-6.4.1.tar.gz', - checksum='0a614e7d7d525d9ec88d5a30c887786d7c3681bd123bb6679fb9a4ec5f4609fe') +archive = download_file('https://github.com/LLNL/sundials/releases/download/v7.1.1/cvode-7.1.1.tar.gz', + checksum='36eb0ccea5e223ff4fbc528ef996bfb292ec8a1238019b929290ae5d444520ff') root = Path(__file__).parent @@ -24,11 +24,12 @@ ['cmake'] + cmake_args + ['-B', build_dir, - '-D', f'BUILD_SHARED_LIBS=OFF', - '-D', f'BUILD_TESTING=OFF', - '-D', f'EXAMPLES_INSTALL=OFF', + '-D', 'BUILD_SHARED_LIBS=OFF', + '-D', 'BUILD_TESTING=OFF', + '-D', 'EXAMPLES_INSTALL=OFF', + '-D', 'SUNDIALS_ENABLE_ERROR_CHECKS=OFF', '-D', f'CMAKE_INSTALL_PREFIX={ install_prefix }', - str(root / 'cvode-6.4.1')] + str(root / 'cvode-7.1.1')] ) check_call([ diff --git a/fmusim/CMakeLists.txt b/fmusim/CMakeLists.txt index e48f3631..327534cc 100644 --- a/fmusim/CMakeLists.txt +++ b/fmusim/CMakeLists.txt @@ -106,7 +106,8 @@ if (WIN32) set(libraries ${LIBXML2_DIR}/lib/libxml2s.lib ${ZLIB_DIR}/lib/zlibstatic.lib - ${CVODE_DIR}/lib/sundials_cvode.lib + ${CVODE_DIR}/lib/sundials_cvode_static.lib + ${CVODE_DIR}/lib/sundials_core_static.lib wsock32 ws2_32 bcrypt @@ -116,6 +117,7 @@ elseif(UNIX AND NOT APPLE) ${LIBXML2_DIR}/lib/libxml2.a ${ZLIB_DIR}lib/libz.a ${CVODE_DIR}/lib/libsundials_cvode.a + ${CVODE_DIR}/lib/libsundials_core.a ${CMAKE_DL_LIBS} m ) @@ -124,6 +126,7 @@ else () ${LIBXML2_DIR}/lib/libxml2.a ${ZLIB_DIR}lib/libz.a ${CVODE_DIR}/lib/libsundials_cvode.a + ${CVODE_DIR}/lib/libsundials_core.a ) endif () diff --git a/fmusim/FMICVode.c b/fmusim/FMICVode.c index b7e07fd7..ddc67842 100644 --- a/fmusim/FMICVode.c +++ b/fmusim/FMICVode.c @@ -20,7 +20,7 @@ struct FMISolverImpl { SUNContext sunctx; N_Vector x; - realtype reltol; + sunrealtype reltol; N_Vector abstol; SUNMatrix A; SUNLinearSolver LS; @@ -40,7 +40,7 @@ struct FMISolverImpl { } SolverImpl_; // Right-hand-side function -static int f(realtype t, N_Vector x, N_Vector ydot, void* user_data) { +static int f(sunrealtype t, N_Vector x, N_Vector ydot, void* user_data) { FMISolver* solver = (FMISolver*)user_data; @@ -60,7 +60,7 @@ static int f(realtype t, N_Vector x, N_Vector ydot, void* user_data) { } // Root function -static int g(realtype t, N_Vector x, realtype* gout, void* user_data) { +static int g(sunrealtype t, N_Vector x, sunrealtype* gout, void* user_data) { FMISolver* solver = (FMISolver*)user_data; @@ -113,7 +113,7 @@ FMISolver* FMICVodeCreate(const FMISolverParameters* solverFunctions) { solver->getEventIndicators = solverFunctions->getEventIndicators; solver->logError = solverFunctions->logError; - CALL_CVODE(SUNContext_Create(NULL, &solver->sunctx)); + CALL_CVODE(SUNContext_Create(SUN_COMM_NULL, &solver->sunctx)); solver->cvode_mem = CVodeCreate(CV_BDF, solver->sunctx); ASSERT_NOT_NULL(solver->cvode_mem);