Skip to content

Commit

Permalink
dom eig update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Oct 24, 2024
1 parent c8ca95b commit cbc1a61
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/arkode/C_serial/ark_analytic_lsrk.out
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Final Statistics:
Current time = 10.00468816776983
Steps = 1454
Step attempts = 1457
Stability limited steps = 0
Stability limited steps = 30
Accuracy limited steps = 1457
Error test fails = 3
NLS step fails = 0
Expand All @@ -34,7 +34,7 @@ RHS fn evals = 160393
Number of dom_eig updates = 1
Max. num. of stages used = 196
Max. num. of stages allowed = 200
Max. spectral radius = 1010000.00
Min. spectral radius = 1010000.00
Max. spectral radius = 1010000
Min. spectral radius = 1010000

ACCURACY at the final time = 9.76996e-14
2 changes: 1 addition & 1 deletion examples/arkode/C_serial/ark_analytic_lsrk_varjac.out
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Initial step size = 1.930101110942615e-10
Last step size = 0.02203090645841201
Current step size = 0.02203090645841201
RHS fn evals = 150638
Number of dom_eig updates = 136
Number of dom_eig updates = 65
Max. num. of stages used = 187
Max. num. of stages allowed = 200
Max. spectral radius = 1010099.739553962
Expand Down
6 changes: 3 additions & 3 deletions src/arkode/arkode_lsrkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2255,17 +2255,16 @@ void lsrkStep_DomEigUpdateLogic(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem,
ark_mem->fn_is_current = SUNTRUE;

step_mem->dom_eig_is_current = (step_mem->const_Jac == SUNTRUE);
step_mem->dom_eig_nst = (step_mem->dom_eig_nst + 1) % step_mem->dom_eig_freq;

step_mem->dom_eig_update = SUNFALSE;
if (step_mem->dom_eig_nst == 0)
if(step_mem->dom_eig_nst + step_mem->dom_eig_freq <= ark_mem->nst_attempts)
{
step_mem->dom_eig_update = !step_mem->dom_eig_is_current;
}
}
else
{
step_mem->dom_eig_update = !step_mem->dom_eig_is_current;
step_mem->dom_eig_nst = 0;
}
}

Expand Down Expand Up @@ -2311,6 +2310,7 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem)
SUNRsqrt(SUNSQR(step_mem->lambdaR) + SUNSQR(step_mem->lambdaI));

step_mem->dom_eig_is_current = SUNTRUE;
step_mem->dom_eig_nst = ark_mem->nst_attempts;

step_mem->spectral_radius_max =
(step_mem->spectral_radius > step_mem->spectral_radius_max)
Expand Down
2 changes: 1 addition & 1 deletion src/arkode/arkode_lsrkstep_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef struct ARKodeLSRKStepMemRec
long int dom_eig_num_evals; /* num of dom_eig computations */
int stage_max; /* num of max stages used */
int stage_max_limit; /* max allowed num of stages */
int dom_eig_nst; /* num of steps that successfully used dom_eig; indicates dom_eig update when 0; */
int dom_eig_nst; /* num of step at which the last domainant eigenvalue was computed */

/* Spectral info */
sunrealtype lambdaR; /* Real part of the dominated eigenvalue*/
Expand Down
2 changes: 1 addition & 1 deletion src/arkode/arkode_lsrkstep_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp)
fprintf(fp, " Maximum number of stages allowed = %i\n",
step_mem->stage_max_limit);
fprintf(fp, " Maximum number of stages used = %i\n", step_mem->stage_max);
fprintf(fp, " Num of steps that successfully used dom eig = %i\n",
fprintf(fp, " Num of step when the last dom eig call happened= %i\n",
step_mem->dom_eig_nst);
fprintf(fp, " Current real part of the dom eig = %" RSYM "\n",
step_mem->lambdaR);
Expand Down

0 comments on commit cbc1a61

Please sign in to comment.