Skip to content

Commit

Permalink
Squash commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Roberts committed Jun 21, 2024
1 parent 49ecc83 commit 3f3be17
Show file tree
Hide file tree
Showing 64 changed files with 882 additions and 1,548 deletions.
12 changes: 0 additions & 12 deletions include/sundials/sundials_linearsolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,6 @@ SUNErrCode SUNLinSolFree(SUNLinearSolver S);
#define SUNLS_QRFACT_FAIL 807 /* QRfact found singular matrix */
#define SUNLS_LUFACT_FAIL 808 /* LUfact found singular matrix */

/* -----------------------------------------------------------------------------
* SUNLinearSolver messages
* ---------------------------------------------------------------------------*/

#if defined(SUNDIALS_EXTENDED_PRECISION)
#define SUNLS_MSG_RESIDUAL "\t\tlin. iteration %ld, lin. residual: %Lg\n"
#elif defined(SUNDIALS_DOUBLE_PRECISION)
#define SUNLS_MSG_RESIDUAL "\t\tlin. iteration %ld, lin. residual: %g\n"
#else
#define SUNLS_MSG_RESIDUAL "\t\tlin. iteration %ld, lin. residual: %g\n"
#endif

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 0 additions & 12 deletions include/sundials/sundials_nonlinearsolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,6 @@ SUNErrCode SUNNonlinSolGetNumConvFails(SUNNonlinearSolver NLS,
#define SUN_NLS_CONTINUE +901 /* not converged, keep iterating */
#define SUN_NLS_CONV_RECVR +902 /* convergece failure, try to recover */

/* -----------------------------------------------------------------------------
* SUNNonlinearSolver messages
* ---------------------------------------------------------------------------*/

#if defined(SUNDIALS_EXTENDED_PRECISION)
#define SUN_NLS_MSG_RESIDUAL "\tnonlin. iteration %ld, nonlin. residual: %Lg\n"
#elif defined(SUNDIALS_DOUBLE_PRECISION)
#define SUN_NLS_MSG_RESIDUAL "\tnonlin. iteration %ld, nonlin. residual: %g\n"
#else
#define SUN_NLS_MSG_RESIDUAL "\tnonlin. iteration %ld, nonlin. residual: %g\n"
#endif

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions include/sundials/sundials_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,18 @@ extern "C" {
*------------------------------------------------------------------
*/

#define SUN_STRING_HELPER(x) #x
#define SUN_STRING(x) SUN_STRING_HELPER(x)

#if defined(SUNDIALS_SINGLE_PRECISION)

typedef float sunrealtype;
#define SUN_RCONST(x) x##F
#define SUN_BIG_REAL FLT_MAX
#define SUN_SMALL_REAL FLT_MIN
#define SUN_UNIT_ROUNDOFF FLT_EPSILON
#define SUN_REAL_FORMAT_E "%." SUN_STRING(FLT_DIG) "e"
#define SUN_REAL_FORMAT_G "%." SUN_STRING(FLT_DIG) "g"

#elif defined(SUNDIALS_DOUBLE_PRECISION)

Expand All @@ -99,6 +104,8 @@ typedef double sunrealtype;
#define SUN_BIG_REAL DBL_MAX
#define SUN_SMALL_REAL DBL_MIN
#define SUN_UNIT_ROUNDOFF DBL_EPSILON
#define SUN_REAL_FORMAT_E "%." SUN_STRING(DBL_DIG) "e"
#define SUN_REAL_FORMAT_G "%." SUN_STRING(DBL_DIG) "g"

#elif defined(SUNDIALS_EXTENDED_PRECISION)

Expand All @@ -107,6 +114,8 @@ typedef long double sunrealtype;
#define SUN_BIG_REAL LDBL_MAX
#define SUN_SMALL_REAL LDBL_MIN
#define SUN_UNIT_ROUNDOFF LDBL_EPSILON
#define SUN_REAL_FORMAT_E "% ." SUN_STRING(LDBL_DIG) "Le"
#define SUN_REAL_FORMAT_G "% ." SUN_STRING(LDBL_DIG) "Lg"

#endif

Expand Down
58 changes: 31 additions & 27 deletions src/arkode/arkode.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout,
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::ARKodeEvolve",
"start-step",
"step = %li, attempt = %i, h = %" RSYM
", tcur = %" RSYM,
"step = %li, attempt = %i, h = " SUN_REAL_FORMAT_G
", tcur = " SUN_REAL_FORMAT_G,
ark_mem->nst, attempts, ark_mem->h, ark_mem->tcur);
#endif

Expand Down Expand Up @@ -1259,17 +1259,17 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile)
fprintf(outfile, "user_efun = %i\n", ark_mem->user_efun);
fprintf(outfile, "tstopset = %i\n", ark_mem->tstopset);
fprintf(outfile, "tstopinterp = %i\n", ark_mem->tstopinterp);
fprintf(outfile, "tstop = %" RSYM "\n", ark_mem->tstop);
fprintf(outfile, "tstop = " SUN_REAL_FORMAT_G "\n", ark_mem->tstop);
fprintf(outfile, "VabstolMallocDone = %i\n", ark_mem->VabstolMallocDone);
fprintf(outfile, "MallocDone = %i\n", ark_mem->MallocDone);
fprintf(outfile, "initsetup = %i\n", ark_mem->initsetup);
fprintf(outfile, "init_type = %i\n", ark_mem->init_type);
fprintf(outfile, "firststage = %i\n", ark_mem->firststage);
fprintf(outfile, "uround = %" RSYM "\n", ark_mem->uround);
fprintf(outfile, "reltol = %" RSYM "\n", ark_mem->reltol);
fprintf(outfile, "Sabstol = %" RSYM "\n", ark_mem->Sabstol);
fprintf(outfile, "uround = " SUN_REAL_FORMAT_G "\n", ark_mem->uround);
fprintf(outfile, "reltol = " SUN_REAL_FORMAT_G "\n", ark_mem->reltol);
fprintf(outfile, "Sabstol = " SUN_REAL_FORMAT_G "\n", ark_mem->Sabstol);
fprintf(outfile, "fixedstep = %i\n", ark_mem->fixedstep);
fprintf(outfile, "tolsf = %" RSYM "\n", ark_mem->tolsf);
fprintf(outfile, "tolsf = " SUN_REAL_FORMAT_G "\n", ark_mem->tolsf);
fprintf(outfile, "call_fullrhs = %i\n", ark_mem->call_fullrhs);

