-
Notifications
You must be signed in to change notification settings - Fork 165
sundials4py: expose optional KLU SUNLinearSolver bindings #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
18
commits into
develop
Choose a base branch
from
copilot/expose-klu-sunlinear-solver
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9cb1a39
Python: expose optional SUNLinSol_KLU in sundials4py
Copilot 633b5cf
Tests: refine optional KLU sunlinearsolver check
Copilot 65fd586
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 74eed27
Python: add KLU brusselator example and docs
Copilot fcf8926
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 6ee9d1c
Python: apply ruff formatting for KLU example
Copilot 8ade506
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 3566c56
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 d6cccae
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 655d256
regen
balos1 bf0ad6a
Apply suggestions from code review
balos1 5b0cbc7
Apply suggestions from code review
balos1 cefc201
Agent (Codex GPT-5) generated commit:
balos1 2550ff4
Agent (Codex GPT-5) generated commit:
balos1 1b22d25
Agent (Codex GPT-5) generated commit:
balos1 286a0e4
sundials4py: apply litgen_check diff for KLU bindings
Copilot 5f6671c
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 47fe7fd
Merge branch 'develop' into copilot/expose-klu-sunlinear-solver
balos1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* ----------------------------------------------------------------- | ||
| * Programmer(s): Cody J. Balos @ LLNL | ||
| * ----------------------------------------------------------------- | ||
| * SUNDIALS Copyright Start | ||
| * Copyright (c) 2025-2026, Lawrence Livermore National Security, | ||
| * University of Maryland Baltimore County, and the SUNDIALS contributors. | ||
| * Copyright (c) 2013-2025, Lawrence Livermore National Security | ||
| * and Southern Methodist University. | ||
| * Copyright (c) 2002-2013, Lawrence Livermore National Security. | ||
| * All rights reserved. | ||
| * | ||
| * See the top-level LICENSE and NOTICE files for details. | ||
| * | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * SUNDIALS Copyright End | ||
| * -----------------------------------------------------------------*/ | ||
|
|
||
| #include "sundials4py.hpp" | ||
|
|
||
| #include <sundials/sundials_core.hpp> | ||
| #include <sunlinsol/sunlinsol_klu.h> | ||
|
|
||
| namespace nb = nanobind; | ||
| using namespace sundials::experimental; | ||
|
|
||
| namespace sundials4py { | ||
|
|
||
| void bind_sunlinsol_klu(nb::module_& m) | ||
| { | ||
| #include "sunlinsol_klu_generated.hpp" | ||
| } | ||
|
|
||
| } // namespace sundials4py |
52 changes: 52 additions & 0 deletions
52
bindings/sundials4py/sunlinsol/sunlinsol_klu_generated.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // #ifndef _SUNLINSOL_KLU_H | ||
| // | ||
| // #ifndef _KLU_H | ||
| // | ||
| // #endif | ||
| // | ||
| // #ifdef __cplusplus | ||
| // #endif | ||
| // | ||
|
|
||
| auto pyClass_SUNLinearSolverContent_KLU = | ||
| nb::class_<_SUNLinearSolverContent_KLU>(m, "_SUNLinearSolverContent_KLU", "") | ||
| .def(nb::init<>()) // implicit default constructor | ||
| ; | ||
|
|
||
| m.def( | ||
| "SUNLinSol_KLU", | ||
| [](N_Vector y, SUNMatrix A, | ||
| SUNContext sunctx) -> std::shared_ptr<std::remove_pointer_t<SUNLinearSolver>> | ||
| { | ||
| auto SUNLinSol_KLU_adapt_return_type_to_shared_ptr = | ||
| [](N_Vector y, SUNMatrix A, SUNContext sunctx) | ||
| -> std::shared_ptr<std::remove_pointer_t<SUNLinearSolver>> | ||
| { | ||
| auto lambda_result = SUNLinSol_KLU(y, A, sunctx); | ||
|
|
||
| return our_make_shared<std::remove_pointer_t<SUNLinearSolver>, | ||
| SUNLinearSolverDeleter>(lambda_result); | ||
| }; | ||
|
|
||
| return SUNLinSol_KLU_adapt_return_type_to_shared_ptr(y, A, sunctx); | ||
| }, | ||
| nb::arg("y"), nb::arg("A"), nb::arg("sunctx"), "nb::keep_alive<0, 3>()", | ||
| nb::keep_alive<0, 3>()); | ||
|
|
||
| m.def("SUNLinSol_KLUReInit", SUNLinSol_KLUReInit, nb::arg("S"), nb::arg("A"), | ||
| nb::arg("nnz"), nb::arg("reinit_type")); | ||
|
|
||
| m.def("SUNLinSol_KLUSetOrdering", SUNLinSol_KLUSetOrdering, nb::arg("S"), | ||
| nb::arg("ordering_choice")); | ||
|
|
||
| m.def("SUNLinSol_KLUGetSymbolic", SUNLinSol_KLUGetSymbolic, nb::arg("S")); | ||
|
|
||
| m.def("SUNLinSol_KLUGetNumeric", SUNLinSol_KLUGetNumeric, nb::arg("S")); | ||
|
|
||
| m.def("SUNLinSol_KLUGetCommon", SUNLinSol_KLUGetCommon, nb::arg("S")); | ||
|
balos1 marked this conversation as resolved.
|
||
| // #ifdef __cplusplus | ||
| // | ||
| // #endif | ||
| // | ||
| // #endif | ||
| // | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.