Skip to content

Commit

Permalink
ARKstepCreateSUNStepper -> ARKodeCreateSUNStepper
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Roberts committed Sep 28, 2024
1 parent 12e1c2b commit 319d899
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 468 deletions.
27 changes: 14 additions & 13 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
# SUNDIALS Copyright End
# ---------------------------------------------------------------

# Steps to add an external addon to SUNDIALS:
# WARNING: external addons are not maintained by the SUNDIALS team
# and may come with their own license with different rules.
# Steps to add an external addon to SUNDIALS: WARNING: external addons are not
# maintained by the SUNDIALS team and may come with their own license with
# different rules.
#
# 1. Clone/copy the addon into <sundials root>/external/
# (the same directory as this file you are reading).
# 2. Copy the sundials-addon-example block for your own external project.
# 3. When building SUNDIALS, set the CMake option SUNDIALS_ENABLE_EXTERNAL_ADDONS to ON
# 4. Build SUNDIALS as usual.
# 1. Clone/copy the addon into <sundials root>/external/ (the same directory as
# this file you are reading).
# 2. Copy the sundials-addon-example block for your own external project.
# 3. When building SUNDIALS, set the CMake option SUNDIALS_ENABLE_EXTERNAL_ADDONS
# to ON
# 4. Build SUNDIALS as usual.

include(FetchContent)

