diff --git a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst index eef8e78ef4..f9e8ae12ef 100644 --- a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst +++ b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst @@ -531,9 +531,6 @@ Optional inputs for IVP method selection :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value - .. deprecated:: x.y.z - - Use :c:func:`ARKodeSetUseCompensatedSums` instead. .. _ARKODE.Usage.SPRKStep.SPRKStepRootfindingInput: diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 6f4a4f2c49..34af1d3284 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -861,7 +861,6 @@ Supply a pointer for user data :c:func:`ARKodeSetUserData` Maximum no. of ARKODE error test failures :c:func:`ARKodeSetMaxErrTestFails` 7 Set inequality constraints on solution :c:func:`ARKodeSetConstraints` ``NULL`` Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstrFails` 10 -Use compensated summation :c:func:`ARKodeSetUseCompensatedSums` off ================================================ ======================================= ======================= @@ -1347,26 +1346,6 @@ Use compensated summation :c:func:`ARKodeSetUseCompensat .. versionadded:: x.y.z -.. c:function:: int ARKodeSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) - - Specifies if :ref:`compensated summation (and the incremental form) ` - should be used where applicable. This is currently only supported when using - the SPRKStep time-stepping module, but may be incorporated more thoroughly into - ARKODE in a future release. - - This increases the computational cost by 2 extra vector operations per stage - and an additional 5 per time step. It also requires one extra vector to be - stored. However, it is signficantly more robust to roundoff error - accumulation. - - :param arkode_mem: pointer to the ARKODE memory block. - :param onoff: should compensated summation be used (1) or not (0). - - :retval ARK_SUCCESS: the function exited successfully. - :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. - :retval ARK_ILL_INPUT: an argument had an illegal value. - - .. _ARKODE.Usage.ARKodeAdaptivityInputTable: diff --git a/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c b/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c index bcb05f830b..8bfca224ed 100644 --- a/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c +++ b/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c @@ -109,8 +109,8 @@ int main(int argc, char* argv[]) retval = ARKodeSetOrder(arkode_mem, order); if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } - retval = ARKodeSetUseCompensatedSums(arkode_mem, use_compsums); - if (check_retval(&retval, "ARKodeSetUseCompensatedSums", 1)) { return 1; } + retval = SPRKStepSetUseCompensatedSums(arkode_mem, use_compsums); + if (check_retval(&retval, "SPRKStepSetUseCompensatedSums", 1)) { return 1; } retval = ARKodeSetFixedStep(arkode_mem, dt); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_harmonic_symplectic.c b/examples/arkode/C_serial/ark_harmonic_symplectic.c index 60a9d41d33..72ddfa656c 100644 --- a/examples/arkode/C_serial/ark_harmonic_symplectic.c +++ b/examples/arkode/C_serial/ark_harmonic_symplectic.c @@ -131,8 +131,8 @@ int main(int argc, char* argv[]) retval = ARKodeSetUserData(arkode_mem, &udata); if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } - retval = ARKodeSetUseCompensatedSums(arkode_mem, use_compsums); - if (check_retval(&retval, "ARKodeSetUseCompensatedSums", 1)) { return 1; } + retval = SPRKStepSetUseCompensatedSums(arkode_mem, use_compsums); + if (check_retval(&retval, "SPRKStepSetUseCompensatedSums", 1)) { return 1; } retval = ARKodeSetFixedStep(arkode_mem, dt); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_kepler.c b/examples/arkode/C_serial/ark_kepler.c index f298389049..5492d040fd 100644 --- a/examples/arkode/C_serial/ark_kepler.c +++ b/examples/arkode/C_serial/ark_kepler.c @@ -168,8 +168,8 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) retval = SPRKStepSetMethodName(arkode_mem, method_name); if (check_retval(&retval, "SPRKStepSetMethodName", 1)) { return 1; } - retval = ARKodeSetUseCompensatedSums(arkode_mem, use_compsums); - if (check_retval(&retval, "ARKodeSetUseCompensatedSums", 1)) { return 1; } + retval = SPRKStepSetUseCompensatedSums(arkode_mem, use_compsums); + if (check_retval(&retval, "SPRKStepSetUseCompensatedSums", 1)) { return 1; } if (step_mode == 0) { diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 01b60e99f3..14027693af 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -266,8 +266,6 @@ SUNDIALS_EXPORT int ARKodeSetStopTime(void* arkode_mem, sunrealtype tstop); SUNDIALS_EXPORT int ARKodeClearStopTime(void* arkode_mem); SUNDIALS_EXPORT int ARKodeSetFixedStep(void* arkode_mem, sunrealtype hfixed); SUNDIALS_EXPORT int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails); -SUNDIALS_EXPORT int ARKodeSetUseCompensatedSums(void* arkode_mem, - sunbooleantype onoff); SUNDIALS_EXPORT int ARKodeSetUserData(void* arkode_mem, void* user_data); diff --git a/include/arkode/arkode_sprkstep.h b/include/arkode/arkode_sprkstep.h index d4fa99e1da..f3e8f333b2 100644 --- a/include/arkode/arkode_sprkstep.h +++ b/include/arkode/arkode_sprkstep.h @@ -60,8 +60,8 @@ int SPRKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); /* Optional input functions -- must be called AFTER SPRKStepCreate */ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDefaults instead") int SPRKStepSetDefaults(void* arkode_mem); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetUseCompensatedSums instead") -int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff); +SUNDIALS_EXPORT int SPRKStepSetUseCompensatedSums(void* arkode_mem, + sunbooleantype onoff); SUNDIALS_EXPORT int SPRKStepSetMethod(void* arkode_mem, ARKodeSPRKTable sprk_storage); SUNDIALS_EXPORT int SPRKStepSetMethodName(void* arkode_mem, const char* method); diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index b723026a1c..95675b448e 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -366,7 +366,7 @@ int ARKodeResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, /* Call the stepper-specific resize (if provided) */ if (ark_mem->step_resize) { - return (ark_mem->step_resize(arkode_mem, y0, hscale, t0, resize, resize_data)); + return (ark_mem->step_resize(ark_mem, y0, hscale, t0, resize, resize_data)); } /* Problem has been successfully re-sized */ @@ -402,7 +402,7 @@ int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR) } /* Call stepper routine to perform remaining reset operations (if provided) */ - if (ark_mem->step_reset) { return (ark_mem->step_reset(arkode_mem, tR, yR)); } + if (ark_mem->step_reset) { return (ark_mem->step_reset(ark_mem, tR, yR)); } return (ARK_SUCCESS); } @@ -1356,7 +1356,7 @@ void ARKodeFree(void** arkode_mem) ark_mem = (ARKodeMem)(*arkode_mem); /* free the time-stepper module memory (if provided) */ - if (ark_mem->step_free) { ark_mem->step_free(*arkode_mem); } + if (ark_mem->step_free) { ark_mem->step_free(ark_mem); } /* free vector storage */ arkFreeVectors(ark_mem); @@ -1384,7 +1384,7 @@ void ARKodeFree(void** arkode_mem) /* free the root-finding module */ if (ark_mem->root_mem != NULL) { - (void)arkRootFree(*arkode_mem); + (void)arkRootFree(ark_mem); ark_mem->root_mem = NULL; } @@ -1735,7 +1735,7 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile) #endif /* Call stepper PrintMem function (if provided) */ - if (ark_mem->step_printmem) { ark_mem->step_printmem(arkode_mem, outfile); } + if (ark_mem->step_printmem) { ark_mem->step_printmem(ark_mem, outfile); } } /*--------------------------------------------------------------- @@ -3410,8 +3410,8 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, larger/smaller than current step, depending on dsm) */ ttmp = (dsm <= ONE) ? ark_mem->tn + ark_mem->h : ark_mem->tn; nsttmp = (dsm <= ONE) ? ark_mem->nst + 1 : ark_mem->nst; - retval = arkAdapt((void*)ark_mem, hadapt_mem, ark_mem->ycur, ttmp, ark_mem->h, - dsm, nsttmp); + retval = arkAdapt(ark_mem, hadapt_mem, ark_mem->ycur, ttmp, ark_mem->h, dsm, + nsttmp); if (retval != ARK_SUCCESS) { return (ARK_ERR_FAILURE); } /* if we've made it here then no nonrecoverable failures occurred; someone above diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 93a7c8b35b..5d6896a46f 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -91,20 +91,12 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile) computes and sets the value of ark_eta inside of the ARKodeMem data structure. ---------------------------------------------------------------*/ -int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, +int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, sunrealtype tcur, sunrealtype hcur, sunrealtype dsm, long int nst) { int retval; sunrealtype h_acc, h_cfl, int_dir; - ARKodeMem ark_mem; int controller_order; - 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; /* Request error-based step size from adaptivity controller */ if (hadapt_mem->pq == 0) diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index 9f96027ca4..757be20da1 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -22,6 +22,8 @@ #include #include +#include "arkode_types_impl.h" + #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif @@ -108,7 +110,7 @@ typedef struct ARKodeHAdaptMemRec ARKodeHAdaptMem arkAdaptInit(void); void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile); -int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, +int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, sunrealtype tcur, sunrealtype hcur, sunrealtype dsm, long int nst); #ifdef __cplusplus diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 2c3e936965..6774f0bd76 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -266,17 +266,16 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, This routine resizes the memory within the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; SUNNonlinearSolver NLS; sunindextype lrw1, liw1, lrw_diff, liw_diff; int i, retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Determine change in vector sizes */ @@ -396,8 +395,8 @@ int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -458,14 +457,13 @@ int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, Computes y based on the current prediction and given correction. ---------------------------------------------------------------*/ -int arkStep_ComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) +int arkStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z) { int retval; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } N_VLinearSum(ONE, step_mem->zpred, ONE, zcor, z); @@ -476,18 +474,16 @@ int arkStep_ComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) /*--------------------------------------------------------------- arkStep_Free frees all ARKStep memory. ---------------------------------------------------------------*/ -void arkStep_Free(void* arkode_mem) +void arkStep_Free(ARKodeMem ark_mem) { int j; sunindextype Bliw, Blrw; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - /* nothing to do if arkode_mem is already NULL */ - if (arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL ARKStep module */ - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem != NULL) { step_mem = (ARKodeARKStepMem)ark_mem->step_mem; @@ -625,9 +621,8 @@ void arkStep_Free(void* arkode_mem) This routine outputs the memory from the ARKStep structure to a specified file pointer (useful when debugging). ---------------------------------------------------------------*/ -void arkStep_PrintMem(void* arkode_mem, FILE* outfile) +void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; @@ -636,7 +631,7 @@ void arkStep_PrintMem(void* arkode_mem, FILE* outfile) #endif /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } /* output integer quantities */ @@ -724,21 +719,20 @@ void arkStep_PrintMem(void* arkode_mem, FILE* outfile) interface routines, data structure, and solver type to the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int arkStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* free any existing system solver */ - if (step_mem->lfree != NULL) { step_mem->lfree(arkode_mem); } + if (step_mem->lfree != NULL) { step_mem->lfree(ark_mem); } /* Attach the provided routines, data structure and solve type */ step_mem->linit = linit; @@ -762,22 +756,21 @@ int arkStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, interface routines, data structure, and solver type to the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_AttachMasssol(void* arkode_mem, ARKMassInitFn minit, +int arkStep_AttachMasssol(ARKodeMem ark_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, ARKMassMultFn mmult, ARKMassSolveFn msolve, ARKMassFreeFn mfree, sunbooleantype time_dep, SUNLinearSolver_Type msolve_type, void* mass_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* free any existing mass matrix solver */ - if (step_mem->mfree != NULL) { step_mem->mfree(arkode_mem); } + if (step_mem->mfree != NULL) { step_mem->mfree(ark_mem); } /* Attach the provided routines, data structure and solve type */ step_mem->minit = minit; @@ -801,14 +794,11 @@ int arkStep_AttachMasssol(void* arkode_mem, ARKMassInitFn minit, This routine NULLifies the lsetup function pointer in the ARKStep module. ---------------------------------------------------------------*/ -void arkStep_DisableLSetup(void* arkode_mem) +void arkStep_DisableLSetup(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; /* access ARKodeARKStepMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem == NULL) { return; } step_mem = (ARKodeARKStepMem)ark_mem->step_mem; @@ -822,14 +812,11 @@ void arkStep_DisableLSetup(void* arkode_mem) This routine NULLifies the msetup function pointer in the ARKStep module. ---------------------------------------------------------------*/ -void arkStep_DisableMSetup(void* arkode_mem) +void arkStep_DisableMSetup(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; /* access ARKodeARKStepMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem == NULL) { return; } step_mem = (ARKodeARKStepMem)ark_mem->step_mem; @@ -843,14 +830,13 @@ void arkStep_DisableMSetup(void* arkode_mem) This routine returns the system linear solver interface memory structure, lmem. ---------------------------------------------------------------*/ -void* arkStep_GetLmem(void* arkode_mem) +void* arkStep_GetLmem(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure, and return lmem */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->lmem); } @@ -861,14 +847,13 @@ void* arkStep_GetLmem(void* arkode_mem) This routine returns the mass matrix solver interface memory structure, mass_mem. ---------------------------------------------------------------*/ -void* arkStep_GetMassMem(void* arkode_mem) +void* arkStep_GetMassMem(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure, and return mass_mem */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->mass_mem); } @@ -878,14 +863,13 @@ void* arkStep_GetMassMem(void* arkode_mem) This routine returns the implicit RHS function pointer, fi. ---------------------------------------------------------------*/ -ARKRhsFn arkStep_GetImplicitRHS(void* arkode_mem) +ARKRhsFn arkStep_GetImplicitRHS(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure, and return fi */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->fi); } @@ -896,15 +880,14 @@ ARKRhsFn arkStep_GetImplicitRHS(void* arkode_mem) This routine fills the current value of gamma, and states whether the gamma ratio fails the dgmax criteria. ---------------------------------------------------------------*/ -int arkStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set outputs */ @@ -951,15 +934,14 @@ int arkStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int arkStep_Init(void* arkode_mem, int init_type) +int arkStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int j, retval; sunbooleantype reset_efun; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if reset */ @@ -1265,10 +1247,9 @@ int arkStep_Init(void* arkode_mem, int init_type) when estimating the initial time step size, so we strive to store the intermediate parts so that they do not interfere with the other two modes. ----------------------------------------------------------------------------*/ -int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int nvec, retval; sunbooleantype recomputeRHS; @@ -1277,7 +1258,7 @@ int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, sunrealtype stage_coefs = ONE; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* local shortcuts for use with fused vector operations */ @@ -1635,19 +1616,18 @@ int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int arkStep_TakeStep_Z(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { int retval, is, is_start, mode; sunbooleantype implicit_stage; sunbooleantype deduce_stage; sunbooleantype save_stages; sunbooleantype stiffly_accurate; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; N_Vector zcor0; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if problem will involve no algebraic solvers, initialize nflagPtr to success */ @@ -2010,13 +1990,13 @@ int arkStep_TakeStep_Z(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) ---------------------------------------------------------------*/ /*--------------------------------------------------------------- - arkStep_AccessStepMem: + arkStep_AccessARKODEStepMem: Shortcut routine to unpack ark_mem and step_mem structures from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int arkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem) +int arkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -2026,6 +2006,8 @@ int arkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeARKStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -2036,6 +2018,26 @@ int arkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + arkStep_AccessStepMem: + + Shortcut routine to unpack ark_mem and step_mem structures from + void* pointer. If either is missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int arkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeARKStepMem* step_mem) +{ + /* access ARKodeARKStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_ARKSTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeARKStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- arkStep_CheckNVector: @@ -3056,9 +3058,9 @@ int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - retval = arkStep_AccessStepMem(inner_arkode_mem, - "ARKStepCreateMRIStepInnerStepper", &ark_mem, - &step_mem); + retval = arkStep_AccessARKODEStepMem(inner_arkode_mem, + "ARKStepCreateMRIStepInnerStepper", + &ark_mem, &step_mem); if (retval) { arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -3253,8 +3255,8 @@ int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index edca35e890..b8d091c424 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -166,64 +166,66 @@ typedef struct ARKodeARKStepMemRec ===============================================================*/ /* Interface routines supplied to ARKODE */ -int arkStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int arkStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); -int arkStep_AttachMasssol(void* arkode_mem, ARKMassInitFn minit, +int arkStep_AttachMasssol(ARKodeMem ark_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, ARKMassMultFn mmult, ARKMassSolveFn msolve, ARKMassFreeFn lfree, sunbooleantype time_dep, SUNLinearSolver_Type msolve_type, void* mass_mem); -void arkStep_DisableLSetup(void* arkode_mem); -void arkStep_DisableMSetup(void* arkode_mem); -int arkStep_Init(void* arkode_mem, int init_type); -void* arkStep_GetLmem(void* arkode_mem); -void* arkStep_GetMassMem(void* arkode_mem); -ARKRhsFn arkStep_GetImplicitRHS(void* arkode_mem); -int arkStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +void arkStep_DisableLSetup(ARKodeMem ark_mem); +void arkStep_DisableMSetup(ARKodeMem ark_mem); +int arkStep_Init(ARKodeMem ark_mem, int init_type); +void* arkStep_GetLmem(ARKodeMem ark_mem); +void* arkStep_GetMassMem(ARKodeMem ark_mem); +ARKRhsFn arkStep_GetImplicitRHS(ARKodeMem ark_mem); +int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail); -int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int arkStep_TakeStep_Z(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int arkStep_SetUserData(void* arkode_mem, void* user_data); -int arkStep_SetDefaults(void* arkode_mem); -int arkStep_SetOrder(void* arkode_mem, int ord); -int arkStep_SetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS); -int arkStep_SetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi); -int arkStep_SetLinear(void* arkode_mem, int timedepend); -int arkStep_SetNonlinear(void* arkode_mem); -int arkStep_SetNonlinCRDown(void* arkode_mem, sunrealtype crdown); -int arkStep_SetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); -int arkStep_SetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); -int arkStep_SetLSetupFrequency(void* arkode_mem, int msbp); -int arkStep_SetPredictorMethod(void* arkode_mem, int pred_method); -int arkStep_SetMaxNonlinIters(void* arkode_mem, int maxcor); -int arkStep_SetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef); -int arkStep_SetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage); -int arkStep_SetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce); -int arkStep_GetCurrentGamma(void* arkode_mem, sunrealtype* gamma); -int arkStep_GetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, +int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int arkStep_SetDefaults(ARKodeMem ark_mem); +int arkStep_SetOrder(ARKodeMem ark_mem, int ord); +int arkStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS); +int arkStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fi); +int arkStep_SetLinear(ARKodeMem ark_mem, int timedepend); +int arkStep_SetNonlinear(ARKodeMem ark_mem); +int arkStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown); +int arkStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv); +int arkStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax); +int arkStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp); +int arkStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method); +int arkStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor); +int arkStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef); +int arkStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage); +int arkStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce); +int arkStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma); +int arkStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data); -int arkStep_GetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups); -int arkStep_GetNumNonlinSolvIters(void* arkode_mem, long int* nniters); -int arkStep_GetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails); -int arkStep_GetNonlinSolvStats(void* arkode_mem, long int* nniters, +int arkStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups); +int arkStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters); +int arkStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails); +int arkStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, long int* nnfails); -int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); -int arkStep_WriteParameters(void* arkode_mem, FILE* fp); -int arkStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR); -int arkStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int arkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int arkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); -int arkStep_ComputeState(void* arkode_mem, N_Vector zcor, N_Vector z); -void arkStep_Free(void* arkode_mem); -void arkStep_PrintMem(void* arkode_mem, FILE* outfile); +int arkStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); +void arkStep_Free(ARKodeMem ark_mem); +void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int arkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem); +int arkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem); +int arkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeARKStepMem* step_mem); sunbooleantype arkStep_CheckNVector(N_Vector tmpl); int arkStep_SetButcherTables(ARKodeMem ark_mem); int arkStep_CheckButcherTables(ARKodeMem ark_mem); @@ -260,7 +262,7 @@ int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); /* private functions for relaxation */ -int arkStep_SetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); +int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); int arkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, long int* relax_jac_fn_evals, sunrealtype* delta_e_out); int arkStep_GetOrder(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 13fec5ff58..65d0474f2d 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -719,10 +719,10 @@ char* ARKStepGetLinReturnFlagName(long int flag) * ---------------------------------------------------------------------------*/ /* ARKStep-specific utility routine */ -int arkStep_SetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) +int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) { - return (arkRelaxCreate(arkode_mem, rfn, rjac, arkStep_RelaxDeltaE, - arkStep_GetOrder)); + return ( + arkRelaxCreate(ark_mem, rfn, rjac, arkStep_RelaxDeltaE, arkStep_GetOrder)); } int ARKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) @@ -846,27 +846,26 @@ int ARKStepSetErrorBias(void* arkode_mem, sunrealtype bias) ARKStep optional input functions -- stepper-specific ===============================================================*/ -int arkStep_SetUserData(void* arkode_mem, void* user_data) +int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set user data in ARKODE LS mem */ if (step_mem->lmem != NULL) { - retval = arkLSSetUserData(arkode_mem, user_data); + retval = arkLSSetUserData(ark_mem, user_data); if (retval != ARKLS_SUCCESS) { return (retval); } } /* set user data in ARKODE LSMass mem */ if (step_mem->mass_mem != NULL) { - retval = arkLSSetMassUserData(arkode_mem, user_data); + retval = arkLSSetMassUserData(ark_mem, user_data); if (retval != ARKLS_SUCCESS) { return (retval); } } @@ -882,14 +881,13 @@ int arkStep_SetUserData(void* arkode_mem, void* user_data) structures/options related to the ARKODE infrastructure itself (e.g., root-finding and post-process step). ---------------------------------------------------------------*/ -int arkStep_SetDefaults(void* arkode_mem) +int arkStep_SetDefaults(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set default values for integrator optional inputs */ @@ -936,8 +934,8 @@ int ARKStepSetOptimalParams(void* arkode_mem) int retval; long int lenrw, leniw; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* access ARKodeHAdaptMem structure */ @@ -1212,15 +1210,14 @@ int ARKStepSetOptimalParams(void* arkode_mem) Specifies the method order ---------------------------------------------------------------*/ -int arkStep_SetOrder(void* arkode_mem, int ord) +int arkStep_SetOrder(ARKodeMem ark_mem, int ord) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; sunindextype Blrw, Bliw; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set user-provided value, or default, depending on argument */ @@ -1263,14 +1260,13 @@ int arkStep_SetOrder(void* arkode_mem, int ord) using an iterative linear solver this flag denotes time dependence of the preconditioner. ---------------------------------------------------------------*/ -int arkStep_SetLinear(void* arkode_mem, int timedepend) +int arkStep_SetLinear(ARKodeMem ark_mem, int timedepend) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameters */ @@ -1288,14 +1284,13 @@ int arkStep_SetLinear(void* arkode_mem, int timedepend) Used to undo a previous call to arkStep_SetLinear. Automatically loosens DeltaGammaMax back to default value. ---------------------------------------------------------------*/ -int arkStep_SetNonlinear(void* arkode_mem) +int arkStep_SetNonlinear(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameters */ @@ -1318,8 +1313,8 @@ int ARKStepSetExplicit(void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* ensure that fe is defined */ @@ -1349,8 +1344,8 @@ int ARKStepSetImplicit(void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* ensure that fi is defined */ @@ -1394,8 +1389,8 @@ int ARKStepSetImEx(void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* ensure that fe and fi are defined */ @@ -1452,8 +1447,8 @@ int ARKStepSetTables(void* arkode_mem, int q, int p, ARKodeButcherTable Bi, ARKodeARKStepMem step_mem; sunindextype Blrw, Bliw; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check for illegal inputs */ @@ -1621,8 +1616,8 @@ int ARKStepSetTableNum(void* arkode_mem, ARKODE_DIRKTableID itable, ARKodeARKStepMem step_mem; sunindextype Blrw, Bliw; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* clear any existing parameters and Butcher tables */ @@ -1797,14 +1792,13 @@ int ARKStepSetTableName(void* arkode_mem, const char* itable, const char* etable crdown. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int arkStep_SetNonlinCRDown(void* arkode_mem, sunrealtype crdown) +int arkStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -1821,14 +1815,13 @@ int arkStep_SetNonlinCRDown(void* arkode_mem, sunrealtype crdown) rdiv. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int arkStep_SetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) +int arkStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -1845,14 +1838,13 @@ int arkStep_SetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) dgmax. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int arkStep_SetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) +int arkStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -1870,14 +1862,13 @@ int arkStep_SetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) negative values imply recomputation of lsetup at each nonlinear solve; a zero value implies a reset to the default. ---------------------------------------------------------------*/ -int arkStep_SetLSetupFrequency(void* arkode_mem, int msbp) +int arkStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -1894,14 +1885,13 @@ int arkStep_SetLSetupFrequency(void* arkode_mem, int msbp) Non-default choices are {1,2,3,4}, all others will use default (trivial) predictor. ---------------------------------------------------------------*/ -int arkStep_SetPredictorMethod(void* arkode_mem, int pred_method) +int arkStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameter */ @@ -1917,14 +1907,13 @@ int arkStep_SetPredictorMethod(void* arkode_mem, int pred_method) one solve. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int arkStep_SetMaxNonlinIters(void* arkode_mem, int maxcor) +int arkStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } SUNFunctionBegin(ark_mem->sunctx); @@ -1959,14 +1948,13 @@ int arkStep_SetMaxNonlinIters(void* arkode_mem, int maxcor) Specifies the coefficient in the nonlinear solver convergence test. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int arkStep_SetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) +int arkStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* argument <= 0 sets default, otherwise set input */ @@ -1981,14 +1969,13 @@ int arkStep_SetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) predictor function having type ARKStagePredictFn. A NULL input function disables calls to this routine. ---------------------------------------------------------------*/ -int arkStep_SetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) +int arkStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure and set function pointer */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } step_mem->stage_predict = PredictStage; @@ -2007,14 +1994,13 @@ int arkStep_SetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) fi(z_i), and SUNFALSE indicates that fi(z_i) is computed with an additional evaluation of fi. ---------------------------------------------------------------*/ -int arkStep_SetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) +int arkStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure and set function pointer */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } step_mem->deduce_rhs = deduce; @@ -2028,12 +2014,11 @@ int arkStep_SetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) /*--------------------------------------------------------------- arkStep_GetCurrentGamma: Returns the current value of gamma ---------------------------------------------------------------*/ -int arkStep_GetCurrentGamma(void* arkode_mem, sunrealtype* gamma) +int arkStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma) { int retval; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *gamma = step_mem->gamma; return (retval); @@ -2050,8 +2035,8 @@ int ARKStepGetNumRhsEvals(void* arkode_mem, long int* fe_evals, long int* fi_eva ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get values from step_mem */ @@ -2066,14 +2051,13 @@ int ARKStepGetNumRhsEvals(void* arkode_mem, long int* fe_evals, long int* fi_eva Returns the current number of calls to the lsetup routine ---------------------------------------------------------------*/ -int arkStep_GetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) +int arkStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get value from step_mem */ @@ -2095,8 +2079,8 @@ int ARKStepGetCurrentButcherTables(void* arkode_mem, ARKodeButcherTable* Bi, ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get tables from step_mem */ @@ -2119,8 +2103,8 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set expsteps and accsteps from adaptivity structure */ @@ -2142,14 +2126,13 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Returns the current number of nonlinear solver iterations ---------------------------------------------------------------*/ -int arkStep_GetNumNonlinSolvIters(void* arkode_mem, long int* nniters) +int arkStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nniters = step_mem->nls_iters; @@ -2162,14 +2145,13 @@ int arkStep_GetNumNonlinSolvIters(void* arkode_mem, long int* nniters) Returns the current number of nonlinear solver convergence fails ---------------------------------------------------------------*/ -int arkStep_GetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) +int arkStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set output from step_mem */ @@ -2183,15 +2165,14 @@ int arkStep_GetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) Returns nonlinear solver statistics ---------------------------------------------------------------*/ -int arkStep_GetNonlinSolvStats(void* arkode_mem, long int* nniters, +int arkStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, long int* nnfails) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nniters = step_mem->nls_iters; @@ -2205,16 +2186,15 @@ int arkStep_GetNonlinSolvStats(void* arkode_mem, long int* nniters, Prints integrator statistics ---------------------------------------------------------------*/ -int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; ARKLsMem arkls_mem; ARKLsMassMem arklsm_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } switch (fmt) @@ -2235,9 +2215,9 @@ int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* linear solver stats */ fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) + if (ark_mem->step_getlinmem(ark_mem)) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); @@ -2260,9 +2240,9 @@ int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) } /* mass solve stats */ - if (ark_mem->step_getmassmem(arkode_mem)) + if (ark_mem->step_getmassmem(ark_mem)) { - arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(arkode_mem)); + arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); fprintf(outfile, "Mass setups = %ld\n", arklsm_mem->nmsetups); fprintf(outfile, "Mass solves = %ld\n", @@ -2295,9 +2275,9 @@ int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* linear solver stats */ fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) + if (ark_mem->step_getlinmem(ark_mem)) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); @@ -2324,9 +2304,9 @@ int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) } /* mass solve stats */ - if (ark_mem->step_getmassmem(arkode_mem)) + if (ark_mem->step_getmassmem(ark_mem)) { - arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(arkode_mem)); + arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); fprintf(outfile, ",Mass setups,%ld", arklsm_mem->nmsetups); fprintf(outfile, ",Mass solves,%ld", arklsm_mem->nmsolves); fprintf(outfile, ",Mass Prec setup evals,%ld", arklsm_mem->npe); @@ -2357,14 +2337,13 @@ int arkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int arkStep_WriteParameters(void* arkode_mem, FILE* fp) +int arkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* print integrator parameters to file */ @@ -2415,8 +2394,8 @@ int ARKStepWriteButcher(void* arkode_mem, FILE* fp) ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that Butcher table is non-NULL (otherwise report error) */ diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index e05464cb27..d6105f8ed4 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -33,14 +33,13 @@ This routine attaches a SUNNonlinearSolver object to the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_SetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) +int arkStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if NLS input is NULL */ @@ -338,14 +337,13 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) right-hand side function to use in the evaluation of nonlinear system functions. ---------------------------------------------------------------*/ -int arkStep_SetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) +int arkStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fi) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nls_fi) { step_mem->nls_fi = nls_fi; } @@ -360,17 +358,16 @@ int arkStep_SetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) This routine provides access to the relevant data needed to compute the nonlinear system function. ---------------------------------------------------------------*/ -int arkStep_GetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, +int arkStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *tcur = ark_mem->tcur; @@ -400,8 +397,8 @@ int arkStep_NlsLSetup(sunbooleantype jbad, sunbooleantype* jcur, void* arkode_me ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update convfail based on jbad flag */ @@ -442,8 +439,8 @@ int arkStep_NlsLSolve(N_Vector b, void* arkode_mem) ARKodeARKStepMem step_mem; int retval, nonlin_iter; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* retrieve nonlinear solver iteration from module */ @@ -497,8 +494,8 @@ int arkStep_NlsResidual_MassIdent(N_Vector zcor, N_Vector r, void* arkode_mem) sunrealtype c[3]; N_Vector X[3]; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -559,8 +556,8 @@ int arkStep_NlsResidual_MassFixed(N_Vector zcor, N_Vector r, void* arkode_mem) sunrealtype c[3]; N_Vector X[3]; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -627,8 +624,8 @@ int arkStep_NlsResidual_MassTDep(N_Vector zcor, N_Vector r, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -692,8 +689,8 @@ int arkStep_NlsFPFunction_MassIdent(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -755,8 +752,8 @@ int arkStep_NlsFPFunction_MassFixed(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -824,8 +821,8 @@ int arkStep_NlsFPFunction_MassTDep(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -880,8 +877,8 @@ int arkStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, sunrealtype delnrm, dcon; int m, retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if the problem is linearly implicit, just return success */ diff --git a/src/arkode/arkode_bandpre.c b/src/arkode/arkode_bandpre.c index c54566cc54..ad1d72e2b1 100644 --- a/src/arkode/arkode_bandpre.c +++ b/src/arkode/arkode_bandpre.c @@ -62,8 +62,8 @@ int ARKBandPrecInit(void* arkode_mem, sunindextype N, sunindextype mu, sunindextype mup, mlp, storagemu; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Test compatibility of NVECTOR package with the BAND preconditioner */ @@ -201,8 +201,8 @@ int ARKBandPrecGetWorkSpace(void* arkode_mem, long int* lenrwBP, long int* leniw long int lrw, liw; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if ARKBandPrecData is NULL */ @@ -261,8 +261,8 @@ int ARKBandPrecGetNumRhsEvals(void* arkode_mem, long int* nfevalsBP) ARKBandPrecData pdata; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if ARKBandPrecData is NULL */ diff --git a/src/arkode/arkode_bbdpre.c b/src/arkode/arkode_bbdpre.c index e090d5084d..aa2c2fb652 100644 --- a/src/arkode/arkode_bbdpre.c +++ b/src/arkode/arkode_bbdpre.c @@ -60,8 +60,8 @@ int ARKBBDPrecInit(void* arkode_mem, sunindextype Nlocal, sunindextype mudq, long int lrw, liw; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Test compatibility of NVECTOR package with the BBD preconditioner */ @@ -297,8 +297,8 @@ int ARKBBDPrecReInit(void* arkode_mem, sunindextype mudq, sunindextype mldq, sunindextype Nlocal; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately ARKBBDPrecData is NULL */ @@ -333,8 +333,8 @@ int ARKBBDPrecGetWorkSpace(void* arkode_mem, long int* lenrwBBDP, ARKBBDPrecData pdata; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately ARKBBDPrecData is NULL */ @@ -361,8 +361,8 @@ int ARKBBDPrecGetNumGfnEvals(void* arkode_mem, long int* ngevalsBBDP) ARKBBDPrecData pdata; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if ARKBBDPrecData is NULL */ diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 7031764f55..8fdaa5047c 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -148,16 +148,15 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) This routine resizes the memory within the ERKStep module. ---------------------------------------------------------------*/ -int erkStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; sunindextype lrw1, liw1, lrw_diff, liw_diff; int i, retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Determine change in vector sizes */ @@ -201,7 +200,7 @@ int ERKStepReInit(void* arkode_mem, ARKRhsFn f, sunrealtype t0, N_Vector y0) int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -249,18 +248,16 @@ int ERKStepReInit(void* arkode_mem, ARKRhsFn f, sunrealtype t0, N_Vector y0) /*--------------------------------------------------------------- erkStep_Free frees all ERKStep memory. ---------------------------------------------------------------*/ -void erkStep_Free(void* arkode_mem) +void erkStep_Free(ARKodeMem ark_mem) { int j; sunindextype Bliw, Blrw; - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - /* nothing to do if arkode_mem is already NULL */ - if (arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL ERKStep module */ - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem != NULL) { step_mem = (ARKodeERKStepMem)ark_mem->step_mem; @@ -313,9 +310,8 @@ void erkStep_Free(void* arkode_mem) This routine outputs the memory from the ERKStep structure to a specified file pointer (useful when debugging). ---------------------------------------------------------------*/ -void erkStep_PrintMem(void* arkode_mem, FILE* outfile) +void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; @@ -324,7 +320,7 @@ void erkStep_PrintMem(void* arkode_mem, FILE* outfile) #endif /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } /* output integer quantities */ @@ -372,14 +368,13 @@ void erkStep_PrintMem(void* arkode_mem, FILE* outfile) With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int erkStep_Init(void* arkode_mem, int init_type) +int erkStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval, j; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if resize or reset */ @@ -516,16 +511,15 @@ int erkStep_Init(void* arkode_mem, int init_type) when estimating the initial time step size, so we strive to store the intermediate parts so that they do not interfere with the other two modes. ----------------------------------------------------------------------------*/ -int erkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { int retval; - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; sunbooleantype recomputeRHS; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* perform RHS functions contingent on 'mode' argument */ @@ -626,19 +620,18 @@ int erkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { int retval, is, js, nvec, mode; sunrealtype* cvals; N_Vector* Xvecs; - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; /* initialize algebraic solver convergence flag to success */ *nflagPtr = ARK_SUCCESS; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* local shortcuts for fused vector operations */ @@ -753,13 +746,13 @@ int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) ---------------------------------------------------------------*/ /*--------------------------------------------------------------- - erkStep_AccessStepMem: + erkStep_AccessARKODEStepMem: - Shortcut routine to unpack ark_mem and step_mem structures from - void* pointer. If either is missing it returns ARK_MEM_NULL. + Shortcut routine to unpack both ark_mem and step_mem structures + from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int erkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem) +int erkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -769,6 +762,8 @@ int erkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeERKStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -779,6 +774,26 @@ int erkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + erkStep_AccessStepMem: + + Shortcut routine to unpack the step_mem structure from + ark_mem. If missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int erkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeERKStepMem* step_mem) +{ + /* access ARKodeERKStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_ERKSTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeERKStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- erkStep_CheckNVector: diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 629ea9f6f6..e3ecdc7baf 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -68,31 +68,33 @@ typedef struct ARKodeERKStepMemRec ===============================================================*/ /* Interface routines supplied to ARKODE */ -int erkStep_Init(void* arkode_mem, int init_type); -int erkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int erkStep_Init(ARKodeMem ark_mem, int init_type); +int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int erkStep_SetUserData(void* arkode_mem, void* user_data); -int erkStep_SetDefaults(void* arkode_mem); -int erkStep_SetOrder(void* arkode_mem, int ord); -int erkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); -int erkStep_WriteParameters(void* arkode_mem, FILE* fp); -int erkStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR); -int erkStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int erkStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int erkStep_SetDefaults(ARKodeMem ark_mem); +int erkStep_SetOrder(ARKodeMem ark_mem, int ord); +int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int erkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int erkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); -void erkStep_Free(void* arkode_mem); -void erkStep_PrintMem(void* arkode_mem, FILE* outfile); +void erkStep_Free(ARKodeMem ark_mem); +void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int erkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem); +int erkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem); +int erkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeERKStepMem* step_mem); sunbooleantype erkStep_CheckNVector(N_Vector tmpl); int erkStep_SetButcherTable(ARKodeMem ark_mem); int erkStep_CheckButcherTable(ARKodeMem ark_mem); int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsm); /* private functions for relaxation */ -int erkStep_SetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); +int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); int erkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, long int* relax_jac_fn_evals, sunrealtype* delta_e_out); int erkStep_GetOrder(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 151f37270a..dece670718 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -351,10 +351,10 @@ int ERKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) * ---------------------------------------------------------------------------*/ /* ERKStep-specific utility routine */ -int erkStep_SetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) +int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) { - return (arkRelaxCreate(arkode_mem, rfn, rjac, erkStep_RelaxDeltaE, - erkStep_GetOrder)); + return ( + arkRelaxCreate(ark_mem, rfn, rjac, erkStep_RelaxDeltaE, erkStep_GetOrder)); } int ERKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) @@ -485,15 +485,14 @@ int ERKStepSetErrorBias(void* arkode_mem, sunrealtype bias) Does not change problem-defining function pointers or user_data pointer. ---------------------------------------------------------------*/ -int erkStep_SetDefaults(void* arkode_mem) +int erkStep_SetDefaults(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; long int lenrw, leniw; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Remove current SUNAdaptController object, and replace with "PI" */ @@ -553,15 +552,14 @@ int erkStep_SetDefaults(void* arkode_mem) Specifies the method order ---------------------------------------------------------------*/ -int erkStep_SetOrder(void* arkode_mem, int ord) +int erkStep_SetOrder(ARKodeMem ark_mem, int ord) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; sunindextype Blrw, Bliw; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set user-provided value, or default, depending on argument */ @@ -600,8 +598,8 @@ int ERKStepSetTable(void* arkode_mem, ARKodeButcherTable B) sunindextype Blrw, Bliw; int retval; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check for legal inputs */ @@ -658,8 +656,8 @@ int ERKStepSetTableNum(void* arkode_mem, ARKODE_ERKTableID etable) sunindextype Blrw, Bliw; int retval; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that argument specifies an explicit table */ @@ -727,8 +725,8 @@ int ERKStepGetNumRhsEvals(void* arkode_mem, long int* fevals) ARKodeERKStepMem step_mem; int retval; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get values from step_mem */ @@ -748,8 +746,8 @@ int ERKStepGetCurrentButcherTable(void* arkode_mem, ARKodeButcherTable* B) ARKodeERKStepMem step_mem; int retval; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get tables from step_mem */ @@ -770,8 +768,8 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, ARKodeERKStepMem step_mem; int retval; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set expsteps and accsteps from adaptivity structure */ @@ -791,14 +789,13 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Prints integrator statistics ---------------------------------------------------------------*/ -int erkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } switch (fmt) @@ -828,14 +825,13 @@ int erkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int erkStep_WriteParameters(void* arkode_mem, FILE* fp) +int erkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* print integrator parameters to file */ @@ -857,8 +853,8 @@ int ERKStepWriteButcher(void* arkode_mem, FILE* fp) ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that Butcher table is non-NULL (otherwise report error) */ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 3cecc4b9f0..2f4b33518d 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -147,92 +147,92 @@ extern "C" { located at the end of this file */ /* linear solver interface functions */ -typedef int (*ARKLinsolInitFn)(void* arkode_mem); -typedef int (*ARKLinsolSetupFn)(void* arkode_mem, int convfail, +typedef int (*ARKLinsolInitFn)(ARKodeMem ark_mem); +typedef int (*ARKLinsolSetupFn)(ARKodeMem ark_mem, int convfail, sunrealtype tpred, N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); -typedef int (*ARKLinsolSolveFn)(void* arkode_mem, N_Vector b, sunrealtype tcur, +typedef int (*ARKLinsolSolveFn)(ARKodeMem ark_mem, N_Vector b, sunrealtype tcur, N_Vector ycur, N_Vector fcur, sunrealtype client_tol, int mnewt); -typedef int (*ARKLinsolFreeFn)(void* arkode_mem); +typedef int (*ARKLinsolFreeFn)(ARKodeMem ark_mem); /* mass-matrix solver interface functions */ -typedef int (*ARKMassInitFn)(void* arkode_mem); -typedef int (*ARKMassSetupFn)(void* arkode_mem, sunrealtype t, N_Vector vtemp1, +typedef int (*ARKMassInitFn)(ARKodeMem ark_mem); +typedef int (*ARKMassSetupFn)(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); typedef int (*ARKMassMultFn)(void* arkode_mem, N_Vector v, N_Vector Mv); -typedef int (*ARKMassSolveFn)(void* arkode_mem, N_Vector b, +typedef int (*ARKMassSolveFn)(ARKodeMem ark_mem, N_Vector b, sunrealtype client_tol); -typedef int (*ARKMassFreeFn)(void* arkode_mem); +typedef int (*ARKMassFreeFn)(ARKodeMem ark_mem); /* time stepper interface functions */ -typedef int (*ARKTimestepInitFn)(void* arkode_mem, int init_type); -typedef int (*ARKTimestepAttachLinsolFn)(void* arkode_mem, ARKLinsolInitFn linit, +typedef int (*ARKTimestepInitFn)(ARKodeMem ark_mem, int init_type); +typedef int (*ARKTimestepAttachLinsolFn)(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); typedef int (*ARKTimestepAttachMasssolFn)( - void* arkode_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, + ARKodeMem ark_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, ARKMassMultFn mmult, ARKMassSolveFn msolve, ARKMassFreeFn mfree, sunbooleantype time_dep, SUNLinearSolver_Type msolve_type, void* mass_mem); -typedef void (*ARKTimestepDisableLSetup)(void* arkode_mem); -typedef void (*ARKTimestepDisableMSetup)(void* arkode_mem); -typedef void* (*ARKTimestepGetLinMemFn)(void* arkode_mem); -typedef void* (*ARKTimestepGetMassMemFn)(void* arkode_mem); -typedef ARKRhsFn (*ARKTimestepGetImplicitRHSFn)(void* arkode_mem); -typedef int (*ARKTimestepGetGammasFn)(void* arkode_mem, sunrealtype* gamma, +typedef void (*ARKTimestepDisableLSetup)(ARKodeMem ark_mem); +typedef void (*ARKTimestepDisableMSetup)(ARKodeMem ark_mem); +typedef void* (*ARKTimestepGetLinMemFn)(ARKodeMem ark_mem); +typedef void* (*ARKTimestepGetMassMemFn)(ARKodeMem ark_mem); +typedef ARKRhsFn (*ARKTimestepGetImplicitRHSFn)(ARKodeMem ark_mem); +typedef int (*ARKTimestepGetGammasFn)(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail); -typedef int (*ARKTimestepFullRHSFn)(void* arkode_mem, sunrealtype t, N_Vector y, - N_Vector f, int mode); -typedef int (*ARKTimestepStepFn)(void* arkode_mem, sunrealtype* dsm, int* nflag); -typedef int (*ARKTimetepSetUserDataFn)(void* arkode_mem, void* user_data); -typedef int (*ARKTimestepPrintAllStats)(void* arkode_mem, FILE* outfile, +typedef int (*ARKTimestepFullRHSFn)(ARKodeMem ark_mem, sunrealtype t, + N_Vector y, N_Vector f, int mode); +typedef int (*ARKTimestepStepFn)(ARKodeMem ark_mem, sunrealtype* dsm, int* nflag); +typedef int (*ARKTimetepSetUserDataFn)(ARKodeMem ark_mem, void* user_data); +typedef int (*ARKTimestepPrintAllStats)(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); -typedef int (*ARKTimestepWriteParameters)(void* arkode_mem, FILE* fp); -typedef int (*ARKTimestepResize)(void* arkode_mem, N_Vector ynew, +typedef int (*ARKTimestepWriteParameters)(ARKodeMem ark_mem, FILE* fp); +typedef int (*ARKTimestepResize)(ARKodeMem ark_mem, N_Vector ynew, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); -typedef int (*ARKTimestepReset)(void* arkode_mem, sunrealtype tR, N_Vector yR); -typedef void (*ARKTimestepFree)(void* arkode_mem); -typedef void (*ARKTimestepPrintMem)(void* arkode_mem, FILE* outfile); -typedef int (*ARKTimestepSetDefaults)(void* arkode_mem); -typedef int (*ARKTimestepComputeState)(void* arkode_mem, N_Vector zcor, +typedef int (*ARKTimestepReset)(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +typedef void (*ARKTimestepFree)(ARKodeMem ark_mem); +typedef void (*ARKTimestepPrintMem)(ARKodeMem ark_mem, FILE* outfile); +typedef int (*ARKTimestepSetDefaults)(ARKodeMem ark_mem); +typedef int (*ARKTimestepComputeState)(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); -typedef int (*ARKTimestepSetRelaxFn)(void* arkode_mem, ARKRelaxFn rfn, +typedef int (*ARKTimestepSetRelaxFn)(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); -typedef int (*ARKTimestepSetOrder)(void* arkode_mem, int maxord); -typedef int (*ARKTimestepSetNonlinearSolver)(void* arkode_mem, +typedef int (*ARKTimestepSetOrder)(ARKodeMem ark_mem, int maxord); +typedef int (*ARKTimestepSetNonlinearSolver)(ARKodeMem ark_mem, SUNNonlinearSolver NLS); -typedef int (*ARKTimestepSetLinear)(void* arkode_mem, int timedepend); -typedef int (*ARKTimestepSetNonlinear)(void* arkode_mem); -typedef int (*ARKTimestepSetNlsRhsFn)(void* arkode_mem, ARKRhsFn nls_fi); -typedef int (*ARKTimestepSetDeduceImplicitRhs)(void* arkode_mem, +typedef int (*ARKTimestepSetLinear)(ARKodeMem ark_mem, int timedepend); +typedef int (*ARKTimestepSetNonlinear)(ARKodeMem ark_mem); +typedef int (*ARKTimestepSetNlsRhsFn)(ARKodeMem ark_mem, ARKRhsFn nls_fi); +typedef int (*ARKTimestepSetDeduceImplicitRhs)(ARKodeMem ark_mem, sunbooleantype deduce); -typedef int (*ARKTimestepSetNonlinCRDown)(void* arkode_mem, sunrealtype crdown); -typedef int (*ARKTimestepSetNonlinRDiv)(void* arkode_mem, sunrealtype rdiv); -typedef int (*ARKTimestepSetDeltaGammaMax)(void* arkode_mem, sunrealtype dgmax); -typedef int (*ARKTimestepSetLSetupFrequency)(void* arkode_mem, int msbp); -typedef int (*ARKTimestepSetPredictorMethod)(void* arkode_mem, int method); -typedef int (*ARKTimestepSetMaxNonlinIters)(void* arkode_mem, int maxcor); -typedef int (*ARKTimestepSetNonlinConvCoef)(void* arkode_mem, +typedef int (*ARKTimestepSetNonlinCRDown)(ARKodeMem ark_mem, sunrealtype crdown); +typedef int (*ARKTimestepSetNonlinRDiv)(ARKodeMem ark_mem, sunrealtype rdiv); +typedef int (*ARKTimestepSetDeltaGammaMax)(ARKodeMem ark_mem, sunrealtype dgmax); +typedef int (*ARKTimestepSetLSetupFrequency)(ARKodeMem ark_mem, int msbp); +typedef int (*ARKTimestepSetPredictorMethod)(ARKodeMem ark_mem, int method); +typedef int (*ARKTimestepSetMaxNonlinIters)(ARKodeMem ark_mem, int maxcor); +typedef int (*ARKTimestepSetNonlinConvCoef)(ARKodeMem ark_mem, sunrealtype nlscoef); -typedef int (*ARKTimestepSetStagePredictFn)(void* arkode_mem, +typedef int (*ARKTimestepSetStagePredictFn)(ARKodeMem ark_mem, ARKStagePredictFn PredictStage); -typedef int (*ARKTimestepGetNumLinSolvSetups)(void* arkode_mem, +typedef int (*ARKTimestepGetNumLinSolvSetups)(ARKodeMem ark_mem, long int* nlinsetups); -typedef int (*ARKTimestepGetCurrentGamma)(void* arkode_mem, sunrealtype* gamma); +typedef int (*ARKTimestepGetCurrentGamma)(ARKodeMem ark_mem, sunrealtype* gamma); typedef int (*ARKTimestepGetNonlinearSystemData)( - void* arkode_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, + ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data); -typedef int (*ARKTimestepGetNumNonlinSolvIters)(void* arkode_mem, +typedef int (*ARKTimestepGetNumNonlinSolvIters)(ARKodeMem ark_mem, long int* nniters); -typedef int (*ARKTimestepGetNumNonlinSolvConvFails)(void* arkode_mem, +typedef int (*ARKTimestepGetNumNonlinSolvConvFails)(ARKodeMem ark_mem, long int* nnfails); -typedef int (*ARKTimestepGetNonlinSolvStats)(void* arkode_mem, long int* nniters, +typedef int (*ARKTimestepGetNonlinSolvStats)(ARKodeMem ark_mem, long int* nniters, long int* nnfails); /*=============================================================== @@ -248,15 +248,15 @@ typedef struct _generic_ARKInterp* ARKInterp; /* Structure containing function pointers to interpolation operations */ struct _generic_ARKInterpOps { - int (*resize)(void* arkode_mem, ARKInterp interp, ARKVecResizeFn resize, + int (*resize)(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); - void (*free)(void* arkode_mem, ARKInterp interp); + void (*free)(ARKodeMem ark_mem, ARKInterp interp); void (*print)(ARKInterp interp, FILE* outfile); - int (*setdegree)(void* arkode_mem, ARKInterp interp, int degree); - int (*init)(void* arkode_mem, ARKInterp interp, sunrealtype tnew); - int (*update)(void* arkode_mem, ARKInterp interp, sunrealtype tnew); - int (*evaluate)(void* arkode_mem, ARKInterp interp, sunrealtype tau, int d, + int (*setdegree)(ARKodeMem ark_mem, ARKInterp interp, int degree); + int (*init)(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); + int (*update)(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); + int (*evaluate)(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); }; @@ -269,15 +269,15 @@ struct _generic_ARKInterp }; /* ARKInterp module functions */ -int arkInterpResize(void* arkode_mem, ARKInterp interp, ARKVecResizeFn resize, +int arkInterpResize(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); -void arkInterpFree(void* arkode_mem, ARKInterp interp); +void arkInterpFree(ARKodeMem ark_mem, ARKInterp interp); void arkInterpPrintMem(ARKInterp interp, FILE* outfile); -int arkInterpSetDegree(void* arkode_mem, ARKInterp interp, int degree); -int arkInterpInit(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpUpdate(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, sunrealtype tau, +int arkInterpSetDegree(ARKodeMem ark_mem, ARKInterp interp, int degree); +int arkInterpInit(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpUpdate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpEvaluate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); /*=============================================================== diff --git a/src/arkode/arkode_interp.c b/src/arkode/arkode_interp.c index c481e465df..2d61283c7a 100644 --- a/src/arkode/arkode_interp.c +++ b/src/arkode/arkode_interp.c @@ -31,19 +31,19 @@ interpolation modules ---------------------------------------------------------------*/ -int arkInterpResize(void* arkode_mem, ARKInterp interp, ARKVecResizeFn resize, +int arkInterpResize(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->resize(arkode_mem, interp, resize, resize_data, + return ((int)interp->ops->resize(ark_mem, interp, resize, resize_data, lrw_diff, liw_diff, tmpl)); } -void arkInterpFree(void* arkode_mem, ARKInterp interp) +void arkInterpFree(ARKodeMem ark_mem, ARKInterp interp) { if (interp == NULL) { return; } - interp->ops->free(arkode_mem, interp); + interp->ops->free(ark_mem, interp); return; } @@ -54,29 +54,29 @@ void arkInterpPrintMem(ARKInterp interp, FILE* outfile) return; } -int arkInterpSetDegree(void* arkode_mem, ARKInterp interp, int degree) +int arkInterpSetDegree(ARKodeMem ark_mem, ARKInterp interp, int degree) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->setdegree(arkode_mem, interp, degree)); + return ((int)interp->ops->setdegree(ark_mem, interp, degree)); } -int arkInterpInit(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpInit(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->init(arkode_mem, interp, tnew)); + return ((int)interp->ops->init(ark_mem, interp, tnew)); } -int arkInterpUpdate(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpUpdate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->update(arkode_mem, interp, tnew)); + return ((int)interp->ops->update(ark_mem, interp, tnew)); } -int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, sunrealtype tau, +int arkInterpEvaluate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->evaluate(arkode_mem, interp, tau, d, order, yout)); + return ((int)interp->ops->evaluate(ark_mem, interp, tau, d, order, yout)); } /*--------------------------------------------------------------- @@ -90,16 +90,11 @@ int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, sunrealtype tau, cloning an input template N_Vector. This returns a non-NULL structure if no errors occurred, or a NULL value otherwise. ---------------------------------------------------------------*/ -ARKInterp arkInterpCreate_Hermite(void* arkode_mem, int degree) +ARKInterp arkInterpCreate_Hermite(ARKodeMem ark_mem, int degree) { ARKInterp interp; ARKInterpContent_Hermite content; ARKInterpOps ops; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* check for valid degree */ if (degree < 0 || degree > ARK_INTERP_MAX_DEGREE) { return (NULL); } @@ -168,17 +163,11 @@ ARKInterp arkInterpCreate_Hermite(void* arkode_mem, int degree) This routine resizes the internal vectors. ---------------------------------------------------------------*/ -int arkInterpResize_Hermite(void* arkode_mem, ARKInterp interp, +int arkInterpResize_Hermite(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector y0) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* resize vectors */ if (interp == NULL) { return (ARK_SUCCESS); } @@ -219,14 +208,8 @@ int arkInterpResize_Hermite(void* arkode_mem, ARKInterp interp, This routine frees the Hermite ARKInterp structure. ---------------------------------------------------------------*/ -void arkInterpFree_Hermite(void* arkode_mem, ARKInterp interp) +void arkInterpFree_Hermite(ARKodeMem ark_mem, ARKInterp interp) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; - /* if interpolation structure is NULL, just return */ if (interp == NULL) { return; } @@ -321,20 +304,13 @@ void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile) polynomial]. Return values: - ARK_MEM_NULL -- if either arkode_mem or interp are NULL ARK_ILL_INPUT -- if the input is outside of allowable bounds ARK_INTERP_FAIL -- if the interpolation module has already been initialized, ARK_SUCCESS -- successful completion. ---------------------------------------------------------------*/ -int arkInterpSetDegree_Hermite(void* arkode_mem, ARKInterp interp, int degree) +int arkInterpSetDegree_Hermite(ARKodeMem ark_mem, ARKInterp interp, int degree) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* if this degree is already stored, just return */ if (abs(degree) == HINT_DEGREE(interp)) { return (ARK_SUCCESS); } @@ -370,14 +346,8 @@ int arkInterpSetDegree_Hermite(void* arkode_mem, ARKInterp interp, int degree) 4. Calls the full RHS routine to fill fnew 5. Copies fnew into fold ---------------------------------------------------------------*/ -int arkInterpInit_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpInit_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* initialize time values */ HINT_TOLD(interp) = tnew; HINT_TNEW(interp) = tnew; @@ -430,14 +400,9 @@ int arkInterpInit_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew) This routine copies ynew into yold, and fnew into fold, so that yold and fold contain the previous values. ---------------------------------------------------------------*/ -int arkInterpUpdate_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpUpdate_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { int retval; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* call full RHS if needed -- called just BEFORE the end of a step, so yn has NOT been updated to ycur yet */ @@ -491,7 +456,7 @@ int arkInterpUpdate_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew where h = tnew-told, i.e. values -1 ARK_INTERP_MAX_DEGREE) { return (NULL); } @@ -932,16 +887,12 @@ ARKInterp arkInterpCreate_Lagrange(void* arkode_mem, int degree) This routine resizes the internal vectors. ---------------------------------------------------------------*/ -int arkInterpResize_Lagrange(void* arkode_mem, ARKInterp I, ARKVecResizeFn resize, - void* resize_data, sunindextype lrw_diff, - sunindextype liw_diff, N_Vector y0) +int arkInterpResize_Lagrange(ARKodeMem ark_mem, ARKInterp I, + ARKVecResizeFn resize, void* resize_data, + sunindextype lrw_diff, sunindextype liw_diff, + N_Vector y0) { int i; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* resize vectors */ if (I == NULL) { return (ARK_SUCCESS); } @@ -968,14 +919,9 @@ int arkInterpResize_Lagrange(void* arkode_mem, ARKInterp I, ARKVecResizeFn resiz This routine frees the Lagrange ARKInterp structure. ---------------------------------------------------------------*/ -void arkInterpFree_Lagrange(void* arkode_mem, ARKInterp I) +void arkInterpFree_Lagrange(ARKodeMem ark_mem, ARKInterp I) { int i; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; /* if interpolation structure is NULL, just return */ if (I == NULL) { return; } @@ -1083,20 +1029,13 @@ void arkInterpPrintMem_Lagrange(ARKInterp I, FILE* outfile) polynomial]. Return values: - ARK_MEM_NULL -- if either arkode_mem or interp are NULL ARK_ILL_INPUT -- if the input is outside of allowable bounds ARK_INTERP_FAIL -- if the interpolation module has already been initialized, ARK_SUCCESS -- successful completion. ---------------------------------------------------------------*/ -int arkInterpSetDegree_Lagrange(void* arkode_mem, ARKInterp I, int degree) +int arkInterpSetDegree_Lagrange(ARKodeMem ark_mem, ARKInterp I, int degree) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* if this degree is already stored, just return */ if (abs(degree) + 1 == LINT_NMAX(I)) { return (ARK_SUCCESS); } @@ -1131,14 +1070,9 @@ int arkInterpSetDegree_Lagrange(void* arkode_mem, ARKInterp I, int degree) 3. copies current (t,y) from main ARKODE memory into history 4. updates the 'active' history counter to 1 ---------------------------------------------------------------*/ -int arkInterpInit_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) +int arkInterpInit_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tnew) { int i; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* check if storage has increased since the last init */ if (LINT_NMAX(I) > LINT_NMAXALLOC(I)) @@ -1224,20 +1158,15 @@ int arkInterpInit_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) into the first history vector Otherwise it just returns with success. ---------------------------------------------------------------*/ -int arkInterpUpdate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) +int arkInterpUpdate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tnew) { int i; - ARKodeMem ark_mem; sunrealtype tdiff; N_Vector ytmp; int nhist, nmax; sunrealtype* thist; N_Vector* yhist; - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* set readability shortcuts */ nhist = LINT_NHIST(I); nmax = LINT_NMAX(I); @@ -1298,7 +1227,7 @@ int arkInterpUpdate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) fixed step sizes, otherwise the stated lower bound is only approximate). ---------------------------------------------------------------*/ -int arkInterpEvaluate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tau, +int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tau, int deriv, int degree, N_Vector yout) { /* local variables */ @@ -1306,15 +1235,10 @@ int arkInterpEvaluate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tau, sunrealtype tval; sunrealtype a[6]; N_Vector X[6]; - ARKodeMem ark_mem; int nhist; sunrealtype* thist; N_Vector* yhist; - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* set readability shortcuts */ nhist = LINT_NHIST(I); thist = LINT_THIST(I); diff --git a/src/arkode/arkode_interp_impl.h b/src/arkode/arkode_interp_impl.h index 502817746e..7222259942 100644 --- a/src/arkode/arkode_interp_impl.h +++ b/src/arkode/arkode_interp_impl.h @@ -71,18 +71,19 @@ typedef struct _ARKInterpContent_Hermite* ARKInterpContent_Hermite; /* Hermite structure operations */ -ARKInterp arkInterpCreate_Hermite(void* arkode_mem, int degree); +ARKInterp arkInterpCreate_Hermite(ARKodeMem ark_mem, int degree); -int arkInterpResize_Hermite(void* arkode_mem, ARKInterp interp, +int arkInterpResize_Hermite(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); -void arkInterpFree_Hermite(void* arkode_mem, ARKInterp interp); +void arkInterpFree_Hermite(ARKodeMem ark_mem, ARKInterp interp); void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile); -int arkInterpSetDegree_Hermite(void* arkode_mem, ARKInterp interp, int degree); -int arkInterpInit_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpUpdate_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpEvaluate_Hermite(void* arkode_mem, ARKInterp interp, +int arkInterpSetDegree_Hermite(ARKodeMem ark_mem, ARKInterp interp, int degree); +int arkInterpInit_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpUpdate_Hermite(ARKodeMem ark_mem, ARKInterp interp, + sunrealtype tnew); +int arkInterpEvaluate_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); /*=============================================================== @@ -117,19 +118,19 @@ typedef struct _ARKInterpContent_Lagrange* ARKInterpContent_Lagrange; /* Lagrange structure operations */ -ARKInterp arkInterpCreate_Lagrange(void* arkode_mem, int degree); +ARKInterp arkInterpCreate_Lagrange(ARKodeMem ark_mem, int degree); -int arkInterpResize_Lagrange(void* arkode_mem, ARKInterp interp, +int arkInterpResize_Lagrange(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); -void arkInterpFree_Lagrange(void* arkode_mem, ARKInterp interp); +void arkInterpFree_Lagrange(ARKodeMem ark_mem, ARKInterp interp); void arkInterpPrintMem_Lagrange(ARKInterp interp, FILE* outfile); -int arkInterpSetDegree_Lagrange(void* arkode_mem, ARKInterp interp, int degree); -int arkInterpInit_Lagrange(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpUpdate_Lagrange(void* arkode_mem, ARKInterp interp, +int arkInterpSetDegree_Lagrange(ARKodeMem ark_mem, ARKInterp interp, int degree); +int arkInterpInit_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpUpdate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpEvaluate_Lagrange(void* arkode_mem, ARKInterp interp, +int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); /* Lagrange structure utility routines */ diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 55e380a2b7..f09db2c998 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -131,7 +131,8 @@ int ARKodeSetOrder(void* arkode_mem, int ord) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -278,8 +279,8 @@ int ARKodeSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -290,7 +291,8 @@ int ARKodeSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -325,8 +327,8 @@ int ARKodeSetLinear(void* arkode_mem, int timedepend) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -337,7 +339,8 @@ int ARKodeSetLinear(void* arkode_mem, int timedepend) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -363,8 +366,8 @@ int ARKodeSetNonlinear(void* arkode_mem) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -375,7 +378,8 @@ int ARKodeSetNonlinear(void* arkode_mem) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -402,8 +406,8 @@ int ARKodeSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -414,7 +418,8 @@ int ARKodeSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -446,8 +451,8 @@ int ARKodeSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -458,7 +463,8 @@ int ARKodeSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -485,8 +491,8 @@ int ARKodeSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -497,7 +503,8 @@ int ARKodeSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -524,8 +531,8 @@ int ARKodeSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -536,7 +543,8 @@ int ARKodeSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -563,8 +571,8 @@ int ARKodeSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -575,7 +583,8 @@ int ARKodeSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -603,8 +612,8 @@ int ARKodeSetLSetupFrequency(void* arkode_mem, int msbp) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -615,7 +624,8 @@ int ARKodeSetLSetupFrequency(void* arkode_mem, int msbp) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -640,8 +650,8 @@ int ARKodeSetPredictorMethod(void* arkode_mem, int pred_method) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -652,7 +662,8 @@ int ARKodeSetPredictorMethod(void* arkode_mem, int pred_method) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -679,8 +690,8 @@ int ARKodeSetMaxNonlinIters(void* arkode_mem, int maxcor) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -691,7 +702,8 @@ int ARKodeSetMaxNonlinIters(void* arkode_mem, int maxcor) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -717,8 +729,8 @@ int ARKodeSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -729,7 +741,8 @@ int ARKodeSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -754,8 +767,8 @@ int ARKodeSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -766,7 +779,8 @@ int ARKodeSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -833,8 +847,8 @@ int ARKodeSetAdaptController(void* arkode_mem, SUNAdaptController C) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -928,8 +942,8 @@ int ARKodeSetMaxHnilWarns(void* arkode_mem, int mxhnil) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -960,8 +974,8 @@ int ARKodeSetInitStep(void* arkode_mem, sunrealtype hin) /* Guard against hin==0 for non-adaptive time stepper modules */ if ((!ark_mem->step_supports_adaptive) && (hin == ZERO)) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -998,8 +1012,8 @@ int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1044,8 +1058,8 @@ int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1362,8 +1376,8 @@ int ARKodeSetConstraints(void* arkode_mem, N_Vector constraints) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive && (constraints != NULL)) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1428,8 +1442,8 @@ int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1753,8 +1767,8 @@ int ARKodeSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1793,8 +1807,8 @@ int ARKodeSetAdaptivityAdjustment(void* arkode_mem, int adjust) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1822,8 +1836,8 @@ int ARKodeSetSafetyFactor(void* arkode_mem, sunrealtype safety) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1860,8 +1874,8 @@ int ARKodeSetErrorBias(void* arkode_mem, sunrealtype bias) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1902,8 +1916,8 @@ int ARKodeSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1933,8 +1947,8 @@ int ARKodeSetMinReduction(void* arkode_mem, sunrealtype eta_min) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1963,8 +1977,8 @@ int ARKodeSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2001,8 +2015,8 @@ int ARKodeSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2031,8 +2045,8 @@ int ARKodeSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2061,8 +2075,8 @@ int ARKodeSetSmallNumEFails(void* arkode_mem, int small_nef) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2091,8 +2105,8 @@ int ARKodeSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2121,8 +2135,8 @@ int ARKodeSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2162,8 +2176,8 @@ int ARKodeSetMaxErrTestFails(void* arkode_mem, int maxnef) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2194,8 +2208,8 @@ int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2205,29 +2219,6 @@ int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - ARKodeSetUseCompensatedSums: - - Specifies that ARKODE should use compensated (Kahan) summation - where relevant to mitigate roundoff error. - ---------------------------------------------------------------*/ -int ARKodeSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) -{ - 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; - - if (onoff) { ark_mem->use_compensated_sums = SUNTRUE; } - else { ark_mem->use_compensated_sums = SUNFALSE; } - - return (ARK_SUCCESS); -} - /*=============================================================== ARKODE optional output utility functions ===============================================================*/ @@ -2411,19 +2402,20 @@ int ARKodeGetCurrentGamma(void* arkode_mem, sunrealtype* gamma) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_getcurrentgamma) { - return (ark_mem->step_getcurrentgamma(arkode_mem, gamma)); + return (ark_mem->step_getcurrentgamma(ark_mem, gamma)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2488,8 +2480,8 @@ int ARKodeGetResWeights(void* arkode_mem, N_Vector rweight) /* Guard against use for time steppers that do not support mass matrices */ if (!ark_mem->step_supports_massmatrix) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support non-identity mass matrices"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2620,8 +2612,8 @@ int ARKodeGetNumConstrFails(void* arkode_mem, long int* nconstrfails) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2648,8 +2640,8 @@ int ARKodeGetNumExpSteps(void* arkode_mem, long int* nsteps) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2676,8 +2668,8 @@ int ARKodeGetNumAccSteps(void* arkode_mem, long int* nsteps) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2704,8 +2696,8 @@ int ARKodeGetNumErrTestFails(void* arkode_mem, long int* netfails) /* Guard against use for non-adaptive time stepper modules */ if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not support temporal adaptivity"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2733,7 +2725,8 @@ int ARKodeComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) /* Guard against use for incompatible time stepper modules */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support algebraic solvers"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2741,11 +2734,12 @@ int ARKodeComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_computestate) { - return (ark_mem->step_computestate(arkode_mem, zcor, z)); + return (ark_mem->step_computestate(ark_mem, zcor, z)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2774,7 +2768,8 @@ int ARKodeGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, /* Guard against use for incompatible time stepper modules */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support algebraic solvers"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2782,12 +2777,13 @@ int ARKodeGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_getnonlinearsystemdata) { - return (ark_mem->step_getnonlinearsystemdata(arkode_mem, tcur, zpred, z, Fi, + return (ark_mem->step_getnonlinearsystemdata(ark_mem, tcur, zpred, z, Fi, gamma, sdata, user_data)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2812,7 +2808,8 @@ int ARKodeGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) /* Guard against use for incompatible time stepper modules */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support algebraic solvers"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2820,11 +2817,12 @@ int ARKodeGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_getnumnonlinsolviters) { - return (ark_mem->step_getnumnonlinsolviters(arkode_mem, nniters)); + return (ark_mem->step_getnumnonlinsolviters(ark_mem, nniters)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2849,19 +2847,20 @@ int ARKodeGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_getnumnonlinsolvconvfails) { - return (ark_mem->step_getnumnonlinsolvconvfails(arkode_mem, nnfails)); + return (ark_mem->step_getnumnonlinsolvconvfails(ark_mem, nnfails)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2887,19 +2886,20 @@ int ARKodeGetNonlinSolvStats(void* arkode_mem, long int* nniters, /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_getnonlinsolvstats) { - return (ark_mem->step_getnonlinsolvstats(arkode_mem, nniters, nnfails)); + return (ark_mem->step_getnonlinsolvstats(ark_mem, nniters, nnfails)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2925,8 +2925,8 @@ int ARKodeGetNumStepSolveFails(void* arkode_mem, long int* nncfails) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -2953,19 +2953,20 @@ int ARKodeGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } /* Call stepper routine to compute the state (if provided) */ if (ark_mem->step_getnumlinsolvsetups) { - return (ark_mem->step_getnumlinsolvsetups(arkode_mem, nlinsetups)); + return (ark_mem->step_getnumlinsolvsetups(ark_mem, nlinsetups)); } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support this function"); return (ARK_STEPPER_UNSUPPORTED); } @@ -3065,14 +3066,14 @@ int ARKodePrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* Print relaxation stats */ if (ark_mem->relax_enabled) { - retval = arkRelaxPrintAllStats(arkode_mem, outfile, fmt); + retval = arkRelaxPrintAllStats(ark_mem, outfile, fmt); if (retval != ARK_SUCCESS) { return (retval); } } /* Print stepper stats (if provided) */ if (ark_mem->step_printallstats) { - return (ark_mem->step_printallstats(arkode_mem, outfile, fmt)); + return (ark_mem->step_printallstats(ark_mem, outfile, fmt)); } return (ARK_SUCCESS); diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index 63ab562f66..a9198a5c7a 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -35,7 +35,7 @@ /* Prototypes for internal functions */ static int arkLsLinSys(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, SUNMatrix M, sunbooleantype jok, sunbooleantype* jcur, - sunrealtype gamma, void* user_data, N_Vector tmp1, + sunrealtype gamma, void* arkode_mem, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); /*=============================================================== @@ -66,8 +66,8 @@ int ARKodeSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -189,7 +189,7 @@ int ARKodeSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) arkls_mem->jtsetup = NULL; arkls_mem->jtimes = arkLsDQJtimes; arkls_mem->Jt_data = ark_mem; - arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(arkode_mem); + arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(ark_mem); if (arkls_mem->Jt_f == NULL) { @@ -285,7 +285,7 @@ int ARKodeSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) else { arkls_mem->scalesol = SUNFALSE; } /* Attach ARKLs interface to time stepper module */ - retval = ark_mem->step_attachlinsol(arkode_mem, arkLsInitialize, arkLsSetup, + retval = ark_mem->step_attachlinsol(ark_mem, arkLsInitialize, arkLsSetup, arkLsSolve, arkLsFree, LSType, arkls_mem); if (retval != ARK_SUCCESS) { @@ -518,7 +518,7 @@ int ARKodeSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, if (iterative) { arkls_mem->nrmfac = SUNRsqrt(N_VGetLength(arkls_mem->x)); } /* Attach ARKLs interface to time stepper module */ - retval = ark_mem->step_attachmasssol(arkode_mem, arkLsMassInitialize, + retval = ark_mem->step_attachmasssol(ark_mem, arkLsMassInitialize, arkLsMassSetup, arkLsMTimes, arkLsMassSolve, arkLsMassFree, time_dep, LSType, arkls_mem); @@ -549,15 +549,15 @@ int ARKodeSetJacFn(void* arkode_mem, ARKLsJacFn jac) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -600,8 +600,8 @@ int ARKodeSetMassFn(void* arkode_mem, ARKLsMassFn mass) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -643,15 +643,15 @@ int ARKodeSetEpsLin(void* arkode_mem, sunrealtype eplifac) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -672,15 +672,15 @@ int ARKodeSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -715,15 +715,15 @@ int ARKodeSetJacEvalFrequency(void* arkode_mem, long int msbj) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -743,15 +743,15 @@ int ARKodeSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -777,15 +777,15 @@ int ARKodeSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, SUNPSolveFn arkls_psolve; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -828,15 +828,15 @@ int ARKodeSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -863,7 +863,7 @@ int ARKodeSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, arkls_mem->jtsetup = NULL; arkls_mem->jtimes = arkLsDQJtimes; arkls_mem->Jt_data = ark_mem; - arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(arkode_mem); + arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(ark_mem); if (arkls_mem->Jt_f == NULL) { @@ -887,15 +887,15 @@ int ARKodeSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -911,7 +911,7 @@ int ARKodeSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) if (jtimesRhsFn != NULL) { arkls_mem->Jt_f = jtimesRhsFn; } else { - arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(arkode_mem); + arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(ark_mem); if (arkls_mem->Jt_f == NULL) { @@ -931,15 +931,15 @@ int ARKodeSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARKLS_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -969,14 +969,13 @@ int ARKodeSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) } /* arkLSSetUserData sets user_data pointers in arkLS */ -int arkLSSetUserData(void* arkode_mem, void* user_data) +int arkLSSetUserData(ARKodeMem ark_mem, void* user_data) { - ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARKLS_SUCCESS) { return (retval); } /* Set data for Jacobian */ @@ -1004,15 +1003,15 @@ int ARKodeGetJac(void* arkode_mem, SUNMatrix* J) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARKLS_SUCCESS) { return retval; } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1027,15 +1026,15 @@ int ARKodeGetJacTime(void* arkode_mem, sunrealtype* t_J) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARKLS_SUCCESS) { return retval; } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1050,15 +1049,15 @@ int ARKodeGetJacNumSteps(void* arkode_mem, long int* nst_J) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARKLS_SUCCESS) { return retval; } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1079,15 +1078,15 @@ int ARKodeGetLinWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) long int lrw, liw; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1140,15 +1139,15 @@ int ARKodeGetNumJacEvals(void* arkode_mem, long int* njevals) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1168,15 +1167,15 @@ int ARKodeGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1195,15 +1194,15 @@ int ARKodeGetNumPrecEvals(void* arkode_mem, long int* npevals) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1222,15 +1221,15 @@ int ARKodeGetNumPrecSolves(void* arkode_mem, long int* npsolves) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1249,15 +1248,15 @@ int ARKodeGetNumLinIters(void* arkode_mem, long int* nliters) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1276,15 +1275,15 @@ int ARKodeGetNumLinConvFails(void* arkode_mem, long int* nlcfails) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1303,15 +1302,15 @@ int ARKodeGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1330,15 +1329,15 @@ int ARKodeGetNumJtimesEvals(void* arkode_mem, long int* njvevals) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1357,8 +1356,8 @@ int ARKodeGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups) ARKLsMassMem arkls_mem; int retval; - /* access ARKMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1384,15 +1383,15 @@ int ARKodeGetLastLinFlag(void* arkode_mem, long int* flag) ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not need an algebraic solver */ if (!ark_mem->step_supports_algebraic) { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, - "time-stepping module does not require an algebraic solver"); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); return (ARK_STEPPER_UNSUPPORTED); } @@ -1440,8 +1439,8 @@ int ARKodeSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1469,8 +1468,8 @@ int ARKodeSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1515,8 +1514,8 @@ int ARKodeSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, SUNPSolveFn arkls_mpsolve; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1566,8 +1565,8 @@ int ARKodeSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1613,14 +1612,13 @@ int ARKodeSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, } /* arkLSMassSetUserData sets user_data pointers in arkLSMass */ -int arkLSSetMassUserData(void* arkode_mem, void* user_data) +int arkLSSetMassUserData(ARKodeMem ark_mem, void* user_data) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; /* access ARKLsMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARKLS_SUCCESS) { return (retval); } /* Set data for mass matrix */ @@ -1645,8 +1643,8 @@ int ARKodeGetMassWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) long int lrw, liw; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1707,8 +1705,8 @@ int ARKodeGetNumMassSetups(void* arkode_mem, long int* nmsetups) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1734,8 +1732,8 @@ int ARKodeGetNumMassMult(void* arkode_mem, long int* nmvevals) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1761,8 +1759,8 @@ int ARKodeGetNumMassSolves(void* arkode_mem, long int* nmsolves) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1788,8 +1786,8 @@ int ARKodeGetNumMassPrecEvals(void* arkode_mem, long int* npevals) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1815,8 +1813,8 @@ int ARKodeGetNumMassPrecSolves(void* arkode_mem, long int* npsolves) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1842,8 +1840,8 @@ int ARKodeGetNumMassIters(void* arkode_mem, long int* nmiters) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1869,8 +1867,8 @@ int ARKodeGetNumMassConvFails(void* arkode_mem, long int* nmcfails) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1895,8 +1893,8 @@ int ARKodeGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1922,8 +1920,8 @@ int ARKodeGetNumMTSetups(void* arkode_mem, long int* nmtsetups) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1949,8 +1947,8 @@ int ARKodeGetLastMassFlag(void* arkode_mem, long int* flag) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Guard against use for time steppers that do not support mass matrices */ @@ -1990,8 +1988,8 @@ int arkLsATimes(void* arkode_mem, N_Vector v, N_Vector z) sunrealtype gamma, gamrat; sunbooleantype dgamma_fail, *jcur; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Access mass matrix solver (if it exists) */ @@ -2049,8 +2047,8 @@ int arkLsPSetup(void* arkode_mem) sunbooleantype dgamma_fail, *jcur; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get gamma values from time step module */ @@ -2090,8 +2088,8 @@ int arkLsPSolve(void* arkode_mem, N_Vector r, N_Vector z, sunrealtype tol, int l sunbooleantype dgamma_fail, *jcur; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get gamma values from time step module */ @@ -2125,8 +2123,8 @@ int arkLsMTimes(void* arkode_mem, N_Vector v, N_Vector z) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* perform multiply by either calling the user-supplied routine @@ -2181,8 +2179,8 @@ int arkLsMPSetup(void* arkode_mem) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* only proceed if the mass matrix is time-independent or if @@ -2212,8 +2210,8 @@ int arkLsMPSolve(void* arkode_mem, N_Vector r, N_Vector z, sunrealtype tol, int ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* call the user-supplied psolve routine, and accumulate count */ @@ -2237,8 +2235,8 @@ int arkLsDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, ARKRhsFn fi; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* verify that Jac is non-NULL */ @@ -2511,8 +2509,8 @@ int arkLsDQJtimes(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, sunrealtype sig, siginv; int iter, retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Initialize perturbation to 1/||v|| */ @@ -2557,8 +2555,8 @@ static int arkLsLinSys(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARKLS_SUCCESS) { return (retval); } /* Check if Jacobian needs to be updated */ @@ -2642,25 +2640,23 @@ static int arkLsLinSys(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, arkLsInitialize performs remaining initializations specific to the linear solver interface (and solver itself) ---------------------------------------------------------------*/ -int arkLsInitialize(void* arkode_mem) +int arkLsInitialize(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMem arkls_mem; ARKLsMassMem arkls_massmem; int retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* access ARKLsMassMem (if applicable) */ arkls_massmem = NULL; if (ark_mem->step_getmassmem != NULL) { - if (ark_mem->step_getmassmem(arkode_mem) != NULL) + if (ark_mem->step_getmassmem(ark_mem) != NULL) { - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, - &arkls_massmem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_massmem); if (retval != ARK_SUCCESS) { return (retval); } } } @@ -2801,13 +2797,13 @@ int arkLsInitialize(void* arkode_mem) if ((arkls_mem->A == NULL) && (arkls_mem->pset == NULL) && (ark_mem->step_disablelsetup != NULL)) { - ark_mem->step_disablelsetup(arkode_mem); + ark_mem->step_disablelsetup(ark_mem); } /* When using a matrix-embedded linear solver, disable lsetup call and solution scaling */ if (SUNLinSolGetType(arkls_mem->LS) == SUNLINEARSOLVER_MATRIX_EMBEDDED) { - ark_mem->step_disablelsetup(arkode_mem); + ark_mem->step_disablelsetup(ark_mem); arkls_mem->scalesol = SUNFALSE; } @@ -2829,11 +2825,10 @@ int arkLsInitialize(void* arkode_mem) This routine then calls the LS 'setup' routine with A. ---------------------------------------------------------------*/ -int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, +int arkLsSetup(ARKodeMem ark_mem, int convfail, sunrealtype tpred, N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3) { - ARKodeMem ark_mem = NULL; ARKLsMem arkls_mem = NULL; void* ark_step_massmem = NULL; SUNMatrix M = NULL; @@ -2842,7 +2837,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, int retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Immediately return when using matrix-embedded linear solver */ @@ -2859,7 +2854,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, arkls_mem->fcur = fpred; /* get gamma values from time step module */ - arkls_mem->last_flag = ark_mem->step_getgammas(arkode_mem, &gamma, &gamrat, + arkls_mem->last_flag = ark_mem->step_getgammas(ark_mem, &gamma, &gamrat, &jcur, &dgamma_fail); if (arkls_mem->last_flag) { @@ -2880,7 +2875,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, /* Check for mass matrix module and setup mass matrix */ if (ark_mem->step_getmassmem) { - ark_step_massmem = ark_mem->step_getmassmem(arkode_mem); + ark_step_massmem = ark_mem->step_getmassmem(ark_mem); } if (ark_step_massmem) @@ -2889,8 +2884,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, M = ((ARKLsMassMem)ark_step_massmem)->M; /* Setup mass matrix linear solver (including recomputation of mass matrix) */ - arkls_mem->last_flag = arkLsMassSetup(arkode_mem, tpred, vtemp1, vtemp2, - vtemp3); + arkls_mem->last_flag = arkLsMassSetup(ark_mem, tpred, vtemp1, vtemp2, vtemp3); if (arkls_mem->last_flag) { arkProcessError(ark_mem, ARKLS_SUNMAT_FAIL, __LINE__, __func__, __FILE__, @@ -2973,11 +2967,10 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, When using a non-NULL SUNMatrix, this will additionally scale the solution appropriately when gamrat != 1. ---------------------------------------------------------------*/ -int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, +int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, N_Vector fnow, sunrealtype eRNrm, int mnewt) { sunrealtype bnorm, resnorm; - ARKodeMem ark_mem; ARKLsMem arkls_mem; sunrealtype gamma, gamrat, delta, deltar, rwt_mean; sunbooleantype dgamma_fail, *jcur; @@ -2985,7 +2978,7 @@ int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, int nli_inc, retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set scalar tcur and vectors ycur and fcur for use by the @@ -3079,7 +3072,7 @@ int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, account for change in gamma (this is only beneficial if M==I) */ if (arkls_mem->scalesol) { - arkls_mem->last_flag = ark_mem->step_getgammas(arkode_mem, &gamma, &gamrat, + arkls_mem->last_flag = ark_mem->step_getgammas(ark_mem, &gamma, &gamrat, &jcur, &dgamma_fail); if (arkls_mem->last_flag != ARK_SUCCESS) { @@ -3169,16 +3162,14 @@ int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, arkLsFree frees memory associates with the ARKLs system solver interface. ---------------------------------------------------------------*/ -int arkLsFree(void* arkode_mem) +int arkLsFree(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMem arkls_mem; void* ark_step_lmem; /* Return immediately if ARKodeMem, ARKLsMem are NULL */ - if (arkode_mem == NULL) { return (ARKLS_SUCCESS); } - ark_mem = (ARKodeMem)arkode_mem; - ark_step_lmem = ark_mem->step_getlinmem(arkode_mem); + if (ark_mem == NULL) { return (ARKLS_SUCCESS); } + ark_step_lmem = ark_mem->step_getlinmem(ark_mem); if (ark_step_lmem == NULL) { return (ARKLS_SUCCESS); } arkls_mem = (ARKLsMem)ark_step_lmem; @@ -3221,14 +3212,13 @@ int arkLsFree(void* arkode_mem) arkLsMassInitialize performs remaining initializations specific to the mass matrix solver interface (and solver itself) ---------------------------------------------------------------*/ -int arkLsMassInitialize(void* arkode_mem) +int arkLsMassInitialize(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* reset counters */ @@ -3280,13 +3270,13 @@ int arkLsMassInitialize(void* arkode_mem) if ((arkls_mem->M == NULL) && (arkls_mem->pset == NULL) && (arkls_mem->mtsetup == NULL) && (ark_mem->step_disablemsetup != NULL)) { - ark_mem->step_disablemsetup(arkode_mem); + ark_mem->step_disablemsetup(ark_mem); } /* When using a matrix-embedded linear solver, disable lsetup call */ if (SUNLinSolGetType(arkls_mem->LS) == SUNLINEARSOLVER_MATRIX_EMBEDDED) { - ark_mem->step_disablemsetup(arkode_mem); + ark_mem->step_disablemsetup(ark_mem); } /* Call LS initialize routine */ @@ -3297,16 +3287,15 @@ int arkLsMassInitialize(void* arkode_mem) /*--------------------------------------------------------------- arkLsMassSetup calls the LS 'setup' routine. ---------------------------------------------------------------*/ -int arkLsMassSetup(void* arkode_mem, sunrealtype t, N_Vector vtemp1, +int arkLsMassSetup(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; sunbooleantype call_mtsetup, call_mvsetup, call_lssetup; int retval; /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Immediately return when using matrix-embedded linear solver */ @@ -3451,16 +3440,15 @@ int arkLsMassSetup(void* arkode_mem, sunrealtype t, N_Vector vtemp1, and scaling vectors, calling the solver, and accumulating statistics from the solve for use/reporting by ARKODE. ---------------------------------------------------------------*/ -int arkLsMassSolve(void* arkode_mem, N_Vector b, sunrealtype nlscoef) +int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef) { sunrealtype resnorm, delta, rwt_mean; - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; long int nps_inc; int nli_inc, retval; /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set input tolerance for iterative solvers (in 2-norm) */ @@ -3596,16 +3584,14 @@ int arkLsMassSolve(void* arkode_mem, N_Vector b, sunrealtype nlscoef) arkLsMassFree frees memory associates with the ARKLs mass matrix solver interface. ---------------------------------------------------------------*/ -int arkLsMassFree(void* arkode_mem) +int arkLsMassFree(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; void* ark_step_massmem; /* Return immediately if ARKodeMem, ARKLsMassMem are NULL */ - if (arkode_mem == NULL) { return (ARKLS_SUCCESS); } - ark_mem = (ARKodeMem)arkode_mem; - ark_step_massmem = ark_mem->step_getmassmem(arkode_mem); + if (ark_mem == NULL) { return (ARKLS_SUCCESS); } + ark_step_massmem = ark_mem->step_getmassmem(ark_mem); if (ark_step_massmem == NULL) { return (ARKLS_SUCCESS); } arkls_mem = (ARKLsMassMem)ark_step_massmem; @@ -3691,14 +3677,16 @@ int arkLsInitializeMassCounters(ARKLsMassMem arkls_mem) } /*--------------------------------------------------------------- - arkLs_AccessLMem and arkLs_AccessMassMem: + arkLs_AccessARKODELMem, arkLs_AccessLMem, + arkLs_AccessARKODEMassMem and arkLs_AccessMassMem: Shortcut routines to unpack ark_mem, ls_mem and mass_mem - structures from void* pointer. If any is missing it returns - ARKLS_MEM_NULL, ARKLS_LMEM_NULL or ARKLS_MASSMEM_NULL. + structures from void* pointer and ark_mem structure. If any + is missing it returns ARKLS_MEM_NULL, ARKLS_LMEM_NULL or + ARKLS_MASSMEM_NULL. ---------------------------------------------------------------*/ -int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKLsMem* arkls_mem) +int arkLs_AccessARKODELMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMem* arkls_mem) { void* ark_step_lmem; if (arkode_mem == NULL) @@ -3708,7 +3696,7 @@ int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; - ark_step_lmem = (*ark_mem)->step_getlinmem(arkode_mem); + ark_step_lmem = (*ark_mem)->step_getlinmem(*ark_mem); if (ark_step_lmem == NULL) { arkProcessError(*ark_mem, ARKLS_LMEM_NULL, __LINE__, fname, __FILE__, @@ -3719,8 +3707,22 @@ int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_SUCCESS); } -int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKLsMassMem* arkls_mem) +int arkLs_AccessLMem(ARKodeMem ark_mem, const char* fname, ARKLsMem* arkls_mem) +{ + void* ark_step_lmem; + ark_step_lmem = ark_mem->step_getlinmem(ark_mem); + if (ark_step_lmem == NULL) + { + arkProcessError(ark_mem, ARKLS_LMEM_NULL, __LINE__, fname, __FILE__, + MSG_LS_LMEM_NULL); + return (ARKLS_LMEM_NULL); + } + *arkls_mem = (ARKLsMem)ark_step_lmem; + return (ARKLS_SUCCESS); +} + +int arkLs_AccessARKODEMassMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMassMem* arkls_mem) { void* ark_step_massmem; if (arkode_mem == NULL) @@ -3730,7 +3732,7 @@ int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; - ark_step_massmem = (*ark_mem)->step_getmassmem(arkode_mem); + ark_step_massmem = (*ark_mem)->step_getmassmem(*ark_mem); if (ark_step_massmem == NULL) { arkProcessError(*ark_mem, ARKLS_MASSMEM_NULL, __LINE__, fname, __FILE__, @@ -3741,6 +3743,21 @@ int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_SUCCESS); } +int arkLs_AccessMassMem(ARKodeMem ark_mem, const char* fname, + ARKLsMassMem* arkls_mem) +{ + void* ark_step_massmem; + ark_step_massmem = ark_mem->step_getmassmem(ark_mem); + if (ark_step_massmem == NULL) + { + arkProcessError(ark_mem, ARKLS_MASSMEM_NULL, __LINE__, fname, __FILE__, + MSG_LS_MASSMEM_NULL); + return (ARKLS_MASSMEM_NULL); + } + *arkls_mem = (ARKLsMassMem)ark_step_massmem; + return (ARKLS_SUCCESS); +} + /*--------------------------------------------------------------- EOF ---------------------------------------------------------------*/ diff --git a/src/arkode/arkode_ls_impl.h b/src/arkode/arkode_ls_impl.h index c13797391e..21c869536e 100644 --- a/src/arkode/arkode_ls_impl.h +++ b/src/arkode/arkode_ls_impl.h @@ -217,51 +217,56 @@ int arkLsBandDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, N_Vector tmp1, N_Vector tmp2); /* Generic linit/lsetup/lsolve/lfree interface routines for ARKODE to call */ -int arkLsInitialize(void* arkode_mem); +int arkLsInitialize(ARKodeMem ark_mem); -int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, +int arkLsSetup(ARKodeMem ark_mem, int convfail, sunrealtype tpred, N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); -int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tcur, N_Vector ycur, +int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tcur, N_Vector ycur, N_Vector fcur, sunrealtype eRnrm, int mnewt); -int arkLsFree(void* arkode_mem); +int arkLsFree(ARKodeMem ark_mem); /* Generic minit/msetup/mmult/msolve/mfree routines for ARKODE to call */ -int arkLsMassInitialize(void* arkode_mem); +int arkLsMassInitialize(ARKodeMem ark_mem); -int arkLsMassSetup(void* arkode_mem, sunrealtype t, N_Vector vtemp1, +int arkLsMassSetup(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); int arkLsMassMult(void* arkode_mem, N_Vector v, N_Vector Mv); -int arkLsMassSolve(void* arkode_mem, N_Vector b, sunrealtype nlscoef); +int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef); -int arkLsMassFree(void* arkode_mem); +int arkLsMassFree(ARKodeMem ark_mem); /* Auxilliary functions */ int arkLsInitializeCounters(ARKLsMem arkls_mem); int arkLsInitializeMassCounters(ARKLsMassMem arkls_mem); -int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKLsMem* arkls_mem); +int arkLs_AccessARKODELMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMem* arkls_mem); -int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, +int arkLs_AccessLMem(ARKodeMem ark_mem, const char* fname, ARKLsMem* arkls_mem); + +int arkLs_AccessARKODEMassMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMassMem* arkls_mem); + +int arkLs_AccessMassMem(ARKodeMem ark_mem, const char* fname, ARKLsMassMem* arkls_mem); /* Set/get routines called by time-stepper module */ -int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A); +int arkLSSetLinearSolver(ARKodeMem ark_mem, SUNLinearSolver LS, SUNMatrix A); -int arkLSSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, +int arkLSSetMassLinearSolver(ARKodeMem ark_mem, SUNLinearSolver LS, SUNMatrix M, sunbooleantype time_dep); -int arkLSSetUserData(void* arkode_mem, void* user_data); +int arkLSSetUserData(ARKodeMem ark_mem, void* user_data); -int arkLSSetMassUserData(void* arkode_mem, void* user_data); +int arkLSSetMassUserData(ARKodeMem ark_mem, void* user_data); -int arkLSGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M); +int arkLSGetCurrentMassMatrix(ARKodeMem ark_mem, SUNMatrix* M); /*--------------------------------------------------------------- Error Messages diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 3bc477e217..8485b85eb7 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -252,17 +252,16 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, This routine resizes the memory within the MRIStep module. ---------------------------------------------------------------*/ -int mriStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; SUNNonlinearSolver NLS; sunindextype lrw1, liw1, lrw_diff, liw_diff; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Determine change in vector sizes */ @@ -395,8 +394,8 @@ int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, SUNNonlinearSolver NLS; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -481,14 +480,13 @@ int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, values are retained). It is called after the main ARKODE infrastructure is reset. ---------------------------------------------------------------*/ -int mriStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR) +int mriStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Reset the inner integrator with this same state */ @@ -503,14 +501,13 @@ int mriStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR) Computes y based on the current prediction and given correction. ---------------------------------------------------------------*/ -int mriStep_ComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) +int mriStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z) { int retval; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } N_VLinearSum(ONE, step_mem->zpred, ONE, zcor, z); @@ -521,17 +518,15 @@ int mriStep_ComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) /*--------------------------------------------------------------- mriStep_Free frees all MRIStep memory. ---------------------------------------------------------------*/ -void mriStep_Free(void* arkode_mem) +void mriStep_Free(ARKodeMem ark_mem) { sunindextype Cliw, Clrw; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; - /* nothing to do if arkode_mem is already NULL */ - if (arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL MRIStep module */ - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem != NULL) { step_mem = (ARKodeMRIStepMem)ark_mem->step_mem; @@ -644,14 +639,13 @@ void mriStep_Free(void* arkode_mem) This routine outputs the memory from the MRIStep structure to a specified file pointer (useful when debugging). ---------------------------------------------------------------*/ -void mriStep_PrintMem(void* arkode_mem, FILE* outfile) +void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int i, retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } /* output integer quantities */ @@ -755,21 +749,20 @@ void mriStep_PrintMem(void* arkode_mem, FILE* outfile) interface routines, data structure, and solver type to the MRIStep module. ---------------------------------------------------------------*/ -int mriStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int mriStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* free any existing system solver */ - if (step_mem->lfree != NULL) { step_mem->lfree(arkode_mem); } + if (step_mem->lfree != NULL) { step_mem->lfree(ark_mem); } /* Attach the provided routines, data structure and solve type */ step_mem->linit = linit; @@ -791,14 +784,13 @@ int mriStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, This routine NULLifies the lsetup function pointer in the MRIStep module. ---------------------------------------------------------------*/ -void mriStep_DisableLSetup(void* arkode_mem) +void mriStep_DisableLSetup(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } /* nullify the lsetup function pointer */ @@ -811,14 +803,13 @@ void mriStep_DisableLSetup(void* arkode_mem) This routine returns the system linear solver interface memory structure, lmem. ---------------------------------------------------------------*/ -void* mriStep_GetLmem(void* arkode_mem) +void* mriStep_GetLmem(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure, and return lmem */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->lmem); } @@ -828,14 +819,13 @@ void* mriStep_GetLmem(void* arkode_mem) This routine returns the implicit RHS function pointer, fi. ---------------------------------------------------------------*/ -ARKRhsFn mriStep_GetImplicitRHS(void* arkode_mem) +ARKRhsFn mriStep_GetImplicitRHS(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure, and return fi */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } if (step_mem->implicit_rhs) { return (step_mem->fsi); } else { return (NULL); } @@ -847,15 +837,14 @@ ARKRhsFn mriStep_GetImplicitRHS(void* arkode_mem) This routine fills the current value of gamma, and states whether the gamma ratio fails the dgmax criteria. ---------------------------------------------------------------*/ -int mriStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set outputs */ @@ -881,15 +870,14 @@ int mriStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int mriStep_Init(void* arkode_mem, int init_type) +int mriStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval, j; sunbooleantype reset_efun; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if reset */ @@ -1181,15 +1169,14 @@ int mriStep_Init(void* arkode_mem, int init_type) Presently ff(t,y) is always called with ARK_FULLRHS_OTHER mode. ----------------------------------------------------------------------------*/ -int mriStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* ensure that inner stepper provides fullrhs function */ @@ -1420,9 +1407,8 @@ int mriStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int mriStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem; /* outer ARKODE memory */ ARKodeMRIStepMem step_mem; /* outer stepper memory */ int is; /* current stage index */ int retval; /* reusable return flag */ @@ -1433,7 +1419,7 @@ int mriStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) *dsmPtr = ZERO; /* access the MRIStep mem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* call nonlinear solver setup if it exists */ @@ -1639,13 +1625,13 @@ int mriStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) ---------------------------------------------------------------*/ /*--------------------------------------------------------------- - mriStep_AccessStepMem: + mriStep_AccessARKODEStepMem: Shortcut routine to unpack ark_mem and step_mem structures from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int mriStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem) +int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -1655,6 +1641,8 @@ int mriStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeMRIStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -1665,6 +1653,26 @@ int mriStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + mriStep_AccessStepMem: + + Shortcut routine to unpack step_mem structure from ark_mem. + If missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int mriStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeMRIStepMem* step_mem) +{ + /* access ARKodeMRIStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_MRISTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeMRIStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- mriStep_CheckNVector: diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 4db2c5f9ee..f875810246 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -186,57 +186,59 @@ struct _MRIStepInnerStepper ===============================================================*/ /* Interface routines supplied to ARKODE */ -int mriStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int mriStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); -void mriStep_DisableLSetup(void* arkode_mem); -int mriStep_Init(void* arkode_mem, int init_type); -void* mriStep_GetLmem(void* arkode_mem); -ARKRhsFn mriStep_GetImplicitRHS(void* arkode_mem); -int mriStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +void mriStep_DisableLSetup(ARKodeMem ark_mem); +int mriStep_Init(ARKodeMem ark_mem, int init_type); +void* mriStep_GetLmem(ARKodeMem ark_mem); +ARKRhsFn mriStep_GetImplicitRHS(ARKodeMem ark_mem); +int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail); -int mriStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int mriStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int mriStep_SetUserData(void* arkode_mem, void* user_data); -int mriStep_SetDefaults(void* arkode_mem); -int mriStep_SetOrder(void* arkode_mem, int ord); -int mriStep_SetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS); -int mriStep_SetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi); -int mriStep_SetLinear(void* arkode_mem, int timedepend); -int mriStep_SetNonlinear(void* arkode_mem); -int mriStep_SetNonlinCRDown(void* arkode_mem, sunrealtype crdown); -int mriStep_SetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); -int mriStep_SetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); -int mriStep_SetLSetupFrequency(void* arkode_mem, int msbp); -int mriStep_SetPredictorMethod(void* arkode_mem, int pred_method); -int mriStep_SetMaxNonlinIters(void* arkode_mem, int maxcor); -int mriStep_SetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef); -int mriStep_SetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage); -int mriStep_SetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce); -int mriStep_GetCurrentGamma(void* arkode_mem, sunrealtype* gamma); -int mriStep_GetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, +int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int mriStep_SetDefaults(ARKodeMem ark_mem); +int mriStep_SetOrder(ARKodeMem ark_mem, int ord); +int mriStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS); +int mriStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fi); +int mriStep_SetLinear(ARKodeMem ark_mem, int timedepend); +int mriStep_SetNonlinear(ARKodeMem ark_mem); +int mriStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown); +int mriStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv); +int mriStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax); +int mriStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp); +int mriStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method); +int mriStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor); +int mriStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef); +int mriStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage); +int mriStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce); +int mriStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma); +int mriStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data); -int mriStep_GetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups); -int mriStep_GetNumNonlinSolvIters(void* arkode_mem, long int* nniters); -int mriStep_GetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails); -int mriStep_GetNonlinSolvStats(void* arkode_mem, long int* nniters, +int mriStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups); +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_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); -int mriStep_WriteParameters(void* arkode_mem, FILE* fp); -int mriStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR); -int mriStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +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); +int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); -int mriStep_ComputeState(void* arkode_mem, N_Vector zcor, N_Vector z); -void mriStep_Free(void* arkode_mem); -void mriStep_PrintMem(void* arkode_mem, FILE* outfile); +int mriStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); +void mriStep_Free(ARKodeMem ark_mem); +void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int mriStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem); +int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem); +int mriStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeMRIStepMem* step_mem); sunbooleantype mriStep_CheckNVector(N_Vector tmpl); int mriStep_SetCoupling(ARKodeMem ark_mem); int mriStep_CheckCoupling(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index e7267cfe02..a17e98c910 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -470,20 +470,19 @@ char* MRIStepGetLinReturnFlagName(long int flag) MRIStep optional input functions -- stepper-specific ===============================================================*/ -int mriStep_SetUserData(void* arkode_mem, void* user_data) +int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set user data in ARKODELS mem */ if (step_mem->lmem != NULL) { - retval = arkLSSetUserData(arkode_mem, user_data); + retval = arkLSSetUserData(ark_mem, user_data); if (retval != ARKLS_SUCCESS) { return (retval); } } @@ -497,14 +496,13 @@ int mriStep_SetUserData(void* arkode_mem, void* user_data) Does not change problem-defining function pointers or user_data pointer. ---------------------------------------------------------------*/ -int mriStep_SetDefaults(void* arkode_mem) +int mriStep_SetDefaults(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set default values for integrator optional inputs */ @@ -545,14 +543,13 @@ int mriStep_SetDefaults(void* arkode_mem) using an iterative linear solver this flag denotes time dependence of the preconditioner. ---------------------------------------------------------------*/ -int mriStep_SetLinear(void* arkode_mem, int timedepend) +int mriStep_SetLinear(ARKodeMem ark_mem, int timedepend) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameters */ @@ -571,14 +568,13 @@ int mriStep_SetLinear(void* arkode_mem, int timedepend) mriStep_SetLinear. Automatically loosens DeltaGammaMax back to default value. ---------------------------------------------------------------*/ -int mriStep_SetNonlinear(void* arkode_mem) +int mriStep_SetNonlinear(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameters */ @@ -594,15 +590,14 @@ int mriStep_SetNonlinear(void* arkode_mem) Specifies the method order ---------------------------------------------------------------*/ -int mriStep_SetOrder(void* arkode_mem, int ord) +int mriStep_SetOrder(ARKodeMem ark_mem, int ord) { int retval; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; sunindextype Tlrw, Tliw; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval) { return (retval); } /* check for illegal inputs */ @@ -635,8 +630,8 @@ int MRIStepSetCoupling(void* arkode_mem, MRIStepCoupling MRIC) ARKodeMRIStepMem step_mem; sunindextype Tlrw, Tliw; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check for illegal inputs */ @@ -688,8 +683,8 @@ int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set pre inner evolve function */ @@ -709,8 +704,8 @@ int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set pre inner evolve function */ @@ -726,14 +721,13 @@ int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) crdown. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int mriStep_SetNonlinCRDown(void* arkode_mem, sunrealtype crdown) +int mriStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -750,14 +744,13 @@ int mriStep_SetNonlinCRDown(void* arkode_mem, sunrealtype crdown) rdiv. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int mriStep_SetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) +int mriStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -774,14 +767,13 @@ int mriStep_SetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) dgmax. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int mriStep_SetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) +int mriStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -799,14 +791,13 @@ int mriStep_SetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) negative values imply recomputation of lsetup at each nonlinear solve; a zero value implies a reset to the default. ---------------------------------------------------------------*/ -int mriStep_SetLSetupFrequency(void* arkode_mem, int msbp) +int mriStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -823,14 +814,13 @@ int mriStep_SetLSetupFrequency(void* arkode_mem, int msbp) Non-default choices are {1,2,3,4}, all others will use default (trivial) predictor. ---------------------------------------------------------------*/ -int mriStep_SetPredictorMethod(void* arkode_mem, int pred_method) +int mriStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameter */ @@ -846,14 +836,13 @@ int mriStep_SetPredictorMethod(void* arkode_mem, int pred_method) one solve. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int mriStep_SetMaxNonlinIters(void* arkode_mem, int maxcor) +int mriStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return error message if no NLS module is present */ @@ -886,14 +875,13 @@ int mriStep_SetMaxNonlinIters(void* arkode_mem, int maxcor) Specifies the coefficient in the nonlinear solver convergence test. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int mriStep_SetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) +int mriStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* argument <= 0 sets default, otherwise set input */ @@ -908,14 +896,13 @@ int mriStep_SetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) predictor function having type ARKStagePredictFn. A NULL input function disables calls to this routine. ---------------------------------------------------------------*/ -int mriStep_SetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) +int mriStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure and set function pointer */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } step_mem->stage_predict = PredictStage; @@ -934,14 +921,13 @@ int mriStep_SetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) fi(z_i), and SUNFALSE indicates that fi(z_i) is computed with an additional evaluation of fi. ---------------------------------------------------------------*/ -int mriStep_SetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) +int mriStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure and set function pointer */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } step_mem->deduce_rhs = deduce; @@ -963,8 +949,8 @@ int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get the last return value from the inner stepper */ @@ -976,12 +962,11 @@ int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) /*--------------------------------------------------------------- mriStep_GetCurrentGamma: Returns the current value of gamma ---------------------------------------------------------------*/ -int mriStep_GetCurrentGamma(void* arkode_mem, sunrealtype* gamma) +int mriStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma) { int retval; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *gamma = step_mem->gamma; return (retval); @@ -999,8 +984,8 @@ int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get number of fse and fsi evals from step_mem */ @@ -1015,14 +1000,13 @@ int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, Returns the current number of calls to the lsetup routine ---------------------------------------------------------------*/ -int mriStep_GetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) +int mriStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get value from step_mem */ @@ -1036,14 +1020,13 @@ int mriStep_GetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) Returns the current number of nonlinear solver iterations ---------------------------------------------------------------*/ -int mriStep_GetNumNonlinSolvIters(void* arkode_mem, long int* nniters) +int mriStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nniters = step_mem->nls_iters; @@ -1056,14 +1039,13 @@ int mriStep_GetNumNonlinSolvIters(void* arkode_mem, long int* nniters) Returns the current number of nonlinear solver convergence fails ---------------------------------------------------------------*/ -int mriStep_GetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) +int mriStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set output from step_mem */ @@ -1077,15 +1059,14 @@ int mriStep_GetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) Returns nonlinear solver statistics ---------------------------------------------------------------*/ -int mriStep_GetNonlinSolvStats(void* arkode_mem, long int* nniters, +int mriStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, long int* nnfails) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nniters = step_mem->nls_iters; @@ -1105,8 +1086,8 @@ int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get coupling structure from step_mem */ @@ -1120,15 +1101,14 @@ int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC) Prints integrator statistics ---------------------------------------------------------------*/ -int mriStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; ARKLsMem arkls_mem; int retval; /* access ARKode MRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } switch (fmt) @@ -1149,9 +1129,9 @@ int mriStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* linear solver stats */ fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) + if (ark_mem->step_getlinmem(ark_mem)) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); @@ -1191,9 +1171,9 @@ int mriStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* linear solver stats */ fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) + if (ark_mem->step_getlinmem(ark_mem)) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); @@ -1239,14 +1219,13 @@ int mriStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int mriStep_WriteParameters(void* arkode_mem, FILE* fp) +int mriStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* print integrator parameters to file */ @@ -1300,8 +1279,8 @@ int MRIStepWriteCoupling(void* arkode_mem, FILE* fp) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that coupling structure is non-NULL (otherwise report error) */ diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index a309894170..aeb450b95a 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -33,14 +33,13 @@ This routine attaches a SUNNonlinearSolver object to the MRIStep module. ---------------------------------------------------------------*/ -int mriStep_SetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) +int mriStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if NLS input is NULL */ @@ -94,7 +93,7 @@ int mriStep_SetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) /* set convergence test function */ retval = SUNNonlinSolSetConvTestFn(step_mem->NLS, mriStep_NlsConvTest, - arkode_mem); + (void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -135,14 +134,13 @@ int mriStep_SetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) right-hand side function to use in the evaluation of nonlinear system functions. ---------------------------------------------------------------*/ -int mriStep_SetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fsi) +int mriStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fsi) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nls_fsi) { step_mem->nls_fsi = nls_fsi; } @@ -157,17 +155,16 @@ int mriStep_SetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fsi) This routine provides access to the relevant data needed to compute the nonlinear system function. ---------------------------------------------------------------*/ -int mriStep_GetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, +int mriStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, N_Vector* F, sunrealtype* gamma, N_Vector* sdata, void** user_data) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *tcur = ark_mem->tcur; @@ -372,8 +369,8 @@ int mriStep_NlsLSetup(sunbooleantype jbad, sunbooleantype* jcur, void* arkode_me ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update convfail based on jbad flag */ @@ -415,8 +412,8 @@ int mriStep_NlsLSolve(N_Vector b, void* arkode_mem) ARKodeMRIStepMem step_mem; int retval, nonlin_iter; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* retrieve nonlinear solver iteration from module */ @@ -462,8 +459,8 @@ int mriStep_NlsResidual(N_Vector zcor, N_Vector r, void* arkode_mem) sunrealtype c[3]; N_Vector X[3]; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -517,8 +514,8 @@ int mriStep_NlsFPFunction(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -568,8 +565,8 @@ int mriStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, sunrealtype delnrm, dcon; int m, retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if the problem is linearly implicit, just return success */ diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index 29cb246340..b59c85604e 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -815,21 +815,10 @@ int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) * ===========================================================================*/ /* Constructor called by stepper */ -int arkRelaxCreate(void* arkode_mem, ARKRelaxFn relax_fn, +int arkRelaxCreate(ARKodeMem ark_mem, ARKRelaxFn relax_fn, ARKRelaxJacFn relax_jac_fn, ARKRelaxDeltaEFn delta_e_fn, ARKRelaxGetOrderFn get_order_fn) { - ARKodeMem ark_mem; - - /* Check inputs */ - if (!arkode_mem) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return ARK_MEM_NULL; - } - ark_mem = (ARKodeMem)arkode_mem; - /* Disable relaxation if both user inputs are NULL */ if (!relax_fn && !relax_jac_fn) { diff --git a/src/arkode/arkode_relaxation_impl.h b/src/arkode/arkode_relaxation_impl.h index cc116193ff..a8c9001ed0 100644 --- a/src/arkode/arkode_relaxation_impl.h +++ b/src/arkode/arkode_relaxation_impl.h @@ -99,7 +99,7 @@ struct ARKodeRelaxMemRec * ---------------------------------------------------------------------------*/ /* Driver and Stepper Functions */ -int arkRelaxCreate(void* arkode_mem, ARKRelaxFn relax_fn, +int arkRelaxCreate(ARKodeMem ark_mem, ARKRelaxFn relax_fn, ARKRelaxJacFn relax_jac_fn, ARKRelaxDeltaEFn delta_e_fn, ARKRelaxGetOrderFn get_order_fn); int arkRelaxDestroy(ARKodeRelaxMem relax_mem); diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index 1672835360..4cf245d5e0 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -171,16 +171,15 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, This routine resizes the memory within the SPRKStep module. ---------------------------------------------------------------*/ -int sprkStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; sunindextype lrw1, liw1, lrw_diff, liw_diff; int retval; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Determine change in vector sizes */ @@ -232,8 +231,9 @@ int SPRKStepReInit(void* arkode_mem, ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -291,14 +291,13 @@ int SPRKStepReInit(void* arkode_mem, ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, problem from the given time with the input state (all counter values are retained). ---------------------------------------------------------------*/ -int sprkStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR) +int sprkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } N_VConst(SUN_RCONST(0.0), step_mem->yerr); @@ -308,16 +307,14 @@ int sprkStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR) /*--------------------------------------------------------------- sprkStep_Free frees all SPRKStep memory. ---------------------------------------------------------------*/ -void sprkStep_Free(void* arkode_mem) +void sprkStep_Free(ARKodeMem ark_mem) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; - /* nothing to do if arkode_mem is already NULL */ - if (arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL SPRKStep module */ - ark_mem = (ARKodeMem)(arkode_mem); if (ark_mem->step_mem != NULL) { step_mem = (ARKodeSPRKStepMem)ark_mem->step_mem; @@ -365,14 +362,13 @@ void sprkStep_Free(void* arkode_mem) With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int sprkStep_Init(void* arkode_mem, int init_type) +int sprkStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if reset */ @@ -486,15 +482,14 @@ inline int sprkStep_f2(ARKodeSPRKStepMem step_mem, sunrealtype tcur, Since RHS values are not stored in SPRKStep we evaluate the RHS functions for all modes. ----------------------------------------------------------------------------*/ -int sprkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { int retval = 0; - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* perform RHS functions contingent on 'mode' argument */ @@ -539,9 +534,8 @@ int sprkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, This requires only 2 vectors in principle, but we use three since we persist the stage data. Only the stage data vector belongs to SPRKStep, the other two are reused from the ARKODE core. */ -int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; N_Vector prev_stage = NULL; N_Vector curr_stage = NULL; @@ -551,7 +545,7 @@ int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } prev_stage = ark_mem->yn; @@ -615,10 +609,9 @@ int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Increment SPRK algorithm with compensated summation. This algorithm requires 6 vectors, but 5 of them are reused from the ARKODE core. */ -int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, +int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; N_Vector delta_Yi = NULL; N_Vector yn_plus_delta_Yi = NULL; @@ -629,7 +622,7 @@ int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Vector shortcuts */ @@ -721,13 +714,13 @@ int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, ---------------------------------------------------------------*/ /*--------------------------------------------------------------- - sprkStep_AccessStepMem: + sprkStep_AccessARKODEStepMem: Shortcut routine to unpack ark_mem and step_mem structures from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem) +int sprkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -737,6 +730,8 @@ int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeSPRKStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -747,6 +742,26 @@ int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + sprkStep_AccessStepMem: + + Shortcut routine to unpack step_mem structure from ark_mem. + If missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int sprkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeSPRKStepMem* step_mem) +{ + /* access ARKodeSPRKStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_SPRKSTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeSPRKStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- sprkStep_CheckNVector: diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index 48250ea92e..3f7928dbc7 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -66,26 +66,28 @@ typedef struct ARKodeSPRKStepMemRec SPRK time step module private function prototypes ===============================================================*/ -int sprkStep_Init(void* arkode_mem, int init_type); -int sprkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int sprkStep_Init(ARKodeMem ark_mem, int init_type); +int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, +int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int sprkStep_SetUserData(void* arkode_mem, void* user_data); -int sprkStep_SetDefaults(void* arkode_mem); -int sprkStep_SetOrder(void* arkode_mem, int ord); -int sprkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); -int sprkStep_WriteParameters(void* arkode_mem, FILE* fp); -int sprkStep_Reset(void* arkode_mem, sunrealtype tR, N_Vector yR); -int sprkStep_Resize(void* arkode_mem, N_Vector y0, sunrealtype hscale, +int sprkStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int sprkStep_SetDefaults(ARKodeMem ark_mem); +int sprkStep_SetOrder(ARKodeMem ark_mem, int ord); +int sprkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int sprkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int sprkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); -void sprkStep_Free(void* arkode_mem); -void sprkStep_PrintMem(void* arkode_mem, FILE* outfile); +void sprkStep_Free(ARKodeMem ark_mem); +void sprkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem); +int sprkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem); +int sprkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeSPRKStepMem* step_mem); sunbooleantype sprkStep_CheckNVector(N_Vector tmpl); /* f1 = p' (Force evaluation) */ int sprkStep_f1(ARKodeSPRKStepMem step_mem, sunrealtype tcur, N_Vector ycur, diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index ac8d979bfd..bfa793145d 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -216,20 +216,10 @@ int SPRKStepWriteParameters(void* arkode_mem, FILE* fp) structures/options related to the ARKODE infrastructure itself (e.g., root-finding and post-process step). ---------------------------------------------------------------*/ -int sprkStep_SetDefaults(void* arkode_mem) +int sprkStep_SetDefaults(ARKodeMem ark_mem) { - ARKodeMem ark_mem = NULL; - ARKodeSPRKStepMem step_mem = NULL; - int retval = 0; - - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - /* use the default method order */ - sprkStep_SetOrder(arkode_mem, 0); - - return (ARK_SUCCESS); + return (sprkStep_SetOrder(ark_mem, 0)); } /*--------------------------------------------------------------- @@ -243,14 +233,15 @@ int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (onoff) { - retval = ARKodeSetUseCompensatedSums(arkode_mem, SUNTRUE); - ark_mem->step = sprkStep_TakeStep_Compensated; + ark_mem->use_compensated_sums = SUNTRUE; + ark_mem->step = sprkStep_TakeStep_Compensated; if (!step_mem->yerr) { if (!arkAllocVec(ark_mem, ark_mem->yn, &(step_mem->yerr))) @@ -261,8 +252,8 @@ int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) } else { - retval = ARKodeSetUseCompensatedSums(arkode_mem, SUNFALSE); - ark_mem->step = sprkStep_TakeStep; + ark_mem->use_compensated_sums = SUNFALSE; + ark_mem->step = sprkStep_TakeStep; } return (retval); @@ -282,8 +273,9 @@ int SPRKStepSetMethod(void* arkode_mem, ARKodeSPRKTable sprk_storage) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (step_mem->method) @@ -308,8 +300,9 @@ int SPRKStepSetMethodName(void* arkode_mem, const char* method) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (step_mem->method) @@ -328,14 +321,13 @@ int SPRKStepSetMethodName(void* arkode_mem, const char* method) Specifies the method order ---------------------------------------------------------------*/ -int sprkStep_SetOrder(void* arkode_mem, int ord) +int sprkStep_SetOrder(ARKodeMem ark_mem, int ord) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Invalid orders result in the default order being used. */ @@ -369,8 +361,9 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nf1 = step_mem->nf1; @@ -390,8 +383,9 @@ int SPRKStepGetCurrentMethod(void* arkode_mem, ARKodeSPRKTable* sprk_storage) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *sprk_storage = step_mem->method; @@ -404,14 +398,13 @@ int SPRKStepGetCurrentMethod(void* arkode_mem, ARKodeSPRKTable* sprk_storage) Prints integrator statistics ---------------------------------------------------------------*/ -int sprkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int sprkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } switch (fmt) @@ -444,14 +437,13 @@ int sprkStep_PrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int sprkStep_WriteParameters(void* arkode_mem, FILE* fp) +int sprkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* print integrator parameters to file */ diff --git a/src/arkode/fmod/farkode_mod.c b/src/arkode/fmod/farkode_mod.c index dc0299d451..1d9bf58f1f 100644 --- a/src/arkode/fmod/farkode_mod.c +++ b/src/arkode/fmod/farkode_mod.c @@ -1069,20 +1069,6 @@ SWIGEXPORT int _wrap_FARKodeSetMaxNumConstrFails(void *farg1, int const *farg2) } -SWIGEXPORT int _wrap_FARKodeSetUseCompensatedSums(void *farg1, int const *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)ARKodeSetUseCompensatedSums(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKodeSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod/farkode_mod.f90 b/src/arkode/fmod/farkode_mod.f90 index 6dc40bb8c2..71bfe0e030 100644 --- a/src/arkode/fmod/farkode_mod.f90 +++ b/src/arkode/fmod/farkode_mod.f90 @@ -154,7 +154,6 @@ module farkode_mod public :: FARKodeClearStopTime public :: FARKodeSetFixedStep public :: FARKodeSetMaxNumConstrFails - public :: FARKodeSetUseCompensatedSums public :: FARKodeSetUserData public :: FARKodeSetPostprocessStepFn public :: FARKodeSetPostprocessStageFn @@ -931,15 +930,6 @@ function swigc_FARKodeSetMaxNumConstrFails(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FARKodeSetUseCompensatedSums(farg1, farg2) & -bind(C, name="_wrap_FARKodeSetUseCompensatedSums") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FARKodeSetUserData(farg1, farg2) & bind(C, name="_wrap_FARKodeSetUserData") & result(fresult) @@ -3207,22 +3197,6 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & swig_result = fresult end function -function FARKodeSetUseCompensatedSums(arkode_mem, onoff) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: onoff -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = onoff -fresult = swigc_FARKodeSetUseCompensatedSums(farg1, farg2) -swig_result = fresult -end function - function FARKodeSetUserData(arkode_mem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING