From 47e16b2267abf378970ecd7842a878f548f792c6 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 21 May 2024 07:46:15 -0700 Subject: [PATCH] update input checks and comments in SetDegree --- src/arkode/arkode_interp.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/arkode/arkode_interp.c b/src/arkode/arkode_interp.c index 9ed3c38b05..daf42de479 100644 --- a/src/arkode/arkode_interp.c +++ b/src/arkode/arkode_interp.c @@ -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 @@ -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; @@ -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 @@ -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;