# COPY THE FetchContent BLOCK BELOW FOR YOUR OWN EXTERNAL ADDON
# COMMENT THESE LINES OUT TO DISABLE THE EXAMPLE ADDON
FetchContent_Declare(sundials-addon-example
SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/sundials-addon-example
)
# COPY THE FetchContent BLOCK BELOW FOR YOUR OWN EXTERNAL ADDON COMMENT THESE
# LINES OUT TO DISABLE THE EXAMPLE ADDON
FetchContent_Declare(
sundials-addon-example SOURCE_DIR
${PROJECT_SOURCE_DIR}/external/sundials-addon-example)
FetchContent_MakeAvailable(sundials-addon-example)
# COPY THE BLOCK ABOVE FOR YOUR OWN EXTERNAL ADDON
4 changes: 4 additions & 0 deletions include/arkode/arkode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <arkode/arkode_butcher.h>
#include <stdio.h>
#include <sundials/sundials_core.h>
#include <sundials/sundials_stepper.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
Expand Down Expand Up @@ -412,6 +413,9 @@ SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveFails(void* arkode_mem,
SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveIters(void* arkode_mem,
long int* iters);

/* SUNStepper functions */
SUNDIALS_EXPORT int ARKodeCreateSUNStepper(void* arkode_mem, SUNStepper* stepper);

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 0 additions & 4 deletions include/arkode/arkode_arkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ SUNDIALS_EXPORT int ARKStepGetTimestepperStats(
SUNDIALS_EXPORT int ARKStepCreateMRIStepInnerStepper(void* arkode_mem,
MRIStepInnerStepper* stepper);

/* SUNStepper interface functions */
SUNDIALS_EXPORT int ARKStepCreateSUNStepper(void* arkode_mem,
SUNStepper* stepper);

/* --------------------------------------------------------------------------
* Deprecated Functions -- all are superseded by shared ARKODE-level routines
* -------------------------------------------------------------------------- */
Expand Down
44 changes: 22 additions & 22 deletions include/sundials/sundials_stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ extern "C" {
#endif

/* TryStep step result flags */
#define SUNSTEPPER_TRYSTEP_FAILED -1
#define SUNSTEPPER_TRYSTEP_SUCCESS +0
#define SUNSTEPPER_TRYSTEP_ADAPT +1
// #define SUNSTEPPER_TRYSTEP_FAILED (-1)
// #define SUNSTEPPER_TRYSTEP_SUCCESS (+0)
// #define SUNSTEPPER_TRYSTEP_ADAPT (+1)

typedef int (*SUNJacFn)(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac,
void* user_data, N_Vector tmp1, N_Vector tmp2,
Expand All @@ -35,15 +35,15 @@ typedef _SUNDIALS_STRUCT_ SUNStepper_* SUNStepper;

typedef SUNErrCode (*SUNStepperEvolveFn)(SUNStepper stepper, sunrealtype t0,
sunrealtype tout, N_Vector y,
sunrealtype* tret, int* stop_reason);
sunrealtype* tret);

typedef SUNErrCode (*SUNStepperOneStepFn)(SUNStepper stepper, sunrealtype t0,
sunrealtype tout, N_Vector y,
sunrealtype* tret, int* stop_reason);
sunrealtype* tret);

typedef SUNErrCode (*SUNStepperTryStepFn)(SUNStepper stepper, sunrealtype t0,
sunrealtype tout, N_Vector y,
sunrealtype* tret, int* stop_reason);
sunrealtype* tret);

typedef SUNErrCode (*SUNStepperFullRhsFn)(SUNStepper stepper, sunrealtype t,
N_Vector y, N_Vector f, int mode);
Expand All @@ -54,6 +54,11 @@ typedef SUNErrCode (*SUNStepperResetFn)(SUNStepper stepper, sunrealtype tR,
typedef SUNErrCode (*SUNStepperSetStopTimeFn)(SUNStepper stepper,
sunrealtype tstop);

typedef SUNErrCode (*SUNStepperSetForcingFn)(SUNStepper stepper,
sunrealtype tshift,
sunrealtype tscale,
N_Vector* forcing, int nforcing);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_Create(SUNContext sunctx, SUNStepper* stepper);

Expand Down Expand Up @@ -85,37 +90,32 @@ SUNDIALS_EXPORT
SUNErrCode SUNStepper_SetStopTimeFn(SUNStepper stepper,
SUNStepperSetStopTimeFn fn);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_AddForcing(SUNStepper stepper, sunrealtype t, N_Vector f);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_GetForcingData(SUNStepper stepper, sunrealtype* tshift,
sunrealtype* tscale, N_Vector** forcing,
int* nforcing);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_SetForcing(SUNStepper stepper, int count, N_Vector tmpl);
SUNDIALS_EXPORT SUNErrCode SUNStepper_SetForcingFn(SUNStepper stepper,
SUNStepperSetForcingFn fn);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_Evolve(SUNStepper stepper, sunrealtype t0, sunrealtype tout,
N_Vector y, sunrealtype* tret, int* stop_reason);
SUNErrCode SUNStepper_Evolve(SUNStepper stepper, sunrealtype t0,
sunrealtype tout, N_Vector y, sunrealtype* tret);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_OneStep(SUNStepper stepper, sunrealtype t0,
sunrealtype tout, N_Vector y, sunrealtype* tret,
int* stop_reason);
sunrealtype tout, N_Vector y, sunrealtype* tret);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_TryStep(SUNStepper stepper, sunrealtype t0,
sunrealtype tout, N_Vector y, sunrealtype* tret,
int* stop_reason);
sunrealtype tout, N_Vector y, sunrealtype* tret);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_Reset(SUNStepper stepper, sunrealtype tR, N_Vector yR);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_SetStopTime(SUNStepper stepper, sunrealtype tstop);

SUNDIALS_EXPORT
SUNErrCode SUNStepper_SetForcing(SUNStepper stepper, sunrealtype tshift,
sunrealtype tscale, N_Vector* forcing,
int nforcing);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/arkode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(arkode_SOURCES
arkode_sprkstep_io.c
arkode_sprkstep.c
arkode_sprk.c
arkode_sunstepper.c
arkode_user_controller.c
arkode.c)

Expand Down
2 changes: 2 additions & 0 deletions src/arkode/arkode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,11 +1436,13 @@ ARKodeMem arkCreate(SUNContext sunctx)
ark_mem->step_getnumnonlinsolviters = NULL;
ark_mem->step_getnumnonlinsolvconvfails = NULL;
ark_mem->step_getnonlinsolvstats = NULL;
ark_mem->step_setforcing = NULL;
ark_mem->step_mem = NULL;
ark_mem->step_supports_adaptive = SUNFALSE;
ark_mem->step_supports_implicit = SUNFALSE;
ark_mem->step_supports_massmatrix = SUNFALSE;
ark_mem->step_supports_relaxation = SUNFALSE;
ark_mem->step_supports_forcing = SUNFALSE;

/* Initialize root finding variables */
ark_mem->root_mem = NULL;
Expand Down
Loading

0 comments on commit 319d899

Please sign in to comment.