diff --git a/CHANGELOG.md b/CHANGELOG.md index af8ab0fa26..88e256e887 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Multiple minor updates were made to the ARKODE package. We removed an extraneous copy of the output vector when using ARKODE in `ARK_ONE_STEP` mode. We added the +function `ARKodeGetStageIndex` that returns the index of the stage currently +being processed, and the total number of stages in the method, for users who must +compute auxiliary quantities in their IVP right-hand side functions during some +stages and not others (e.g., in all but the first or last stage). We added the function `ARKodeAllocateInternalData` to ARKODE to enable stage-related data allocation before the first call to `ARKodeEvolve` (but after all other optional input routines have been called), to support users who measure memory diff --git a/bindings/sundials4py/arkode/arkode_generated.hpp b/bindings/sundials4py/arkode/arkode_generated.hpp index a494d031d4..ae68602b7e 100644 --- a/bindings/sundials4py/arkode/arkode_generated.hpp +++ b/bindings/sundials4py/arkode/arkode_generated.hpp @@ -500,6 +500,26 @@ m.def("ARKodeGetReturnFlagName", ARKodeGetReturnFlagName, nb::arg("flag")); m.def("ARKodeWriteParameters", ARKodeWriteParameters, nb::arg("arkode_mem"), nb::arg("fp")); +m.def( + "ARKodeGetStageIndex", + [](void* arkode_mem) -> std::tuple + { + auto ARKodeGetStageIndex_adapt_modifiable_immutable_to_return = + [](void* arkode_mem) -> std::tuple + { + int stage_adapt_modifiable; + int max_stages_adapt_modifiable; + + int r = ARKodeGetStageIndex(arkode_mem, &stage_adapt_modifiable, + &max_stages_adapt_modifiable); + return std::make_tuple(r, stage_adapt_modifiable, + max_stages_adapt_modifiable); + }; + + return ARKodeGetStageIndex_adapt_modifiable_immutable_to_return(arkode_mem); + }, + nb::arg("arkode_mem")); + m.def( "ARKodeGetNumExpSteps", [](void* arkode_mem) -> std::tuple @@ -674,6 +694,40 @@ m.def( }, nb::arg("arkode_mem")); +m.def( + "ARKodeGetLastTime", + [](void* arkode_mem) -> std::tuple + { + auto ARKodeGetLastTime_adapt_modifiable_immutable_to_return = + [](void* arkode_mem) -> std::tuple + { + sunrealtype tn_adapt_modifiable; + + int r = ARKodeGetLastTime(arkode_mem, &tn_adapt_modifiable); + return std::make_tuple(r, tn_adapt_modifiable); + }; + + return ARKodeGetLastTime_adapt_modifiable_immutable_to_return(arkode_mem); + }, + nb::arg("arkode_mem")); + +m.def( + "ARKodeGetLastState", + [](void* arkode_mem) -> std::tuple + { + auto ARKodeGetLastState_adapt_modifiable_immutable_to_return = + [](void* arkode_mem) -> std::tuple + { + N_Vector state_adapt_modifiable; + + int r = ARKodeGetLastState(arkode_mem, &state_adapt_modifiable); + return std::make_tuple(r, state_adapt_modifiable); + }; + + return ARKodeGetLastState_adapt_modifiable_immutable_to_return(arkode_mem); + }, + nb::arg("arkode_mem"), "nb::rv_policy::reference", nb::rv_policy::reference); + m.def( "ARKodeGetCurrentTime", [](void* arkode_mem) -> std::tuple diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index c9f25a21f8..59ddf75f69 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -3622,6 +3622,8 @@ Actual initial time step size used :c:func:`ARKodeGetActualI Step size used for the last successful step :c:func:`ARKodeGetLastStep` Step size to be attempted on the next step :c:func:`ARKodeGetCurrentStep` Integration direction, e.g., forward or backward :c:func:`ARKodeGetStepDirection` +Last saved time reached by the solver :c:func:`ARKodeGetLastTime` +Last saved solution reached by the solver :c:func:`ARKodeGetLastState` Current internal time reached by the solver :c:func:`ARKodeGetCurrentTime` Current internal solution reached by the solver :c:func:`ARKodeGetCurrentState` Current :math:`\gamma` value used by the solver :c:func:`ARKodeGetCurrentGamma` @@ -3641,6 +3643,7 @@ Estimated local truncation error vector :c:func:`ARKodeGetEstLoca Number of constraint test failures :c:func:`ARKodeGetNumConstrFails` Retrieve a pointer for user data :c:func:`ARKodeGetUserData` Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumulatedError` +Current stage index, and total number of stages :c:func:`ARKodeGetStageIndex` ===================================================== ============================================ @@ -3744,6 +3747,38 @@ Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumul .. versionadded:: 6.2.0 +.. c:function:: int ARKodeGetLastTime(void* arkode_mem, sunrealtype* tn) + + Returns the last saved time reached by the solver. + + :param arkode_mem: pointer to the ARKODE memory block. + :param tn: last saved time reached. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetLastState(void *arkode_mem, N_Vector *yn) + + Returns the last saved solution reached by the solver. + + :param arkode_mem: pointer to the ARKODE memory block. + :param yn: last saved solution. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + Users should exercise extreme caution when using this function, + as altering values of *yn* may lead to undesirable behavior, depending + on the particular use case and on when this routine is called. + + .. versionadded:: x.y.z + + .. c:function:: int ARKodeGetCurrentTime(void* arkode_mem, sunrealtype* tcur) Returns the current internal time reached by the solver. @@ -4117,6 +4152,21 @@ Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumul .. versionadded:: 6.2.0 +.. c:function:: int ARKodeGetStageIndex(void* arkode_mem, int* stage, int *max_stages) + + Returns the index of the current stage (0-based) and the total number of + stages in the method. + + :param arkode_mem: pointer to the ARKODE memory block. + :param stage: pointer to storage for the current stage index. + :param max_stages: pointer to storage for the number of stages in the method. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index a5ba6594d8..da70a0ee86 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -7,6 +7,10 @@ Multiple minor updates were made to the ARKODE package. We removed an extraneous copy of the output vector when using ARKODE in ``ARK_ONE_STEP`` mode. We added the +function :c:func:`ARKodeGetStageIndex` that returns the index of the stage currently +being processed, and the total number of stages in the method, for users who must +compute auxiliary quantities in their IVP right-hand side functions during some +stages and not others (e.g., in all but the first or last stage). We added the function :c:func:`ARKodeAllocateInternalData` to ARKODE to enable stage-related data allocation before the first call to :c:func:`ARKodeEvolve` (but after all other optional input routines have been called), to support users who measure memory diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index c5b2bb6495..2bb9dc7b39 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -382,6 +382,8 @@ SUNDIALS_EXPORT int ARKodePrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); SUNDIALS_EXPORT char* ARKodeGetReturnFlagName(long int flag); SUNDIALS_EXPORT int ARKodeWriteParameters(void* arkode_mem, FILE* fp); +SUNDIALS_EXPORT int ARKodeGetStageIndex(void* arkode_mem, int* stage, + int* max_stages); /* Optional output functions (temporal adaptivity) */ SUNDIALS_EXPORT int ARKodeGetNumExpSteps(void* arkode_mem, long int* expsteps); @@ -404,6 +406,9 @@ SUNDIALS_EXPORT int ARKodeGetAccumulatedError(void* arkode_mem, /* Optional output functions (implicit solver) */ SUNDIALS_EXPORT int ARKodeGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups); +SUNDIALS_EXPORT int ARKodeGetLastTime(void* arkode_mem, sunrealtype* tn); +SUNDIALS_EXPORT int ARKodeGetLastState(void* arkode_mem, + N_Vector* state); // nb::rv_policy::reference SUNDIALS_EXPORT int ARKodeGetCurrentTime(void* arkode_mem, sunrealtype* tcur); SUNDIALS_EXPORT int ARKodeGetCurrentState(void* arkode_mem, N_Vector* state); // nb::rv_policy::reference diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 22c36a0afc..686f0c5faf 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1580,6 +1580,7 @@ ARKodeMem arkCreate(SUNContext sunctx) ark_mem->step_getnumnonlinsolviters = NULL; ark_mem->step_getnumnonlinsolvconvfails = NULL; ark_mem->step_getnonlinsolvstats = NULL; + ark_mem->step_getstageindex = NULL; ark_mem->step_setforcing = NULL; ark_mem->step_mem = NULL; ark_mem->step_supports_adaptive = SUNFALSE; diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 641b06abc3..7095819f14 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -143,6 +143,7 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, ark_mem->step_getnumnonlinsolvconvfails = arkStep_GetNumNonlinSolvConvFails; ark_mem->step_getnonlinsolvstats = arkStep_GetNonlinSolvStats; ark_mem->step_setforcing = arkStep_SetInnerForcing; + ark_mem->step_getstageindex = arkStep_GetStageIndex; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; ark_mem->step_supports_massmatrix = SUNTRUE; @@ -1711,6 +1712,9 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) *nflagPtr = ARK_SUCCESS; } + /* initialize the current stage index */ + step_mem->istage = 0; + /* call nonlinear solver setup if it exists */ if (step_mem->NLS) { diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 48736e3e1c..9ae6783b1d 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -243,6 +243,7 @@ void arkStep_Free(ARKodeMem ark_mem); void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); int arkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* f, int nvecs); +int arkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages); /* Internal utility routines */ int arkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 34e1af5d5c..7bbd6bd249 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -1298,6 +1298,26 @@ int arkStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + arkStep_GetStageIndex: + + Returns the current stage index and number of stages + ---------------------------------------------------------------*/ +int arkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages) +{ + ARKodeARKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + *stage = step_mem->istage; + *max_stages = step_mem->stages; + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- arkStep_PrintAllStats: diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index e47dce5120..965cc19e7e 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -109,6 +109,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) ark_mem->step_getnumrhsevals = erkStep_GetNumRhsEvals; ark_mem->step_getestlocalerrors = erkStep_GetEstLocalErrors; ark_mem->step_setforcing = erkStep_SetInnerForcing; + ark_mem->step_getstageindex = erkStep_GetStageIndex; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_relaxation = SUNTRUE; ark_mem->step_mem = (void*)step_mem; @@ -364,6 +365,7 @@ void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) /* output integer quantities */ fprintf(outfile, "ERKStep: q = %i\n", step_mem->q); fprintf(outfile, "ERKStep: p = %i\n", step_mem->p); + fprintf(outfile, "ERKStep: istage = %i\n", step_mem->istage); fprintf(outfile, "ERKStep: stages = %i\n", step_mem->stages); /* output long integer quantities */ @@ -770,6 +772,9 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) cvals = step_mem->cvals; Xvecs = step_mem->Xvecs; + /* initialize the current stage index */ + step_mem->istage = 0; + SUNLogInfo(ARK_LOGGER, "begin-stages-list", "stage = 0, tcur = " SUN_FORMAT_G, ark_mem->tcur); SUNLogExtraDebugVec(ARK_LOGGER, "stage", ark_mem->yn, "z_0(:) ="); @@ -836,6 +841,9 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) the first stage RHS is just the full RHS from the start of the step */ for (is = 1; is < step_mem->stages; is++) { + /* store current stage index */ + step_mem->istage = is; + /* Set current stage time(s) */ ark_mem->tcur = ark_mem->tn + step_mem->B->c[is] * ark_mem->h; diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 804d958169..641896bf31 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -58,6 +58,7 @@ typedef struct ARKodeERKStepMemRec N_Vector* F; /* explicit RHS at each stage */ int q; /* method order */ int p; /* embedding order */ + int istage; /* current stage */ int stages; /* number of stages */ ARKodeButcherTable B; /* ERK Butcher table */ @@ -106,6 +107,7 @@ int erkStep_GetNumRhsEvals(ARKodeMem ark_mem, int partition_index, int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); int erkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* f, int nvecs); +int erkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages); /* Internal utility routines */ int erkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 7d422d862f..fc32863b1a 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -398,6 +398,26 @@ int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + erkStep_GetStageIndex: + + Returns the current stage index and number of stages + ---------------------------------------------------------------*/ +int erkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages) +{ + ARKodeERKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure */ + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + *stage = step_mem->istage; + *max_stages = step_mem->stages; + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- erkStep_PrintAllStats: diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 13dbdebd3b..5d1be5e4c1 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -230,6 +230,8 @@ typedef int (*ARKTimestepSetUseCompensatedSums)(ARKodeMem ark_mem, sunbooleantype onoff); typedef int (*ARKTimestepSetOptions)(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); +typedef int (*ARKTimestepGetStageIndex)(ARKodeMem ark_mem, int* stage, + int* max_stages); /* time stepper interface functions -- temporal adaptivity */ typedef int (*ARKTimestepGetEstLocalErrors)(ARKodeMem ark_mem, N_Vector ele); @@ -423,6 +425,7 @@ struct ARKodeMemRec ARKTimestepSetStepDirection step_setstepdirection; ARKTimestepSetUseCompensatedSums step_setusecompensatedsums; ARKTimestepSetOptions step_setoptions; + ARKTimestepGetStageIndex step_getstageindex; /* Time stepper module -- temporal adaptivity */ sunbooleantype step_supports_adaptive; diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index a9ab400166..c7c6808895 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2569,6 +2569,46 @@ int ARKodeGetEstLocalErrors(void* arkode_mem, N_Vector ele) } } +/*--------------------------------------------------------------- + ARKodeGetLastTime: + + Returns the last saved value of the independent variable + ---------------------------------------------------------------*/ +int ARKodeGetLastTime(void* arkode_mem, sunrealtype* tn) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + *tn = ark_mem->tn; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeGetLastState: + + Returns the last saved time step solution. + ---------------------------------------------------------------*/ +int ARKodeGetLastState(void* arkode_mem, N_Vector* yn) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + *yn = ark_mem->yn; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- ARKodeGetCurrentTime: @@ -3184,6 +3224,38 @@ int ARKodeGetUserData(void* arkode_mem, void** user_data) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + ARKodeGetStageIndex: + + Returns the index of the current stage and the total number of + stages. If this is not supplied by the time-stepping module + then it returns (0,1), indicating that it is currently in the + first of only a single stage. + ---------------------------------------------------------------*/ +int ARKodeGetStageIndex(void* arkode_mem, int* stage, int* max_stages) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getstageindex) + { + return (ark_mem->step_getstageindex(ark_mem, stage, max_stages)); + } + else + { + *stage = 0; + *max_stages = 1; + return (ARK_SUCCESS); + } +} + /*----------------------------------------------------------------- ARKodePrintAllStats diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 3ac9e7708b..98feb295b7 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -180,6 +180,7 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, ark_mem->step_setdefaults = lsrkStep_SetDefaults; ark_mem->step_getnumrhsevals = lsrkStep_GetNumRhsEvals; ark_mem->step_getestlocalerrors = lsrkStep_GetEstLocalErrors; + ark_mem->step_getstageindex = lsrkStep_GetStageIndex; ark_mem->step_mem = (void*)step_mem; ark_mem->step_supports_adaptive = SUNTRUE; @@ -579,6 +580,10 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunrealtype* cvals = step_mem->cvals; N_Vector* Xvecs = step_mem->Xvecs; + /* Initialize the current stage index */ + step_mem->istage = 0; + step_mem->req_stages = step_mem->stage_max_limit; + /* Compute dominant eigenvalue and update stats */ if (step_mem->dom_eig_update) { @@ -710,6 +715,9 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evaluate stages j = 2,...,step_mem->req_stages */ for (int j = 2; j <= step_mem->req_stages; j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Evaluate RHS and store in tempv3 */ ark_mem->tcur = ark_mem->tn + ark_mem->h * thjm1; @@ -814,7 +822,8 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) SUNLogInfo(ARK_LOGGER, "begin-compute-embedding", ""); /* final stage processing */ - ark_mem->tcur = ark_mem->tn + ark_mem->h; + step_mem->istage = step_mem->req_stages; + ark_mem->tcur = ark_mem->tn + ark_mem->h; /* apply user-supplied stage preprocessing function (if supplied) */ if (ark_mem->PreProcessRHS != NULL) @@ -919,6 +928,10 @@ int lsrkStep_TakeStepRKL(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunrealtype* cvals = step_mem->cvals; N_Vector* Xvecs = step_mem->Xvecs; + /* Initialize the current stage index */ + step_mem->istage = 0; + step_mem->req_stages = step_mem->stage_max_limit; + /* Compute dominant eigenvalue and update stats */ if (step_mem->dom_eig_update) { @@ -1040,6 +1053,9 @@ int lsrkStep_TakeStepRKL(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evaluate stages j = 2,...,step_mem->req_stages */ for (int j = 2; j <= step_mem->req_stages; j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Evaluate RHS and store in tempv3 */ ark_mem->tcur = ark_mem->tn + ark_mem->h * cjm1; @@ -1132,10 +1148,11 @@ int lsrkStep_TakeStepRKL(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) SUNLogInfo(ARK_LOGGER, "end-stages-list", "status = success"); SUNLogExtraDebugVec(ARK_LOGGER, "updated solution", ark_mem->ycur, "ycur(:) ="); + SUNLogInfo(ARK_LOGGER, "begin-compute-embedding", ""); /* final stage processing */ - SUNLogInfo(ARK_LOGGER, "begin-compute-embedding", ""); - ark_mem->tcur = ark_mem->tn + ark_mem->h; + step_mem->istage = step_mem->req_stages; + ark_mem->tcur = ark_mem->tn + ark_mem->h; /* apply user-supplied stage preprocessing function (if supplied) */ if (ark_mem->PreProcessRHS != NULL) @@ -1230,6 +1247,9 @@ int lsrkStep_TakeStepSSPs2(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr sunrealtype* cvals = step_mem->cvals; N_Vector* Xvecs = step_mem->Xvecs; + /* Initialize the current stage index */ + step_mem->istage = 0; + /* Initialize method coefficients */ const sunrealtype rs = (sunrealtype)step_mem->req_stages; const sunrealtype sm1inv = ONE / (rs - ONE); @@ -1316,6 +1336,9 @@ int lsrkStep_TakeStepSSPs2(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr /* Evaluate stages j = 2,...,step_mem->req_stages - 1 */ for (int j = 2; j < step_mem->req_stages; j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Complete previous stage by evaluating RHS and storing it in tempv2 */ ark_mem->tcur = ark_mem->tn + (j - 1) * hsm1inv; @@ -1371,7 +1394,8 @@ int lsrkStep_TakeStepSSPs2(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr } /* Complete the next-to-last stage by evaluating the RHS and storing it in tempv2 */ - ark_mem->tcur = ark_mem->tn + ark_mem->h; + step_mem->istage = step_mem->req_stages - 1; + ark_mem->tcur = ark_mem->tn + ark_mem->h; if (ark_mem->PreProcessRHS != NULL) { retval = ark_mem->PreProcessRHS(ark_mem->tcur, ark_mem->ycur, @@ -1475,6 +1499,9 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr sunrealtype* cvals = step_mem->cvals; N_Vector* Xvecs = step_mem->Xvecs; + /* Initialize the current stage index */ + step_mem->istage = 0; + /* Initialize method coefficients */ const sunrealtype rs = (sunrealtype)step_mem->req_stages; const sunrealtype rn = SUNRsqrt(rs); @@ -1547,6 +1574,9 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr /* Evaluate first stage group */ for (int j = 2; j <= ((in - 1) * (in - 2) / 2); j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Complete previous stage by evaluating RHS and storing it in tempv3 */ ark_mem->tcur = ark_mem->tn + (j - 1) * hrat; @@ -1608,6 +1638,9 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr /* Evaluate second stage group */ for (int j = ((in - 1) * (in - 2) / 2 + 1); j <= (in * (in + 1) / 2 - 1); j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Complete previous stage by evaluating RHS and storing it in tempv3 */ ark_mem->tcur = ark_mem->tn + (j - 1) * hrat; @@ -1664,7 +1697,8 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr } /* Complete the last stage from the second stage group */ - ark_mem->tcur = ark_mem->tn + hrat * (rn * (rn + ONE) / TWO - ONE); + step_mem->istage = (in * (in + 1) / 2 - 1); + ark_mem->tcur = ark_mem->tn + hrat * (rn * (rn + ONE) / TWO - ONE); /* apply user-supplied stage preprocessing function (if supplied) */ if (ark_mem->PreProcessRHS != NULL) @@ -1731,6 +1765,9 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr /* Evaluate final stage group */ for (int j = (in * (in + 1) / 2 + 1); j <= step_mem->req_stages; j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Complete the previous stage */ ark_mem->tcur = ark_mem->tn + (j - in - 1) * hrat; @@ -1848,6 +1885,9 @@ int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr sunrealtype* cvals = step_mem->cvals; N_Vector* Xvecs = step_mem->Xvecs; + /* Initialize the current stage index */ + step_mem->istage = 0; + /* Initialize method coefficients */ const sunrealtype rs = SUN_RCONST(4.0); const sunrealtype hp5 = ark_mem->h * SUN_RCONST(0.5); @@ -1915,6 +1955,9 @@ int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr } } + /* update stage index */ + step_mem->istage = 1; + /* apply user-supplied stage preprocessing function (if supplied) */ if (ark_mem->PreProcessRHS != NULL) { @@ -1965,6 +2008,9 @@ int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr } } + /* update stage index */ + step_mem->istage = 2; + /* Evaluate stage RHS */ /* apply user-supplied stage preprocessing function (if supplied) */ @@ -2028,6 +2074,9 @@ int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr } } + /* update stage index */ + step_mem->istage = 3; + /* Evaluate stage RHS */ /* apply user-supplied stage preprocessing function (if supplied) */ @@ -2120,6 +2169,9 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt sunrealtype* cvals = step_mem->cvals; N_Vector* Xvecs = step_mem->Xvecs; + /* Initialize the current stage index */ + step_mem->istage = 0; + /* Initialize method coefficients */ const sunrealtype hsixth = ark_mem->h / SIX; const sunrealtype hfifth = ark_mem->h / FIVE; @@ -2191,6 +2243,9 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Evaluate stages j = 2,...,4 */ for (int j = 2; j <= 5; j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Complete previous stage by evaluating RHS and storing in tempv3 */ ark_mem->tcur = ark_mem->tn + (j - 1) * hsixth; @@ -2277,6 +2332,9 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Evaluate stages j = 6,...,9 */ for (int j = 6; j <= 9; j++) { + /* set stage index (0-based) */ + step_mem->istage = j - 1; + /* Complete previous stage by evaluating RHS and storing in tempv3 */ ark_mem->tcur = ark_mem->tn + (j - 4) * hsixth; @@ -2337,7 +2395,10 @@ int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } } - /* Complete the 9th stage by evaluating RHS and storing in tempv3 */ + /* set stage index (0-based) */ + step_mem->istage = 9; + + /* Complete the last stage by evaluating RHS and storing in tempv3 */ ark_mem->tcur = ark_mem->tn + ark_mem->h; /* apply user-supplied stage preprocessing function (if supplied) */ @@ -2470,18 +2531,16 @@ void lsrkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "LSRKStep: q = %i\n", step_mem->q); fprintf(outfile, "LSRKStep: p = %i\n", step_mem->p); + fprintf(outfile, "LSRKStep: istage = %i\n", step_mem->istage); + fprintf(outfile, "LSRKStep: req_stages = %i\n", step_mem->req_stages); if (step_mem->is_SSP) { - fprintf(outfile, "LSRKStep: req_stages = %i\n", - step_mem->req_stages); fprintf(outfile, "LSRKStep: nfe = %li\n", step_mem->nfe); } else if (!step_mem->is_SSP) { /* output integer quantities */ - fprintf(outfile, "LSRKStep: req_stages = %i\n", - step_mem->req_stages); fprintf(outfile, "LSRKStep: dom_eig_nst = %li\n", step_mem->dom_eig_nst); fprintf(outfile, "LSRKStep: stage_max = %i\n", diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 7dde8529bc..e6aeb4eee4 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -139,7 +139,8 @@ typedef struct ARKodeLSRKStepMemRec int q; /* method order */ int p; /* embedding order */ - int req_stages; /* number of requested stages */ + int istage; /* current stage */ + int req_stages; /* number of stages in step */ ARKODE_LSRKMethodType LSRKmethod; @@ -209,6 +210,7 @@ void lsrkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); int lsrkStep_GetNumRhsEvals(ARKodeMem ark_mem, int partition_index, long int* rhs_evals); int lsrkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); +int lsrkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages); /* Internal utility routines */ int lsrkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index a6cf3c61cf..f9ebd232a6 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -772,6 +772,26 @@ int lsrkStep_SetDefaults(ARKodeMem ark_mem) return ARK_SUCCESS; } +/*--------------------------------------------------------------- + lsrkStep_GetStageIndex: + + Returns the current stage index and number of stages + ---------------------------------------------------------------*/ +int lsrkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages) +{ + ARKodeLSRKStepMem step_mem; + int retval; + + /* access ARKodeLSRKStepMem structure */ + retval = lsrkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + *stage = step_mem->istage; + *max_stages = step_mem->req_stages; + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- lsrkStep_PrintAllStats: diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 80657971c7..bc8257af16 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -140,6 +140,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_getnumnonlinsolvconvfails = mriStep_GetNumNonlinSolvConvFails; ark_mem->step_getnonlinsolvstats = mriStep_GetNonlinSolvStats; ark_mem->step_setforcing = mriStep_SetInnerForcing; + ark_mem->step_getstageindex = mriStep_GetStageIndex; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; ark_mem->step_mem = (void*)step_mem; @@ -1837,6 +1838,9 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt do_embedding = !ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE); + /* initialize the current stage index */ + step_mem->istage = 0; + /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); @@ -1948,6 +1952,9 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Loop over remaining internal stages */ for (is = 1; is < step_mem->stages - 1; is++) { + /* Set current stage index (0-based) */ + step_mem->istage = is; + /* Set relevant stage times (including desired stage time for implicit solves) */ t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; tf = ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; @@ -2141,7 +2148,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* perform embedded stage (if needed) */ if (do_embedding) { - is = step_mem->stages; + /* Set current stage index */ + step_mem->istage = is = step_mem->stages; /* Copy ark_mem->ycur into ark_mem->tempv4, since it serves as the initial condition for both this embedding stage, and the subsequent final stage. */ @@ -2219,7 +2227,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Compute final stage (for evolved solution), along with error estimate */ { - is = step_mem->stages - 1; + /* Set current stage index */ + step_mem->istage = is = step_mem->stages - 1; /* Set relevant stage times (including desired stage time for implicit solves) */ t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; @@ -2389,6 +2398,9 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ytilde = ark_mem->tempv4; ytemp = ark_mem->tempv2; + /* initialize the current stage index */ + step_mem->istage = 0; + /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); @@ -2501,6 +2513,9 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Loop over stages */ for (stage = 1; stage < max_stages; stage++) { + /* Set current stage index */ + step_mem->istage = stage; + /* Determine if this is an "embedding" or "solution" stage */ solution = (stage == step_mem->stages - 1); embedding = (stage == step_mem->stages); @@ -2872,6 +2887,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* initial time for step */ t0 = ark_mem->tn; + /* initialize the current stage index */ + step_mem->istage = 0; + /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); @@ -2990,7 +3008,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { /* Get stage index from group; skip to the next group if we've reached the end of this one */ - stage = step_mem->MRIC->group[ig][is]; + step_mem->istage = stage = step_mem->MRIC->group[ig][is]; if (stage < 0) { break; } nextstage = -1; if (stage < step_mem->stages) diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 66d76e08db..61a5f163b6 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -269,6 +269,7 @@ int mriStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters); int mriStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails); int mriStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, long int* nnfails); +int mriStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages); int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); int mriStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); int mriStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 306e791f24..c18a48eeb6 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -828,6 +828,26 @@ int mriStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + mriStep_GetStageIndex: + + Returns the current stage index and number of stages + ---------------------------------------------------------------*/ +int mriStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages) +{ + ARKodeMRIStepMem step_mem; + int retval; + + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + *stage = step_mem->istage; + *max_stages = step_mem->stages; + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- mriStep_PrintAllStats: diff --git a/src/arkode/arkode_splittingstep.c b/src/arkode/arkode_splittingstep.c index 789cb59971..124e5b5852 100644 --- a/src/arkode/arkode_splittingstep.c +++ b/src/arkode/arkode_splittingstep.c @@ -312,6 +312,7 @@ static int splittingStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, SUNLogInfo(ARK_LOGGER, "begin-sequential-methods-list", "sequential method = 0"); + step_mem->istage = 0; retval = splittingStep_SequentialMethod(ark_mem, step_mem, 0, ark_mem->ycur); SUNLogExtraDebugVec(ARK_LOGGER, "sequential state", ark_mem->ycur, "y_seq(:) ="); @@ -331,6 +332,7 @@ static int splittingStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, for (int i = 1; i < coefficients->sequential_methods; i++) { + step_mem->istage = i; SUNLogInfo(ARK_LOGGER, "begin-sequential-methods-list", "sequential method = %i", i); @@ -423,6 +425,7 @@ static void splittingStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) if (retval != ARK_SUCCESS) { return; } /* output integer quantities */ + fprintf(outfile, "SplittingStep: istage = %i\n", step_mem->istage); fprintf(outfile, "SplittingStep: partitions = %i\n", step_mem->partitions); fprintf(outfile, "SplittingStep: order = %i\n", step_mem->order); @@ -455,6 +458,31 @@ static int splittingStep_SetOrder(ARKodeMem ark_mem, int order) return ARK_SUCCESS; } +/*--------------------------------------------------------------- + Returns the current stage index and number of stages + ---------------------------------------------------------------*/ +static int splittingStep_GetStageIndex(ARKodeMem ark_mem, int* istage, + int* num_stages) +{ + ARKodeSplittingStepMem step_mem; + int retval = splittingStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* if coefficients structure is not yet available, return defaults */ + if (step_mem->coefficients == NULL) + { + *istage = 0; + *num_stages = 1; + } + else + { + *istage = step_mem->istage; + *num_stages = step_mem->coefficients->sequential_methods; + } + + return (ARK_SUCCESS); +} + /*------------------------------------------------------------------------------ Routine to set SplittingStep options ----------------------------------------------------------------------------*/ @@ -661,6 +689,7 @@ void* SplittingStepCreate(SUNStepper* steppers, int partitions, sunrealtype t0, ark_mem->step_setoptions = splittingStep_SetOptions; ark_mem->step_setdefaults = splittingStep_SetDefaults; ark_mem->step_setorder = splittingStep_SetOrder; + ark_mem->step_getstageindex = splittingStep_GetStageIndex; ark_mem->step_mem = (void*)step_mem; /* Set default values for ARKStep optional inputs */ diff --git a/src/arkode/arkode_splittingstep_impl.h b/src/arkode/arkode_splittingstep_impl.h index 6dff626768..51438d27d3 100644 --- a/src/arkode/arkode_splittingstep_impl.h +++ b/src/arkode/arkode_splittingstep_impl.h @@ -28,6 +28,7 @@ typedef struct ARKodeSplittingStepMemRec SplittingStepCoefficients coefficients; long int* n_stepper_evolves; + int istage; int partitions; int order; }* ARKodeSplittingStepMem; diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index 2cfe794a6d..3ffb1d8bb5 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -123,6 +123,7 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, ark_mem->step_setdefaults = sprkStep_SetDefaults; ark_mem->step_setorder = sprkStep_SetOrder; ark_mem->step_getnumrhsevals = sprkStep_GetNumRhsEvals; + ark_mem->step_getstageindex = sprkStep_GetStageIndex; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index e858659a29..9a5e6a291b 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -91,6 +91,7 @@ void sprkStep_Free(ARKodeMem ark_mem); void sprkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); int sprkStep_GetNumRhsEvals(ARKodeMem ark_mem, int partition_index, long int* rhs_evals); +int sprkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages); /* Internal utility routines */ int sprkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 3d335c5d9b..1d48aaa57d 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -275,6 +275,35 @@ int sprkStep_SetOrder(ARKodeMem ark_mem, int ord) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + sprkStep_GetStageIndex: + + Returns the current stage index and number of stages + ---------------------------------------------------------------*/ +int sprkStep_GetStageIndex(ARKodeMem ark_mem, int* stage, int* max_stages) +{ + ARKodeSPRKStepMem step_mem; + int retval; + + /* access ARKodeSPRKStepMem structure */ + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* if table is not yet set, return defaults */ + if (step_mem->method == NULL) + { + *stage = 0; + *max_stages = 1; + } + else + { + *stage = step_mem->istage; + *max_stages = step_mem->method->stages; + } + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- sprkStep_PrintAllStats: diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index 395c7ce83a..b498eac483 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -1561,6 +1561,22 @@ SWIGEXPORT int _wrap_FARKodeWriteParameters(void *farg1, void *farg2) { } +SWIGEXPORT int _wrap_FARKodeGetStageIndex(void *farg1, int *farg2, int *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int *)(farg2); + arg3 = (int *)(farg3); + result = (int)ARKodeGetStageIndex(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeGetNumExpSteps(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1709,6 +1725,34 @@ SWIGEXPORT int _wrap_FARKodeGetNumLinSolvSetups(void *farg1, long *farg2) { } +SWIGEXPORT int _wrap_FARKodeGetLastTime(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetLastTime(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetLastState(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector *arg2 = (N_Vector *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector *)(farg2); + result = (int)ARKodeGetLastState(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeGetCurrentTime(void *farg1, double *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index ce0e0296eb..ab899d62f3 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -213,6 +213,7 @@ module farkode_mod public :: FARKodePrintAllStats public :: FARKodeGetReturnFlagName public :: FARKodeWriteParameters + public :: FARKodeGetStageIndex public :: FARKodeGetNumExpSteps public :: FARKodeGetNumAccSteps public :: FARKodeGetNumErrTestFails @@ -223,6 +224,8 @@ module farkode_mod public :: FARKodeGetStepStats public :: FARKodeGetAccumulatedError public :: FARKodeGetNumLinSolvSetups + public :: FARKodeGetLastTime + public :: FARKodeGetLastState public :: FARKodeGetCurrentTime public :: FARKodeGetCurrentState public :: FARKodeGetCurrentGamma @@ -1299,6 +1302,16 @@ function swigc_FARKodeWriteParameters(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKodeGetStageIndex(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeGetStageIndex") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + function swigc_FARKodeGetNumExpSteps(farg1, farg2) & bind(C, name="_wrap_FARKodeGetNumExpSteps") & result(fresult) @@ -1393,6 +1406,24 @@ function swigc_FARKodeGetNumLinSolvSetups(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKodeGetLastTime(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastTime") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLastState(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastState") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + function swigc_FARKodeGetCurrentTime(farg1, farg2) & bind(C, name="_wrap_FARKodeGetCurrentTime") & result(fresult) @@ -4014,6 +4045,25 @@ function FARKodeWriteParameters(arkode_mem, fp) & swig_result = fresult end function +function FARKodeGetStageIndex(arkode_mem, stage, max_stages) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: stage +integer(C_INT), dimension(*), target, intent(inout) :: max_stages +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(stage(1)) +farg3 = c_loc(max_stages(1)) +fresult = swigc_FARKodeGetStageIndex(farg1, farg2, farg3) +swig_result = fresult +end function + function FARKodeGetNumExpSteps(arkode_mem, expsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4186,6 +4236,38 @@ function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & swig_result = fresult end function +function FARKodeGetLastTime(arkode_mem, tn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: tn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(tn(1)) +fresult = swigc_FARKodeGetLastTime(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLastState(arkode_mem, state) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: state +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = state +fresult = swigc_FARKodeGetLastState(farg1, farg2) +swig_result = fresult +end function + function FARKodeGetCurrentTime(arkode_mem, tcur) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index faaf3eefd7..e6774f8b0d 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -1561,6 +1561,22 @@ SWIGEXPORT int _wrap_FARKodeWriteParameters(void *farg1, void *farg2) { } +SWIGEXPORT int _wrap_FARKodeGetStageIndex(void *farg1, int *farg2, int *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int *)(farg2); + arg3 = (int *)(farg3); + result = (int)ARKodeGetStageIndex(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeGetNumExpSteps(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1709,6 +1725,34 @@ SWIGEXPORT int _wrap_FARKodeGetNumLinSolvSetups(void *farg1, long *farg2) { } +SWIGEXPORT int _wrap_FARKodeGetLastTime(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetLastTime(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetLastState(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector *arg2 = (N_Vector *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector *)(farg2); + result = (int)ARKodeGetLastState(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeGetCurrentTime(void *farg1, double *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 4bd678a75f..98f1541e36 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -213,6 +213,7 @@ module farkode_mod public :: FARKodePrintAllStats public :: FARKodeGetReturnFlagName public :: FARKodeWriteParameters + public :: FARKodeGetStageIndex public :: FARKodeGetNumExpSteps public :: FARKodeGetNumAccSteps public :: FARKodeGetNumErrTestFails @@ -223,6 +224,8 @@ module farkode_mod public :: FARKodeGetStepStats public :: FARKodeGetAccumulatedError public :: FARKodeGetNumLinSolvSetups + public :: FARKodeGetLastTime + public :: FARKodeGetLastState public :: FARKodeGetCurrentTime public :: FARKodeGetCurrentState public :: FARKodeGetCurrentGamma @@ -1299,6 +1302,16 @@ function swigc_FARKodeWriteParameters(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKodeGetStageIndex(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeGetStageIndex") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + function swigc_FARKodeGetNumExpSteps(farg1, farg2) & bind(C, name="_wrap_FARKodeGetNumExpSteps") & result(fresult) @@ -1393,6 +1406,24 @@ function swigc_FARKodeGetNumLinSolvSetups(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKodeGetLastTime(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastTime") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLastState(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastState") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + function swigc_FARKodeGetCurrentTime(farg1, farg2) & bind(C, name="_wrap_FARKodeGetCurrentTime") & result(fresult) @@ -4014,6 +4045,25 @@ function FARKodeWriteParameters(arkode_mem, fp) & swig_result = fresult end function +function FARKodeGetStageIndex(arkode_mem, stage, max_stages) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: stage +integer(C_INT), dimension(*), target, intent(inout) :: max_stages +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(stage(1)) +farg3 = c_loc(max_stages(1)) +fresult = swigc_FARKodeGetStageIndex(farg1, farg2, farg3) +swig_result = fresult +end function + function FARKodeGetNumExpSteps(arkode_mem, expsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4186,6 +4236,38 @@ function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & swig_result = fresult end function +function FARKodeGetLastTime(arkode_mem, tn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: tn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(tn(1)) +fresult = swigc_FARKodeGetLastTime(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLastState(arkode_mem, state) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: state +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = state +fresult = swigc_FARKodeGetLastState(farg1, farg2) +swig_result = fresult +end function + function FARKodeGetCurrentTime(arkode_mem, tcur) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/test/answers b/test/answers index 55c4feeefc..649ef300fa 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 55c4feeefc0e783e31e19b2d03fdfb85bd9f42ff +Subproject commit 649ef300faaad58ea9981892f3525669fa7cf60a diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index 0d8484b569..121d6b5148 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -76,7 +76,27 @@ set(unit_tests "ark_test_prealloc_lsrkstep.cpp\;1\;" "ark_test_prealloc_mristep.cpp\;1\;" "ark_test_prealloc_splittingstep.cpp\;1\;" - "ark_test_prealloc_sprkstep.cpp\;1\;") + "ark_test_prealloc_sprkstep.cpp\;1\;" + "ark_test_stageinfo_arkstep.cpp\;0\;" # ERK + "ark_test_stageinfo_arkstep.cpp\;1\;" # DIRK + "ark_test_stageinfo_arkstep.cpp\;2\;" # ImEx + "ark_test_stageinfo_erkstep.cpp\;\;" + "ark_test_stageinfo_forcingstep.cpp\;\;" + "ark_test_stageinfo_lsrkstep.cpp\;0\;" # RKC + "ark_test_stageinfo_lsrkstep.cpp\;1\;" # RKL + "ark_test_stageinfo_lsrkstep.cpp\;2\;" # SSPs2 + "ark_test_stageinfo_lsrkstep.cpp\;3\;" # SSPs3 + "ark_test_stageinfo_lsrkstep.cpp\;4\;" # SSP43 + "ark_test_stageinfo_lsrkstep.cpp\;5\;" # SSP104 + "ark_test_stageinfo_mristep.cpp\;0\;" # MRIGARK Explicit + "ark_test_stageinfo_mristep.cpp\;1\;" # MRIGARK Implicit + "ark_test_stageinfo_mristep.cpp\;2\;" # MRIGARK ImEx + "ark_test_stageinfo_mristep.cpp\;3\;" # MRISR Explicit + "ark_test_stageinfo_mristep.cpp\;4\;" # MRISR Implicit + "ark_test_stageinfo_mristep.cpp\;5\;" # MRISR ImEx + "ark_test_stageinfo_mristep.cpp\;6\;" # MERK + "ark_test_stageinfo_splittingstep.cpp\;\;" + "ark_test_stageinfo_sprkstep.cpp\;\;") # Add the build and install targets for each test foreach(test_tuple ${unit_tests}) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep.cpp new file mode 100644 index 0000000000..4145c3d236 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep.cpp @@ -0,0 +1,304 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in ARKStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators, vectors, linear solvers, and nonlinear solvers +#include "arkode/arkode_arkstep.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_context.hpp" +#include "sundials/sundials_matrix.h" +#include "sunlinsol/sunlinsol_spgmr.h" + +#include "problems/kpr.hpp" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::kpr; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start ARKStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Use ERK (0) or DIRK (1) otherwise use ImEx + int method_type = 0; + if (argc > 1) { method_type = stoi(argv[1]); } + + // Create initial condition + N_Vector y = N_VNew_Serial(2, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + + sunrealtype utrue, vtrue; + int flag = true_sol(zero, &utrue, &vtrue); + if (check_flag(flag, "true_sol")) { return 1; } + + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = utrue; + ydata[1] = vtrue; + + // Create ARKStep memory structure + if (method_type == 0) + { + cout << "Using ERK method" << endl; + arkode_mem = ARKStepCreate(ode_rhs, nullptr, zero, y, sunctx); + if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } + } + else if (method_type == 1) + { + cout << "Using DIRK method" << endl; + arkode_mem = ARKStepCreate(nullptr, ode_rhs, zero, y, sunctx); + if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } + } + else + { + cout << "Using ImEx method" << endl; + arkode_mem = ARKStepCreate(ode_rhs_ex, ode_rhs_im, zero, y, sunctx); + if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } + } + + flag = ARKodeSetUserData(arkode_mem, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + // Relative and absolute tolerances + const sunrealtype rtol = SUN_RCONST(1.0e-6); + const sunrealtype atol = SUN_RCONST(1.0e-10); + + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } + + SUNMatrix A = nullptr; + SUNLinearSolver LS = nullptr; + + if (method_type > 0) + { + cout << "Using Newton nonlinear solver" << endl; + cout << "Using GMRES iterative linear solver" << endl; + + LS = SUNLinSol_SPGMR(y, SUN_PREC_NONE, 0, sunctx); + if (check_ptr(LS, "SUNLinSol_SPGMR")) { return 1; } + + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } + } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = one; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + // Output initial contion + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << " t "; + cout << " u "; + cout << " v "; + cout << " u err "; + cout << " v err " << endl; + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << abs(ydata[0] - utrue) << setw(25) << abs(ydata[1] - vtrue) + << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKode")) { return 1; } + + flag = true_sol(tret, &utrue, &vtrue); + if (check_flag(flag, "true_sol")) { return 1; } + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << abs(ydata[0] - utrue) << setw(25) + << abs(ydata[1] - vtrue) << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + SUNMatDestroy(A); + SUNLinSolFree(LS); + ARKodeFree(&arkode_mem); + + cout << "End ARKStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_0.out new file mode 100644 index 0000000000..49bdd17c7d --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_0.out @@ -0,0 +1,60 @@ +Start ARKStep StageInfo test +Using ERK method + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 5) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 4.71e-08 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 2.06e-04 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 5) at t = 4.12e-05 (tn = 0.00e+00 , tcur = 4.12e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 5) at t = 4.12e-05 (tn = 0.00e+00 , tcur = 4.12e-05), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 2 of 5) at t = 6.18e-05 (tn = 0.00e+00 , tcur = 6.18e-05), ||y||_2 = 2.1213200432e+00] + [Pre-RHS processing (stage 2 of 5) at t = 6.18e-05 (tn = 0.00e+00 , tcur = 6.18e-05), ||y||_2 = 2.1213200432e+00] + [Post-stage processing (stage 3 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213199340e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213199340e+00] + [Post-stage processing (stage 4 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Post-step processing at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + 1.0298602561e-04 1.2247448703e+00 1.7320501952e+00 2.2204460493e-16 0.0000000000e+00 + [Pre-step processing at t = 1.03e-04 (tn = 1.03e-04 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + [Post-stage processing (stage 1 of 5) at t = 5.97e-03 (tn = 1.03e-04 , tcur = 5.97e-03), ||y||_2 = 2.1212628048e+00] + [Pre-RHS processing (stage 1 of 5) at t = 5.97e-03 (tn = 1.03e-04 , tcur = 5.97e-03), ||y||_2 = 2.1212628048e+00] + [Post-stage processing (stage 2 of 5) at t = 8.90e-03 (tn = 1.03e-04 , tcur = 8.90e-03), ||y||_2 = 2.1151489033e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.90e-03 (tn = 1.03e-04 , tcur = 8.90e-03), ||y||_2 = 2.1151489033e+00] + [Post-stage processing (stage 3 of 5) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1129070894e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1129070894e+00] + [Post-stage processing (stage 4 of 5) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1110724436e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1110724436e+00] + [Post-step processing at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02),||y||_2 = 2.1110724436e+00] + 1.4770752770e-02 1.2247225752e+00 1.7195003557e+00 2.8937936936e-08 2.5927171299e-08 + [Pre-step processing at t = 1.48e-02 (tn = 1.48e-02 , tcur = 1.48e-02),||y||_2 = 2.1110724436e+00] + [Post-stage processing (stage 1 of 5) at t = 2.06e-02 (tn = 1.48e-02 , tcur = 2.06e-02), ||y||_2 = 2.1030688076e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.06e-02 (tn = 1.48e-02 , tcur = 2.06e-02), ||y||_2 = 2.1030688076e+00] + [Post-stage processing (stage 2 of 5) at t = 2.35e-02 (tn = 1.48e-02 , tcur = 2.35e-02), ||y||_2 = 2.0933502627e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.35e-02 (tn = 1.48e-02 , tcur = 2.35e-02), ||y||_2 = 2.0933502627e+00] + [Post-stage processing (stage 3 of 5) at t = 2.93e-02 (tn = 1.48e-02 , tcur = 2.93e-02), ||y||_2 = 2.0833181435e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.93e-02 (tn = 1.48e-02 , tcur = 2.93e-02), ||y||_2 = 2.0833181435e+00] + [Post-stage processing (stage 4 of 5) at t = 2.93e-02 (tn = 1.48e-02 , tcur = 2.93e-02), ||y||_2 = 2.0816387141e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.93e-02 (tn = 1.48e-02 , tcur = 2.93e-02), ||y||_2 = 2.0816387141e+00] + [Post-step processing at t = 2.93e-02 (tn = 1.48e-02 , tcur = 2.93e-02),||y||_2 = 2.0816387141e+00] + 2.9275139161e-02 1.2246573481e+00 1.6832807581e+00 5.5763322404e-08 6.7822652161e-08 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.0292751391609328 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.000102986025609508 +Last step size = 0.0145043863910885 +Current step size = 0.0149829090634053 +Explicit RHS fn evals = 15 +Implicit RHS fn evals = 0 +NLS iters = 0 +NLS fails = 0 +NLS iters per step = 0 +LS setups = 0 +End ARKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_1.out new file mode 100644 index 0000000000..86966c499a --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_1.out @@ -0,0 +1,144 @@ +Start ARKStep StageInfo test +Using DIRK method +Using Newton nonlinear solver +Using GMRES iterative linear solver + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 6) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 6) at t = 4.71e-08 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 6) at t = 2.06e-04 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 6) at t = 5.15e-05 (tn = 0.00e+00 , tcur = 5.15e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 6) at t = 5.15e-05 (tn = 0.00e+00 , tcur = 5.15e-05), ||y||_2 = 2.1213183410e+00] + [Post-stage processing (stage 1 of 6) at t = 5.15e-05 (tn = 0.00e+00 , tcur = 5.15e-05), ||y||_2 = 2.1213202184e+00] + [Pre-RHS processing (stage 1 of 6) at t = 5.15e-05 (tn = 0.00e+00 , tcur = 5.15e-05), ||y||_2 = 2.1213202184e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.51e-05 (tn = 0.00e+00 , tcur = 1.51e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.51e-05 (tn = 0.00e+00 , tcur = 1.51e-05), ||y||_2 = 2.1213183410e+00] + [Post-stage processing (stage 2 of 6) at t = 1.51e-05 (tn = 0.00e+00 , tcur = 1.51e-05), ||y||_2 = 2.1213203328e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.51e-05 (tn = 0.00e+00 , tcur = 1.51e-05), ||y||_2 = 2.1213203328e+00] + [Pre-RHS processing (stage 3 of 6) at t = 6.44e-05 (tn = 0.00e+00 , tcur = 6.44e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 3 of 6) at t = 6.44e-05 (tn = 0.00e+00 , tcur = 6.44e-05), ||y||_2 = 2.1213183410e+00] + [Post-stage processing (stage 3 of 6) at t = 6.44e-05 (tn = 0.00e+00 , tcur = 6.44e-05), ||y||_2 = 2.1213201480e+00] + [Pre-RHS processing (stage 3 of 6) at t = 6.44e-05 (tn = 0.00e+00 , tcur = 6.44e-05), ||y||_2 = 2.1213201480e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.07e-04 (tn = 0.00e+00 , tcur = 1.07e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.07e-04 (tn = 0.00e+00 , tcur = 1.07e-04), ||y||_2 = 2.1213183410e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.07e-04 (tn = 0.00e+00 , tcur = 1.07e-04), ||y||_2 = 2.1213198021e+00] + [Post-stage processing (stage 4 of 6) at t = 1.07e-04 (tn = 0.00e+00 , tcur = 1.07e-04), ||y||_2 = 2.1213198021e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.07e-04 (tn = 0.00e+00 , tcur = 1.07e-04), ||y||_2 = 2.1213198021e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213183410e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Post-stage processing (stage 5 of 6) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Post-step processing at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + 1.0298602561e-04 1.2247448703e+00 1.7320501952e+00 7.8541617654e-12 2.7311486406e-14 + [Pre-step processing at t = 1.03e-04 (tn = 1.03e-04 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1213178432e+00] + [Pre-RHS processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1213208437e+00] + [Pre-RHS processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1181363161e+00] + [Pre-RHS processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1181350533e+00] + [Post-stage processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1181363096e+00] + [Pre-RHS processing (stage 1 of 6) at t = 8.22e-03 (tn = 1.03e-04 , tcur = 8.22e-03), ||y||_2 = 2.1181363096e+00] + [Pre-RHS processing (stage 2 of 6) at t = 2.48e-03 (tn = 1.03e-04 , tcur = 2.48e-03), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 2 of 6) at t = 2.48e-03 (tn = 1.03e-04 , tcur = 2.48e-03), ||y||_2 = 2.1213178432e+00] + [Pre-RHS processing (stage 2 of 6) at t = 2.48e-03 (tn = 1.03e-04 , tcur = 2.48e-03), ||y||_2 = 2.1213208437e+00] + [Pre-RHS processing (stage 2 of 6) at t = 2.48e-03 (tn = 1.03e-04 , tcur = 2.48e-03), ||y||_2 = 2.1210284133e+00] + [Post-stage processing (stage 2 of 6) at t = 2.48e-03 (tn = 1.03e-04 , tcur = 2.48e-03), ||y||_2 = 2.1210284133e+00] + [Pre-RHS processing (stage 2 of 6) at t = 2.48e-03 (tn = 1.03e-04 , tcur = 2.48e-03), ||y||_2 = 2.1210284133e+00] + [Pre-RHS processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1213178432e+00] + [Pre-RHS processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1213208437e+00] + [Pre-RHS processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1163722075e+00] + [Pre-RHS processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1163703971e+00] + [Post-stage processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1163721824e+00] + [Pre-RHS processing (stage 3 of 6) at t = 1.03e-02 (tn = 1.03e-04 , tcur = 1.03e-02), ||y||_2 = 2.1163721824e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1213178432e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1213208437e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1077899282e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1077876968e+00] + [Post-stage processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1077895068e+00] + [Pre-RHS processing (stage 4 of 6) at t = 1.70e-02 (tn = 1.03e-04 , tcur = 1.70e-02), ||y||_2 = 2.1077895068e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1213178432e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1213208437e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1087855077e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1087832801e+00] + [Post-stage processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 5 of 6) at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02), ||y||_2 = 2.1087851653e+00] + [Post-step processing at t = 1.63e-02 (tn = 1.03e-04 , tcur = 1.63e-02),||y||_2 = 2.1087851653e+00] + 1.6345098954e-02 1.2247176001e+00 1.7166949855e+00 4.4663852616e-09 6.0447387096e-09 + [Pre-step processing at t = 1.63e-02 (tn = 1.63e-02 , tcur = 1.63e-02),||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.1087831891e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.1087861718e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.0935038900e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.0935017090e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.0935030131e+00] + [Post-stage processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.0935030131e+00] + [Pre-RHS processing (stage 1 of 6) at t = 2.44e-02 (tn = 1.63e-02 , tcur = 2.44e-02), ||y||_2 = 2.0935030131e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1087831891e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1087861719e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1049048432e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1049026275e+00] + [Post-stage processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1049048030e+00] + [Pre-RHS processing (stage 2 of 6) at t = 1.87e-02 (tn = 1.63e-02 , tcur = 1.87e-02), ||y||_2 = 2.1049048030e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.1087831891e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.1087861718e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.0887688409e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.0887666742e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.0887671857e+00] + [Post-stage processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.0887671857e+00] + [Pre-RHS processing (stage 3 of 6) at t = 2.65e-02 (tn = 1.63e-02 , tcur = 2.65e-02), ||y||_2 = 2.0887671857e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.1087831890e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.1087861717e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.0706044622e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.0706023387e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.0705966594e+00] + [Post-stage processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.0705966594e+00] + [Pre-RHS processing (stage 4 of 6) at t = 3.32e-02 (tn = 1.63e-02 , tcur = 3.32e-02), ||y||_2 = 2.0705966594e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.1087851653e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.1087831890e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.1087861718e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.0725003000e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.0724981727e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.0724934048e+00] + [Post-stage processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.0724934048e+00] + [Pre-RHS processing (stage 5 of 6) at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02), ||y||_2 = 2.0724934048e+00] + [Post-step processing at t = 3.25e-02 (tn = 1.63e-02 , tcur = 3.25e-02),||y||_2 = 2.0724934048e+00] + 3.2548715292e-02 1.2246367417e+00 1.6719730154e+00 8.0260507129e-09 5.9880216341e-09 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.0325487152923576 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.000102986025609508 +Last step size = 0.0162036163379197 +Current step size = 0.0160003634180696 +Explicit RHS fn evals = 0 +Implicit RHS fn evals = 49 +NLS iters = 31 +NLS fails = 0 +NLS iters per step = 10.3333333333333 +LS setups = 0 +Jac fn evals = 0 +LS RHS fn evals = 34 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 34 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 34 +LS iters per NLS iter = 1.09677419354839 +Jac evals per NLS iter = 0 +Prec evals per NLS iter = 0 +End ARKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_2.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_2.out new file mode 100644 index 0000000000..0c42465ad2 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_arkstep_2.out @@ -0,0 +1,172 @@ +Start ARKStep StageInfo test +Using ImEx method +Using Newton nonlinear solver +Using GMRES iterative linear solver + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 7) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 7) at t = 4.71e-08 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 7) at t = 2.06e-04 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 7) at t = 2.54e-05 (tn = 0.00e+00 , tcur = 2.54e-05), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 7) at t = 2.54e-05 (tn = 0.00e+00 , tcur = 2.54e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 7) at t = 2.54e-05 (tn = 0.00e+00 , tcur = 2.54e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.34e-05 (tn = 0.00e+00 , tcur = 4.34e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.34e-05 (tn = 0.00e+00 , tcur = 4.34e-05), ||y||_2 = 2.1213183410e+00] + [Post-stage processing (stage 2 of 7) at t = 4.34e-05 (tn = 0.00e+00 , tcur = 4.34e-05), ||y||_2 = 2.1213202546e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.34e-05 (tn = 0.00e+00 , tcur = 4.34e-05), ||y||_2 = 2.1213202546e+00] + [Pre-RHS processing (stage 3 of 7) at t = 3.45e-05 (tn = 0.00e+00 , tcur = 3.45e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 3 of 7) at t = 3.45e-05 (tn = 0.00e+00 , tcur = 3.45e-05), ||y||_2 = 2.1213183410e+00] + [Post-stage processing (stage 3 of 7) at t = 3.45e-05 (tn = 0.00e+00 , tcur = 3.45e-05), ||y||_2 = 2.1213202874e+00] + [Pre-RHS processing (stage 3 of 7) at t = 3.45e-05 (tn = 0.00e+00 , tcur = 3.45e-05), ||y||_2 = 2.1213202874e+00] + [Pre-RHS processing (stage 4 of 7) at t = 7.72e-06 (tn = 0.00e+00 , tcur = 7.72e-06), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 4 of 7) at t = 7.72e-06 (tn = 0.00e+00 , tcur = 7.72e-06), ||y||_2 = 2.1213183409e+00] + [Post-stage processing (stage 4 of 7) at t = 7.72e-06 (tn = 0.00e+00 , tcur = 7.72e-06), ||y||_2 = 2.1213203407e+00] + [Pre-RHS processing (stage 4 of 7) at t = 7.72e-06 (tn = 0.00e+00 , tcur = 7.72e-06), ||y||_2 = 2.1213203407e+00] + [Pre-RHS processing (stage 5 of 7) at t = 7.21e-05 (tn = 0.00e+00 , tcur = 7.21e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 5 of 7) at t = 7.21e-05 (tn = 0.00e+00 , tcur = 7.21e-05), ||y||_2 = 2.1213183410e+00] + [Pre-RHS processing (stage 5 of 7) at t = 7.21e-05 (tn = 0.00e+00 , tcur = 7.21e-05), ||y||_2 = 2.1213200983e+00] + [Post-stage processing (stage 5 of 7) at t = 7.21e-05 (tn = 0.00e+00 , tcur = 7.21e-05), ||y||_2 = 2.1213200983e+00] + [Pre-RHS processing (stage 5 of 7) at t = 7.21e-05 (tn = 0.00e+00 , tcur = 7.21e-05), ||y||_2 = 2.1213200983e+00] + [Pre-RHS processing (stage 6 of 7) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 6 of 7) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213183410e+00] + [Pre-RHS processing (stage 6 of 7) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Post-stage processing (stage 6 of 7) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 6 of 7) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Post-step processing at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + 1.0298602561e-04 1.2247448703e+00 1.7320501952e+00 2.2204460493e-16 0.0000000000e+00 + [Pre-step processing at t = 1.03e-04 (tn = 1.03e-04 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 0 of 7) at t = 1.03e-04 (tn = 1.03e-04 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 1 of 7) at t = 8.73e-03 (tn = 1.03e-04 , tcur = 8.73e-03), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 1 of 7) at t = 8.73e-03 (tn = 1.03e-04 , tcur = 8.73e-03), ||y||_2 = 2.1213179609e+00] + [Pre-RHS processing (stage 1 of 7) at t = 8.73e-03 (tn = 1.03e-04 , tcur = 8.73e-03), ||y||_2 = 2.1213210506e+00] + [Pre-RHS processing (stage 1 of 7) at t = 8.73e-03 (tn = 1.03e-04 , tcur = 8.73e-03), ||y||_2 = 2.1212262228e+00] + [Post-stage processing (stage 1 of 7) at t = 8.73e-03 (tn = 1.03e-04 , tcur = 8.73e-03), ||y||_2 = 2.1212262228e+00] + [Pre-RHS processing (stage 1 of 7) at t = 8.73e-03 (tn = 1.03e-04 , tcur = 8.73e-03), ||y||_2 = 2.1212262228e+00] + [Pre-RHS processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1213178446e+00] + [Pre-RHS processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1213208465e+00] + [Pre-RHS processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1109952863e+00] + [Pre-RHS processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1109963352e+00] + [Post-stage processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1109953892e+00] + [Pre-RHS processing (stage 2 of 7) at t = 1.48e-02 (tn = 1.03e-04 , tcur = 1.48e-02), ||y||_2 = 2.1109953892e+00] + [Pre-RHS processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1213178450e+00] + [Pre-RHS processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1213208473e+00] + [Pre-RHS processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1147654560e+00] + [Pre-RHS processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1147665074e+00] + [Post-stage processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1147654976e+00] + [Pre-RHS processing (stage 3 of 7) at t = 1.18e-02 (tn = 1.03e-04 , tcur = 1.18e-02), ||y||_2 = 2.1147654976e+00] + [Pre-RHS processing (stage 4 of 7) at t = 2.72e-03 (tn = 1.03e-04 , tcur = 2.72e-03), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 4 of 7) at t = 2.72e-03 (tn = 1.03e-04 , tcur = 2.72e-03), ||y||_2 = 2.1213178266e+00] + [Pre-RHS processing (stage 4 of 7) at t = 2.72e-03 (tn = 1.03e-04 , tcur = 2.72e-03), ||y||_2 = 2.1213208099e+00] + [Pre-RHS processing (stage 4 of 7) at t = 2.72e-03 (tn = 1.03e-04 , tcur = 2.72e-03), ||y||_2 = 2.1209503426e+00] + [Post-stage processing (stage 4 of 7) at t = 2.72e-03 (tn = 1.03e-04 , tcur = 2.72e-03), ||y||_2 = 2.1209503426e+00] + [Pre-RHS processing (stage 4 of 7) at t = 2.72e-03 (tn = 1.03e-04 , tcur = 2.72e-03), ||y||_2 = 2.1209503426e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.1213178428e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.1213208430e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.0932810331e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.0932820701e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.0932790587e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.0932817810e+00] + [Post-stage processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.0932817810e+00] + [Pre-RHS processing (stage 5 of 7) at t = 2.45e-02 (tn = 1.03e-04 , tcur = 2.45e-02), ||y||_2 = 2.0932817810e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.1213178433e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.1213208439e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.0649440080e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.0649450254e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.0649420305e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.0649469358e+00] + [Post-stage processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.0649469358e+00] + [Pre-RHS processing (stage 6 of 7) at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02), ||y||_2 = 2.0649469358e+00] + [Post-step processing at t = 3.50e-02 (tn = 1.03e-04 , tcur = 3.50e-02),||y||_2 = 2.0649991558e+00] + 3.5024521932e-02 1.2246196097e+00 1.6626870797e+00 6.6819398681e-08 6.5525542281e-07 + [Pre-step processing at t = 3.50e-02 (tn = 3.50e-02 , tcur = 3.50e-02),||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 0 of 7) at t = 3.50e-02 (tn = 3.50e-02 , tcur = 3.50e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0649972631e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0650001842e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0383154536e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0383164246e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0383135369e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0383161449e+00] + [Post-stage processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0383161449e+00] + [Pre-RHS processing (stage 1 of 7) at t = 4.36e-02 (tn = 3.50e-02 , tcur = 4.36e-02), ||y||_2 = 2.0383161449e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0649972629e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0650001838e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0114167342e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0114176855e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0114148140e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0114194404e+00] + [Post-stage processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0114194404e+00] + [Pre-RHS processing (stage 2 of 7) at t = 4.96e-02 (tn = 3.50e-02 , tcur = 4.96e-02), ||y||_2 = 2.0114194404e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0649972629e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0650001839e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0236350168e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0236359771e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0236330982e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0236366549e+00] + [Post-stage processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0236366549e+00] + [Pre-RHS processing (stage 3 of 7) at t = 4.66e-02 (tn = 3.50e-02 , tcur = 4.66e-02), ||y||_2 = 2.0236366549e+00] + [Pre-RHS processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0649972622e+00] + [Pre-RHS processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0650001825e+00] + [Pre-RHS processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0565069828e+00] + [Pre-RHS processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0565079665e+00] + [Post-stage processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0565070541e+00] + [Pre-RHS processing (stage 4 of 7) at t = 3.76e-02 (tn = 3.50e-02 , tcur = 3.76e-02), ||y||_2 = 2.0565070541e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 2.0649972625e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 2.0650001830e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 1.9686832168e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 1.9686841353e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 1.9686812913e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 1.9686914710e+00] + [Post-stage processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 1.9686914710e+00] + [Pre-RHS processing (stage 5 of 7) at t = 5.93e-02 (tn = 3.50e-02 , tcur = 5.93e-02), ||y||_2 = 1.9686914710e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 2.0649991558e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 2.0649972625e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 2.0650001830e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 1.9163575635e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 1.9163584389e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 1.9163556320e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 1.9163758117e+00] + [Post-stage processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 1.9163758117e+00] + [Pre-RHS processing (stage 6 of 7) at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02), ||y||_2 = 1.9163758117e+00] + [Post-step processing at t = 6.97e-02 (tn = 3.50e-02 , tcur = 6.97e-02),||y||_2 = 1.9169542285e+00] + 6.9697813939e-02 1.2242491983e+00 1.4751025098e+00 2.2221884333e-08 2.5857302401e-06 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.0696978139393375 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.000102986025609508 +Last step size = 0.0346732920075373 +Current step size = 0.0331306528243113 +Explicit RHS fn evals = 23 +Implicit RHS fn evals = 62 +NLS iters = 39 +NLS fails = 0 +NLS iters per step = 13 +LS setups = 0 +Jac fn evals = 0 +LS RHS fn evals = 46 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 46 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 46 +LS iters per NLS iter = 1.17948717948718 +Jac evals per NLS iter = 0 +Prec evals per NLS iter = 0 +End ARKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_erkstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_erkstep.cpp new file mode 100644 index 0000000000..375bee9e5c --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_erkstep.cpp @@ -0,0 +1,265 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in ERKStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators, vectors, linear solvers, and nonlinear solvers +#include "arkode/arkode_erkstep.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_context.hpp" + +#include "problems/kpr.hpp" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::kpr; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start ERKStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Create initial condition + N_Vector y = N_VNew_Serial(2, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + + sunrealtype utrue, vtrue; + int flag = true_sol(zero, &utrue, &vtrue); + if (check_flag(flag, "true_sol")) { return 1; } + + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = utrue; + ydata[1] = vtrue; + + // Create ERKStep memory structure + arkode_mem = ERKStepCreate(ode_rhs, zero, y, sunctx); + if (check_ptr(arkode_mem, "ERKStepCreate")) { return 1; } + + flag = ARKodeSetUserData(arkode_mem, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + // Relative and absolute tolerances + const sunrealtype rtol = SUN_RCONST(1.0e-6); + const sunrealtype atol = SUN_RCONST(1.0e-10); + + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = one; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + // Output initial contion + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << " t "; + cout << " u "; + cout << " v "; + cout << " u err "; + cout << " v err " << endl; + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << abs(ydata[0] - utrue) << setw(25) << abs(ydata[1] - vtrue) + << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { return 1; } + + flag = true_sol(tret, &utrue, &vtrue); + if (check_flag(flag, "true_sol")) { return 1; } + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << abs(ydata[0] - utrue) << setw(25) + << abs(ydata[1] - vtrue) << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + ARKodeFree(&arkode_mem); + + cout << "End ERKStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_erkstep.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_erkstep.out new file mode 100644 index 0000000000..f14856a4d7 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_erkstep.out @@ -0,0 +1,64 @@ +Start ERKStep StageInfo test + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 5) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 4.71e-08 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 2.06e-04 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 5) at t = 4.12e-05 (tn = 0.00e+00 , tcur = 4.12e-05), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 5) at t = 4.12e-05 (tn = 0.00e+00 , tcur = 4.12e-05), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 2 of 5) at t = 6.18e-05 (tn = 0.00e+00 , tcur = 6.18e-05), ||y||_2 = 2.1213200432e+00] + [Pre-RHS processing (stage 2 of 5) at t = 6.18e-05 (tn = 0.00e+00 , tcur = 6.18e-05), ||y||_2 = 2.1213200432e+00] + [Post-stage processing (stage 3 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213199340e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213199340e+00] + [Post-stage processing (stage 4 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04), ||y||_2 = 2.1213198430e+00] + [Post-step processing at t = 1.03e-04 (tn = 0.00e+00 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + 1.0298602561e-04 1.2247448703e+00 1.7320501952e+00 2.2204460493e-16 0.0000000000e+00 + [Pre-step processing at t = 1.03e-04 (tn = 1.03e-04 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + [Post-stage processing (stage 1 of 5) at t = 6.56e-03 (tn = 1.03e-04 , tcur = 6.56e-03), ||y||_2 = 2.1212571010e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.56e-03 (tn = 1.03e-04 , tcur = 6.56e-03), ||y||_2 = 2.1212571010e+00] + [Post-stage processing (stage 2 of 5) at t = 9.78e-03 (tn = 1.03e-04 , tcur = 9.78e-03), ||y||_2 = 2.1138657565e+00] + [Pre-RHS processing (stage 2 of 5) at t = 9.78e-03 (tn = 1.03e-04 , tcur = 9.78e-03), ||y||_2 = 2.1138657565e+00] + [Post-stage processing (stage 3 of 5) at t = 1.62e-02 (tn = 1.03e-04 , tcur = 1.62e-02), ||y||_2 = 2.1111621630e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.62e-02 (tn = 1.03e-04 , tcur = 1.62e-02), ||y||_2 = 2.1111621630e+00] + [Post-stage processing (stage 4 of 5) at t = 1.62e-02 (tn = 1.03e-04 , tcur = 1.62e-02), ||y||_2 = 2.1089486502e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.62e-02 (tn = 1.03e-04 , tcur = 1.62e-02), ||y||_2 = 2.1089486502e+00] + [Post-step failure processing at t = 1.62e-02 (tn = 1.03e-04 , tcur = 1.62e-02),||y||_2 = 2.1089486502e+00] + [Pre-step processing at t = 1.03e-04 (tn = 1.03e-04 , tcur = 1.03e-04),||y||_2 = 2.1213198430e+00] + [Post-stage processing (stage 1 of 5) at t = 6.49e-03 (tn = 1.03e-04 , tcur = 6.49e-03), ||y||_2 = 2.1212577772e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.49e-03 (tn = 1.03e-04 , tcur = 6.49e-03), ||y||_2 = 2.1212577772e+00] + [Post-stage processing (stage 2 of 5) at t = 9.68e-03 (tn = 1.03e-04 , tcur = 9.68e-03), ||y||_2 = 2.1140241446e+00] + [Pre-RHS processing (stage 2 of 5) at t = 9.68e-03 (tn = 1.03e-04 , tcur = 9.68e-03), ||y||_2 = 2.1140241446e+00] + [Post-stage processing (stage 3 of 5) at t = 1.61e-02 (tn = 1.03e-04 , tcur = 1.61e-02), ||y||_2 = 2.1113775352e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.61e-02 (tn = 1.03e-04 , tcur = 1.61e-02), ||y||_2 = 2.1113775352e+00] + [Post-stage processing (stage 4 of 5) at t = 1.61e-02 (tn = 1.03e-04 , tcur = 1.61e-02), ||y||_2 = 2.1092106860e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.61e-02 (tn = 1.03e-04 , tcur = 1.61e-02), ||y||_2 = 2.1092106860e+00] + [Post-step processing at t = 1.61e-02 (tn = 1.03e-04 , tcur = 1.61e-02),||y||_2 = 2.1092106860e+00] + 1.6063645340e-02 1.2247184913e+00 1.7172170321e+00 4.4212199679e-08 2.9106373090e-08 + [Pre-step processing at t = 1.61e-02 (tn = 1.61e-02 , tcur = 1.61e-02),||y||_2 = 2.1092106860e+00] + [Post-stage processing (stage 1 of 5) at t = 2.24e-02 (tn = 1.61e-02 , tcur = 2.24e-02), ||y||_2 = 2.0996520676e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.24e-02 (tn = 1.61e-02 , tcur = 2.24e-02), ||y||_2 = 2.0996520676e+00] + [Post-stage processing (stage 2 of 5) at t = 2.56e-02 (tn = 1.61e-02 , tcur = 2.56e-02), ||y||_2 = 2.0880076268e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.56e-02 (tn = 1.61e-02 , tcur = 2.56e-02), ||y||_2 = 2.0880076268e+00] + [Post-stage processing (stage 3 of 5) at t = 3.20e-02 (tn = 1.61e-02 , tcur = 3.20e-02), ||y||_2 = 2.0760211062e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.20e-02 (tn = 1.61e-02 , tcur = 3.20e-02), ||y||_2 = 2.0760211062e+00] + [Post-stage processing (stage 4 of 5) at t = 3.20e-02 (tn = 1.61e-02 , tcur = 3.20e-02), ||y||_2 = 2.0740200715e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.20e-02 (tn = 1.61e-02 , tcur = 3.20e-02), ||y||_2 = 2.0740200715e+00] + [Post-step processing at t = 3.20e-02 (tn = 1.61e-02 , tcur = 3.20e-02),||y||_2 = 2.0740200715e+00] + 3.2023388180e-02 1.2246401240e+00 1.6738625462e+00 8.7464898657e-08 1.4947668547e-07 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.0320233881803733 +Steps = 3 +Step attempts = 4 +Stability limited steps = 0 +Accuracy limited steps = 4 +Error test fails = 1 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.000102986025609508 +Last step size = 0.0159597428408288 +Current step size = 0.0166588795523219 +RHS fn evals = 19 +End ERKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_forcingstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_forcingstep.cpp new file mode 100644 index 0000000000..e5b6bf75d2 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_forcingstep.cpp @@ -0,0 +1,296 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in ForcingStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators and vectors +#include "arkode/arkode_erkstep.h" +#include "arkode/arkode_forcingstep.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_context.hpp" + +#include "problems/estep.hpp" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::estep; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start ForcingStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Step sizes: overall, partition 1, partition 2 + sunrealtype dt = SUN_RCONST(0.001); + sunrealtype dt_1 = dt / 2; + sunrealtype dt_2 = dt / 4; + + // Create initial condition + N_Vector y = N_VNew_Serial(1, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + + int flag = initial_condition(y); + if (check_flag(flag, "initial_condition")) { return 1; } + + // Create partition 1 integrator + void* stepper_1 = ERKStepCreate(ode_rhs_1, zero, y, sunctx); + if (check_ptr(stepper_1, "ERKStepCreate")) { return 1; } + + flag = ARKodeSetUserData(stepper_1, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + flag = ARKodeSetFixedStep(stepper_1, dt_1); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Create partition 1 integrator + void* stepper_2 = ERKStepCreate(ode_rhs_2, zero, y, sunctx); + if (check_ptr(stepper_2, "ERKStepCreate")) { return 1; } + + flag = ARKodeSetFixedStep(stepper_2, dt_2); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Create the overall integrator + SUNStepper steppers[2]; + + flag = ARKodeCreateSUNStepper(stepper_1, &steppers[0]); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + flag = ARKodeCreateSUNStepper(stepper_2, &steppers[1]); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + arkode_mem = ForcingStepCreate(steppers[0], steppers[1], zero, y, sunctx); + if (check_ptr(arkode_mem, "ForcingStepCreate")) { return 1; } + + flag = ARKodeSetFixedStep(arkode_mem, dt); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // True solution vector + N_Vector yt = N_VClone(y); + + flag = true_solution(zero, problem_data, yt); + if (check_flag(flag, "true_solution")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = one; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + const int width = numeric_limits::digits10 + 8; + + // Output initial contion + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << setw(width) << " t"; + cout << setw(width) << " y"; + cout << setw(width) << " y err" << endl; + for (int i = 0; i < 3 * width; i++) { cout << "-"; } + cout << endl; + + sunrealtype* y_data = N_VGetArrayPointer(y); + sunrealtype* yt_data = N_VGetArrayPointer(yt); + + cout << setw(width) << tret << setw(width) << y_data[0] << setw(width) + << abs(y_data[0] - yt_data[0]) << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { return 1; } + + flag = true_solution(tret, problem_data, yt); + if (check_flag(flag, "true_solution")) { return 1; } + + cout << setw(width) << tret << setw(width) << y_data[0] << setw(width) + << abs(y_data[0] - yt_data[0]) << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 3 * width; i++) { cout << "-"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + N_VDestroy(yt); + ARKodeFree(&arkode_mem); + ARKodeFree(&stepper_1); + ARKodeFree(&stepper_2); + SUNStepper_Destroy(&steppers[0]); + SUNStepper_Destroy(&steppers[1]); + + cout << "End ForcingStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_forcingstep.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_forcingstep.out new file mode 100644 index 0000000000..c27dcd9965 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_forcingstep.out @@ -0,0 +1,28 @@ +Start ForcingStep StageInfo test + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 1.0000000000e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 9.9900100033e-01] + 1.0000000000e-03 9.9900100033e-01 9.9999966707e-07 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 9.9900100033e-01] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 9.9800200066e-01] + 2.0000000000e-03 9.9800200066e-01 1.9979980046e-06 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 9.9800200066e-01] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 9.9700300299e-01] + 3.0000000000e-03 9.9700300299e-01 2.9939930263e-06 +--------------------------------------------------------------------- +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Partition 1 evolves = 3 +Partition 2 evolves = 3 +End ForcingStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep.cpp new file mode 100644 index 0000000000..17ee8ab6cc --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep.cpp @@ -0,0 +1,305 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in LSRKStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators, vectors, linear solvers, and nonlinear solvers +#include "arkode/arkode_lsrkstep.h" +#include "nvector/nvector_serial.h" + +#include "problems/prv.hpp" +#include "sundials/sundials_nvector.h" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::prv; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start LSRKStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Use RKC (0), RKL (1), SSPs2 (2), SSPs3 (3), SSP43 (4), SSP104 (5) + int method = 0; + if (argc > 1) { method = stoi(argv[1]); } + + // Create initial condition + N_Vector y = N_VNew_Serial(1, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + N_VConst(true_solution(zero), y); + + // Create LSRKStep memory structure + if (method < 2) { arkode_mem = LSRKStepCreateSTS(ode_rhs, zero, y, sunctx); } + else { arkode_mem = LSRKStepCreateSSP(ode_rhs, zero, y, sunctx); } + if (check_ptr(arkode_mem, "LSRKStepCreate")) { return 1; } + + // Select method + int flag; + if (method == 0) + { + cout << "Using RKC method" << endl; + flag = LSRKStepSetSTSMethodByName(arkode_mem, "ARKODE_LSRK_RKC_2"); + } + else if (method == 1) + { + cout << "Using RKL method" << endl; + flag = LSRKStepSetSTSMethodByName(arkode_mem, "ARKODE_LSRK_RKL_2"); + } + else if (method == 2) + { + cout << "Using SSP(s,2) method" << endl; + flag = LSRKStepSetSSPMethodByName(arkode_mem, "ARKODE_LSRK_SSP_S_2"); + } + else if (method == 3) + { + cout << "Using SSP(9,3) method" << endl; + flag = LSRKStepSetSSPMethodByName(arkode_mem, "ARKODE_LSRK_SSP_S_3"); + if (flag == 0) { flag = LSRKStepSetNumSSPStages(arkode_mem, 4); } + } + else if (method == 4) + { + cout << "Using SSP(4,3) method" << endl; + flag = LSRKStepSetSSPMethodByName(arkode_mem, "ARKODE_LSRK_SSP_S_3"); + if (flag == 0) { flag = LSRKStepSetNumSSPStages(arkode_mem, 4); } + } + else if (method == 5) + { + cout << "Using SSP(10,4) method" << endl; + flag = LSRKStepSetSSPMethodByName(arkode_mem, "ARKODE_LSRK_SSP_10_4"); + } + else + { + cerr << "Invalid method option\n"; + return 1; + } + if (check_flag(flag, "LSRKStepSetMethodByName")) { return 1; } + + flag = ARKodeSetUserData(arkode_mem, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + // Relative and absolute tolerances + const sunrealtype rtol = SUN_RCONST(1.0e-6); + const sunrealtype atol = SUN_RCONST(1.0e-10); + + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } + + // Specify dominant eigenvalue function + flag = LSRKStepSetDomEigFn(arkode_mem, ode_dom_eig); + if (check_flag(flag, "LSRKStepSetDomEigFn")) { return 1; } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = one; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + const int width = numeric_limits::digits10 + 8; + + // Output initial contion + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << setw(width) << " t"; + cout << setw(width) << " y"; + cout << setw(width) << " y err" << endl; + for (int i = 0; i < 3 * width; i++) { cout << "-"; } + cout << endl; + + sunrealtype* y_data = N_VGetArrayPointer(y); + + cout << setw(width) << tret << setw(width) << y_data[0] << setw(width) + << abs(y_data[0] - true_solution(tret)) << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { return 1; } + + cout << setw(width) << tret << setw(width) << y_data[0] << setw(width) + << abs(y_data[0] - true_solution(tret)) << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 3 * width; i++) { cout << "-"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + ARKodeFree(&arkode_mem); + + cout << "End LSRKStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_0.out new file mode 100644 index 0000000000..de95754b54 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_0.out @@ -0,0 +1,45 @@ +Start LSRKStep StageInfo test +Using RKC method + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 0) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 0.0000000000e+00] + [Pre-RHS processing (stage 0 of 0) at t = 1.49e-12 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.4901161194e-12] + [Pre-RHS processing (stage 0 of 0) at t = 1.22e-11 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.2207031250e-11] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 0.0000000000e+00] + [Post-stage processing (stage 0 of 2) at t = 1.47e-12 (tn = 0.00e+00 , tcur = 1.47e-12), ||y||_2 = 1.4693648727e-12] + [Pre-RHS processing (stage 1 of 2) at t = 1.47e-12 (tn = 0.00e+00 , tcur = 1.47e-12), ||y||_2 = 1.4693648727e-12] + [Pre-RHS processing (stage 2 of 2) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-step processing at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + 6.1035156250e-12 6.1035156250e-12 1.2116903504e-26 + [Pre-step processing at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + [Post-stage processing (stage 0 of 2) at t = 1.47e-08 (tn = 6.10e-12 , tcur = 1.47e-08), ||y||_2 = 1.4699752242e-08] + [Pre-RHS processing (stage 1 of 2) at t = 1.47e-08 (tn = 6.10e-12 , tcur = 1.47e-08), ||y||_2 = 1.4699752242e-08] + [Pre-RHS processing (stage 2 of 2) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-step processing at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + 6.1041259766e-08 6.1041259766e-08 5.2939559203e-22 + [Pre-step processing at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + [Post-stage processing (stage 0 of 2) at t = 3.55e-07 (tn = 6.10e-08 , tcur = 3.55e-07), ||y||_2 = 3.5491423430e-07] + [Pre-RHS processing (stage 1 of 2) at t = 3.55e-07 (tn = 6.10e-08 , tcur = 3.55e-07), ||y||_2 = 3.5491423430e-07] + [Pre-RHS processing (stage 2 of 2) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Post-step processing at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06),||y||_2 = 1.2817443848e-06] + 1.2817443848e-06 1.2817443848e-06 3.8518823276e-19 +--------------------------------------------------------------------- +Current time = 1.28174438476563e-06 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 6.103515625e-12 +Last step size = 1.220703125e-06 +Current step size = 2.44140625e-05 +RHS fn evals = 9 +Number of dom_eig updates = 1 +Max. num. of stages used = 2 +Max. num. of stages allowed = 200 +Max. spectral radius = 999.9 +Min. spectral radius = 999.9 +End LSRKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_1.out new file mode 100644 index 0000000000..851b298a95 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_1.out @@ -0,0 +1,45 @@ +Start LSRKStep StageInfo test +Using RKL method + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 0) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 0.0000000000e+00] + [Pre-RHS processing (stage 0 of 0) at t = 1.49e-12 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.4901161194e-12] + [Pre-RHS processing (stage 0 of 0) at t = 1.22e-11 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.2207031250e-11] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 0.0000000000e+00] + [Post-stage processing (stage 0 of 2) at t = 2.03e-12 (tn = 0.00e+00 , tcur = 2.03e-12), ||y||_2 = 2.0345052083e-12] + [Pre-RHS processing (stage 1 of 2) at t = 2.03e-12 (tn = 0.00e+00 , tcur = 2.03e-12), ||y||_2 = 2.0345052083e-12] + [Pre-RHS processing (stage 2 of 2) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-step processing at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + 6.1035156250e-12 6.1035156250e-12 0.0000000000e+00 + [Pre-step processing at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + [Post-stage processing (stage 0 of 2) at t = 2.04e-08 (tn = 6.10e-12 , tcur = 2.04e-08), ||y||_2 = 2.0351155599e-08] + [Pre-RHS processing (stage 1 of 2) at t = 2.04e-08 (tn = 6.10e-12 , tcur = 2.04e-08), ||y||_2 = 2.0351155599e-08] + [Pre-RHS processing (stage 2 of 2) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-step processing at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + 6.1041259766e-08 6.1041259766e-08 3.9704669403e-23 + [Pre-step processing at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + [Post-stage processing (stage 0 of 2) at t = 4.68e-07 (tn = 6.10e-08 , tcur = 4.68e-07), ||y||_2 = 4.6794230143e-07] + [Pre-RHS processing (stage 1 of 2) at t = 4.68e-07 (tn = 6.10e-08 , tcur = 4.68e-07), ||y||_2 = 4.6794230143e-07] + [Pre-RHS processing (stage 2 of 2) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Post-step processing at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06),||y||_2 = 1.2817443848e-06] + 1.2817443848e-06 1.2817443848e-06 3.0323779512e-19 +--------------------------------------------------------------------- +Current time = 1.28174438476563e-06 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 6.103515625e-12 +Last step size = 1.220703125e-06 +Current step size = 2.44140625e-05 +RHS fn evals = 9 +Number of dom_eig updates = 1 +Max. num. of stages used = 2 +Max. num. of stages allowed = 200 +Max. spectral radius = 999.9 +Min. spectral radius = 999.9 +End LSRKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_2.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_2.out new file mode 100644 index 0000000000..97f718113c --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_2.out @@ -0,0 +1,40 @@ +Start LSRKStep StageInfo test +Using SSP(s,2) method + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 2) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 0.0000000000e+00] + [Pre-RHS processing (stage 0 of 2) at t = 1.49e-12 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.4901161194e-12] + [Pre-RHS processing (stage 0 of 2) at t = 1.22e-11 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.2207031250e-11] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 0.0000000000e+00] + [Post-stage processing (stage 0 of 2) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Pre-RHS processing (stage 1 of 2) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-step processing at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + 6.1035156250e-12 6.1035156250e-12 0.0000000000e+00 + [Pre-step processing at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + [Pre-RHS processing (stage 0 of 2) at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-stage processing (stage 0 of 2) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Pre-RHS processing (stage 1 of 2) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-step processing at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + 6.1041259766e-08 6.1041259766e-08 3.9704669403e-23 + [Pre-step processing at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + [Pre-RHS processing (stage 0 of 2) at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-stage processing (stage 0 of 2) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Pre-RHS processing (stage 1 of 2) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Post-step processing at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06),||y||_2 = 1.2817443848e-06] + 1.2817443848e-06 1.2817443848e-06 3.0366131159e-19 +--------------------------------------------------------------------- +Current time = 1.28174438476563e-06 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 6.103515625e-12 +Last step size = 1.220703125e-06 +Current step size = 2.44140625e-05 +RHS fn evals = 8 +Number of stages used = 2 +End LSRKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_3.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_3.out new file mode 100644 index 0000000000..37f0e8cb88 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_3.out @@ -0,0 +1,58 @@ +Start LSRKStep StageInfo test +Using SSP(s,3) method + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 4) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 0.0000000000e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.49e-12 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.4901161194e-12] + [Pre-RHS processing (stage 0 of 4) at t = 1.22e-11 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.2207031250e-11] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 0.0000000000e+00] + [Post-stage processing (stage 0 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Pre-RHS processing (stage 0 of 4) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 3.0517578125e-12] + [Post-stage processing (stage 0 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 6.1035156158e-12] + [Pre-RHS processing (stage 1 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 6.1035156158e-12] + [Post-stage processing (stage 1 of 4) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 9.1552734191e-12] + [Pre-RHS processing (stage 2 of 4) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 9.1552734191e-12] + [Post-stage processing (stage 2 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 6.1035156158e-12] + [Pre-RHS processing (stage 3 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 6.1035156158e-12] + [Post-step processing at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12),||y||_2 = 9.1552734191e-12] + 6.1035156250e-12 9.1552734191e-12 3.0517577941e-12 + [Pre-step processing at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12),||y||_2 = 9.1552734191e-12] + [Pre-RHS processing (stage 0 of 4) at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12), ||y||_2 = 9.1552734191e-12] + [Post-stage processing (stage 0 of 4) at t = 1.72e-11 (tn = 6.10e-12 , tcur = 1.72e-11), ||y||_2 = 2.0228798238e-11] + [Pre-RHS processing (stage 0 of 4) at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12), ||y||_2 = 2.0228798238e-11] + [Post-stage processing (stage 0 of 4) at t = 1.72e-11 (tn = 6.10e-12 , tcur = 1.72e-11), ||y||_2 = 3.1302322936e-11] + [Pre-RHS processing (stage 1 of 4) at t = 1.72e-11 (tn = 6.10e-12 , tcur = 1.72e-11), ||y||_2 = 3.1302322936e-11] + [Post-stage processing (stage 1 of 4) at t = 2.83e-11 (tn = 6.10e-12 , tcur = 2.83e-11), ||y||_2 = 4.2375847634e-11] + [Pre-RHS processing (stage 2 of 4) at t = 2.83e-11 (tn = 6.10e-12 , tcur = 2.83e-11), ||y||_2 = 4.2375847634e-11] + [Post-stage processing (stage 2 of 4) at t = 1.72e-11 (tn = 6.10e-12 , tcur = 1.72e-11), ||y||_2 = 3.1302322936e-11] + [Pre-RHS processing (stage 3 of 4) at t = 1.72e-11 (tn = 6.10e-12 , tcur = 1.72e-11), ||y||_2 = 3.1302322936e-11] + [Post-step processing at t = 2.83e-11 (tn = 6.10e-12 , tcur = 2.83e-11),||y||_2 = 4.2375847634e-11] + 2.8250565330e-11 4.2375847634e-11 1.4125282303e-11 + [Pre-step processing at t = 2.83e-11 (tn = 2.83e-11 , tcur = 2.83e-11),||y||_2 = 4.2375847634e-11] + [Pre-RHS processing (stage 0 of 4) at t = 2.83e-11 (tn = 2.83e-11 , tcur = 2.83e-11), ||y||_2 = 4.2375847634e-11] + [Post-stage processing (stage 0 of 4) at t = 5.44e-11 (tn = 2.83e-11 , tcur = 5.44e-11), ||y||_2 = 6.8524126345e-11] + [Pre-RHS processing (stage 0 of 4) at t = 2.83e-11 (tn = 2.83e-11 , tcur = 2.83e-11), ||y||_2 = 6.8524126345e-11] + [Post-stage processing (stage 0 of 4) at t = 5.44e-11 (tn = 2.83e-11 , tcur = 5.44e-11), ||y||_2 = 9.4672404379e-11] + [Pre-RHS processing (stage 1 of 4) at t = 5.44e-11 (tn = 2.83e-11 , tcur = 5.44e-11), ||y||_2 = 9.4672404379e-11] + [Post-stage processing (stage 1 of 4) at t = 8.05e-11 (tn = 2.83e-11 , tcur = 8.05e-11), ||y||_2 = 1.2082068241e-10] + [Pre-RHS processing (stage 2 of 4) at t = 8.05e-11 (tn = 2.83e-11 , tcur = 8.05e-11), ||y||_2 = 1.2082068241e-10] + [Post-stage processing (stage 2 of 4) at t = 5.44e-11 (tn = 2.83e-11 , tcur = 5.44e-11), ||y||_2 = 9.4672404379e-11] + [Pre-RHS processing (stage 3 of 4) at t = 5.44e-11 (tn = 2.83e-11 , tcur = 5.44e-11), ||y||_2 = 9.4672404379e-11] + [Post-step processing at t = 8.05e-11 (tn = 2.83e-11 , tcur = 8.05e-11),||y||_2 = 1.2082068241e-10] + 8.0547123483e-11 1.2082068241e-10 4.0273558929e-11 +--------------------------------------------------------------------- +Current time = 8.05471234832829e-11 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 6.103515625e-12 +Last step size = 5.22965581530996e-11 +Current step size = 9.27352060660382e-11 +RHS fn evals = 17 +Number of stages used = 4 +End LSRKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_4.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_4.out new file mode 100644 index 0000000000..e802bfd349 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_4.out @@ -0,0 +1,52 @@ +Start LSRKStep StageInfo test +Using SSP(4,3) method + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 4) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 0.0000000000e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.49e-12 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.4901161194e-12] + [Pre-RHS processing (stage 0 of 4) at t = 1.22e-11 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.2207031250e-11] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 0.0000000000e+00] + [Post-stage processing (stage 0 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Pre-RHS processing (stage 1 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Post-stage processing (stage 1 of 4) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Pre-RHS processing (stage 2 of 4) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-stage processing (stage 2 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Pre-RHS processing (stage 3 of 4) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Post-step processing at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + 6.1035156250e-12 6.1035156250e-12 8.0779356695e-28 + [Pre-step processing at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + [Pre-RHS processing (stage 0 of 4) at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-stage processing (stage 0 of 4) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Pre-RHS processing (stage 1 of 4) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Post-stage processing (stage 1 of 4) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Pre-RHS processing (stage 2 of 4) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-stage processing (stage 2 of 4) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Pre-RHS processing (stage 3 of 4) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Post-step processing at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + 6.1041259766e-08 6.1041259766e-08 0.0000000000e+00 + [Pre-step processing at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + [Pre-RHS processing (stage 0 of 4) at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-stage processing (stage 0 of 4) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Pre-RHS processing (stage 1 of 4) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Post-stage processing (stage 1 of 4) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Pre-RHS processing (stage 2 of 4) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Post-stage processing (stage 2 of 4) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Pre-RHS processing (stage 3 of 4) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Post-step processing at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06),||y||_2 = 1.2817443848e-06] + 1.2817443848e-06 1.2817443848e-06 2.1175823681e-22 +--------------------------------------------------------------------- +Current time = 1.28174438476563e-06 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 6.103515625e-12 +Last step size = 1.220703125e-06 +Current step size = 2.44140625e-05 +RHS fn evals = 14 +Number of stages used = 4 +End LSRKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_5.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_5.out new file mode 100644 index 0000000000..7239080362 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_lsrkstep_5.out @@ -0,0 +1,91 @@ +Start LSRKStep StageInfo test +Using SSP(10,4) method + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-RHS processing (stage 0 of 10) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 0.0000000000e+00] + [Pre-RHS processing (stage 0 of 10) at t = 1.49e-12 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.4901161194e-12] + [Pre-RHS processing (stage 0 of 10) at t = 1.22e-11 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 1.2207031250e-11] + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 0.0000000000e+00] + [Post-stage processing (stage 0 of 10) at t = 1.02e-12 (tn = 0.00e+00 , tcur = 1.02e-12), ||y||_2 = 1.0172526042e-12] + [Pre-RHS processing (stage 1 of 10) at t = 1.02e-12 (tn = 0.00e+00 , tcur = 1.02e-12), ||y||_2 = 1.0172526042e-12] + [Post-stage processing (stage 1 of 10) at t = 2.03e-12 (tn = 0.00e+00 , tcur = 2.03e-12), ||y||_2 = 2.0345052083e-12] + [Pre-RHS processing (stage 2 of 10) at t = 2.03e-12 (tn = 0.00e+00 , tcur = 2.03e-12), ||y||_2 = 2.0345052083e-12] + [Post-stage processing (stage 2 of 10) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Pre-RHS processing (stage 3 of 10) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Post-stage processing (stage 3 of 10) at t = 4.07e-12 (tn = 0.00e+00 , tcur = 4.07e-12), ||y||_2 = 4.0690104167e-12] + [Pre-RHS processing (stage 4 of 10) at t = 4.07e-12 (tn = 0.00e+00 , tcur = 4.07e-12), ||y||_2 = 4.0690104167e-12] + [Post-stage processing (stage 4 of 10) at t = 5.09e-12 (tn = 0.00e+00 , tcur = 5.09e-12), ||y||_2 = 5.0862630208e-12] + [Post-stage processing (stage 4 of 10) at t = 2.03e-12 (tn = 0.00e+00 , tcur = 2.03e-12), ||y||_2 = 2.0345052083e-12] + [Pre-RHS processing (stage 5 of 10) at t = 2.03e-12 (tn = 0.00e+00 , tcur = 2.03e-12), ||y||_2 = 2.0345052083e-12] + [Post-stage processing (stage 5 of 10) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Pre-RHS processing (stage 6 of 10) at t = 3.05e-12 (tn = 0.00e+00 , tcur = 3.05e-12), ||y||_2 = 3.0517578125e-12] + [Post-stage processing (stage 6 of 10) at t = 4.07e-12 (tn = 0.00e+00 , tcur = 4.07e-12), ||y||_2 = 4.0690104167e-12] + [Pre-RHS processing (stage 7 of 10) at t = 4.07e-12 (tn = 0.00e+00 , tcur = 4.07e-12), ||y||_2 = 4.0690104167e-12] + [Post-stage processing (stage 7 of 10) at t = 5.09e-12 (tn = 0.00e+00 , tcur = 5.09e-12), ||y||_2 = 5.0862630208e-12] + [Pre-RHS processing (stage 8 of 10) at t = 5.09e-12 (tn = 0.00e+00 , tcur = 5.09e-12), ||y||_2 = 5.0862630208e-12] + [Post-stage processing (stage 8 of 10) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Pre-RHS processing (stage 9 of 10) at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-step processing at t = 6.10e-12 (tn = 0.00e+00 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + 6.1035156250e-12 6.1035156250e-12 8.0779356695e-28 + [Pre-step processing at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12),||y||_2 = 6.1035156250e-12] + [Pre-RHS processing (stage 0 of 10) at t = 6.10e-12 (tn = 6.10e-12 , tcur = 6.10e-12), ||y||_2 = 6.1035156250e-12] + [Post-stage processing (stage 0 of 10) at t = 1.02e-08 (tn = 6.10e-12 , tcur = 1.02e-08), ||y||_2 = 1.0178629557e-08] + [Pre-RHS processing (stage 1 of 10) at t = 1.02e-08 (tn = 6.10e-12 , tcur = 1.02e-08), ||y||_2 = 1.0178629557e-08] + [Post-stage processing (stage 1 of 10) at t = 2.04e-08 (tn = 6.10e-12 , tcur = 2.04e-08), ||y||_2 = 2.0351155599e-08] + [Pre-RHS processing (stage 2 of 10) at t = 2.04e-08 (tn = 6.10e-12 , tcur = 2.04e-08), ||y||_2 = 2.0351155599e-08] + [Post-stage processing (stage 2 of 10) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Pre-RHS processing (stage 3 of 10) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Post-stage processing (stage 3 of 10) at t = 4.07e-08 (tn = 6.10e-12 , tcur = 4.07e-08), ||y||_2 = 4.0696207682e-08] + [Pre-RHS processing (stage 4 of 10) at t = 4.07e-08 (tn = 6.10e-12 , tcur = 4.07e-08), ||y||_2 = 4.0696207682e-08] + [Post-stage processing (stage 4 of 10) at t = 5.09e-08 (tn = 6.10e-12 , tcur = 5.09e-08), ||y||_2 = 5.0868733724e-08] + [Post-stage processing (stage 4 of 10) at t = 2.04e-08 (tn = 6.10e-12 , tcur = 2.04e-08), ||y||_2 = 2.0351155599e-08] + [Pre-RHS processing (stage 5 of 10) at t = 2.04e-08 (tn = 6.10e-12 , tcur = 2.04e-08), ||y||_2 = 2.0351155599e-08] + [Post-stage processing (stage 5 of 10) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Pre-RHS processing (stage 6 of 10) at t = 3.05e-08 (tn = 6.10e-12 , tcur = 3.05e-08), ||y||_2 = 3.0523681641e-08] + [Post-stage processing (stage 6 of 10) at t = 4.07e-08 (tn = 6.10e-12 , tcur = 4.07e-08), ||y||_2 = 4.0696207682e-08] + [Pre-RHS processing (stage 7 of 10) at t = 4.07e-08 (tn = 6.10e-12 , tcur = 4.07e-08), ||y||_2 = 4.0696207682e-08] + [Post-stage processing (stage 7 of 10) at t = 5.09e-08 (tn = 6.10e-12 , tcur = 5.09e-08), ||y||_2 = 5.0868733724e-08] + [Pre-RHS processing (stage 8 of 10) at t = 5.09e-08 (tn = 6.10e-12 , tcur = 5.09e-08), ||y||_2 = 5.0868733724e-08] + [Post-stage processing (stage 8 of 10) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Pre-RHS processing (stage 9 of 10) at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-step processing at t = 6.10e-08 (tn = 6.10e-12 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + 6.1041259766e-08 6.1041259766e-08 0.0000000000e+00 + [Pre-step processing at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08),||y||_2 = 6.1041259766e-08] + [Pre-RHS processing (stage 0 of 10) at t = 6.10e-08 (tn = 6.10e-08 , tcur = 6.10e-08), ||y||_2 = 6.1041259766e-08] + [Post-stage processing (stage 0 of 10) at t = 2.64e-07 (tn = 6.10e-08 , tcur = 2.64e-07), ||y||_2 = 2.6449178060e-07] + [Pre-RHS processing (stage 1 of 10) at t = 2.64e-07 (tn = 6.10e-08 , tcur = 2.64e-07), ||y||_2 = 2.6449178060e-07] + [Post-stage processing (stage 1 of 10) at t = 4.68e-07 (tn = 6.10e-08 , tcur = 4.68e-07), ||y||_2 = 4.6794230143e-07] + [Pre-RHS processing (stage 2 of 10) at t = 4.68e-07 (tn = 6.10e-08 , tcur = 4.68e-07), ||y||_2 = 4.6794230143e-07] + [Post-stage processing (stage 2 of 10) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Pre-RHS processing (stage 3 of 10) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Post-stage processing (stage 3 of 10) at t = 8.75e-07 (tn = 6.10e-08 , tcur = 8.75e-07), ||y||_2 = 8.7484334310e-07] + [Pre-RHS processing (stage 4 of 10) at t = 8.75e-07 (tn = 6.10e-08 , tcur = 8.75e-07), ||y||_2 = 8.7484334310e-07] + [Post-stage processing (stage 4 of 10) at t = 1.08e-06 (tn = 6.10e-08 , tcur = 1.08e-06), ||y||_2 = 1.0782938639e-06] + [Post-stage processing (stage 4 of 10) at t = 4.68e-07 (tn = 6.10e-08 , tcur = 4.68e-07), ||y||_2 = 4.6794230143e-07] + [Pre-RHS processing (stage 5 of 10) at t = 4.68e-07 (tn = 6.10e-08 , tcur = 4.68e-07), ||y||_2 = 4.6794230143e-07] + [Post-stage processing (stage 5 of 10) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Pre-RHS processing (stage 6 of 10) at t = 6.71e-07 (tn = 6.10e-08 , tcur = 6.71e-07), ||y||_2 = 6.7139282227e-07] + [Post-stage processing (stage 6 of 10) at t = 8.75e-07 (tn = 6.10e-08 , tcur = 8.75e-07), ||y||_2 = 8.7484334310e-07] + [Pre-RHS processing (stage 7 of 10) at t = 8.75e-07 (tn = 6.10e-08 , tcur = 8.75e-07), ||y||_2 = 8.7484334310e-07] + [Post-stage processing (stage 7 of 10) at t = 1.08e-06 (tn = 6.10e-08 , tcur = 1.08e-06), ||y||_2 = 1.0782938639e-06] + [Pre-RHS processing (stage 8 of 10) at t = 1.08e-06 (tn = 6.10e-08 , tcur = 1.08e-06), ||y||_2 = 1.0782938639e-06] + [Post-stage processing (stage 8 of 10) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Pre-RHS processing (stage 9 of 10) at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06), ||y||_2 = 1.2817443848e-06] + [Post-step processing at t = 1.28e-06 (tn = 6.10e-08 , tcur = 1.28e-06),||y||_2 = 1.2817443848e-06] + 1.2817443848e-06 1.2817443848e-06 8.4703294725e-22 +--------------------------------------------------------------------- +Current time = 1.28174438476563e-06 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 3 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 6.103515625e-12 +Last step size = 1.220703125e-06 +Current step size = 2.44140625e-05 +RHS fn evals = 32 +Number of stages used = 10 +End LSRKStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep.cpp new file mode 100644 index 0000000000..25791660d3 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep.cpp @@ -0,0 +1,389 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in MRIStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators, vectors, linear solvers, and nonlinear solvers +#include "arkode/arkode.h" +#include "arkode/arkode_arkstep.h" +#include "arkode/arkode_mristep.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_context.hpp" +#include "sundials/sundials_iterative.h" +#include "sundials/sundials_matrix.h" +#include "sunlinsol/sunlinsol_spgmr.h" + +#include "problems/kpr.hpp" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::kpr; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start MRIStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Method to use: + // 0 = Ex-MRI-GARK + // 1 = Im-MRI-GARK + // 2 = ImEx-MRI-GARK + // 3 = Ex-MRI-SR + // 4 = Im-MRI-SR + // 5 = ImEx-MRI-SR + // 6 = MERK + int method_type = 0; + if (argc > 1) { method_type = stoi(argv[1]); } + + // Create initial condition + N_Vector y = N_VNew_Serial(2, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + + sunrealtype utrue, vtrue; + int flag = true_sol(zero, &utrue, &vtrue); + if (check_flag(flag, "true_sol")) { return 1; } + + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = utrue; + ydata[1] = vtrue; + + // Create fast stepper + void* inner_arkode_mem = ARKStepCreate(ode_rhs_ff, nullptr, zero, y, sunctx); + if (check_ptr(inner_arkode_mem, "ARKStepCreate")) { return 1; } + + flag = ARKodeSetUserData(inner_arkode_mem, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + // Relative and absolute tolerances + const sunrealtype inner_rtol = SUN_RCONST(1.0e-6); + const sunrealtype inner_atol = SUN_RCONST(1.0e-10); + + flag = ARKodeSStolerances(inner_arkode_mem, inner_rtol, inner_atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } + + MRIStepInnerStepper stepper = nullptr; + flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); + if (check_flag(flag, "ARKStepCreateMRIStepInnerStepper")) { return 1; } + + // Create MRIStep memory structure + if (method_type == 0) + { + cout << "Using Ex-MRI-GARK method" << endl; + arkode_mem = MRIStepCreate(ode_rhs_s, nullptr, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else if (method_type == 1) + { + cout << "Using Im-MRI-GARK method" << endl; + arkode_mem = MRIStepCreate(nullptr, ode_rhs_s, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else if (method_type == 2) + { + cout << "Using ImEx-MRI-GARK method" << endl; + arkode_mem = MRIStepCreate(ode_rhs_se, ode_rhs_si, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else if (method_type == 3) + { + cout << "Using Ex-MRI-SR method" << endl; + arkode_mem = MRIStepCreate(ode_rhs_s, nullptr, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else if (method_type == 4) + { + cout << "Using Im-MRI-SR method" << endl; + arkode_mem = MRIStepCreate(nullptr, ode_rhs_s, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else if (method_type == 5) + { + cout << "Using ImEx-MRI-SR method" << endl; + arkode_mem = MRIStepCreate(ode_rhs_se, ode_rhs_si, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else if (method_type == 6) + { + cout << "Using MERK method" << endl; + arkode_mem = MRIStepCreate(ode_rhs_s, nullptr, zero, y, stepper, sunctx); + if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } + } + else + { + cerr << "ERROR: Invalid method type option " << method_type; + return 1; + } + + // Set MRI-SR or MERK method + MRIStepCoupling C = nullptr; + if (method_type == 3 || method_type == 4 || method_type == 5) + { + C = MRIStepCoupling_LoadTable(ARKODE_IMEX_MRI_SR32); + if (check_ptr(C, "MRIStepCoupling_LoadTable")) { return 1; } + } + else if (method_type == 6) + { + C = MRIStepCoupling_LoadTable(ARKODE_MERK32); + if (check_ptr(C, "MRIStepCoupling_LoadTable")) { return 1; } + } + + if (C) + { + flag = MRIStepSetCoupling(arkode_mem, C); + if (check_flag(flag, "MRIStepSetCoupling")) { return 1; } + MRIStepCoupling_Free(C); + } + + flag = ARKodeSetUserData(arkode_mem, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + // Relative and absolute tolerances + const sunrealtype rtol = SUN_RCONST(1.0e-6); + const sunrealtype atol = SUN_RCONST(1.0e-10); + + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } + + // Set the slow step size + const sunrealtype hfixed = SUN_RCONST(0.001); + + flag = ARKodeSetFixedStep(arkode_mem, hfixed); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + SUNMatrix A = nullptr; + SUNLinearSolver LS = nullptr; + + if (method_type == 1 || method_type == 2 || method_type == 4 || method_type == 5) + { + cout << "Using Newton nonlinear solver" << endl; + cout << "Using GMRES iterative linear solver" << endl; + + LS = SUNLinSol_SPGMR(y, SUN_PREC_NONE, 0, sunctx); + if (check_ptr(LS, "SUNLinSol_SPGMR")) { return 1; } + + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } + } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = one; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + // Output initial contion + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << " t "; + cout << " u "; + cout << " v "; + cout << " u err "; + cout << " v err " << endl; + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << abs(ydata[0] - utrue) << setw(25) << abs(ydata[1] - vtrue) + << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKode")) { return 1; } + + flag = true_sol(tret, &utrue, &vtrue); + if (check_flag(flag, "true_sol")) { return 1; } + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << abs(ydata[0] - utrue) << setw(25) + << abs(ydata[1] - vtrue) << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + SUNMatDestroy(A); + SUNLinSolFree(LS); + MRIStepInnerStepper_Free(&stepper); + ARKodeFree(&inner_arkode_mem); + ARKodeFree(&arkode_mem); + + cout << "End MRIStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_0.out new file mode 100644 index 0000000000..d9e0a94bac --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_0.out @@ -0,0 +1,52 @@ +Start MRIStep StageInfo test +Using Ex-MRI-GARK method + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 4) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 4) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213151057e+00] + [Pre-RHS processing (stage 1 of 4) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213151057e+00] + [Post-stage processing (stage 2 of 4) at t = 7.50e-04 (tn = 0.00e+00 , tcur = 7.50e-04), ||y||_2 = 2.1212937905e+00] + [Pre-RHS processing (stage 2 of 4) at t = 7.50e-04 (tn = 0.00e+00 , tcur = 7.50e-04), ||y||_2 = 2.1212937905e+00] + [Post-stage processing (stage 3 of 4) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 2.2426505097e-14 1.9984014443e-15 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 1 of 4) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212364434e+00] + [Pre-RHS processing (stage 1 of 4) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212364434e+00] + [Post-stage processing (stage 2 of 4) at t = 1.75e-03 (tn = 1.00e-03 , tcur = 1.75e-03), ||y||_2 = 2.1211758016e+00] + [Pre-RHS processing (stage 2 of 4) at t = 1.75e-03 (tn = 1.00e-03 , tcur = 1.75e-03), ||y||_2 = 2.1211758016e+00] + [Post-stage processing (stage 3 of 4) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 4.4853010195e-14 3.7747582837e-15 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 4) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 1 of 4) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1210634067e+00] + [Pre-RHS processing (stage 1 of 4) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1210634067e+00] + [Post-stage processing (stage 2 of 4) at t = 2.75e-03 (tn = 2.00e-03 , tcur = 2.75e-03), ||y||_2 = 2.1209634544e+00] + [Pre-RHS processing (stage 2 of 4) at t = 2.75e-03 (tn = 2.00e-03 , tcur = 2.75e-03), ||y||_2 = 2.1209634544e+00] + [Post-stage processing (stage 3 of 4) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 6.7279515292e-14 5.3290705182e-15 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 9 +Implicit slow RHS fn evals = 0 +Inner stepper failures = 0 +NLS iters = 0 +NLS fails = 0 +NLS iters per step = 0 +LS setups = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_1.out new file mode 100644 index 0000000000..80768d9871 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_1.out @@ -0,0 +1,110 @@ +Start MRIStep StageInfo test +Using Im-MRI-GARK method +Using Newton nonlinear solver +Using GMRES iterative linear solver + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 8) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213151057e+00] + [Pre-RHS processing (stage 2 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213183373e+00] + [Pre-RHS processing (stage 2 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213213312e+00] + [Pre-RHS processing (stage 2 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213150886e+00] + [Post-stage processing (stage 2 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213150886e+00] + [Pre-RHS processing (stage 2 of 8) at t = 3.33e-04 (tn = 0.00e+00 , tcur = 3.33e-04), ||y||_2 = 2.1213150886e+00] + [Post-stage processing (stage 3 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1212993503e+00] + [Pre-RHS processing (stage 4 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 4 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1213183389e+00] + [Pre-RHS processing (stage 4 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1213213345e+00] + [Pre-RHS processing (stage 4 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1212993415e+00] + [Post-stage processing (stage 4 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1212993415e+00] + [Pre-RHS processing (stage 4 of 8) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1212993415e+00] + [Post-stage processing (stage 5 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731966e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213183413e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213213393e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 2.6090241079e-13 1.1546319456e-14 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 8) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 1 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212364434e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212711424e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212741398e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212364263e+00] + [Post-stage processing (stage 2 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212364263e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.33e-03 (tn = 1.00e-03 , tcur = 1.33e-03), ||y||_2 = 2.1212364263e+00] + [Post-stage processing (stage 3 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1211892263e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1212711424e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1212741398e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1211892175e+00] + [Post-stage processing (stage 4 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1211892175e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1211892175e+00] + [Post-stage processing (stage 5 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211316142e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212711430e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212741409e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 2.9067859231e-12 2.3980817332e-14 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 8) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 1 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1210634067e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1211295605e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1211325579e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1210633896e+00] + [Post-stage processing (stage 2 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1210633896e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.33e-03 (tn = 2.00e-03 , tcur = 2.33e-03), ||y||_2 = 2.1210633896e+00] + [Post-stage processing (stage 3 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1209847405e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1211295605e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1211325579e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1209847317e+00] + [Post-stage processing (stage 4 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1209847317e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1209847317e+00] + [Post-stage processing (stage 5 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956853e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211295608e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211325586e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-stage processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 1.0538681039e-11 3.7747582837e-14 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 0 +Implicit slow RHS fn evals = 27 +Inner stepper failures = 0 +NLS iters = 18 +NLS fails = 0 +NLS iters per step = 6 +LS setups = 0 +Jac fn evals = 0 +LS RHS fn evals = 18 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 18 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 18 +LS iters per NLS iter = 1 +Jac evals per NLS iter = 0 +Prec evals per NLS iter = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_2.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_2.out new file mode 100644 index 0000000000..fcad2aa93a --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_2.out @@ -0,0 +1,116 @@ +Start MRIStep StageInfo test +Using ImEx-MRI-GARK method +Using Newton nonlinear solver +Using GMRES iterative linear solver + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 8) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213113879e+00] + [Pre-RHS processing (stage 2 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213183438e+00] + [Pre-RHS processing (stage 2 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213213443e+00] + [Pre-RHS processing (stage 2 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213113879e+00] + [Post-stage processing (stage 2 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213113879e+00] + [Pre-RHS processing (stage 2 of 8) at t = 4.36e-04 (tn = 0.00e+00 , tcur = 4.36e-04), ||y||_2 = 2.1213113879e+00] + [Post-stage processing (stage 3 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1212960228e+00] + [Pre-RHS processing (stage 4 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 4 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1213183421e+00] + [Pre-RHS processing (stage 4 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1213213409e+00] + [Pre-RHS processing (stage 4 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1212960259e+00] + [Post-stage processing (stage 4 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1212960259e+00] + [Pre-RHS processing (stage 4 of 8) at t = 7.18e-04 (tn = 0.00e+00 , tcur = 7.18e-04), ||y||_2 = 2.1212960259e+00] + [Post-stage processing (stage 5 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731087e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213183406e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213213379e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731290e+00] + [Post-stage processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731290e+00] + [Pre-RHS processing (stage 6 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731290e+00] + [Post-stage processing (stage 7 of 8) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 2.6378899065e-13 8.2156503822e-15 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 8) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 1 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212230476e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212711435e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212741418e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212230476e+00] + [Post-stage processing (stage 2 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212230476e+00] + [Pre-RHS processing (stage 2 of 8) at t = 1.44e-03 (tn = 1.00e-03 , tcur = 1.44e-03), ||y||_2 = 2.1212230476e+00] + [Post-stage processing (stage 3 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1211810603e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1212711432e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1212741414e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1211810634e+00] + [Post-stage processing (stage 4 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1211810634e+00] + [Pre-RHS processing (stage 4 of 8) at t = 1.72e-03 (tn = 1.00e-03 , tcur = 1.72e-03), ||y||_2 = 2.1211810634e+00] + [Post-stage processing (stage 5 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315263e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212711428e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212741405e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315465e+00] + [Post-stage processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315465e+00] + [Pre-RHS processing (stage 6 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315465e+00] + [Post-stage processing (stage 7 of 8) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 3.1354918661e-12 1.3988810110e-14 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 8) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 1 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1210403366e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1211295611e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1211325591e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1210403366e+00] + [Post-stage processing (stage 2 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1210403366e+00] + [Pre-RHS processing (stage 2 of 8) at t = 2.44e-03 (tn = 2.00e-03 , tcur = 2.44e-03), ||y||_2 = 2.1210403366e+00] + [Post-stage processing (stage 3 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1209717381e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1211295610e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1211325588e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1209717412e+00] + [Post-stage processing (stage 4 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1209717412e+00] + [Pre-RHS processing (stage 4 of 8) at t = 2.72e-03 (tn = 2.00e-03 , tcur = 2.72e-03), ||y||_2 = 2.1209717412e+00] + [Post-stage processing (stage 5 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208955974e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211295607e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211325583e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956177e+00] + [Post-stage processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956177e+00] + [Pre-RHS processing (stage 6 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956177e+00] + [Post-stage processing (stage 7 of 8) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 1.1467271577e-11 1.8207657604e-14 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 12 +Implicit slow RHS fn evals = 30 +Inner stepper failures = 0 +NLS iters = 18 +NLS fails = 0 +NLS iters per step = 6 +LS setups = 0 +Jac fn evals = 0 +LS RHS fn evals = 18 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 18 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 18 +LS iters per NLS iter = 1 +Jac evals per NLS iter = 0 +Prec evals per NLS iter = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_3.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_3.out new file mode 100644 index 0000000000..4ddd50175a --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_3.out @@ -0,0 +1,58 @@ +Start MRIStep StageInfo test +Using Ex-MRI-SR method + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987717e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987717e+00] + [Post-stage processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901822e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901822e+00] + [Post-stage processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212596852e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212596852e+00] + [Post-stage processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 7.9936057773e-15 1.3744561045e-13 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 5) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211877224e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211877224e+00] + [Post-stage processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211674743e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211674743e+00] + [Post-stage processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055205e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055205e+00] + [Post-stage processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 1.5987211555e-14 2.6245672302e-13 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 5) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209823117e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209823117e+00] + [Post-stage processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209504105e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209504105e+00] + [Post-stage processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570163e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570163e+00] + [Post-stage processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 2.4202861937e-14 3.7436720390e-13 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 12 +Implicit slow RHS fn evals = 0 +Inner stepper failures = 0 +NLS iters = 0 +NLS fails = 0 +NLS iters per step = 0 +LS setups = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_4.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_4.out new file mode 100644 index 0000000000..e28d9326b8 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_4.out @@ -0,0 +1,119 @@ +Start MRIStep StageInfo test +Using Im-MRI-SR method +Using Newton nonlinear solver +Using GMRES iterative linear solver + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1213183396e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1213213360e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987262e+00] + [Post-stage processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987262e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987262e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1213183393e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1213213353e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901049e+00] + [Post-stage processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901049e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901049e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1213183421e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1213213410e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212597444e+00] + [Post-stage processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212597444e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212597444e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213183414e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213213394e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 2.4846791291e-13 1.5143442056e-13 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 5) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1212711427e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1212741403e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211876769e+00] + [Post-stage processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211876769e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211876769e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1212711425e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1212741399e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211673971e+00] + [Post-stage processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211673971e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211673971e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1212711434e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1212741417e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055797e+00] + [Post-stage processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055797e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055797e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212711431e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212741411e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 2.6707525080e-12 2.9021229864e-13 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 5) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1211295607e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1211325583e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209822662e+00] + [Post-stage processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209822662e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209822662e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1211295606e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1211325581e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209503332e+00] + [Post-stage processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209503332e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209503332e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1211295611e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1211325591e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570755e+00] + [Post-stage processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570755e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570755e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211295609e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211325588e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-stage processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 9.4586560806e-12 4.1744385726e-13 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 0 +Implicit slow RHS fn evals = 36 +Inner stepper failures = 0 +NLS iters = 24 +NLS fails = 0 +NLS iters per step = 8 +LS setups = 0 +Jac fn evals = 0 +LS RHS fn evals = 24 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 24 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 24 +LS iters per NLS iter = 1 +Jac evals per NLS iter = 0 +Prec evals per NLS iter = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_5.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_5.out new file mode 100644 index 0000000000..7780877a70 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_5.out @@ -0,0 +1,119 @@ +Start MRIStep StageInfo test +Using ImEx-MRI-SR method +Using Newton nonlinear solver +Using GMRES iterative linear solver + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 5) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1213183438e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1213213444e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987717e+00] + [Post-stage processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987717e+00] + [Pre-RHS processing (stage 1 of 5) at t = 6.76e-04 (tn = 0.00e+00 , tcur = 6.76e-04), ||y||_2 = 2.1212987717e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1213183444e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1213213455e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901821e+00] + [Post-stage processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901821e+00] + [Pre-RHS processing (stage 2 of 5) at t = 8.00e-04 (tn = 0.00e+00 , tcur = 8.00e-04), ||y||_2 = 2.1212901821e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1213183402e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1213213371e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212596854e+00] + [Post-stage processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212596854e+00] + [Pre-RHS processing (stage 3 of 5) at t = 1.13e-03 (tn = 0.00e+00 , tcur = 1.13e-03), ||y||_2 = 2.1212596854e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213183414e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1213213394e+00] + [Pre-RHS processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 4 of 5) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 2.8288482667e-13 1.3744561045e-13 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 5) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1212711437e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1212741424e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211877224e+00] + [Post-stage processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211877224e+00] + [Pre-RHS processing (stage 1 of 5) at t = 1.68e-03 (tn = 1.00e-03 , tcur = 1.68e-03), ||y||_2 = 2.1211877224e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1212711440e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1212741429e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211674743e+00] + [Post-stage processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211674743e+00] + [Pre-RHS processing (stage 2 of 5) at t = 1.80e-03 (tn = 1.00e-03 , tcur = 1.80e-03), ||y||_2 = 2.1211674743e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1212711427e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1212741403e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055207e+00] + [Post-stage processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055207e+00] + [Pre-RHS processing (stage 3 of 5) at t = 2.13e-03 (tn = 1.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.1211055207e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212711431e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1212741411e+00] + [Pre-RHS processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 4 of 5) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 2.7395863356e-12 2.6245672302e-13 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 5) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1211295613e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1211325595e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209823117e+00] + [Post-stage processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209823117e+00] + [Pre-RHS processing (stage 1 of 5) at t = 2.68e-03 (tn = 2.00e-03 , tcur = 2.68e-03), ||y||_2 = 2.1209823117e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1211295614e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1211325598e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209504105e+00] + [Post-stage processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209504105e+00] + [Pre-RHS processing (stage 2 of 5) at t = 2.80e-03 (tn = 2.00e-03 , tcur = 2.80e-03), ||y||_2 = 2.1209504105e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1211295607e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1211325583e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570165e+00] + [Post-stage processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570165e+00] + [Pre-RHS processing (stage 3 of 5) at t = 3.13e-03 (tn = 2.00e-03 , tcur = 3.13e-03), ||y||_2 = 2.1208570165e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211295609e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1211325588e+00] + [Pre-RHS processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-stage processing (stage 4 of 5) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 9.5614627327e-12 3.7592151614e-13 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 12 +Implicit slow RHS fn evals = 36 +Inner stepper failures = 0 +NLS iters = 24 +NLS fails = 0 +NLS iters per step = 8 +LS setups = 0 +Jac fn evals = 0 +LS RHS fn evals = 24 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 24 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 24 +LS iters per NLS iter = 1 +Jac evals per NLS iter = 0 +Prec evals per NLS iter = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_6.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_6.out new file mode 100644 index 0000000000..92ab1f21fe --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_mristep_6.out @@ -0,0 +1,52 @@ +Start MRIStep StageInfo test +Using MERK method + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.1213203436e+00] + [Pre-RHS processing (stage 0 of 4) at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.1213203436e+00] + [Post-stage processing (stage 1 of 4) at t = 5.00e-04 (tn = 0.00e+00 , tcur = 5.00e-04), ||y||_2 = 2.1213085585e+00] + [Pre-RHS processing (stage 1 of 4) at t = 5.00e-04 (tn = 0.00e+00 , tcur = 5.00e-04), ||y||_2 = 2.1213085585e+00] + [Post-stage processing (stage 2 of 4) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1212993663e+00] + [Pre-RHS processing (stage 2 of 4) at t = 6.67e-04 (tn = 0.00e+00 , tcur = 6.67e-04), ||y||_2 = 2.1212993663e+00] + [Post-stage processing (stage 3 of 4) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + 1.0000000000e-03 1.2247447693e+00 1.7319930735e+00 3.3528735344e-14 1.4566126083e-13 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.1212731452e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.1212731452e+00] + [Post-stage processing (stage 1 of 4) at t = 1.50e-03 (tn = 1.00e-03 , tcur = 1.50e-03), ||y||_2 = 2.1212141650e+00] + [Pre-RHS processing (stage 1 of 4) at t = 1.50e-03 (tn = 1.00e-03 , tcur = 1.50e-03), ||y||_2 = 2.1212141650e+00] + [Post-stage processing (stage 2 of 4) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1211892422e+00] + [Pre-RHS processing (stage 2 of 4) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.1211892422e+00] + [Post-stage processing (stage 3 of 4) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + 2.0000000000e-03 1.2247444631e+00 1.7318198829e+00 6.7057470687e-14 2.7866597918e-13 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.1211315628e+00] + [Pre-RHS processing (stage 0 of 4) at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.1211315628e+00] + [Post-stage processing (stage 1 of 4) at t = 2.50e-03 (tn = 2.00e-03 , tcur = 2.50e-03), ||y||_2 = 2.1210254031e+00] + [Pre-RHS processing (stage 1 of 4) at t = 2.50e-03 (tn = 2.00e-03 , tcur = 2.50e-03), ||y||_2 = 2.1210254031e+00] + [Post-stage processing (stage 2 of 4) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1209847564e+00] + [Pre-RHS processing (stage 2 of 4) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.1209847564e+00] + [Post-stage processing (stage 3 of 4) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.1208956339e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.1208956339e+00] + 3.0000000000e-03 1.2247439528e+00 1.7315312703e+00 1.0058620603e-13 3.9879211045e-13 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Explicit slow RHS fn evals = 9 +Implicit slow RHS fn evals = 0 +Inner stepper failures = 0 +NLS iters = 0 +NLS fails = 0 +NLS iters per step = 0 +LS setups = 0 +End MRIStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_splittingstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_splittingstep.cpp new file mode 100644 index 0000000000..66b1ee3357 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_splittingstep.cpp @@ -0,0 +1,296 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in SplittingStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators and vectors +#include "arkode/arkode_erkstep.h" +#include "arkode/arkode_splittingstep.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_context.hpp" + +#include "problems/estep.hpp" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::estep; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start SplittingStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Step sizes: overall, partition 1, partition 2 + sunrealtype dt = SUN_RCONST(0.001); + sunrealtype dt_1 = dt / 2; + sunrealtype dt_2 = dt / 4; + + // Create initial condition + N_Vector y = N_VNew_Serial(1, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + + int flag = initial_condition(y); + if (check_flag(flag, "initial_condition")) { return 1; } + + // Create partition 1 integrator + void* stepper_1 = ERKStepCreate(ode_rhs_1, zero, y, sunctx); + if (check_ptr(stepper_1, "ERKStepCreate")) { return 1; } + + flag = ARKodeSetUserData(stepper_1, &problem_data); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } + + flag = ARKodeSetFixedStep(stepper_1, dt_1); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Create partition 1 integrator + void* stepper_2 = ERKStepCreate(ode_rhs_2, zero, y, sunctx); + if (check_ptr(stepper_2, "ERKStepCreate")) { return 1; } + + flag = ARKodeSetFixedStep(stepper_2, dt_2); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Create the overall integrator + SUNStepper steppers[2]; + + flag = ARKodeCreateSUNStepper(stepper_1, &steppers[0]); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + flag = ARKodeCreateSUNStepper(stepper_2, &steppers[1]); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + arkode_mem = SplittingStepCreate(steppers, 2, zero, y, sunctx); + if (check_ptr(arkode_mem, "SplittingStepCreate")) { return 1; } + + flag = ARKodeSetFixedStep(arkode_mem, dt); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // True solution vector + N_Vector yt = N_VClone(y); + + flag = true_solution(zero, problem_data, yt); + if (check_flag(flag, "true_solution")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = one; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + const int width = numeric_limits::digits10 + 8; + + // Output initial contion + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << setw(width) << " t"; + cout << setw(width) << " y"; + cout << setw(width) << " y err" << endl; + for (int i = 0; i < 3 * width; i++) { cout << "-"; } + cout << endl; + + sunrealtype* y_data = N_VGetArrayPointer(y); + sunrealtype* yt_data = N_VGetArrayPointer(yt); + + cout << setw(width) << tret << setw(width) << y_data[0] << setw(width) + << abs(y_data[0] - yt_data[0]) << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { return 1; } + + flag = true_solution(tret, problem_data, yt); + if (check_flag(flag, "true_solution")) { return 1; } + + cout << setw(width) << tret << setw(width) << y_data[0] << setw(width) + << abs(y_data[0] - yt_data[0]) << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 3 * width; i++) { cout << "-"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + N_VDestroy(yt); + ARKodeFree(&arkode_mem); + ARKodeFree(&stepper_1); + ARKodeFree(&stepper_2); + SUNStepper_Destroy(&steppers[0]); + SUNStepper_Destroy(&steppers[1]); + + cout << "End SplittingStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_splittingstep.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_splittingstep.out new file mode 100644 index 0000000000..3e8770502d --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_splittingstep.out @@ -0,0 +1,28 @@ +Start SplittingStep StageInfo test + t y y err +--------------------------------------------------------------------- + 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 1.0000000000e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 9.9899900167e-01] + 1.0000000000e-03 9.9899900167e-01 9.9866566894e-07 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 9.9899900167e-01] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 9.9799800734e-01] + 2.0000000000e-03 9.9799800734e-01 1.9953280224e-06 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 9.9799800734e-01] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 9.9699701901e-01] + 3.0000000000e-03 9.9699701901e-01 2.9899850904e-06 +--------------------------------------------------------------------- +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +Partition 1 evolves = 3 +Partition 2 evolves = 3 +End SplittingStep StageInfo test diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_sprkstep.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_sprkstep.cpp new file mode 100644 index 0000000000..8e953e73c2 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_sprkstep.cpp @@ -0,0 +1,253 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ UMBC + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2025-2026, Lawrence Livermore National Security, + * University of Maryland Baltimore County, and the SUNDIALS contributors. + * Copyright (c) 2013-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * Copyright (c) 2002-2013, Lawrence Livermore National Security. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------------------- + * Test stage information and pre/postprocessing routines in SPRKStep + * ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +// Include desired integrators, vectors, linear solvers, and nonlinear solvers +#include "arkode/arkode_sprkstep.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_context.hpp" + +#include "problems/kepler.hpp" +#include "utilities/check_return.hpp" + +using namespace std; +using namespace problems::kepler; + +// Store the main integrator global memory for these tests only, so that we +// can call ARKodeGetLastTime etc in the step and stage pre/postprocessing +// callback functions below. This would normally be stored in user_data, but +// here we reuse problem definitions from other tests. +void* arkode_mem = nullptr; +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data); +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data); +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data); + +int main(int argc, char* argv[]) +{ + cout << "Start SPRKStep StageInfo test" << endl; + + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Create initial condition + N_Vector y = N_VNew_Serial(4, sunctx); + if (check_ptr(y, "N_VNew_Serial")) { return 1; } + + int flag = initial_condition(y, eccentricity); + if (check_flag(flag, "initial_condition")) { return 1; } + + // Create SPRKStep memory structure + arkode_mem = SPRKStepCreate(ode_rhs_force, ode_rhs_velocity, zero, y, sunctx); + if (check_ptr(arkode_mem, "SPKStepCreate")) { return 1; } + + // Step size + const sunrealtype dt = SUN_RCONST(0.001); + flag = ARKodeSetFixedStep(arkode_mem, dt); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } + + // Set pre/post step and stage routines + flag = ARKodeSetPreprocessStepFn(arkode_mem, preprocess_step); + if (check_flag(flag, "ARKodeSetPreprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFn(arkode_mem, postprocess_step); + if (check_flag(flag, "ARKodeSetPostprocessStepFn")) { return 1; } + flag = ARKodeSetPostprocessStepFailFn(arkode_mem, postprocess_step_fail); + if (check_flag(flag, "ARKodeSetPostprocessStepFailFn")) { return 1; } + flag = ARKodeSetPreprocessRHSFn(arkode_mem, preprocess_stage); + if (check_flag(flag, "ARKodeSetPreprocessRHSFn")) { return 1; } + flag = ARKodeSetPostprocessStageFn(arkode_mem, postprocess_stage); + if (check_flag(flag, "ARKodeSetPostprocessStageFn")) { return 1; } + + // Initial time and fist output time + const sunrealtype dtout = dt; // output interval + const int nout = 3; // number of outputs + sunrealtype tret = zero; + sunrealtype tout = tret + dtout; + + // Output initial contion + sunrealtype* ydata = N_VGetArrayPointer(y); + if (check_ptr(y, "N_VGetArrayPointer")) { return 1; } + + cout << scientific; + cout << setprecision(numeric_limits::digits10); + cout << " t "; + cout << " q1 "; + cout << " q2 "; + cout << " q3 "; + cout << " q4 " << endl; + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << ydata[2] << setw(25) << ydata[3] << endl; + + // Advance in time + for (int i = 0; i < nout; i++) + { + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { return 1; } + + cout << setw(22) << tret << setw(25) << ydata[0] << setw(25) << ydata[1] + << setw(25) << ydata[2] << setw(25) << ydata[3] << endl; + + // update output time + tout += dtout; + } + for (int i = 0; i < 9; i++) { cout << "--------------"; } + cout << endl; + + // Print some final statistics + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(flag, "ARKodePrintAllStats")) { return 1; } + + // Clean up and return with successful completion + N_VDestroy(y); + ARKodeFree(&arkode_mem); + + cout << "End SPRKStep StageInfo test" << endl; + + return 0; +} + +// Callback functions +static int preprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Pre-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step processing at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << ")," + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_step_fail(sunrealtype t, N_Vector y, void* user_data) +{ + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + std::cout << " [Post-step failure processing at t = " + << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << ")," << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int preprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Pre-RHS processing (stage " << stage << " of " << max_stages + << ") at t = " << std::setprecision(2) << t << " (tn = " << tn + << " , tcur = " << tcur << "), " << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +static int postprocess_stage(sunrealtype t, N_Vector y, void* user_data) +{ + int stage, max_stages; + sunrealtype tn, tcur; + if (ARKodeGetLastTime(arkode_mem, &tn) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetLastTime" << std::endl; + return -1; + } + if (ARKodeGetCurrentTime(arkode_mem, &tcur) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetCurrentTime" << std::endl; + return -1; + } + if (ARKodeGetStageIndex(arkode_mem, &stage, &max_stages) != ARK_SUCCESS) + { + std::cerr << "Error in ARKodeGetStageIndex" << std::endl; + return -1; + } + std::cout << " [Post-stage processing (stage " << stage << " of " + << max_stages << ") at t = " << std::setprecision(2) << t + << " (tn = " << tn << " , tcur = " << tcur << "), " + << std::setprecision(10) + << "||y||_2 = " << SUNRsqrt(N_VDotProd(y, y)) << "]" << std::endl + << std::flush; + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_sprkstep.out b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_sprkstep.out new file mode 100644 index 0000000000..1388944790 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_stageinfo_sprkstep.out @@ -0,0 +1,64 @@ +Start SPRKStep StageInfo test + t q1 q2 q3 q4 +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 4.000000000000000e-01 0.000000000000000e+00 0.000000000000000e+00 2.000000000000000e+00 + [Pre-step processing at t = 0.00e+00 (tn = 0.00e+00 , tcur = 0.00e+00),||y||_2 = 2.0396078054e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.34e-04 (tn = 0.00e+00 , tcur = 0.00e+00), ||y||_2 = 2.0396078054e+00] + [Pre-RHS processing (stage 0 of 4) at t = 5.15e-04 (tn = 0.00e+00 , tcur = 1.34e-04), ||y||_2 = 2.0396079787e+00] + [Post-stage processing (stage 0 of 4) at t = 1.34e-04 (tn = 0.00e+00 , tcur = 1.34e-04), ||y||_2 = 2.0396081541e+00] + [Pre-RHS processing (stage 1 of 4) at t = -9.03e-05 (tn = 0.00e+00 , tcur = 1.34e-04), ||y||_2 = 2.0396081541e+00] + [Pre-RHS processing (stage 1 of 4) at t = 4.30e-04 (tn = 0.00e+00 , tcur = -9.03e-05), ||y||_2 = 2.0396116094e+00] + [Post-stage processing (stage 1 of 4) at t = -9.03e-05 (tn = 0.00e+00 , tcur = -9.03e-05), ||y||_2 = 2.0396115204e+00] + [Pre-RHS processing (stage 2 of 4) at t = 6.66e-04 (tn = 0.00e+00 , tcur = -9.03e-05), ||y||_2 = 2.0396115204e+00] + [Pre-RHS processing (stage 2 of 4) at t = 8.71e-04 (tn = 0.00e+00 , tcur = 6.66e-04), ||y||_2 = 2.0396057340e+00] + [Post-stage processing (stage 2 of 4) at t = 6.66e-04 (tn = 0.00e+00 , tcur = 6.66e-04), ||y||_2 = 2.0396059367e+00] + [Pre-RHS processing (stage 3 of 4) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 6.66e-04), ||y||_2 = 2.0396059367e+00] + [Pre-RHS processing (stage 3 of 4) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.0396023491e+00] + [Post-stage processing (stage 3 of 4) at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03), ||y||_2 = 2.0396024276e+00] + [Post-step processing at t = 1.00e-03 (tn = 0.00e+00 , tcur = 1.00e-03),||y||_2 = 2.0396024276e+00] + 1.0000000000e-03 3.9999687501e-01 1.9999947917e-03 -6.2499544275e-03 1.9999843751e+00 + [Pre-step processing at t = 1.00e-03 (tn = 1.00e-03 , tcur = 1.00e-03),||y||_2 = 2.0396024276e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.13e-03 (tn = 1.00e-03 , tcur = 1.00e-03), ||y||_2 = 2.0396024276e+00] + [Pre-RHS processing (stage 0 of 4) at t = 1.52e-03 (tn = 1.00e-03 , tcur = 1.13e-03), ||y||_2 = 2.0396010553e+00] + [Post-stage processing (stage 0 of 4) at t = 1.13e-03 (tn = 1.00e-03 , tcur = 1.13e-03), ||y||_2 = 2.0396016098e+00] + [Pre-RHS processing (stage 1 of 4) at t = 9.10e-04 (tn = 1.00e-03 , tcur = 1.13e-03), ||y||_2 = 2.0396016098e+00] + [Pre-RHS processing (stage 1 of 4) at t = 1.43e-03 (tn = 1.00e-03 , tcur = 9.10e-04), ||y||_2 = 2.0396076483e+00] + [Post-stage processing (stage 1 of 4) at t = 9.10e-04 (tn = 1.00e-03 , tcur = 9.10e-04), ||y||_2 = 2.0396074962e+00] + [Pre-RHS processing (stage 2 of 4) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 9.10e-04), ||y||_2 = 2.0396074962e+00] + [Pre-RHS processing (stage 2 of 4) at t = 1.87e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.0395930192e+00] + [Post-stage processing (stage 2 of 4) at t = 1.67e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.0395935467e+00] + [Pre-RHS processing (stage 3 of 4) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 1.67e-03), ||y||_2 = 2.0395935467e+00] + [Pre-RHS processing (stage 3 of 4) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.0395861214e+00] + [Post-stage processing (stage 3 of 4) at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.0395862946e+00] + [Post-step processing at t = 2.00e-03 (tn = 1.00e-03 , tcur = 2.00e-03),||y||_2 = 2.0395862946e+00] + 2.0000000000e-03 3.9998750018e-01 3.9999583342e-03 -1.2499635430e-02 1.9999375021e+00 + [Pre-step processing at t = 2.00e-03 (tn = 2.00e-03 , tcur = 2.00e-03),||y||_2 = 2.0395862946e+00] + [Pre-RHS processing (stage 0 of 4) at t = 2.13e-03 (tn = 2.00e-03 , tcur = 2.00e-03), ||y||_2 = 2.0395862946e+00] + [Pre-RHS processing (stage 0 of 4) at t = 2.52e-03 (tn = 2.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.0395833769e+00] + [Post-stage processing (stage 0 of 4) at t = 2.13e-03 (tn = 2.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.0395843104e+00] + [Pre-RHS processing (stage 1 of 4) at t = 1.91e-03 (tn = 2.00e-03 , tcur = 2.13e-03), ||y||_2 = 2.0395843104e+00] + [Pre-RHS processing (stage 1 of 4) at t = 2.43e-03 (tn = 2.00e-03 , tcur = 1.91e-03), ||y||_2 = 2.0395929317e+00] + [Post-stage processing (stage 1 of 4) at t = 1.91e-03 (tn = 2.00e-03 , tcur = 1.91e-03), ||y||_2 = 2.0395927166e+00] + [Pre-RHS processing (stage 2 of 4) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 1.91e-03), ||y||_2 = 2.0395927166e+00] + [Pre-RHS processing (stage 2 of 4) at t = 2.87e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.0395695501e+00] + [Post-stage processing (stage 2 of 4) at t = 2.67e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.0395704024e+00] + [Pre-RHS processing (stage 3 of 4) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 2.67e-03), ||y||_2 = 2.0395704024e+00] + [Pre-RHS processing (stage 3 of 4) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.0395591399e+00] + [Post-stage processing (stage 3 of 4) at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03), ||y||_2 = 2.0395594079e+00] + [Post-step processing at t = 3.00e-03 (tn = 2.00e-03 , tcur = 3.00e-03),||y||_2 = 2.0395594079e+00] + 3.0000000000e-03 3.9997187592e-01 5.9998593813e-03 -1.8748769629e-02 1.9998593855e+00 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 0.003 +Steps = 3 +Step attempts = 3 +Stability limited steps = 0 +Accuracy limited steps = 0 +Error test fails = 0 +NLS step fails = 0 +Inequality constraint fails = 0 +Initial step size = 0.001 +Last step size = 0.001 +Current step size = 0.001 +f1 RHS fn evals = 12 +f2 RHS fn evals = 12 +End SPRKStep StageInfo test