-
Notifications
You must be signed in to change notification settings - Fork 163
Feature/stageprocessing #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/fes-staging
Are you sure you want to change the base?
Changes from all commits
328eea1
9195cda
876b016
0fa2494
c8bf4cb
4b24a20
e16f6f2
0e0b8d2
84f706b
98864f9
f8736ea
d6d209e
801108c
a76be01
1036279
2f6a251
019702b
ed6d1f4
66985fa
24792e5
4fb8e68
c9b0b06
2920ca4
e9af994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -904,6 +904,18 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, | |
| "step = %li, tn = " SUN_FORMAT_G ", h = " SUN_FORMAT_G, | ||
| ark_mem->nst + 1, ark_mem->tn, ark_mem->h); | ||
|
|
||
| /* fill (tcur,ycur) with the last accepted step solution */ | ||
| ark_mem->tcur = ark_mem->tn; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note in the change log this fixes an error in the logging output where the time of the first stage would be incorrect when reattempting a step. |
||
| N_VScale(ONE, ark_mem->yn, ark_mem->ycur); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In some cases this copy is redundant (i.e., when taking internal steps in normal mode) because
Some related issues when preprocessing a step:
|
||
|
|
||
| /* call the user-supplied step preprocessing function (if it exists) */ | ||
| if (ark_mem->PreProcessStep != NULL) | ||
| { | ||
| retval = ark_mem->PreProcessStep(ark_mem->tcur, ark_mem->ycur, | ||
| ark_mem->ps_data); | ||
| if (retval != 0) { return (ARK_POSTPROCESS_STEP_FAIL); } | ||
| } | ||
|
|
||
| /* Call time stepper module to attempt a step: | ||
| 0 => step completed successfully | ||
| >0 => step encountered recoverable failure; reduce step if possible | ||
|
|
@@ -1001,6 +1013,14 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, | |
| ark_mem->h *= ark_mem->eta; | ||
| ark_mem->next_h = ark_mem->hprime = ark_mem->h; | ||
|
|
||
| /* since the previous step attempt failed, call the user-supplied step failure postprocessing function (if it exists) */ | ||
| if (ark_mem->PostProcessStepFail != NULL) | ||
| { | ||
| retval = ark_mem->PostProcessStepFail(ark_mem->tcur, ark_mem->ycur, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a failed step This would also address the idea noted above about possibly not needing to call |
||
| ark_mem->ps_data); | ||
| if (retval != 0) { return (ARK_POSTPROCESS_STEP_FAIL); } | ||
| } | ||
|
|
||
| } /* end looping for step attempts */ | ||
|
|
||
| /* If step attempt loop succeeded, complete step (update current time, solution, | ||
|
|
@@ -1587,12 +1607,15 @@ ARKodeMem arkCreate(SUNContext sunctx) | |
| ark_mem->VRabstolMallocDone = SUNFALSE; | ||
| ark_mem->MallocDone = SUNFALSE; | ||
|
|
||
| /* No user-supplied step postprocessing function yet */ | ||
| ark_mem->ProcessStep = NULL; | ||
| ark_mem->ps_data = NULL; | ||
| /* No user-supplied step pre- or post-processing functions yet */ | ||
| ark_mem->PreProcessStep = NULL; | ||
| ark_mem->PostProcessStep = NULL; | ||
| ark_mem->PostProcessStepFail = NULL; | ||
| ark_mem->ps_data = NULL; | ||
|
|
||
| /* No user-supplied stage postprocessing function yet */ | ||
| ark_mem->ProcessStage = NULL; | ||
| /* No user-supplied stage pre- or post-processing functions yet */ | ||
| ark_mem->PreProcessRHS = NULL; | ||
| ark_mem->PostProcessStage = NULL; | ||
|
|
||
| /* No user_data pointer yet */ | ||
| ark_mem->user_data = NULL; | ||
|
|
@@ -2727,9 +2750,10 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) | |
| } | ||
|
|
||
| /* apply user-supplied step postprocessing function (if supplied) */ | ||
| if (ark_mem->ProcessStep != NULL) | ||
| if (ark_mem->PostProcessStep != NULL) | ||
| { | ||
| retval = ark_mem->ProcessStep(ark_mem->tcur, ark_mem->ycur, ark_mem->ps_data); | ||
| retval = ark_mem->PostProcessStep(ark_mem->tcur, ark_mem->ycur, | ||
| ark_mem->ps_data); | ||
| if (retval != 0) { return (ARK_POSTPROCESS_STEP_FAIL); } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking of the state/RHS consistency for FSAL methods above, this probably needs to move inside the steppers so they can call |
||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RHS call in |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1330,22 +1330,29 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| /* compute the full RHS */ | ||||||||||||||||
| if (!(ark_mem->fn_is_current)) | ||||||||||||||||
| { | ||||||||||||||||
| /* compute the explicit component */ | ||||||||||||||||
| if (step_mem->explicit) | ||||||||||||||||
| /* apply user-supplied stage preprocessing function (if supplied) */ | ||||||||||||||||
| if (ark_mem->PreProcessRHS != NULL) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fe(t, y, step_mem->Fe[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfe++; | ||||||||||||||||
| retval = ark_mem->PreProcessRHS(t, y, ark_mem->user_data); | ||||||||||||||||
| if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the implicit component */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a particular reason to call the implicit RHS first or is this just to make the ordering consistent with what's done in |
||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fi(t, y, step_mem->Fi[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, | ||||||||||||||||
| __FILE__, MSG_ARK_RHSFUNC_FAILED, t); | ||||||||||||||||
| return (ARK_RHSFUNC_FAIL); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute and store M(t)^{-1} fe */ | ||||||||||||||||
| /* compute and store M(t)^{-1} fi */ | ||||||||||||||||
| if (step_mem->mass_type == MASS_TIMEDEP) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fe[0], | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fi[0], | ||||||||||||||||
| step_mem->nlscoef / ark_mem->h); | ||||||||||||||||
| if (retval) | ||||||||||||||||
| { | ||||||||||||||||
|
|
@@ -1356,22 +1363,22 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the implicit component */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
| /* compute the explicit component */ | ||||||||||||||||
| if (step_mem->explicit) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fi(t, y, step_mem->Fi[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
| retval = step_mem->fe(t, y, step_mem->Fe[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfe++; | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, | ||||||||||||||||
| __FILE__, MSG_ARK_RHSFUNC_FAILED, t); | ||||||||||||||||
| return (ARK_RHSFUNC_FAIL); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute and store M(t)^{-1} fi */ | ||||||||||||||||
| /* compute and store M(t)^{-1} fe */ | ||||||||||||||||
| if (step_mem->mass_type == MASS_TIMEDEP) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fi[0], | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fe[0], | ||||||||||||||||
| step_mem->nlscoef / ark_mem->h); | ||||||||||||||||
| if (retval) | ||||||||||||||||
| { | ||||||||||||||||
|
|
@@ -1455,11 +1462,18 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| /* recompute RHS functions */ | ||||||||||||||||
| if (recomputeRHS) | ||||||||||||||||
| { | ||||||||||||||||
| /* compute the explicit component */ | ||||||||||||||||
| if (step_mem->explicit) | ||||||||||||||||
| /* apply user-supplied stage preprocessing function (if supplied) */ | ||||||||||||||||
| if (ark_mem->PreProcessRHS != NULL) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fe(t, y, step_mem->Fe[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfe++; | ||||||||||||||||
| retval = ark_mem->PreProcessRHS(t, y, ark_mem->user_data); | ||||||||||||||||
| if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the implicit component */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fi(t, y, step_mem->Fi[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, | ||||||||||||||||
|
|
@@ -1470,7 +1484,7 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| /* compute and store M(t)^{-1} fi */ | ||||||||||||||||
| if (step_mem->mass_type == MASS_TIMEDEP) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fe[0], | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fi[0], | ||||||||||||||||
| step_mem->nlscoef / ark_mem->h); | ||||||||||||||||
| if (retval) | ||||||||||||||||
| { | ||||||||||||||||
|
|
@@ -1481,11 +1495,11 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the implicit component */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
| /* compute the explicit component */ | ||||||||||||||||
| if (step_mem->explicit) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fi(t, y, step_mem->Fi[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
| retval = step_mem->fe(t, y, step_mem->Fe[0], ark_mem->user_data); | ||||||||||||||||
| step_mem->nfe++; | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, | ||||||||||||||||
|
|
@@ -1496,7 +1510,7 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| /* compute and store M(t)^{-1} fi */ | ||||||||||||||||
| if (step_mem->mass_type == MASS_TIMEDEP) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fi[0], | ||||||||||||||||
| retval = step_mem->msolve((void*)ark_mem, step_mem->Fe[0], | ||||||||||||||||
| step_mem->nlscoef / ark_mem->h); | ||||||||||||||||
| if (retval) | ||||||||||||||||
| { | ||||||||||||||||
|
|
@@ -1564,11 +1578,18 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
|
|
||||||||||||||||
| case ARK_FULLRHS_OTHER: | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the explicit component and store in ark_tempv2 */ | ||||||||||||||||
| if (step_mem->explicit) | ||||||||||||||||
| /* apply user-supplied stage preprocessing function (if supplied) */ | ||||||||||||||||
| if (ark_mem->PreProcessRHS != NULL) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fe(t, y, ark_mem->tempv2, ark_mem->user_data); | ||||||||||||||||
| step_mem->nfe++; | ||||||||||||||||
| retval = ark_mem->PreProcessRHS(t, y, ark_mem->user_data); | ||||||||||||||||
| if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the implicit component and store in sdata */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fi(t, y, step_mem->sdata, ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, | ||||||||||||||||
|
|
@@ -1577,11 +1598,11 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* compute the implicit component and store in sdata */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
| /* compute the explicit component and store in ark_tempv2 */ | ||||||||||||||||
| if (step_mem->explicit) | ||||||||||||||||
| { | ||||||||||||||||
| retval = step_mem->fi(t, y, step_mem->sdata, ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
| retval = step_mem->fe(t, y, ark_mem->tempv2, ark_mem->user_data); | ||||||||||||||||
| step_mem->nfe++; | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, | ||||||||||||||||
|
|
@@ -1845,6 +1866,13 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) | |||||||||||||||
| } | ||||||||||||||||
| else | ||||||||||||||||
| { | ||||||||||||||||
| /* apply user-supplied stage preprocessing function (if supplied) */ | ||||||||||||||||
| if (ark_mem->PreProcessRHS != NULL) | ||||||||||||||||
| { | ||||||||||||||||
| retval = ark_mem->PreProcessRHS(ark_mem->tn, ark_mem->yn, | ||||||||||||||||
| ark_mem->user_data); | ||||||||||||||||
| if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| retval = step_mem->fi(ark_mem->tn, ark_mem->yn, step_mem->Fi[0], | ||||||||||||||||
| ark_mem->user_data); | ||||||||||||||||
| step_mem->nfi++; | ||||||||||||||||
|
|
@@ -2015,10 +2043,10 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) | |||||||||||||||
| /* apply user-supplied stage postprocessing function (if supplied) */ | ||||||||||||||||
| /* NOTE: with internally inconsistent IMEX methods (c_i^E != c_i^I) the value | ||||||||||||||||
| of tcur corresponds to the stage time from the implicit table (c_i^I). */ | ||||||||||||||||
| if (ark_mem->ProcessStage != NULL) | ||||||||||||||||
| if (ark_mem->PostProcessStage != NULL) | ||||||||||||||||
| { | ||||||||||||||||
| retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, | ||||||||||||||||
| ark_mem->user_data); | ||||||||||||||||
| retval = ark_mem->PostProcessStage(ark_mem->tcur, ark_mem->ycur, | ||||||||||||||||
| ark_mem->user_data); | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| SUNLogInfo(ARK_LOGGER, "end-stages-list", | ||||||||||||||||
|
|
@@ -2068,6 +2096,24 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* apply user-supplied stage preprocessing function (if supplied) */ | ||||||||||||||||
| /* NOTE: with internally inconsistent IMEX methods (c_i^E != c_i^I) the value | ||||||||||||||||
| of tcur corresponds to the stage time from the implicit table (c_i^I). */ | ||||||||||||||||
| if (ark_mem->PreProcessRHS != NULL) | ||||||||||||||||
| { | ||||||||||||||||
| if ((step_mem->implicit && !deduce_stage) || (step_mem->explicit)) | ||||||||||||||||
| { | ||||||||||||||||
| retval = ark_mem->PreProcessRHS(ark_mem->tcur, ark_mem->ycur, | ||||||||||||||||
| ark_mem->user_data); | ||||||||||||||||
| if (retval != 0) | ||||||||||||||||
| { | ||||||||||||||||
| SUNLogInfo(ARK_LOGGER, "end-stages-list", | ||||||||||||||||
| "status = failed preprocess stage, retval = %i", retval); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| return (ARK_POSTPROCESS_STAGE_FAIL); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /* store implicit RHS (value in Fi[is] is from preceding nonlinear iteration) */ | ||||||||||||||||
| if (step_mem->implicit) | ||||||||||||||||
| { | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.