From a579ae6f1294ed93bd04f33479862d1aa395f016 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Tue, 29 Oct 2024 15:27:28 +0100 Subject: [PATCH 1/4] Bump CVode to 7.1.1 --- build/build_cvode.py | 17 +++++++++-------- fmusim/CMakeLists.txt | 3 ++- fmusim/FMICVode.c | 8 ++++---- 3 files changed, 15 insertions(+), 13 deletions(-) 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/CMakeLists.txt b/fmusim/CMakeLists.txt index e48f3631..fce9166a 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_core_static.lib + ${CVODE_DIR}/lib/sundials_cvode_static.lib wsock32 ws2_32 bcrypt 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); From 1bc892dd702b27351f2787e71ac988651d1aec84 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Tue, 29 Oct 2024 16:21:46 +0100 Subject: [PATCH 2/4] Add libsundials_core.a to libraries --- fmusim/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fmusim/CMakeLists.txt b/fmusim/CMakeLists.txt index fce9166a..54d0a0b1 100644 --- a/fmusim/CMakeLists.txt +++ b/fmusim/CMakeLists.txt @@ -116,6 +116,7 @@ elseif(UNIX AND NOT APPLE) set(libraries ${LIBXML2_DIR}/lib/libxml2.a ${ZLIB_DIR}lib/libz.a + ${CVODE_DIR}/lib/libsundials_core.a ${CVODE_DIR}/lib/libsundials_cvode.a ${CMAKE_DL_LIBS} m @@ -124,6 +125,7 @@ else () set(libraries ${LIBXML2_DIR}/lib/libxml2.a ${ZLIB_DIR}lib/libz.a + ${CVODE_DIR}/lib/libsundials_core.a ${CVODE_DIR}/lib/libsundials_cvode.a ) endif () From 5d7042d53b2e58001971629d261641b666aae319 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Wed, 30 Oct 2024 10:58:54 +0100 Subject: [PATCH 3/4] Fix order of linked libraries --- fmusim/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fmusim/CMakeLists.txt b/fmusim/CMakeLists.txt index 54d0a0b1..327534cc 100644 --- a/fmusim/CMakeLists.txt +++ b/fmusim/CMakeLists.txt @@ -106,8 +106,8 @@ if (WIN32) set(libraries ${LIBXML2_DIR}/lib/libxml2s.lib ${ZLIB_DIR}/lib/zlibstatic.lib - ${CVODE_DIR}/lib/sundials_core_static.lib ${CVODE_DIR}/lib/sundials_cvode_static.lib + ${CVODE_DIR}/lib/sundials_core_static.lib wsock32 ws2_32 bcrypt @@ -116,8 +116,8 @@ elseif(UNIX AND NOT APPLE) set(libraries ${LIBXML2_DIR}/lib/libxml2.a ${ZLIB_DIR}lib/libz.a - ${CVODE_DIR}/lib/libsundials_core.a ${CVODE_DIR}/lib/libsundials_cvode.a + ${CVODE_DIR}/lib/libsundials_core.a ${CMAKE_DL_LIBS} m ) @@ -125,8 +125,8 @@ else () set(libraries ${LIBXML2_DIR}/lib/libxml2.a ${ZLIB_DIR}lib/libz.a - ${CVODE_DIR}/lib/libsundials_core.a ${CVODE_DIR}/lib/libsundials_cvode.a + ${CVODE_DIR}/lib/libsundials_core.a ) endif () From 7e544d96dfe422fb8249c1abfd42f1b1dd2c95a0 Mon Sep 17 00:00:00 2001 From: Torsten Sommer Date: Wed, 30 Oct 2024 11:52:04 +0100 Subject: [PATCH 4/4] Use CVode 7.1.1 in FMUSim GUI --- fmusim-gui/CMakeLists.txt | 3 ++- fmusim-gui/build/build_cvode.py | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) 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([