Skip to content

Commit 17f57b3

Browse files
committed
Formatting
1 parent 86759b5 commit 17f57b3

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

src/arkode/arkode_lsrkstep.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,13 @@ void lsrkStep_Free(ARKodeMem ark_mem)
306306
{
307307
free(step_mem->cvals);
308308
step_mem->cvals = NULL;
309-
ark_mem->lrw -= 5;
309+
ark_mem->lrw -= step_mem->nfusedopvecs;
310310
}
311311
if (step_mem->Xvecs != NULL)
312312
{
313313
free(step_mem->Xvecs);
314314
step_mem->Xvecs = NULL;
315-
ark_mem->liw -= 5;
315+
ark_mem->liw -= step_mem->nfusedopvecs;
316316
}
317317

318318
/* free the time stepper module itself */
@@ -429,15 +429,15 @@ int lsrkStep_Init(ARKodeMem ark_mem, int init_type)
429429
/* Allocate reusable arrays for fused vector interface */
430430
if (step_mem->cvals == NULL)
431431
{
432-
step_mem->cvals = (sunrealtype*)calloc(5, sizeof(sunrealtype));
432+
step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, sizeof(sunrealtype));
433433
if (step_mem->cvals == NULL) { return (ARK_MEM_FAIL); }
434-
ark_mem->lrw += 5;
434+
ark_mem->lrw += step_mem->nfusedopvecs;
435435
}
436436
if (step_mem->Xvecs == NULL)
437437
{
438-
step_mem->Xvecs = (N_Vector*)calloc(5, sizeof(N_Vector));
438+
step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, sizeof(N_Vector));
439439
if (step_mem->Xvecs == NULL) { return (ARK_MEM_FAIL); }
440-
ark_mem->liw += 5; /* pointers */
440+
ark_mem->liw += step_mem->nfusedopvecs; /* pointers */
441441
}
442442

443443
/* Signal to shared arkode module that full RHS evaluations are required */
@@ -564,7 +564,7 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
564564
sunrealtype* cvals;
565565
sunrealtype w0, w1, temp1, temp2, arg, bjm1, bjm2, mus, thjm1, thjm2, zjm1,
566566
zjm2, dzjm1, dzjm2, d2zjm1, d2zjm2, zj, dzj, d2zj, bj, ajm1, mu, nu, thj;
567-
sunrealtype onep54 = 1.54, c13 = 13.0, p8 = 0.8, p4 = 0.4;
567+
static sunrealtype onep54 = SUN_RCONST(1.54), c13 = SUN_RCONST(13.0), p8 = SUN_RCONST(0.8), p4 = SUN_RCONST(0.4);
568568
N_Vector* Xvecs;
569569
ARKodeLSRKStepMem step_mem;
570570

@@ -673,7 +673,7 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
673673
cvals[4] = -mus * ajm1 * ark_mem->h;
674674
Xvecs[4] = ark_mem->fn;
675675

676-
retval = N_VLinearCombination(5, cvals, Xvecs, ark_mem->ycur);
676+
retval = N_VLinearCombination(step_mem->nfusedopvecs, cvals, Xvecs, ark_mem->ycur);
677677
if (retval != 0) { return (ARK_VECTOROP_ERR); }
678678

