Skip to content

Commit 2eeed28

Browse files
Add interface to partitioned DAE integrator (#614)
* Add interface to partitioned DAE integrator * Add support for partitioned DAE tests in CI (#623) * Add CMake guards for PARTITIONED_DAE. * Add ^sundials@partitioned-dae CI jobs. * Patch out missing partitioned-dae example in SUNDIALS spack package. --------- Co-authored-by: Steven-Roberts <Steven-Roberts@users.noreply.github.com> Co-authored-by: Nicholson Koukpaizan <72402802+nkoukpaizan@users.noreply.github.com>
1 parent 574bd83 commit 2eeed28

11 files changed

Lines changed: 1493 additions & 23 deletions

File tree

‎.github/workflows/spack_default_build.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,17 @@ jobs:
101101
spack_spec:
102102
- gridkit@develop ~asan~enzyme~ipopt~klu~resolve~sundials~ubsan
103103
- gridkit@develop ~asan~enzyme~ipopt~klu~resolve+sundials~ubsan
104+
^sundials@7.8.0
104105
- gridkit@develop +asan+enzyme+ipopt+klu+resolve+sundials~ubsan build_type=RelWithDebInfo
105106
^enzyme@0.0.206
107+
^sundials@7.8.0
106108
- gridkit@develop +asan~enzyme+ipopt+klu+resolve+sundials+ubsan
109+
^sundials@7.8.0
110+
- gridkit@develop +asan+enzyme+ipopt+klu+resolve+sundials~ubsan build_type=RelWithDebInfo
111+
^enzyme@0.0.206
112+
^sundials@partitioned-dae
113+
- gridkit@develop +asan~enzyme+ipopt+klu+resolve+sundials+ubsan
114+
^sundials@partitioned-dae
107115

108116
steps:
109117
- name: Add LLVM

‎CMakeLists.txt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ if(GRIDKIT_ENABLE_SUNDIALS)
147147
CACHE INTERNAL BOOL "Sparse solver enabled in SUNDIALS.")
148148
message(STATUS "KLU support enabled in SUNDIALS.")
149149
endif()
150+
# SUNDIALS::arkode is an alias without include directories. Revisit once SUNDIALS reports partitioned DAE
151+
# support itself.
152+
if(TARGET SUNDIALS::arkode_shared)
153+
get_target_property(_sundials_arkode_includes SUNDIALS::arkode_shared
154+
INTERFACE_INCLUDE_DIRECTORIES)
155+
else()
156+
get_target_property(_sundials_arkode_includes SUNDIALS::arkode_static
157+
INTERFACE_INCLUDE_DIRECTORIES)
158+
endif()
159+
find_file(
160+
GRIDKIT_SUNDIALS_PDAESTEP_HEADER arkode/arkode_pdaestep.h
161+
PATHS ${_sundials_arkode_includes}
162+
NO_DEFAULT_PATH)
163+
if(GRIDKIT_SUNDIALS_PDAESTEP_HEADER)
164+
set(GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE ON)
165+
message(STATUS "Partitioned DAE support enabled in SUNDIALS.")
166+
endif()
150167
endif()
151168

152169
if(GRIDKIT_ENABLE_ZMQ)

‎GridKit/Definitions.hpp.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#cmakedefine GRIDKIT_ENABLE_OPENMP
55
#cmakedefine GRIDKIT_ENABLE_THREADS
66
#cmakedefine GRIDKIT_ENABLE_SUNDIALS_SPARSE
7+
#cmakedefine GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE
78
#cmakedefine GRIDKIT_ENABLE_DEVELOPER_MODE
89

910
#define GRIDKIT_VERSION "@GridKit_VERSION@"

‎GridKit/Solver/Dynamic/CMakeLists.txt‎

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,54 @@
55
# - Cameron Rutherford <cameron.rutherford@pnnl.gov>
66
#]]
77

8+
set(_dynamic_solver_sources Ida.cpp)
9+
set(_dynamic_solver_headers Ida.hpp DynamicSolver.hpp)
10+
set(_dynamic_solver_libraries
11+
PUBLIC
12+
SUNDIALS::nvecserial
13+
PUBLIC
14+
SUNDIALS::idas
15+
PUBLIC
16+
GridKit::definitions
17+
PUBLIC
18+
GridKit::utilities_logger
19+
PUBLIC
20+
GridKit::sparse_matrix
21+
GridKit::dense_vector)
22+
823
if(GRIDKIT_ENABLE_SUNDIALS_SPARSE)
24+
list(
25+
APPEND
26+
_dynamic_solver_libraries
27+
PUBLIC
28+
SUNDIALS::sunlinsolklu)
29+
endif()
30+
31+
gridkit_add_library(
32+
solvers_dyn
33+
SOURCES ${_dynamic_solver_sources}
34+
HEADERS ${_dynamic_solver_headers}
35+
LINK_LIBRARIES ${_dynamic_solver_libraries})
36+
37+
# PDAEStep creates IDA memory, whereas Ida.cpp requires IDAS for adjoints.
38+
# IDA and IDAS export the same IDA* symbols but have incompatible memory layouts.
39+
# Keep their dependencies separate so partition calls bind to the IDA backend.
40+
if(GRIDKIT_ENABLE_SUNDIALS_PARTITIONED_DAE)
941
gridkit_add_library(
10-
solvers_dyn
11-
SOURCES Ida.cpp
12-
HEADERS Ida.hpp DynamicSolver.hpp
42+
solvers_partitioned
43+
SOURCES Partitioned.cpp
44+
HEADERS Partitioned.hpp
1345
LINK_LIBRARIES
1446
PUBLIC
15-
SUNDIALS::nvecserial
16-
PUBLIC
17-
SUNDIALS::idas
18-
PUBLIC
19-
SUNDIALS::sunlinsolklu
20-
PUBLIC
21-
GridKit::definitions
22-
PUBLIC
23-
GridKit::utilities_logger
47+
SUNDIALS::ida
2448
PUBLIC
25-
GridKit::sparse_matrix
26-
GridKit::dense_vector)
27-
else()
28-
gridkit_add_library(
29-
solvers_dyn
30-
SOURCES Ida.cpp
31-
HEADERS Ida.hpp DynamicSolver.hpp
32-
LINK_LIBRARIES
49+
SUNDIALS::arkode
3350
PUBLIC
3451
SUNDIALS::nvecserial
3552
PUBLIC
36-
SUNDIALS::idas
53+
SUNDIALS::nvecmanyvector
54+
PUBLIC
55+
SUNDIALS::sunlinsolspgmr
3756
PUBLIC
3857
GridKit::definitions
3958
PUBLIC

0 commit comments

Comments
 (0)