Skip to content

Commit

Permalink
vector imput in DomEig
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Jul 29, 2024
1 parent b7a124e commit 801b66c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/arkode/CXX_serial/ark_heat2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ static int PSolve(sunrealtype t, N_Vector u, N_Vector f, N_Vector r, N_Vector z,
static int InitUserData(UserData* udata)
{
// Diffusion coefficient
udata->kx = ONE*1000.0;
udata->ky = ONE*1000.0;
udata->kx = ONE*10.0;
udata->ky = ONE*10.0;

// Enable forcing
udata->forcing = true;
Expand Down
8 changes: 4 additions & 4 deletions examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct UserData
static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data);

// Spectral radius estimation routine
static int eig(sunrealtype t, sunrealtype* lambdaR,
static int eig(sunrealtype t, N_Vector y, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data);

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -522,7 +522,7 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data)


// Spectral radius estimation routine
static int eig(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
static int eig(sunrealtype t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
{
// Access problem data
UserData* udata = (UserData*)user_data;
Expand All @@ -549,8 +549,8 @@ static int eig(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void*
static int InitUserData(UserData* udata)
{
// Diffusion coefficient
udata->kx = ONE*1000.0;
udata->ky = ONE*1000.0;
udata->kx = ONE*10.0;
udata->ky = ONE*10.0;

// Enable forcing
udata->forcing = true;
Expand Down
4 changes: 2 additions & 2 deletions examples/arkode/C_serial/lsrk_analytic.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data);

/* User-supplied Dominated Eigenvalue Called by the Solver */
static int DomEig(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data);
static int DomEig(sunrealtype t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data);

/* Private function to check function return values */
static int check_flag(void* flagvalue, const char* funcname, int opt);
Expand Down Expand Up @@ -211,7 +211,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data)
}

/* DomEig routine to estimate the dominated eigenvalue */
static int DomEig(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
static int DomEig(sunrealtype t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
{
sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */
sunrealtype lambda = rdata[0]; /* set shortcut for stiffness parameter */
Expand Down
4 changes: 2 additions & 2 deletions examples/arkode/C_serial/lsrk_analytic_VarJac.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data);

/* User-supplied Dominated Eigenvalue Called by the Solver */
static int DomEig(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data);
static int DomEig(sunrealtype t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data);

/* Private function to check function return values */
static int check_flag(void* flagvalue, const char* funcname, int opt);
Expand Down Expand Up @@ -220,7 +220,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data)
}

/* DomEig routine to estimate the dominated eigenvalue */
static int DomEig(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
static int DomEig(sunrealtype t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data)
{
sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */
sunrealtype lambda = rdata[0]; /* set shortcut for stiffness parameter 1 */
Expand Down
2 changes: 1 addition & 1 deletion include/arkode/arkode_lsrkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
extern "C" {
#endif

typedef int (*ARKDomEigFn)(sunrealtype t, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data);
typedef int (*ARKDomEigFn)(sunrealtype t, N_Vector y, sunrealtype* lambdaR, sunrealtype* lambdaI, void* user_data);

/* ------------------
* LSRKStep Constants
Expand Down
3 changes: 2 additions & 1 deletion src/arkode/arkode_lsrkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,15 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem)

if ((step_mem->isextDomEig))
{
retval = step_mem->extDomEig(ark_mem->tn, &step_mem->lambdaR, &step_mem->lambdaI, ark_mem->user_data);
retval = step_mem->extDomEig(ark_mem->tn, ark_mem->ycur, &step_mem->lambdaR, &step_mem->lambdaI, ark_mem->user_data);
if (retval != ARK_SUCCESS)
{
arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__,
"Unable to estimate the dominant eigenvalue");
return (ARK_DOMEIG_FAIL);
}


if(step_mem->lambdaR*ark_mem->h > ZERO)
{
printf("\nlambdaR*h must be nonpositive\n");
Expand Down

0 comments on commit 801b66c

Please sign in to comment.