/* output counters */
Expand All @@ -1280,18 +1280,18 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile)
fprintf(outfile, "netf = %li\n", ark_mem->netf);

/* output time-stepping values */
fprintf(outfile, "hin = %" RSYM "\n", ark_mem->hin);
fprintf(outfile, "h = %" RSYM "\n", ark_mem->h);
fprintf(outfile, "hprime = %" RSYM "\n", ark_mem->hprime);
fprintf(outfile, "next_h = %" RSYM "\n", ark_mem->next_h);
fprintf(outfile, "eta = %" RSYM "\n", ark_mem->eta);
fprintf(outfile, "tcur = %" RSYM "\n", ark_mem->tcur);
fprintf(outfile, "tretlast = %" RSYM "\n", ark_mem->tretlast);
fprintf(outfile, "hmin = %" RSYM "\n", ark_mem->hmin);
fprintf(outfile, "hmax_inv = %" RSYM "\n", ark_mem->hmax_inv);
fprintf(outfile, "h0u = %" RSYM "\n", ark_mem->h0u);
fprintf(outfile, "tn = %" RSYM "\n", ark_mem->tn);
fprintf(outfile, "hold = %" RSYM "\n", ark_mem->hold);
fprintf(outfile, "hin = " SUN_REAL_FORMAT_G "\n", ark_mem->hin);
fprintf(outfile, "h = " SUN_REAL_FORMAT_G "\n", ark_mem->h);
fprintf(outfile, "hprime = " SUN_REAL_FORMAT_G "\n", ark_mem->hprime);
fprintf(outfile, "next_h = " SUN_REAL_FORMAT_G "\n", ark_mem->next_h);
fprintf(outfile, "eta = " SUN_REAL_FORMAT_G "\n", ark_mem->eta);
fprintf(outfile, "tcur = " SUN_REAL_FORMAT_G "\n", ark_mem->tcur);
fprintf(outfile, "tretlast = " SUN_REAL_FORMAT_G "\n", ark_mem->tretlast);
fprintf(outfile, "hmin = " SUN_REAL_FORMAT_G "\n", ark_mem->hmin);
fprintf(outfile, "hmax_inv = " SUN_REAL_FORMAT_G "\n", ark_mem->hmax_inv);
fprintf(outfile, "h0u = " SUN_REAL_FORMAT_G "\n", ark_mem->h0u);
fprintf(outfile, "tn = " SUN_REAL_FORMAT_G "\n", ark_mem->tn);
fprintf(outfile, "hold = " SUN_REAL_FORMAT_G "\n", ark_mem->hold);
fprintf(outfile, "maxnef = %i\n", ark_mem->maxnef);
fprintf(outfile, "maxncf = %i\n", ark_mem->maxncf);

Expand Down Expand Up @@ -2517,7 +2517,9 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm)

