Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/arkode sts #541

Open
wants to merge 217 commits into
base: develop
Choose a base branch
from
Open

Feature/arkode sts #541

wants to merge 217 commits into from

Conversation

maggul
Copy link
Collaborator

@maggul maggul commented Jul 12, 2024

This is a draft PR for feedback on new STS module.

@drreynolds
Copy link
Collaborator

Unfortunately, the rebase to develop seems to have marked hundreds of files as conflicts. I'll work on fixing this branch now, so that it will be easier for folks to review.

Copy link
Member

@balos1 balos1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I have made it through the documentation.

doc/arkode/guide/source/Constants.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Constants.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst Outdated Show resolved Hide resolved
============================================

The LSRKStep time-stepping module in ARKODE supports a variety of so-called
"low-storage" Runge--Kutta methods. This category includes traditional explicit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cite some references for these different types of low-storage methods?

doc/arkode/guide/source/Mathematics.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Mathematics.rst Outdated Show resolved Hide resolved

When running LSRKStep with either the RKC or RKL methods, the user must supply a dominant eigenvalue estimation function of type :c:type:`ARKDomEigFn`:

.. c:type:: int (*ARKDomEigFn)(sunrealtype* t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we plan on adding complex support later with suncomplextype, I wonder if we should add suncomplextype to sundials_types.h now so it can be used in this function (instead of having a lambdaR and lambdaI). What do you think @gardner48 @drreynolds ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to use this even in the real valued problems, suncomplextype might not be appropriate

Copy link
Collaborator

@Steven-Roberts Steven-Roberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the first half or so of the files. Many of my comments are on inconsistent naming conventions, and I made no attempt to catch all but enough to show the patterns.

You'll also want to update this to add the header info:

#include <sundials/sundials_core.h> // Provides core SUNDIALS types

+-----------------------------------------------+------------------------------------------------------------+
| :index:`ARKODE_LSRK_RKL` | 2nd order Runge-Kutta-Legendre (RKL) method. |
+-----------------------------------------------+------------------------------------------------------------+
| :index:`ARKODE_LSRK_SSPs_2` | Optimal 2nd order s-stage SSP RK method. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this value be all caps?

doc/arkode/guide/source/Constants.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic.c Outdated Show resolved Hide resolved
{
ARKODE_LSRK_RKC = 1, /* ensure enum is int */
ARKODE_LSRK_RKL = 2,
ARKODE_LSRK_RKG = 3,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine since it will be undocumented presumably. I don't see why the particular value matters.

@@ -151,7 +151,7 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0,

/* SPRKStep uses Lagrange interpolation by default, since Hermite is
less compatible with these methods. */
ARKodeSetInterpolantType(ark_mem, ARK_INTERP_LAGRANGE);
ark_mem->interp_type = ARK_INTERP_LAGRANGE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change supposed to be here? I'm not sure if we settled on the way to set the default interpolant (prior to fix for #569), but we should be consistent.

{
case ARKODE_LSRK_RKC_2:
ark_mem->step = lsrkStep_TakeStepRKC;
step_mem->LSRKmethod = ARKODE_LSRK_RKC_2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be brought out of the switch to step_mem->LSRKmethod = method. These are common sources of copy paste errors.

Comment on lines +128 to +143
if (dom_eig != NULL)
{
step_mem->isextDomEig = SUNTRUE;
step_mem->extDomEig = dom_eig;

return (ARK_SUCCESS);
}
else
{
step_mem->isextDomEig = SUNFALSE;
step_mem->extDomEig = NULL;

arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Internal dom_eig is not supported yet!");
return (ARK_ILL_INPUT);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (dom_eig != NULL)
{
step_mem->isextDomEig = SUNTRUE;
step_mem->extDomEig = dom_eig;
return (ARK_SUCCESS);
}
else
{
step_mem->isextDomEig = SUNFALSE;
step_mem->extDomEig = NULL;
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Internal dom_eig is not supported yet!");
return (ARK_ILL_INPUT);
}
step_mem->isextDomEig = dom_eig != NULL;
step_mem->extDomEig = dom_eig;
if (dom_eig == NULL)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Internal dom_eig is not supported yet!");
return (ARK_ILL_INPUT);
}

src/arkode/arkode_lsrkstep_io.c Show resolved Hide resolved
step_mem->constJac = SUNTRUE;
step_mem->domeigfreq = 1;
}
else { step_mem->domeigfreq = nsteps; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this branch set step_mem->constJac = SUNFALSE?

/* LSRK method storage and parameters */
// N_Vector temp1; /* Temp vector storage */
// N_Vector temp2; /* Temp vector storage */
N_Vector* Fe; /* RHS vector storage */
Copy link
Collaborator

@Steven-Roberts Steven-Roberts Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is an array of vectors, only one element is ever used. Can this be replaced with an NVector or is this to support future extensions?

src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
Comment on lines +572 to +573
const sunrealtype onep54 = SUN_RCONST(1.54), c13 = SUN_RCONST(13.0),
p8 = SUN_RCONST(0.8), p4 = SUN_RCONST(0.4);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A citation on where the come from would be helpful

src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@Steven-Roberts Steven-Roberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished reviewing the remaining files. Apologies if I was too pedantic on some of the things not specific to this branch.

src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
}
if (ss == step_mem->stagemaxlimit)
{
hmax = SUN_RCONST(0.95) * (SUNSQR(ss) + ss - 2) / (2.0 * step_mem->sprad);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: use hadapt_mem->safety instead of 0.95

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To that end, we need to create a new double in the step memory and assign its value from hadapt_mem->safety when both of their memories are available (probably in lsrkStep_SetDefaults). Do you think we should have a new step_mem->safety kind of parameter, or keep it in this way?

Copy link
Collaborator

@Steven-Roberts Steven-Roberts Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, sprad already has the domeigsfty applied, so I wonder if the 0.95 should be outright removed.

src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
int domeigfreq; /* indicates dom_eig update after domeigfreq successful steps*/

/* Flags */
sunbooleantype isextDomEig; /* flag indicating user provided dom_eig */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks equivalent to checking if extDomEig != NULL in which case it could be removed. Maybe having both will support future extensions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true. It is just an unused variable for the time being. Should I remove it until we get to that point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants