Skip to content

Commit

Permalink
RK? flags and LSRKodeSet->LSRKStepSet
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Jul 18, 2024
1 parent 116c653 commit 24ddec1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
21 changes: 14 additions & 7 deletions include/arkode/arkode_lsrkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ typedef int (*ARKSprFn)(sunrealtype t, sunrealtype* extsprad, void* user_data);
* LSRKStep Constants
* ------------------ */

/* Method ID for RKC*/
#define RKC 1
/* Method ID for RKL*/
#define RKL 2
/* Method ID for RKG*/
#define RKG 3

/* -------------------
* Exported Functions
* ------------------- */
Expand All @@ -38,17 +45,17 @@ typedef int (*ARKSprFn)(sunrealtype t, sunrealtype* extsprad, void* user_data);
SUNDIALS_EXPORT void* LSRKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0,
N_Vector y0, SUNContext sunctx);

SUNDIALS_EXPORT int LSRKodeSetMethod(void* arkode_mem, int method);
SUNDIALS_EXPORT int LSRKStepSetMethod(void* arkode_mem, int method);

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

SUNDIALS_EXPORT int LSRKodeSetConstJac(void* arkode_mem);
SUNDIALS_EXPORT int LSRKStepSetConstJac(void* arkode_mem);

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

SUNDIALS_EXPORT int LSRKodeSetMaxStageNum(void* arkode_mem, int stagemaxlimit);
SUNDIALS_EXPORT int LSRKStepSetMaxStageNum(void* arkode_mem, int stagemaxlimit);

SUNDIALS_EXPORT int LSRKodeSetSprRadSafetyFactor(void* arkode_mem,
SUNDIALS_EXPORT int LSRKStepSetSprRadSafetyFactor(void* arkode_mem,
sunrealtype sprsfty);

SUNDIALS_EXPORT int LSRKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi,
Expand All @@ -72,4 +79,4 @@ SUNDIALS_EXPORT int LSRKStepGetTimestepperStats(
}
#endif

#endif
#endif
9 changes: 4 additions & 5 deletions src/arkode/arkode_lsrkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,9 @@ sunbooleantype lsrkStep_CheckNVector(N_Vector tmpl)
}

/*---------------------------------------------------------------
lsrkStep_SprRadUpdateLogic:
lsrkStep_ComputeNewSprRad:
This routine checks if the step is accepted or not and reassigns
the SprRad update flags accordingly.
This routine computes new SprRad and returns SUN_SUCCESS.
---------------------------------------------------------------*/

int lsrkStep_ComputeNewSprRad(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem)
Expand All @@ -998,7 +997,7 @@ int lsrkStep_ComputeNewSprRad(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem)
{
printf("\nInternal SprRad is not supported yet!");
printf(
"\nCall LSRKodeSetSprRadFn to provide an external SprRad function\n");
"\nCall LSRKStepSetSprRadFn to provide an external SprRad function\n");

return (ARK_ILL_INPUT);
}
Expand Down Expand Up @@ -1043,4 +1042,4 @@ void lsrkStep_SprRadUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem,

/*===============================================================
EOF
===============================================================*/
===============================================================*/
3 changes: 1 addition & 2 deletions src/arkode/arkode_lsrkstep_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ int lsrkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname,
void lsrkStep_SprRadUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem,
sunrealtype dsm);
sunbooleantype lsrkStep_CheckNVector(N_Vector tmpl);
int lsrkStep_ComputeNewSprRad(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem);

/*===============================================================
Reusable LSRKStep Error Messages
Expand All @@ -124,4 +123,4 @@ int lsrkStep_ComputeNewSprRad(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem);
}
#endif

#endif
#endif
39 changes: 20 additions & 19 deletions src/arkode/arkode_lsrkstep_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
===============================================================*/