679679
thj = mu * thjm1 + nu * thjm2 + mus * (ONE - ajm1);
@@ -757,7 +757,7 @@ int lsrkStep_TakeStepRKL(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
757757
int retval;
758758
sunrealtype* cvals;
759759
sunrealtype w1, bjm1, bjm2, mus, bj, ajm1, cjm1, temj, cj, mu, nu;
760-
sunrealtype p8 = 0.8, p4 = 0.4;
760+
static sunrealtype p8 = SUN_RCONST(0.8), p4 = SUN_RCONST(0.4);
761761
N_Vector* Xvecs;
762762
ARKodeLSRKStepMem step_mem;
763763

@@ -850,7 +850,7 @@ int lsrkStep_TakeStepRKL(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
850850
cvals[4] = -mus * ajm1 * ark_mem->h;
851851
Xvecs[4] = ark_mem->fn;
852852

853-
retval = N_VLinearCombination(5, cvals, Xvecs, ark_mem->ycur);
853+
retval = N_VLinearCombination(step_mem->nfusedopvecs, cvals, Xvecs, ark_mem->ycur);
854854
if (retval != 0) { return (ARK_VECTOROP_ERR); }
855855

856856
/* Shift the data for the next stage */
@@ -938,10 +938,11 @@ int lsrkStep_TakeStepSSPs2(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr
938938
sunrealtype sm1inv = ONE / (rs - ONE);
939939
sunrealtype bt1, bt2, bt3;
940940

941+
/* Embedding coefficients differ when reqstages == 2 */
941942
if (step_mem->reqstages == 2)
942943
{
943-
bt1 = 0.694021459207626;
944-
bt3 = 1 - 0.694021459207626;
944+
bt1 = SUN_RCONST(0.694021459207626);
945+
bt3 = ONE - bt1;
945946
}
946947
else
947948
{
@@ -1183,7 +1184,9 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt
11831184
*nflagPtr = ARK_SUCCESS;
11841185
*dsmPtr = ZERO;
11851186

1186-
sunrealtype onesixth = 1.0 / 6.0;
1187+
static sunrealtype onesixth = ONE / SIX, onefifth = ONE / FIVE, p1 = SUN_RCONST(0.1), p3 = SUN_RCONST(0.3),
1188+
p6 = SUN_RCONST(0.6), onetwntyfth = SUN_RCONST(1.0/25.0), onetwntynth = SUN_RCONST(9.0/25.0),
1189+
fifteen = SUN_RCONST(15.0), negfive = SUN_RCONST(-5.0);
11871190

11881191
/* access ARKodeLSRKStepMem structure */
11891192
retval = lsrkStep_AccessStepMem(ark_mem, __func__, &step_mem);
@@ -1211,7 +1214,7 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt
12111214

12121215
N_VLinearSum(ONE, ark_mem->yn, onesixth * ark_mem->h, ark_mem->fn,
12131216
ark_mem->ycur);
1214-
N_VLinearSum(ONE, ark_mem->yn, 1.0 / 5.0 * ark_mem->h, ark_mem->fn,
1217+
N_VLinearSum(ONE, ark_mem->yn, onefifth * ark_mem->h, ark_mem->fn,
12151218
ark_mem->tempv1);
12161219

12171220
/* Evaluate stages j = 2,...,step_mem->reqstages */
@@ -1226,17 +1229,17 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt
12261229
ark_mem->ycur);
12271230
if (j == 4)
12281231
{
1229-
N_VLinearSum(ONE, ark_mem->tempv1, 3.0 / 10.0 * ark_mem->h, ark_mem->fn,
1232+
N_VLinearSum(ONE, ark_mem->tempv1, p3 * ark_mem->h, ark_mem->fn,
12301233
ark_mem->tempv1);
12311234
}
12321235
}
1233-
N_VLinearSum(1.0 / 25.0, ark_mem->tempv2, 9.0 / 25.0, ark_mem->ycur,
1236+
N_VLinearSum(onetwntyfth, ark_mem->tempv2, onetwntynth, ark_mem->ycur,
12341237
ark_mem->tempv2);
1235-
N_VLinearSum(15, ark_mem->tempv2, -5, ark_mem->ycur, ark_mem->ycur);
1238+
N_VLinearSum(fifteen, ark_mem->tempv2, negfive, ark_mem->ycur, ark_mem->ycur);
12361239
for (int j = 6; j <= 9; j++)
12371240
{
12381241
retval = step_mem->fe(ark_mem->tcur +
1239-
((sunrealtype)j - 4.0) * onesixth * ark_mem->h,
1242+
((sunrealtype)j - FOUR) * onesixth * ark_mem->h,
12401243
ark_mem->ycur, ark_mem->fn, ark_mem->user_data);
12411244
if (retval != ARK_SUCCESS) { return (ARK_RHSFUNC_FAIL); }
12421245

@@ -1245,12 +1248,12 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt
12451248

12461249
if (j == 7)
12471250
{
1248-
N_VLinearSum(ONE, ark_mem->tempv1, 1.0 / 5.0 * ark_mem->h, ark_mem->fn,
1251+
N_VLinearSum(ONE, ark_mem->tempv1, onefifth * ark_mem->h, ark_mem->fn,
12491252
ark_mem->tempv1);
12501253
}
12511254
if (j == 9)
12521255
{
1253-
N_VLinearSum(ONE, ark_mem->tempv1, 3.0 / 10.0 * ark_mem->h, ark_mem->fn,
1256+
N_VLinearSum(ONE, ark_mem->tempv1, p3 * ark_mem->h, ark_mem->fn,
12541257
ark_mem->tempv1);
12551258
}
12561259
}
@@ -1259,8 +1262,8 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt
12591262
ark_mem->user_data);
12601263
if (retval != ARK_SUCCESS) { return (ARK_RHSFUNC_FAIL); }
12611264

1262-
N_VLinearSum(ONE, ark_mem->tempv2, 3.0 / 5.0, ark_mem->ycur, ark_mem->ycur);
1263-
N_VLinearSum(ONE, ark_mem->ycur, 1.0 / 10.0 * ark_mem->h, ark_mem->fn,
1265+
N_VLinearSum(ONE, ark_mem->tempv2, p6, ark_mem->ycur, ark_mem->ycur);
1266+
N_VLinearSum(ONE, ark_mem->ycur, p1 * ark_mem->h, ark_mem->fn,
12641267
ark_mem->ycur);
12651268

12661269
step_mem->nfe += 9;

src/arkode/arkode_lsrkstep_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ typedef struct ARKodeLSRKStepMemRec
8585
/* Reusable fused vector operation arrays */
8686
sunrealtype* cvals;
8787
N_Vector* Xvecs;
88+
int nfusedopvecs; /* length of cvals and Xvecs arrays */
8889

8990
}* ARKodeLSRKStepMem;
9091

src/arkode/arkode_lsrkstep_io.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ int LSRKStepSetMethod(void* arkode_mem, ARKODE_LSRKMethodType method)
5656
case ARKODE_LSRK_RKC:
5757
ark_mem->step = lsrkStep_TakeStepRKC;
5858
step_mem->LSRKmethod = ARKODE_LSRK_RKC;
59+
step_mem->nfusedopvecs = 5;
5960
break;
6061
case ARKODE_LSRK_RKL:
6162
ark_mem->step = lsrkStep_TakeStepRKL;
6263
step_mem->LSRKmethod = ARKODE_LSRK_RKL;
64+
step_mem->nfusedopvecs = 5;
6365
break;
6466
// case ARKODE_LSRK_RKG:
6567
// ark_mem->step = lsrkStep_TakeStepRKG;
6668
// step_mem->LSRKmethod = ARKODE_LSRK_RKG;
69+
// step_mem->nfusedopvecs = 5;
6770
// break;
6871
case ARKODE_LSRK_SSPs_2:
6972
ark_mem->step = lsrkStep_TakeStepSSPs2;

0 commit comments

Comments
 (0)