Skip to content

Commit

Permalink
nsptes = 0 for freq. means Constant Jacobian
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Jul 19, 2024
1 parent eb8aa11 commit 4af1e9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
9 changes: 3 additions & 6 deletions examples/arkode/C_serial/lsrk_analytic.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,9 @@ int main(void)
flag = LSRKStepSetSprRadFn(arkode_mem, spr);
if (check_flag(&flag, "LSRKStepSetSprRadFn", 1)) { return 1; }

/* Specify Constant Jacobian */
flag = LSRKStepSetConstJac(arkode_mem);
if (check_flag(&flag, "LSRKStepSetConstJac", 1)) { return 1; }

/* Specify after how many successful steps SprRad is recomputed */
flag = LSRKStepSetSprRadFrequency(arkode_mem, 25);
/* Specify after how many successful steps SprRad is recomputed
Note that nsteps = 0 refers to Constant Jacobian */
flag = LSRKStepSetSprRadFrequency(arkode_mem, 0);
if (check_flag(&flag, "LSRKStepSetSprRadFrequency", 1)) { return 1; }

/* Specify max number of stages allowed */
Expand Down
2 changes: 0 additions & 2 deletions include/arkode/arkode_lsrkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ SUNDIALS_EXPORT int LSRKStepSetMethod(void* arkode_mem, ARKODE_LSRKMethodType me

SUNDIALS_EXPORT int LSRKStepSetSprRadFn(void* arkode_mem, ARKSprFn spr);

SUNDIALS_EXPORT int LSRKStepSetConstJac(void* arkode_mem);

SUNDIALS_EXPORT int LSRKStepSetSprRadFrequency(void* arkode_mem, int nsteps);

SUNDIALS_EXPORT int LSRKStepSetMaxStageNum(void* arkode_mem, int stagemaxlimit);
Expand Down
35 changes: 13 additions & 22 deletions src/arkode/arkode_lsrkstep_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,11 @@ int LSRKStepSetSprRadFn(void* arkode_mem, ARKSprFn spr)
}
}

/*---------------------------------------------------------------
LSRKStepSetConstJac sets Constant Jacobian.
---------------------------------------------------------------*/
int LSRKStepSetConstJac(void* arkode_mem)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
int retval;

/* access ARKodeMem and ARKodeLSRKStepMem structures */
retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem,
&step_mem);
if (retval != ARK_SUCCESS) { return (retval); }

step_mem->constJac = SUNTRUE;

return (ARK_SUCCESS);
}

/*---------------------------------------------------------------
LSRKStepSetSprRadFrequency sets SprRad computation frequency -
Spectral Radius is recomputed after "nsteps" successful steps.
nsteps = 0 refers to Constant Jacobian
---------------------------------------------------------------*/
int LSRKStepSetSprRadFrequency(void* arkode_mem, int nsteps)
{
Expand All @@ -139,14 +122,22 @@ int LSRKStepSetSprRadFrequency(void* arkode_mem, int nsteps)
&step_mem);
if (retval != ARK_SUCCESS) { return (retval); }

if (nsteps < 1)
if (nsteps < 0)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"nsteps must be greater than 0");
"nsteps must be greater than or equal to 0");
return (ARK_ILL_INPUT);
}

step_mem->sprfreq = nsteps;
if (nsteps == 0)
{
step_mem->constJac = SUNTRUE;
step_mem->sprfreq = 1;
}
else
{
step_mem->sprfreq = nsteps;
}

return (ARK_SUCCESS);
}
Expand Down

0 comments on commit 4af1e9f

Please sign in to comment.