Skip to content

Commit

Permalink
Adjusted order of initial checks in arkInitialSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
drreynolds committed Oct 25, 2024
1 parent 84d4f0d commit 1d87908
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/arkode/arkode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,14 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout)
sunrealtype tout_hin, rh, htmp;
sunbooleantype conOK;

/* Check that user has supplied an initial step size if fixedstep mode is on */
if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO))
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Fixed step mode enabled, but no step size set");
return (ARK_ILL_INPUT);
}

/* If using a built-in routine for error/residual weights with abstol==0,
ensure that N_VMin is available */
if ((!ark_mem->user_efun) && (ark_mem->atolmin0) && (!ark_mem->yn->ops->nvmin))
Expand All @@ -1867,6 +1875,30 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout)
return (ARK_ILL_INPUT);
}

/* Test input tstop for legality (correct direction of integration) */
if (ark_mem->tstopset)
{
htmp = (ark_mem->h == ZERO) ? tout - ark_mem->tcur : ark_mem->h;
if ((ark_mem->tstop - ark_mem->tcur) * htmp <= ZERO)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
MSG_ARK_BAD_TSTOP, ark_mem->tstop, ark_mem->tcur);
return (ARK_ILL_INPUT);
}
}

/* Check to see if y0 satisfies constraints */
if (ark_mem->constraintsSet)
{
conOK = N_VConstrMask(ark_mem->constraints, ark_mem->yn, ark_mem->tempv1);
if (!conOK)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
MSG_ARK_Y0_FAIL_CONSTR);
return (ARK_ILL_INPUT);
}
}

/* Load initial error weights */
retval = ark_mem->efun(ark_mem->yn, ark_mem->ewt, ark_mem->e_data);
if (retval != 0)
Expand Down Expand Up @@ -1923,38 +1955,6 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout)
}
}

/* Check that user has supplied an initial step size if fixedstep mode is on */
if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO))
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Fixed step mode enabled, but no step size set");
return (ARK_ILL_INPUT);
}

/* Test input tstop for legality (correct direction of integration) */
if (ark_mem->tstopset)
{
htmp = (ark_mem->h == ZERO) ? tout - ark_mem->tcur : ark_mem->h;
if ((ark_mem->tstop - ark_mem->tcur) * htmp <= ZERO)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
MSG_ARK_BAD_TSTOP, ark_mem->tstop, ark_mem->tcur);
return (ARK_ILL_INPUT);
}
}

/* Check to see if y0 satisfies constraints */
if (ark_mem->constraintsSet)
{
conOK = N_VConstrMask(ark_mem->constraints, ark_mem->yn, ark_mem->tempv1);
if (!conOK)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
MSG_ARK_Y0_FAIL_CONSTR);
return (ARK_ILL_INPUT);
}
}

/* Create default Hermite interpolation module (if needed) */
if (ark_mem->interp_type != ARK_INTERP_NONE && !(ark_mem->interp))
{
Expand Down

0 comments on commit 1d87908

Please sign in to comment.