-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add backports and shims for SUNDIALS 6 #2521
Conversation
Adds a header for common backports shared between the different SUNDIALS solvers such that the main code only needs to differentiate between SUNDIALS pre/post 3.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, looks much cleaner 👍
clang-tidy-review broke but did actually catch a bug: I had |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
#endif | ||
|
||
ArkodeSolver::ArkodeSolver(Options* opts) : Solver(opts) { | ||
ArkodeSolver::ArkodeSolver(Options* opts) : Solver(opts), suncontext(MPI_COMM_WORLD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: constructor does not initialize these fields: NOUT, TIMESTEP, hcur [cppcoreguidelines-pro-type-member-init]
ArkodeSolver::ArkodeSolver(Options* opts) : Solver(opts), suncontext(MPI_COMM_WORLD) {
^
} | ||
#endif | ||
|
||
CvodeSolver::CvodeSolver(Options* opts) : Solver(opts) { | ||
CvodeSolver::CvodeSolver(Options* opts) : Solver(opts), suncontext(MPI_COMM_WORLD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: constructor does not initialize these fields: NOUT, TIMESTEP, hcur [cppcoreguidelines-pro-type-member-init]
CvodeSolver::CvodeSolver(Options* opts) : Solver(opts), suncontext(MPI_COMM_WORLD) {
^
#endif | ||
|
||
IdaSolver::IdaSolver(Options* opts) : Solver(opts) { | ||
IdaSolver::IdaSolver(Options* opts) : Solver(opts), suncontext(MPI_COMM_WORLD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: constructor does not initialize these fields: NOUT, TIMESTEP [cppcoreguidelines-pro-type-member-init]
IdaSolver::IdaSolver(Options* opts) : Solver(opts), suncontext(MPI_COMM_WORLD) {
^
@@ -160,11 +137,11 @@ int IdaSolver::init(int nout, BoutReal tstep) { | |||
local_N); | |||
|
|||
// Allocate memory | |||
if ((uvec = N_VNew_Parallel(BoutComm::get(), local_N, neq SUNCTX_PLACEHOLDER)) == nullptr) | |||
if ((uvec = N_VNew_Parallel(BoutComm::get(), local_N, neq, suncontext)) == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: statement should be inside braces [readability-braces-around-statements]
if ((uvec = N_VNew_Parallel(BoutComm::get(), local_N, neq, suncontext)) == nullptr)
^
{
throw BoutException("SUNDIALS memory allocation failed\n"); | ||
if ((duvec = N_VNew_Parallel(BoutComm::get(), local_N, neq SUNCTX_PLACEHOLDER)) == nullptr) | ||
if ((duvec = N_VNew_Parallel(BoutComm::get(), local_N, neq, suncontext)) == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: statement should be inside braces [readability-braces-around-statements]
if ((duvec = N_VNew_Parallel(BoutComm::get(), local_N, neq, suncontext)) == nullptr)
^
{
throw BoutException("SUNDIALS memory allocation failed\n"); | ||
if ((id = N_VNew_Parallel(BoutComm::get(), local_N, neq SUNCTX_PLACEHOLDER)) == nullptr) | ||
if ((id = N_VNew_Parallel(BoutComm::get(), local_N, neq, suncontext)) == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: statement should be inside braces [readability-braces-around-statements]
if ((id = N_VNew_Parallel(BoutComm::get(), local_N, neq, suncontext)) == nullptr)
^
{
@@ -180,7 +157,7 @@ int IdaSolver::init(int nout, BoutReal tstep) { | |||
set_id(NV_DATA_P(id)); | |||
|
|||
// Call IDACreate to initialise | |||
if ((idamem = IDACreate(SUNCTX_PLACEHOLDER_)) == nullptr) | |||
if ((idamem = IDACreate(suncontext)) == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: statement should be inside braces [readability-braces-around-statements]
if ((idamem = IDACreate(suncontext)) == nullptr)
^
{
@@ -205,7 +182,7 @@ int IdaSolver::init(int nout, BoutReal tstep) { | |||
// Call IDASpgmr to specify the IDA linear solver IDASPGMR | |||
const auto maxl = (*options)["maxl"].withDefault(6 * n3d); | |||
#if SUNDIALS_VERSION_MAJOR >= 3 | |||
if ((sun_solver = SUNLinSol_SPGMR(uvec, SUN_PREC_NONE, maxl SUNCTX_PLACEHOLDER)) == nullptr) | |||
if ((sun_solver = SUNLinSol_SPGMR(uvec, SUN_PREC_NONE, maxl, suncontext)) == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: statement should be inside braces [readability-braces-around-statements]
if ((sun_solver = SUNLinSol_SPGMR(uvec, SUN_PREC_NONE, maxl, suncontext)) == nullptr)
^
{
Failing test is because Fedora failed to update. This PR is into another PR so I'll merge and let the tests run again there |
Adds a header for common backports shared between the different SUNDIALS solvers such that the main code only needs to differentiate between SUNDIALS pre/post 3.0.0
Tested locally on SUNDIALS 2.7.0, 3.2.1, 4.1.0, 5.8.0, and 6.1.1