Skip to content

Commit

Permalink
update input checks and comments in SetDegree
Browse files Browse the repository at this point in the history
  • Loading branch information
gardner48 committed May 21, 2024
1 parent 1f0a093 commit 47e16b2
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions src/arkode/arkode_interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,8 @@ void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile)
/*---------------------------------------------------------------
arkInterpSetDegree_Hermite
This routine sets a supplied interpolation degree. If the
argument is positive, then we require that
0 <= degree <= ARK_INTERP_MAX_DEGREE
and use this value as the user-specified (or default) degree.
If the argument is negative, then we assume that this has been
called by a time-step module to limit the interpolant degree
based on the temporal method order. In this case we set the
Hermite polynomial degree to be the minimum of (-degree),
ARK_INTERP_MAX_DEGREE, and the previously-set value [i.e., in
case the user has already specified use of a lower-degree
polynomial].
This routine sets a supplied interpolation degree which must be
in the range 0 <= degree <= ARK_INTERP_MAX_DEGREE.
Return values:
ARK_ILL_INPUT -- if the input is outside of allowable bounds
Expand All @@ -312,15 +302,13 @@ void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile)
---------------------------------------------------------------*/
int arkInterpSetDegree_Hermite(ARKodeMem ark_mem, ARKInterp interp, int degree)
{
if (degree > ARK_INTERP_MAX_DEGREE)
if (degree > ARK_INTERP_MAX_DEGREE || degree < 0)
{
arkProcessError(ark_mem, ARK_INTERP_FAIL, __LINE__, __func__, __FILE__,
"Illegal degree specified.");
return ARK_ILL_INPUT;
}

if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; }

HINT_DEGREE(interp) = degree;

return ARK_SUCCESS;
Expand Down Expand Up @@ -1005,18 +993,8 @@ void arkInterpPrintMem_Lagrange(ARKInterp I, FILE* outfile)
/*---------------------------------------------------------------
arkInterpSetDegree_Lagrange
This routine sets a supplied interpolation degree. If the
argument is positive, then we require that
0 <= degree <= ARK_INTERP_MAX_DEGREE
and use this value as the user-specified (or default) degree.
If the argument is negative, then we assume that this has been
called by a time-step module to limit the interpolant degree
based on the temporal method order. In this case we set the
Lagrange polynomial degree to be the minimum of (-degree),
ARK_INTERP_MAX_DEGREE, and the previously-set value [i.e., in
case the user has already specified use of a lower-degree
polynomial].
This routine sets a supplied interpolation degree which must be
in the range 0 <= degree <= ARK_INTERP_MAX_DEGREE.
Return values:
ARK_ILL_INPUT -- if the input is outside of allowable bounds
Expand All @@ -1026,15 +1004,13 @@ void arkInterpPrintMem_Lagrange(ARKInterp I, FILE* outfile)
---------------------------------------------------------------*/
int arkInterpSetDegree_Lagrange(ARKodeMem ark_mem, ARKInterp I, int degree)
{
if (degree > ARK_INTERP_MAX_DEGREE)
if (degree > ARK_INTERP_MAX_DEGREE || degree < 0)
{
arkProcessError(ark_mem, ARK_INTERP_FAIL, __LINE__, __func__, __FILE__,
"Illegal degree specified.");
return ARK_ILL_INPUT;
}

if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; }

LINT_NMAX(I) = degree + 1;

return ARK_SUCCESS;
Expand Down

0 comments on commit 47e16b2

Please sign in to comment.