diff --git a/.github/workflows/spack_default_build.yaml b/.github/workflows/spack_default_build.yaml index 1eec47290e..45ff920085 100644 --- a/.github/workflows/spack_default_build.yaml +++ b/.github/workflows/spack_default_build.yaml @@ -101,9 +101,17 @@ jobs: spack_spec: - gridkit@develop ~asan~enzyme~ipopt~klu~resolve~sundials~ubsan - gridkit@develop ~asan~enzyme~ipopt~klu~resolve+sundials~ubsan + ^sundials@7.8.0 - gridkit@develop +asan+enzyme+ipopt+klu+resolve+sundials~ubsan build_type=RelWithDebInfo ^enzyme@0.0.206 + ^sundials@7.8.0 - gridkit@develop +asan~enzyme+ipopt+klu+resolve+sundials+ubsan + ^sundials@7.8.0 + - gridkit@develop +asan+enzyme+ipopt+klu+resolve+sundials~ubsan build_type=RelWithDebInfo + ^enzyme@0.0.206 + ^sundials@partitioned-dae + - gridkit@develop +asan~enzyme+ipopt+klu+resolve+sundials+ubsan + ^sundials@partitioned-dae steps: - name: Add LLVM diff --git a/CMakeLists.txt b/CMakeLists.txt index 98978ce4b0..96133e758d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,23 @@ if(GRIDKIT_ENABLE_SUNDIALS) CACHE INTERNAL BOOL "Sparse solver enabled in SUNDIALS.") message(STATUS "KLU support enabled in SUNDIALS.") endif() + # SUNDIALS::arkode is an alias without include directories. Revisit once SUNDIALS reports partitioned DAE + # support itself. + if(TARGET SUNDIALS::arkode_shared) + get_target_property(_sundials_arkode_includes SUNDIALS::arkode_shared + INTERFACE_INCLUDE_DIRECTORIES) + else() + get_target_property(_sundials_arkode_includes SUNDIALS::arkode_static + INTERFACE_INCLUDE_DIRECTORIES) + endif() + find_file( + GRIDKIT_SUNDIALS_PDAESTEP_HEADER arkode/arkode_pdaestep.h + PATHS ${_sundials_arkode_includes} + NO_DEFAULT_PATH) + if(GRIDKIT_SUNDIALS_PDAESTEP_HEADER) + set(GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE ON) + message(STATUS "Partitioned DAE support enabled in SUNDIALS.") + endif() endif() if(GRIDKIT_ENABLE_ZMQ) diff --git a/GridKit/Definitions.hpp.in b/GridKit/Definitions.hpp.in index 77075c9dc8..e62757bbb1 100644 --- a/GridKit/Definitions.hpp.in +++ b/GridKit/Definitions.hpp.in @@ -4,6 +4,7 @@ #cmakedefine GRIDKIT_ENABLE_OPENMP #cmakedefine GRIDKIT_ENABLE_THREADS #cmakedefine GRIDKIT_ENABLE_SUNDIALS_SPARSE +#cmakedefine GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE #cmakedefine GRIDKIT_ENABLE_DEVELOPER_MODE #define GRIDKIT_VERSION "@GridKit_VERSION@" diff --git a/GridKit/Solver/Dynamic/CMakeLists.txt b/GridKit/Solver/Dynamic/CMakeLists.txt index aa318524ec..c59956fc3c 100644 --- a/GridKit/Solver/Dynamic/CMakeLists.txt +++ b/GridKit/Solver/Dynamic/CMakeLists.txt @@ -5,8 +5,12 @@ # - Cameron Rutherford #]] -set(_dynamic_solver_sources Ida.cpp Partitioned.cpp) -set(_dynamic_solver_headers Ida.hpp Partitioned.hpp DynamicSolver.hpp) +set(_dynamic_solver_sources Ida.cpp) +set(_dynamic_solver_headers Ida.hpp DynamicSolver.hpp) +if(GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE) + list(APPEND _dynamic_solver_sources Partitioned.cpp) + list(APPEND _dynamic_solver_headers Partitioned.hpp) +endif() set(_dynamic_solver_libraries PUBLIC SUNDIALS::nvecserial diff --git a/buildsystem/spack_repo/gridkit/packages/gridkit/package.py b/buildsystem/spack_repo/gridkit/packages/gridkit/package.py index 6eba3f88fc..f1d7090c31 100644 --- a/buildsystem/spack_repo/gridkit/packages/gridkit/package.py +++ b/buildsystem/spack_repo/gridkit/packages/gridkit/package.py @@ -14,6 +14,7 @@ class Gridkit(CMakePackage): maintainers("nkoukpaizan", "pelesh") version("develop", submodules=True, branch="develop") + version("0.2.0", tag="v0.2.0", commit="d443aeb19748bf17c264d1013c37bb466f6d0136", submodules=True) variant("asan", default=False, description="Enable/Disable address sanitizer") variant("enzyme", default=False, description="Enable/Disable Enzyme") @@ -33,8 +34,10 @@ class Gridkit(CMakePackage): depends_on("ipopt", when="+ipopt") depends_on("resolve@gridkit-pinned+klu", when="+resolve+klu") depends_on("resolve@gridkit-pinned~klu", when="+resolve~klu") - depends_on("sundials@7.8.0+klu~mpi", when="+sundials+klu") - depends_on("sundials@7.8.0~klu~mpi", when="+sundials~klu") + depends_on("sundials@7.8.0+klu~mpi", when="@0.2.0+sundials+klu") + depends_on("sundials@7.8.0~klu~mpi", when="@0.2.0+sundials~klu") + depends_on("sundials@7.8.0,partitioned-dae+klu~mpi", when="@develop+sundials+klu") + depends_on("sundials@7.8.0,partitioned-dae~klu~mpi", when="@develop+sundials~klu") def cmake_args(self): args = [] diff --git a/buildsystem/spack_repo/gridkit/packages/sundials/package.py b/buildsystem/spack_repo/gridkit/packages/sundials/package.py index dd6af2fccf..01de753cc5 100644 --- a/buildsystem/spack_repo/gridkit/packages/sundials/package.py +++ b/buildsystem/spack_repo/gridkit/packages/sundials/package.py @@ -5,3 +5,14 @@ class Sundials(BuiltinSundials): version("7.9.0", tag="v7.9.0", commit="312fc0f3684f27209ca9dc9249d194436eb41a7a") version("7.8.0", tag="v7.8.0", commit="aedc088437064dd55b35c000145f7f5db6ee49e3") + version("partitioned-dae", branch="feature/partitioned-dae-stepper") + + # The branch registers ark_partitioned_dae.c without its .out file, which breaks install. + # Remove once the branch includes examples/arkode/C_serial/ark_partitioned_dae.out. + @when("@partitioned-dae") + def patch(self): + filter_file( + r'^\s*"ark_partitioned_dae\.c\\;\\;develop"\s*$', + "", + join_path("examples", "arkode", "C_serial", "CMakeLists.txt"), + ) diff --git a/tests/UnitTests/Solver/Dynamic/CMakeLists.txt b/tests/UnitTests/Solver/Dynamic/CMakeLists.txt index 3cd04b2aeb..6ae7bda2bc 100644 --- a/tests/UnitTests/Solver/Dynamic/CMakeLists.txt +++ b/tests/UnitTests/Solver/Dynamic/CMakeLists.txt @@ -6,11 +6,15 @@ if(TARGET SUNDIALS::idas) add_test(NAME IDATest COMMAND $) + install(TARGETS test_ida RUNTIME DESTINATION bin) +endif() + +if(GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE) add_executable(test_partitioned runPartitionedTests.cpp) target_link_libraries(test_partitioned GridKit::solvers_dyn GridKit::testing) add_test(NAME PartitionedTest COMMAND $) - install(TARGETS test_ida test_partitioned RUNTIME DESTINATION bin) + install(TARGETS test_partitioned RUNTIME DESTINATION bin) endif() if(GRIDKIT_ENABLE_RESOLVE)