Skip to content

Commit

Permalink
update some ARKODE logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gardner48 committed Jun 14, 2024
1 parent 5056318 commit 87cf8cb
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 171 deletions.
20 changes: 6 additions & 14 deletions src/arkode/arkode_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
}
if (h_cfl <= ZERO) { h_cfl = SUN_RCONST(1.0e30) * SUNRabs(hcur); }

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"new-step-before-bounds",
"h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "new-step-before-bounds",
"h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl);

/* enforce safety factors */
h_acc *= hadapt_mem->safety;
Expand All @@ -149,11 +146,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
/* enforce minimum bound time step reduction */
h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamin * hcur));

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"new-step-after-max-min-bounds",
"h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "new-step-after-max-min-bounds",
"h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl);

/* increment the relevant step counter, set desired step */
if (SUNRabs(h_acc) < SUNRabs(h_cfl)) { hadapt_mem->nst_acc++; }
Expand All @@ -179,10 +173,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
/* enforce maximum time step size */
ark_mem->eta /= SUNMAX(ONE, SUNRabs(hcur) * ark_mem->hmax_inv * ark_mem->eta);

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ARKODE::arkAdapt",
"new-step-eta", "eta = %" RSYM, ark_mem->eta);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "new-step-eta",
"eta = %" RSYM, ark_mem->eta);

return (retval);
}
Expand Down
200 changes: 56 additions & 144 deletions src/arkode/arkode_arkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,32 +1826,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
}
}

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
if (is_start == 1)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage",
"stage = %i, implicit = %i, tcur = %" RSYM, 0,
implicit_stage, ark_mem->tcur);
#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"explicit stage", "z_%i(:) =", 0);
N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp);
if (step_mem->implicit)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"implicit RHS", "Fi_%i(:) =", 0);
N_VPrintFile(step_mem->Fi[0], ARK_LOGGER->debug_fp);
}
if (step_mem->explicit)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"explicit RHS", "Fe_%i(:) =", 0);
N_VPrintFile(step_mem->Fe[0], ARK_LOGGER->debug_fp);
}
#endif
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", "");
}
#endif
SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "begin-stage",
"stage = %i, implicit = %i, tcur = %" RSYM, 0, implicit_stage,
ark_mem->tcur);
SUNLogExtraDebugVecIf(is_start == 1, ARK_LOGGER, __func__, "explicit stage",
"z_%i(:) =", ark_mem->ycur, 0);
SUNLogExtraDebugVecIf(is_start == 1 && step_mem->implicit, ARK_LOGGER, __func__,
"implicit RHS", "Fi_%i(:) =", step_mem->Fi[0], 0);
SUNLogExtraDebugVecIf(is_start == 1 && step_mem->explicit, ARK_LOGGER, __func__,
"explicit RHS", "Fe_%i(:) =", step_mem->Fe[0], 0);
SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "end-stage", "", "");

/* loop over internal stages to the step */
for (is = is_start; is < step_mem->stages; is++)
Expand All @@ -1876,11 +1860,9 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
}
else { ark_mem->tcur = ark_mem->tn + step_mem->Be->c[is] * ark_mem->h; }

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage",
"stage = %i, implicit = %i, tcur = %" RSYM, is,
implicit_stage, ark_mem->tcur);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "begin-stage",
"stage = %i, implicit = %i, tcur = %" RSYM, is, implicit_stage,
ark_mem->tcur);

/* setup time-dependent mass matrix */
if ((step_mem->mass_type == MASS_TIMEDEP) && (step_mem->msetup != NULL))
Expand All @@ -1889,10 +1871,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
ark_mem->tempv2, ark_mem->tempv3);
if (retval != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage",
"status = failed mass setup, retval = %i", retval);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed mass setup, retval = %i", retval);
return (ARK_MASSSETUP_FAIL);
}
}
Expand All @@ -1912,42 +1892,27 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
retval = step_mem->stage_predict(ark_mem->tcur, step_mem->zpred,
ark_mem->user_data);

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
if (retval != 0)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"end-stage",
"status = failed predict, retval = %i", retval);
}
#endif

SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage",
"status = failed predict, retval = %i", retval);
if (retval < 0) { return (ARK_USER_PREDICT_FAIL); }
if (retval > 0) { return (TRY_AGAIN); }
}
}

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "predictor",
"zpred(:) =", "");
N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__, "predictor",
"zpred(:) =", step_mem->zpred, "");

/* set up explicit data for evaluation of ARK stage (store in sdata) */
retval = arkStep_StageSetup(ark_mem, implicit_stage);
if (retval != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage",
"status = failed stage setup, retval = %i", retval);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed stage setup, retval = %i", retval);
return (retval);
}

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "rhs data",
"sdata(:) =", "");
N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__, "rhs data",
"sdata(:) =", step_mem->sdata, "");

/* perform implicit solve if required */
if (implicit_stage)
Expand All @@ -1957,18 +1922,13 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
*nflagPtr = arkStep_Nls(ark_mem, *nflagPtr);
if (*nflagPtr != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage",
"status = failed solve, nflag = %i", *nflagPtr);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed solve, nflag = %i", *nflagPtr);
return (TRY_AGAIN);
}

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"implicit stage", "z_%i(:) =", is);
N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit stage",
"z_%i(:) =", ark_mem->ycur, is);

