Skip to content
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

Support for sundials > 5 #26

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ AS_IF([test "x${with_sundials}" != "xno"] , [
AC_MSG_FAILURE([--with-sundials was given but test for libsundials-dev library failed])
)
)
AC_CHECK_LIB([sundials_core], [SUNContext_Create],
[],
AS_IF([test "x${with_sundials}" != "xcheck"],
AC_MSG_FAILURE([--with-sundials was given but test for libsundials-dev library failed])
)
)
AC_CHECK_HEADER([nvector/nvector_serial.h],
[],
AS_IF([test "x${with_sundials}" != "xcheck"],
Expand Down
8 changes: 6 additions & 2 deletions src/feenox.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@

#ifdef HAVE_SUNDIALS
#include <ida/ida.h>
#include <ida/ida_direct.h>
// #include <ida/ida_direct.h>
#include <nvector/nvector_serial.h>
#include <sundials/sundials_types.h>
#include <sundials/sundials_math.h>
#include <sunmatrix/sunmatrix_dense.h>
#include <sunlinsol/sunlinsol_dense.h>

#ifndef sunrealtype
#define sunrealty realtype
#endif
#endif

// petsc complains if its headers are included from c++ within extern C
Expand Down Expand Up @@ -2094,7 +2098,7 @@ extern int feenox_add_dae(const char *lhs, const char *rhs);
extern int feenox_dae_init(void);
extern int feenox_dae_ic(void);
#ifdef HAVE_SUNDIALS
extern int feenox_ida_dae(realtype t, N_Vector yy, N_Vector yp, N_Vector rr, void *params);
extern int feenox_ida_dae(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector rr, void *params);
#else
extern int feenox_ida_dae(void);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/math/dae.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ char *feenox_find_first_dot(const char *s) {
int feenox_dae_init(void) {

#ifdef HAVE_SUNDIALS
if (sizeof(realtype) != sizeof(double)) {
if (sizeof(sunrealtype) != sizeof(double)) {
feenox_push_error_message("SUNDIALS's realtype is not double");
return FEENOX_ERROR;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ int feenox_dae_ic(void) {


#ifdef HAVE_SUNDIALS
int feenox_ida_dae(realtype t, N_Vector yy, N_Vector yp, N_Vector rr, void *params) {
int feenox_ida_dae(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector rr, void *params) {

// this function is called many times in a single FeenoX time step for intermediate
// times which are internal to IDA, nevertheless there might be some residuals
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ int feenox_parse_phase_space(void) {
return FEENOX_ERROR;
}
#ifdef HAVE_SUNDIALS
if (sizeof(realtype) != sizeof(double)) {
if (sizeof(sunrealtype) != sizeof(double)) {
feenox_push_error_message("\nSUNDIALS was compiled using a different word size than FeenoX, please recompile with double precision floating point arithmetic.");
return FEENOX_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exitifwrong $?
# check TIME_PATH
echo -n "time_path_raw.fee ... "

if [ "x$(${feenox} ${dir}/time_path_sundials.fee | wc -l)" != "x5" ]; then
if [ "x$(${feenox} ${dir}/time_path_raw.fee | wc -l)" != "x5" ]; then
echo "failed"
return 1
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/time_path_sundials.fee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PHASE_SPACE x
TIME_PATH 1e-2 5e-2 1e-1 5e-1 1
end_time = 1
end_time = 1+0.1
x_0 = 1
x_dot = -x
IF in_time_path
Expand Down
Loading