/*---------------------------------------------------------------
LSRKodeSetMethod sets method
RKC => method = 1
RKL => method = 2
RKG => method = 3
LSRKStepSetMethod sets method
RKC => method = RKC
RKL => method = RKL
RKG => method = RKG
---------------------------------------------------------------*/
int LSRKodeSetMethod(void* arkode_mem, int method)
int LSRKStepSetMethod(void* arkode_mem, int method)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
Expand All @@ -50,15 +50,15 @@ int LSRKodeSetMethod(void* arkode_mem, int method)

switch (method)
{
case 1:
case RKC:
ark_mem->step = lsrkStep_TakeStepRKC;
printf("\nSolving with RKC method\n\n");
break;
case 2:
case RKL:
ark_mem->step = lsrkStep_TakeStepRKL;
printf("\nSolving with RKL method\n\n");
break;
case 3:
case RKG:
ark_mem->step = lsrkStep_TakeStepRKG;
printf("\nSolving with RKG method\n\n");
break;
Expand All @@ -73,9 +73,9 @@ int LSRKodeSetMethod(void* arkode_mem, int method)
}

/*---------------------------------------------------------------
LSRKodeSetSprRadFn specifies the SprRad function.
LSRKStepSetSprRadFn specifies the SprRad function.
---------------------------------------------------------------*/
int LSRKodeSetSprRadFn(void* arkode_mem, ARKSprFn spr)
int LSRKStepSetSprRadFn(void* arkode_mem, ARKSprFn spr)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
Expand Down Expand Up @@ -106,9 +106,9 @@ int LSRKodeSetSprRadFn(void* arkode_mem, ARKSprFn spr)
}

/*---------------------------------------------------------------
LSRKodeSetConstJac sets Constant Jacobian.
LSRKStepSetConstJac sets Constant Jacobian.
---------------------------------------------------------------*/
int LSRKodeSetConstJac(void* arkode_mem)
int LSRKStepSetConstJac(void* arkode_mem)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
Expand All @@ -125,10 +125,10 @@ int LSRKodeSetConstJac(void* arkode_mem)
}

/*---------------------------------------------------------------
LSRKodeSetSprRadFrequency sets SprRad computation frequency -
LSRKStepSetSprRadFrequency sets SprRad computation frequency -
Spectral Radius is recomputed after "nsteps" successful steps.
---------------------------------------------------------------*/
int LSRKodeSetSprRadFrequency(void* arkode_mem, int nsteps)
int LSRKStepSetSprRadFrequency(void* arkode_mem, int nsteps)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
Expand All @@ -152,9 +152,9 @@ int LSRKodeSetSprRadFrequency(void* arkode_mem, int nsteps)
}

/*---------------------------------------------------------------
LSRKodeSetMaxStageNum sets the maximum number of stages allowed.
LSRKStepSetMaxStageNum sets the maximum number of stages allowed.
---------------------------------------------------------------*/
int LSRKodeSetMaxStageNum(void* arkode_mem, int stagemaxlimit)
int LSRKStepSetMaxStageNum(void* arkode_mem, int stagemaxlimit)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
Expand All @@ -178,9 +178,9 @@ int LSRKodeSetMaxStageNum(void* arkode_mem, int stagemaxlimit)
}

/*---------------------------------------------------------------
LSRKodeSetSprRadSafetyFactor sets the maximum number of stages allowed.
LSRKStepSetSprRadSafetyFactor sets the maximum number of stages allowed.
---------------------------------------------------------------*/
int LSRKodeSetSprRadSafetyFactor(void* arkode_mem, sunrealtype sprsfty)
int LSRKStepSetSprRadSafetyFactor(void* arkode_mem, sunrealtype sprsfty)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
Expand Down Expand Up @@ -444,6 +444,7 @@ int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp)

/* print integrator parameters to file */
fprintf(fp, "LSRKStep time step module parameters:\n");
fprintf(fp, " Method order %i\n", NULL);
fprintf(fp, "\n");

printf("\nlsrkStep_WriteParameters is not ready yet!\n");
Expand All @@ -453,4 +454,4 @@ int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp)

/*===============================================================
EOF
===============================================================*/
===============================================================*/

0 comments on commit 24ddec1

Please sign in to comment.