|
9 | 9 | #include "sundials/sundials_nvector.h"
|
10 | 10 | #include "sundials_stepper_impl.h"
|
11 | 11 |
|
12 |
| -SUNErrCode SUNStepper_Create(SUNContext sunctx, SUNStepper* stepper) |
| 12 | +SUNErrCode SUNStepper_Create(SUNContext sunctx, SUNStepper* stepper_ptr) |
13 | 13 | {
|
14 | 14 | SUNFunctionBegin(sunctx);
|
15 | 15 |
|
16 |
| - *stepper = NULL; |
17 |
| - *stepper = (SUNStepper)malloc(sizeof(**stepper)); |
| 16 | + SUNStepper stepper = NULL; |
| 17 | + stepper = malloc(sizeof(*stepper)); |
18 | 18 | SUNAssert(stepper, SUN_ERR_MALLOC_FAIL);
|
19 | 19 |
|
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; |
21 | 30 |
|
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); |
24 | 33 |
|
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; |
26 | 39 |
|
27 |
| - /* initialize stepper data */ |
28 |
| - (*stepper)->last_flag = SUN_SUCCESS; |
29 |
| - (*stepper)->sunctx = sunctx; |
| 40 | + *stepper_ptr = stepper; |
30 | 41 |
|
31 | 42 | return SUN_SUCCESS;
|
32 | 43 | }
|
@@ -87,6 +98,13 @@ SUNErrCode SUNStepper_TryStep(SUNStepper stepper, sunrealtype t0,
|
87 | 98 | return SUN_ERR_NOT_IMPLEMENTED;
|
88 | 99 | }
|
89 | 100 |
|
| 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 | + |
90 | 108 | SUNErrCode SUNStepper_SetContent(SUNStepper stepper, void* content)
|
91 | 109 | {
|
92 | 110 | SUNFunctionBegin(stepper->sunctx);
|
|
0 commit comments