/* otherwise no implicit solve is needed */
}
Expand All @@ -1982,11 +1942,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
step_mem->nlscoef);
if (*nflagPtr != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"end-stage",
"status = failed mass solve, nflag = %i", *nflagPtr);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed mass solve, nflag = %i", *nflagPtr);
return (TRY_AGAIN);
}
}
Expand All @@ -1995,11 +1952,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
or updated in prev. block) */
N_VLinearSum(ONE, ark_mem->yn, ONE, step_mem->sdata, ark_mem->ycur);

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"explicit stage", "z_%i(:) =", is);
N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__, "explicit stage",
"z_%i(:) =", ark_mem->ycur, is);
}

/* apply user-supplied stage postprocessing function (if supplied) */
Expand All @@ -2011,11 +1965,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
ark_mem->user_data);
if (retval != 0)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage",
"status = failed postprocess stage, retval = %i",
retval);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed postprocess stage, retval = %i", retval);
return (ARK_POSTPROCESS_STAGE_FAIL);
}
}
Expand All @@ -2033,26 +1984,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
retval = step_mem->fi(ark_mem->tcur, ark_mem->ycur, step_mem->Fi[is],
ark_mem->user_data);
step_mem->nfi++;
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
if (retval != 0)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"end-stage",
"status = failed implicit rhs eval, retval = %i",
retval);
}
#endif
SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage",
"status = failed implicit rhs eval, retval = %i", retval);
}
else if (step_mem->mass_type == MASS_FIXED)
{
retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1);
if (retval != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"end-stage",
"status = failed mass mult, retval = %i", retval);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed mass mult, retval = %i", retval);
return (ARK_MASSMULT_FAIL);
}

Expand All @@ -2065,11 +2006,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
-ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]);
}

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"implicit RHS", "Fi_%i(:) =", is);
N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit RHS",
"Fi_%i(:) =", step_mem->Fi[is], is);

if (retval < 0) { return (ARK_RHSFUNC_FAIL); }
if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); }
Expand All @@ -2081,21 +2019,11 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
retval = step_mem->fe(ark_mem->tn + step_mem->Be->c[is] * ark_mem->h,
ark_mem->ycur, step_mem->Fe[is], ark_mem->user_data);
step_mem->nfe++;
SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage",
"status = failed explicit rhs eval, retval = %i", retval);

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
if (retval != 0)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage",
"status = failed explicit rhs eval, retval = %i",
retval);
}
#endif

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"explicit RHS", "Fe_%i(:) =", is);
N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebug(ARK_LOGGER, __func__, "explicit RHS",
"Fe_%i(:) =", step_mem->Fe[is], is);

if (retval < 0) { return (ARK_RHSFUNC_FAIL); }
if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); }
Expand All @@ -2109,46 +2037,33 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
{
*nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fi[is],
step_mem->nlscoef);
#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"M^{-1} implicit RHS", "Fi_%i(:) =", is);
N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp);
#endif

SUNLogExtraDebugVec(ARK_LOGGER, __func__, "M^{-1} implicit RHS",
"Fi_%i(:) =", step_mem->Fi[is], is);

if (*nflagPtr != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"end-stage",
"status = failed mass solve, nflag = %i", *nflagPtr);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed mass solve, nflag = %i", *nflagPtr);
return (TRY_AGAIN);
}
}
if (step_mem->explicit)
{
*nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fe[is],
step_mem->nlscoef);
#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"M^{-1} explicit RHS", "Fe_%i(:) =", is);
N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__,
"M^{-1} explicit RHS", "Fe_%i(:) =", step_mem->Fe[is], is);
if (*nflagPtr != ARK_SUCCESS)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"end-stage",
"status = failed mass solve, nflag = %i", *nflagPtr);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage",
"status = failed mass solve, nflag = %i", *nflagPtr);
return (TRY_AGAIN);
}
}
}

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage",
"status = success", "");
#endif
SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", "");

} /* loop over stages */

Expand All @@ -2163,11 +2078,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
if (*nflagPtr < 0) { return (*nflagPtr); }
if (*nflagPtr > 0) { return (TRY_AGAIN); }

#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__,
"updated solution", "ycur(:) =", "");
N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp);
#endif
SUNLogExtraDebugVec(ARK_LOGGER, __func__, "updated solution",
"ycur(:) =", ark_mem->ycur, "");

return (ARK_SUCCESS);
}
Expand Down
12 changes: 4 additions & 8 deletions src/arkode/arkode_interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,8 @@ int arkInterpEvaluate_Hermite(ARKodeMem ark_mem, ARKInterp interp,
q = SUNMAX(order, 0); /* respect lower bound */
q = SUNMIN(q, HINT_DEGREE(interp)); /* respect max possible */

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "interp-eval",
"tau = %" RSYM ", d = %i, q = %i", tau, d, q);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "interp-eval",
"tau = %" RSYM ", d = %i, q = %i", tau, d, q);

/* call full RHS if needed -- called just AFTER the end of a step, so yn has
been updated to ycur */
Expand Down Expand Up @@ -1202,10 +1200,8 @@ int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tau,
q = SUNMAX(degree, 0); /* respect lower bound */
q = SUNMIN(q, nhist - 1); /* respect max possible */

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "interp-eval",
"tau = %" RSYM ", d = %i, q = %i", tau, deriv, q);
#endif
SUNLogDebug(ARK_LOGGER, __func__, "interp-eval",
"tau = %" RSYM ", d = %i, q = %i", tau, deriv, q);

/* error on illegal deriv */
if ((deriv < 0) || (deriv > 3))
Expand Down
Loading

0 comments on commit 87cf8cb

Please sign in to comment.