Skip to content

Commit

Permalink
Updated diffusion_2D benchmarkbased on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
drreynolds committed Sep 25, 2024
1 parent 3edafa9 commit 247f441
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions benchmarks/diffusion_2D/main_arkode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ int main(int argc, char* argv[])
return 1;
}

// Return with error on unsupported LSRK method type
if (!uopts.implicit)
{
if ((uopts.lsrkmethod != ARKODE_LSRK_RKC_2) &&
(uopts.lsrkmethod != ARKODE_LSRK_RKL_2))
{
cerr << "ERROR: illegal lsrkmethod" << endl;
return 1;
}
}

// -----------------------------
// Setup parallel decomposition
// -----------------------------
Expand Down Expand Up @@ -168,26 +179,26 @@ int main(int argc, char* argv[])
// Set up implicit solver, if applicable
SUNLinearSolver LS = nullptr;
SUNMatrix A = nullptr;
#if defined(USE_SUPERLU_DIST)
// SuperLU-DIST objects
SuperMatrix A_super;
gridinfo_t grid;
dLUstruct_t A_lu;
dScalePermstruct_t A_scaleperm;
dSOLVEstruct_t A_solve;
SuperLUStat_t A_stat;
superlu_dist_options_t A_opts;
sunrealtype* A_data = nullptr;
sunindextype* A_col_idxs = nullptr;
sunindextype* A_row_ptrs = nullptr;
#endif
if (uopts.implicit)
{
// ---------------------
// Create linear solver
// ---------------------

// Create linear solver
#if defined(USE_SUPERLU_DIST)
// SuperLU-DIST objects
SuperMatrix A_super;
gridinfo_t grid;
dLUstruct_t A_lu;
dScalePermstruct_t A_scaleperm;
dSOLVEstruct_t A_solve;
SuperLUStat_t A_stat;
superlu_dist_options_t A_opts;
sunrealtype* A_data = nullptr;
sunindextype* A_col_idxs = nullptr;
sunindextype* A_row_ptrs = nullptr;
#endif

int prectype = (uopts.preconditioning) ? SUN_PREC_RIGHT : SUN_PREC_NONE;

Expand Down Expand Up @@ -260,15 +271,15 @@ int main(int argc, char* argv[])
// ----------------------

// Create integrator
void* arkode_mem = NULL;
void* arkode_mem = nullptr;
if (uopts.implicit)
{
arkode_mem = ARKStepCreate(NULL, diffusion, ZERO, u, ctx);
arkode_mem = ARKStepCreate(nullptr, diffusion, ZERO, u, ctx);
if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; }
}
else
{
arkode_mem = LSRKStepCreate(diffusion, NULL, ZERO, u, ctx);
arkode_mem = LSRKStepCreate(diffusion, nullptr, ZERO, u, ctx);
if (check_flag((void*)arkode_mem, "LSRKStepCreate", 0)) { return 1; }
}

Expand Down Expand Up @@ -333,7 +344,7 @@ int main(int argc, char* argv[])
}

// Set fixed step size or adaptivity method
SUNAdaptController C = NULL;
SUNAdaptController C = nullptr;
if (uopts.hfixed > ZERO)
{
flag = ARKodeSetFixedStep(arkode_mem, uopts.hfixed);
Expand Down Expand Up @@ -476,8 +487,8 @@ static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
UserData* udata = (UserData*)user_data;

// Fill in spectral radius value
*lambdaR = -SUN_RCONST(8.0) * SUNMAX(udata->kx / udata->dx / udata->dx,
udata->ky / udata->dy / udata->dy);
*lambdaR = -SUN_RCONST(8.0) * std::max(udata->kx / udata->dx / udata->dx,
udata->ky / udata->dy / udata->dy);
*lambdaI = SUN_RCONST(0.0);

// return with success
Expand Down Expand Up @@ -688,10 +699,7 @@ void UserOptions::print()
switch (lsrkmethod)
{
case (ARKODE_LSRK_RKC_2): cout << " method = RKC_2 " << endl; break;
case (ARKODE_LSRK_RKL_2):
cout << " method = RKL_2 " << endl;
break;
// case (ARKODE_LSRK_RKG_2): cout << " method = RKG_2 " << endl; break;
case (ARKODE_LSRK_RKL_2): cout << " method = RKL_2 " << endl; break;
}
cout << " --------------------------------- " << endl;
}
Expand Down

0 comments on commit 247f441

Please sign in to comment.