Skip to content

Commit

Permalink
Add more asserts to controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Roberts committed Sep 11, 2024
1 parent f81a60d commit 7669c93
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ SUNErrCode SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C,
{
SUNFunctionBegin(C->sunctx);

SUNAssert(hnew, SUN_ERR_ARG_CORRUPT);

/* order parameter to use */
const int ord = p + 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ SUNErrCode SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C,
sunrealtype* hnew)
{
SUNFunctionBegin(C->sunctx);
SUNAssert(hnew, SUN_ERR_ARG_CORRUPT);

/* order parameter to use */
const int ord = p + 1;
Expand Down
7 changes: 7 additions & 0 deletions src/sundials/sundials_adaptcontroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <sundials/priv/sundials_errors_impl.h>
#include <sundials/sundials_adaptcontroller.h>
#include <math.h>

#include "sundials/sundials_errors.h"

Expand Down Expand Up @@ -131,6 +132,9 @@ SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h,
SUNErrCode ier = SUN_SUCCESS;
if (C == NULL) { return SUN_ERR_ARG_CORRUPT; }
SUNFunctionBegin(C->sunctx);
SUNAssert(isfinite(h), SUN_ERR_ARG_OUTOFRANGE);
SUNAssert(p > 0, SUN_ERR_ARG_OUTOFRANGE);
SUNAssert(dsm >= SUN_RCONST(0.0), SUN_ERR_ARG_OUTOFRANGE);
SUNAssert(hnew, SUN_ERR_ARG_CORRUPT);
*hnew = h; /* initialize output with identity */
if (C->ops->estimatestep) { ier = C->ops->estimatestep(C, h, p, dsm, hnew); }
Expand Down Expand Up @@ -170,6 +174,7 @@ SUNErrCode SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bia
SUNErrCode ier = SUN_SUCCESS;
if (C == NULL) { return SUN_ERR_ARG_CORRUPT; }
SUNFunctionBegin(C->sunctx);
SUNAssert(bias >= SUN_RCONST(1.0), SUN_ERR_ARG_OUTOFRANGE);
if (C->ops->seterrorbias) { ier = C->ops->seterrorbias(C, bias); }
return (ier);
}
Expand All @@ -180,6 +185,8 @@ SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h,
SUNErrCode ier = SUN_SUCCESS;
if (C == NULL) { return SUN_ERR_ARG_CORRUPT; }
SUNFunctionBegin(C->sunctx);
SUNAssert(isfinite(h), SUN_ERR_ARG_OUTOFRANGE);
SUNAssert(dsm >= SUN_RCONST(0.0), SUN_ERR_ARG_OUTOFRANGE);
if (C->ops->updateh) { ier = C->ops->updateh(C, h, dsm); }
return (ier);
}
Expand Down

0 comments on commit 7669c93

Please sign in to comment.