From: Daniel Arndt Date: Fri, 3 Nov 2017 16:27:49 +0000 (+0100) Subject: Support both SUNDIALS 2.7.0 and 3.0.0 X-Git-Tag: v9.0.0-rc1~816^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=957585e9d615410f16157acb84563241852627de;p=dealii.git Support both SUNDIALS 2.7.0 and 3.0.0 --- diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index fcf1065a62..1074270ed6 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -216,6 +216,31 @@ (major)*1000000 + (minor)*10000 + (subminor)*100 + (patch)) #endif + /* + * SUNDIALS: + * + * Note: The following definitions will be set in sundials_config.h, + * so we don't repeat them here. + * + * SUNDIALS_VERSION_MAJOR + * SUNDIALS_VERSION_MINOR + * SUNDIALS_VERSION_PATCH + */ + + #define DEAL_II_SUNDIALS_VERSION_GTE(major,minor,subminor) \ + ((SUNDIALS_VERSION_MAJOR * 10000 + \ + SUNDIALS_VERSION_MINOR * 100 + \ + SUNDIALS_VERSION_SUBMINOR) \ + >= \ + (major)*10000 + (minor)*100 + (subminor)) + + #define DEAL_II_SUNDIALS_VERSION_LT(major,minor,subminor) \ + ((SUNDIALS_VERSION_MAJOR * 10000 + \ + SUNDIALS_VERSION_MINOR * 100 + \ + SUNDIALS_VERSION_SUBMINOR) \ + < \ + (major)*10000 + (minor)*100 + (subminor)) + /* * PETSc: * diff --git a/include/deal.II/sundials/ida.h b/include/deal.II/sundials/ida.h index b270ebe0df..5441c4675f 100644 --- a/include/deal.II/sundials/ida.h +++ b/include/deal.II/sundials/ida.h @@ -35,9 +35,12 @@ #include #include -#include -#include -#include +#include +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) +# include +# include +# include +#endif #include #include #include diff --git a/source/sundials/arkode.cc b/source/sundials/arkode.cc index ff2afbad10..33d62dbf70 100644 --- a/source/sundials/arkode.cc +++ b/source/sundials/arkode.cc @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -137,7 +139,9 @@ namespace SUNDIALS template int t_arkode_solve_jacobian(ARKodeMem arkode_mem, N_Vector b, +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) N_Vector, +#endif N_Vector ycur, N_Vector fcur) { @@ -186,8 +190,13 @@ namespace SUNDIALS template int t_arkode_solve_mass(ARKodeMem arkode_mem, +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) N_Vector b, - N_Vector) + N_Vector +#else + N_Vector b +#endif + ) { ARKode &solver = *static_cast *>(arkode_mem->ark_user_data); GrowingVectorMemory mem; @@ -424,7 +433,9 @@ namespace SUNDIALS if (setup_jacobian) { ARKode_mem->ark_lsetup = t_arkode_setup_jacobian; +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) ARKode_mem->ark_setupNonNull = true; +#endif } } else @@ -441,7 +452,9 @@ namespace SUNDIALS if (setup_mass) { ARKode_mem->ark_msetup = t_arkode_setup_mass; +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) ARKode_mem->ark_MassSetupNonNull = true; +#endif } } diff --git a/source/sundials/ida.cc b/source/sundials/ida.cc index 188a44cc97..3bbc1eada6 100644 --- a/source/sundials/ida.cc +++ b/source/sundials/ida.cc @@ -387,7 +387,9 @@ namespace SUNDIALS IDA_mem->ida_lsetup = t_dae_lsetup; IDA_mem->ida_lsolve = t_dae_solve; +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) IDA_mem->ida_setupNonNull = true; +#endif status = IDASetMaxOrd(ida_mem, data.maximum_order); AssertIDA(status); diff --git a/source/sundials/kinsol.cc b/source/sundials/kinsol.cc index 178940a478..d807fbfda0 100644 --- a/source/sundials/kinsol.cc +++ b/source/sundials/kinsol.cc @@ -22,17 +22,24 @@ #include #include #ifdef DEAL_II_WITH_TRILINOS -#include -#include +# include +# include #endif #ifdef DEAL_II_WITH_PETSC -#include -#include +# include +# include #endif #include #include -#include +#include +#if DEAL_II_SUNDIALS_VERSION_GTE(3,0,0) +# include +# include +# include +#else +# include +#endif #include #include @@ -254,12 +261,20 @@ namespace SUNDIALS if (setup_jacobian) { KIN_mem->kin_lsetup = t_kinsol_setup_jacobian; +#if DEAL_II_SUNDIALS_VERSION_LT(3,0,0) KIN_mem->kin_setupNonNull = true; +#endif } } else { +#if DEAL_II_SUNDIALS_VERSION_GTE(3,0,0) + const auto J = SUNDenseMatrix(system_size, system_size); + const auto LS = SUNDenseLinearSolver(u_scale, J); + status = KINDlsSetLinearSolver(kinsol_mem, LS, J); +#else status = KINDense(kinsol_mem, system_size); +#endif AssertKINSOL(status); }