#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkCompleteStep",
"end-step", "step = %li, h = %" RSYM ", tcur = %" RSYM,
"end-step",
"step = %li, h = " SUN_REAL_FORMAT_G
", tcur = " SUN_REAL_FORMAT_G,
ark_mem->nst, ark_mem->h, ark_mem->tcur);
#endif

Expand Down Expand Up @@ -2625,9 +2627,10 @@ int arkHandleFailure(ARKodeMem ark_mem, int flag)
MSG_ARK_MASSSOLVE_FAIL);
break;
case ARK_NLS_SETUP_FAIL:
arkProcessError(ark_mem, ARK_NLS_SETUP_FAIL, __LINE__, __func__,
__FILE__, "At t = %Lg the nonlinear solver setup failed unrecoverably",
(long double)ark_mem->tcur);
arkProcessError(ark_mem, ARK_NLS_SETUP_FAIL, __LINE__, __func__, __FILE__,
"At t = " SUN_REAL_FORMAT_G
" the nonlinear solver setup failed unrecoverably",
ark_mem->tcur);
break;
case ARK_VECTOROP_ERR:
arkProcessError(ark_mem, ARK_VECTOROP_ERR, __LINE__, __func__, __FILE__,
Expand Down Expand Up @@ -2655,17 +2658,18 @@ int arkHandleFailure(ARKodeMem ark_mem, int flag)
break;
case ARK_INTERP_FAIL:
arkProcessError(ark_mem, ARK_INTERP_FAIL, __LINE__, __func__, __FILE__,
"At t = %Lg the interpolation module failed unrecoverably",
(long double)ark_mem->tcur);
"At t = " SUN_REAL_FORMAT_G
" the interpolation module failed unrecoverably",
ark_mem->tcur);
break;
case ARK_INVALID_TABLE:
arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__,
"ARKODE was provided an invalid method table");
break;
case ARK_RELAX_FAIL:
arkProcessError(ark_mem, ARK_RELAX_FAIL, __LINE__, __func__, __FILE__,
"At t = %Lg the relaxation module failed",
(long double)ark_mem->tcur);
"At t = " SUN_REAL_FORMAT_G " the relaxation module failed",
ark_mem->tcur);
break;
case ARK_RELAX_MEM_NULL:
arkProcessError(ark_mem, ARK_RELAX_MEM_NULL, __LINE__, __func__, __FILE__,
Expand Down
40 changes: 27 additions & 13 deletions src/arkode/arkode_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,27 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile)
{
if (hadapt_mem != NULL)
{
fprintf(outfile, "ark_hadapt: etamax = %" RSYM "\n", hadapt_mem->etamax);
fprintf(outfile, "ark_hadapt: etamx1 = %" RSYM "\n", hadapt_mem->etamx1);
fprintf(outfile, "ark_hadapt: etamxf = %" RSYM "\n", hadapt_mem->etamxf);
fprintf(outfile, "ark_hadapt: etamin = %" RSYM "\n", hadapt_mem->etamin);
fprintf(outfile, "ark_hadapt: etamax = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->etamax);
fprintf(outfile, "ark_hadapt: etamx1 = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->etamx1);
fprintf(outfile, "ark_hadapt: etamxf = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->etamxf);
fprintf(outfile, "ark_hadapt: etamin = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->etamin);
fprintf(outfile, "ark_hadapt: small_nef = %i\n", hadapt_mem->small_nef);
fprintf(outfile, "ark_hadapt: etacf = %" RSYM "\n", hadapt_mem->etacf);
fprintf(outfile, "ark_hadapt: cfl = %" RSYM "\n", hadapt_mem->cfl);
fprintf(outfile, "ark_hadapt: safety = %" RSYM "\n", hadapt_mem->safety);
fprintf(outfile, "ark_hadapt: growth = %" RSYM "\n", hadapt_mem->growth);
fprintf(outfile, "ark_hadapt: lbound = %" RSYM "\n", hadapt_mem->lbound);
fprintf(outfile, "ark_hadapt: ubound = %" RSYM "\n", hadapt_mem->ubound);
fprintf(outfile, "ark_hadapt: etacf = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->etacf);
fprintf(outfile, "ark_hadapt: cfl = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->cfl);
fprintf(outfile, "ark_hadapt: safety = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->safety);
fprintf(outfile, "ark_hadapt: growth = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->growth);
fprintf(outfile, "ark_hadapt: lbound = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->lbound);
fprintf(outfile, "ark_hadapt: ubound = " SUN_REAL_FORMAT_G "\n",
hadapt_mem->ubound);
fprintf(outfile, "ark_hadapt: nst_acc = %li\n", hadapt_mem->nst_acc);
fprintf(outfile, "ark_hadapt: nst_exp = %li\n", hadapt_mem->nst_exp);
fprintf(outfile, "ark_hadapt: pq = %i\n", hadapt_mem->pq);
Expand Down Expand Up @@ -136,7 +146,9 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt",
"new-step-before-bounds",
"h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl);
"h_acc = " SUN_REAL_FORMAT_G
", h_cfl = " SUN_REAL_FORMAT_G,
h_acc, h_cfl);
#endif

/* enforce safety factors */
Expand All @@ -152,7 +164,9 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt",
"new-step-after-max-min-bounds",
"h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl);
"h_acc = " SUN_REAL_FORMAT_G
", h_cfl = " SUN_REAL_FORMAT_G,
h_acc, h_cfl);
#endif

/* increment the relevant step counter, set desired step */
Expand Down Expand Up @@ -181,7 +195,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,

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

return (retval);
Expand Down
30 changes: 16 additions & 14 deletions src/arkode/arkode_arkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,16 @@ void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile)
fprintf(outfile, "ARKStep: implicit Butcher table:\n");
ARKodeButcherTable_Write(step_mem->Bi, outfile);
}
fprintf(outfile, "ARKStep: gamma = %" RSYM "\n", step_mem->gamma);
fprintf(outfile, "ARKStep: gammap = %" RSYM "\n", step_mem->gammap);
fprintf(outfile, "ARKStep: gamrat = %" RSYM "\n", step_mem->gamrat);
fprintf(outfile, "ARKStep: crate = %" RSYM "\n", step_mem->crate);
fprintf(outfile, "ARKStep: eRNrm = %" RSYM "\n", step_mem->eRNrm);
fprintf(outfile, "ARKStep: nlscoef = %" RSYM "\n", step_mem->nlscoef);
fprintf(outfile, "ARKStep: crdown = %" RSYM "\n", step_mem->crdown);
fprintf(outfile, "ARKStep: rdiv = %" RSYM "\n", step_mem->rdiv);
fprintf(outfile, "ARKStep: dgmax = %" RSYM "\n", step_mem->dgmax);
fprintf(outfile, "ARKStep: gamma = " SUN_REAL_FORMAT_G "\n", step_mem->gamma);
fprintf(outfile, "ARKStep: gammap = " SUN_REAL_FORMAT_G "\n", step_mem->gammap);
fprintf(outfile, "ARKStep: gamrat = " SUN_REAL_FORMAT_G "\n", step_mem->gamrat);
fprintf(outfile, "ARKStep: crate = " SUN_REAL_FORMAT_G "\n", step_mem->crate);
fprintf(outfile, "ARKStep: eRNrm = " SUN_REAL_FORMAT_G "\n", step_mem->eRNrm);
fprintf(outfile, "ARKStep: nlscoef = " SUN_REAL_FORMAT_G "\n",
step_mem->nlscoef);
fprintf(outfile, "ARKStep: crdown = " SUN_REAL_FORMAT_G "\n", step_mem->crdown);
fprintf(outfile, "ARKStep: rdiv = " SUN_REAL_FORMAT_G "\n", step_mem->rdiv);
fprintf(outfile, "ARKStep: dgmax = " SUN_REAL_FORMAT_G "\n", step_mem->dgmax);

#ifdef SUNDIALS_DEBUG_PRINTVEC
/* output vector quantities */
Expand Down Expand Up @@ -1831,8 +1832,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
{
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO,
"ARKODE::arkStep_TakeStep_Z", "start-stage",
"step = %li, stage = %i, implicit = %i, h = %" RSYM
", tcur = %" RSYM,
"step = %li, stage = %i, implicit = %i, h "
"= " SUN_REAL_FORMAT_G ", tcur = " SUN_REAL_FORMAT_G,
ark_mem->nst, 0, implicit_stage, ark_mem->h,
ark_mem->tcur);
#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG
Expand Down Expand Up @@ -1884,8 +1885,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG,
"ARKODE::arkStep_TakeStep_Z", "start-stage",
"step = %li, stage = %i, implicit = %i, h = %" RSYM
", tcur = %" RSYM,
"step = %li, stage = %i, implicit = %i, h "
"= " SUN_REAL_FORMAT_G ", tcur = " SUN_REAL_FORMAT_G,
ark_mem->nst, is, implicit_stage, ark_mem->h,
ark_mem->tcur);
#endif
Expand Down Expand Up @@ -2093,7 +2094,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO
SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO,
"ARKODE::arkStep_TakeStep_Z", "end-step",
"step = %li, h = %" RSYM ", dsm = %" RSYM ", nflag = %d",
"step = %li, h = " SUN_REAL_FORMAT_G
", dsm = " SUN_REAL_FORMAT_G ", nflag = %d",
ark_mem->nst, ark_mem->h, *dsmPtr, *nflagPtr);
#endif

Expand Down
Loading

0 comments on commit 3f3be17

Please sign in to comment.