Skip to content

Commit a030d57

Browse files
committed
minor fixes
1 parent f97e71b commit a030d57

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

include/sundials/sundials_stepper.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
extern "C" {
2020
#endif
2121

22-
typedef _SUNDIALS_STRUCT_ SUNStepper_s* SUNStepper;
22+
typedef int (*SUNJacFn)(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac,
23+
void* user_data, N_Vector tmp1, N_Vector tmp2,
24+
N_Vector tmp3);
25+
26+
typedef int (*SUNJacTimesFn)(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y,
27+
N_Vector fy, void* user_data, N_Vector tmp);
28+
29+
typedef _SUNDIALS_STRUCT_ SUNStepper_* SUNStepper;
2330

2431
typedef int (*SUNStepperAdvanceFn)(SUNStepper stepper, sunrealtype t0,
2532
sunrealtype tout, N_Vector y,
@@ -87,6 +94,9 @@ SUNErrCode SUNStepper_TryStep(SUNStepper stepper, sunrealtype t0,
8794
sunrealtype tout, N_Vector y, sunrealtype* tret,
8895
int* stop_reason);
8996

97+
SUNDIALS_EXPORT
98+
SUNErrCode SUNStepper_Reset(SUNStepper stepper, sunrealtype tR, N_Vector yR);
99+
90100
#ifdef __cplusplus
91101
}
92102
#endif

src/sundials/sundials_stepper.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,35 @@
99
#include "sundials/sundials_nvector.h"
1010
#include "sundials_stepper_impl.h"
1111

12-
SUNErrCode SUNStepper_Create(SUNContext sunctx, SUNStepper* stepper)
12+
SUNErrCode SUNStepper_Create(SUNContext sunctx, SUNStepper* stepper_ptr)
1313
{
1414
SUNFunctionBegin(sunctx);
1515

16-
*stepper = NULL;
17-
*stepper = (SUNStepper)malloc(sizeof(**stepper));
16+
SUNStepper stepper = NULL;
17+
stepper = malloc(sizeof(*stepper));
1818
SUNAssert(stepper, SUN_ERR_MALLOC_FAIL);
1919

20-
memset(*stepper, 0, sizeof(**stepper));
20+
stepper->content = NULL;
21+
stepper->sunctx = sunctx;
22+
stepper->last_flag = SUN_SUCCESS;
23+
stepper->forcing = NULL;
24+
stepper->nforcing = 0;
25+
stepper->nforcing_allocated = 0;
26+
stepper->tshift = SUN_RCONST(0.0);
27+
stepper->tscale = SUN_RCONST(0.0);
28+
stepper->fused_scalars = NULL;
29+
stepper->fused_vectors = NULL;
2130

22-
(*stepper)->ops = (SUNStepper_Ops)malloc(sizeof(*((*stepper)->ops)));
23-
SUNAssert((*stepper)->ops, SUN_ERR_MALLOC_FAIL);
31+
stepper->ops = malloc(sizeof(*(stepper->ops)));
32+
SUNAssert(stepper->ops, SUN_ERR_MALLOC_FAIL);
2433

25-
memset((*stepper)->ops, 0, sizeof(*((*stepper)->ops)));
34+
stepper->ops->advance = NULL;
35+
stepper->ops->onestep = NULL;
36+
stepper->ops->trystep = NULL;
37+
stepper->ops->fullrhs = NULL;
38+
stepper->ops->reset = NULL;
2639

27-
/* initialize stepper data */
28-
(*stepper)->last_flag = SUN_SUCCESS;
29-
(*stepper)->sunctx = sunctx;
40+
*stepper_ptr = stepper;
3041

3142
return SUN_SUCCESS;
3243
}
@@ -87,6 +98,13 @@ SUNErrCode SUNStepper_TryStep(SUNStepper stepper, sunrealtype t0,
8798
return SUN_ERR_NOT_IMPLEMENTED;
8899
}
89100

101+
SUNErrCode SUNStepper_Reset(SUNStepper stepper, sunrealtype tR, N_Vector yR)
102+
{
103+
SUNFunctionBegin(stepper->sunctx);
104+
if (stepper->ops->advance) { return stepper->ops->reset(stepper, tR, yR); }
105+
return SUN_ERR_NOT_IMPLEMENTED;
106+
}
107+
90108
SUNErrCode SUNStepper_SetContent(SUNStepper stepper, void* content)
91109
{
92110
SUNFunctionBegin(stepper->sunctx);

src/sundials/sundials_stepper_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
extern "C" {
2121
#endif
2222

23-
typedef struct SUNStepper_Ops_s* SUNStepper_Ops;
23+
typedef struct SUNStepper_Ops_* SUNStepper_Ops;
2424

25-
struct SUNStepper_Ops_s
25+
struct SUNStepper_Ops_
2626
{
2727
SUNStepperAdvanceFn advance;
2828
SUNStepperOneStepFn onestep;
@@ -31,7 +31,7 @@ struct SUNStepper_Ops_s
3131
SUNStepperResetFn reset;
3232
};
3333

34-
struct SUNStepper_s
34+
struct SUNStepper_
3535
{
3636
/* stepper specific content and operations */
3737
void* content;

0 commit comments

Comments
 (0)