Skip to content

Commit

Permalink
Ported all unit tests and benchmark codes to use new shared ARKODE UI…
Browse files Browse the repository at this point in the history
… functions
  • Loading branch information
drreynolds committed Apr 18, 2024
1 parent 6ad80b7 commit f7b9e40
Show file tree
Hide file tree
Showing 17 changed files with 763 additions and 761 deletions.
182 changes: 91 additions & 91 deletions benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp

Large diffs are not rendered by default.

182 changes: 91 additions & 91 deletions benchmarks/advection_reaction_3D/raja/arkode_driver.cpp

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions benchmarks/diffusion_2D/main_arkode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,49 +245,49 @@ int main(int argc, char* argv[])
if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; }

// Specify tolerances
flag = ARKStepSStolerances(arkode_mem, uopts.rtol, uopts.atol);
if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; }
flag = ARKodeSStolerances(arkode_mem, uopts.rtol, uopts.atol);
if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; }

// Attach user data
flag = ARKStepSetUserData(arkode_mem, (void*)&udata);
if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; }
flag = ARKodeSetUserData(arkode_mem, (void*)&udata);
if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; }

// Attach linear solver
flag = ARKStepSetLinearSolver(arkode_mem, LS, A);
if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; }
flag = ARKodeSetLinearSolver(arkode_mem, LS, A);
if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; }

#if defined(USE_SUPERLU_DIST)
if (uopts.ls == "sludist")
{
ARKStepSetJacFn(arkode_mem, diffusion_jac);
if (check_flag(&flag, "ARKStepSetJacFn", 1)) return 1;
ARKodeSetJacFn(arkode_mem, diffusion_jac);
if (check_flag(&flag, "ARKodeSetJacFn", 1)) return 1;
}
#endif

if (uopts.preconditioning)
{
// Attach preconditioner
flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve);
if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; }
flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve);
if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; }

// Set linear solver setup frequency (update preconditioner)
flag = ARKStepSetLSetupFrequency(arkode_mem, uopts.msbp);
if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; }
flag = ARKodeSetLSetupFrequency(arkode_mem, uopts.msbp);
if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; }
}

// Set linear solver tolerance factor
flag = ARKStepSetEpsLin(arkode_mem, uopts.epslin);
if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; }
flag = ARKodeSetEpsLin(arkode_mem, uopts.epslin);
if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; }

// Select method order
flag = ARKStepSetOrder(arkode_mem, uopts.order);
if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; }
flag = ARKodeSetOrder(arkode_mem, uopts.order);
if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; }

// Set fixed step size or adaptivity method
if (uopts.hfixed > ZERO)
{
flag = ARKStepSetFixedStep(arkode_mem, uopts.hfixed);
if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; }
flag = ARKodeSetFixedStep(arkode_mem, uopts.hfixed);
if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; }
}
else
{
Expand All @@ -299,17 +299,17 @@ int main(int argc, char* argv[])
// Specify linearly implicit non-time-dependent RHS
if (uopts.linear)
{
flag = ARKStepSetLinear(arkode_mem, 0);
if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; }
flag = ARKodeSetLinear(arkode_mem, 0);
if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; }
}

// Set max steps between outputs
flag = ARKStepSetMaxNumSteps(arkode_mem, uopts.maxsteps);
if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; }
flag = ARKodeSetMaxNumSteps(arkode_mem, uopts.maxsteps);
if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; }

// Set stopping time
flag = ARKStepSetStopTime(arkode_mem, udata.tf);
if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; }
flag = ARKodeSetStopTime(arkode_mem, udata.tf);
if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; }

// -----------------------
// Loop over output times
Expand Down Expand Up @@ -341,8 +341,8 @@ int main(int argc, char* argv[])
SUNDIALS_MARK_BEGIN(prof, "Evolve");

// Evolve in time
flag = ARKStepEvolve(arkode_mem, tout, u, &t, stepmode);
if (check_flag(&flag, "ARKStepEvolve", 1)) { break; }
flag = ARKodeEvolve(arkode_mem, tout, u, &t, stepmode);
if (check_flag(&flag, "ARKodeEvolve", 1)) { break; }

SUNDIALS_MARK_END(prof, "Evolve");

Expand All @@ -367,8 +367,8 @@ int main(int argc, char* argv[])
if (outproc)
{
cout << "Final integrator statistics:" << endl;
flag = ARKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE);
if (check_flag(&flag, "ARKStepPrintAllStats", 1)) { return 1; }
flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE);
if (check_flag(&flag, "ARKodePrintAllStats", 1)) { return 1; }
}

// ---------
Expand All @@ -378,7 +378,7 @@ int main(int argc, char* argv[])
// Free MPI Cartesian communicator
MPI_Comm_free(&(udata.comm_c));

ARKStepFree(&arkode_mem);
ARKodeFree(&arkode_mem);
SUNLinSolFree(LS);

// Free the SuperLU_DIST structures (also frees user allocated arrays
Expand Down
176 changes: 88 additions & 88 deletions test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,86 +258,86 @@ int main(int argc, char* argv[])
if (check_flag((void*)C, "MRIStepCoupling_MIStoMRI", 0)) { return 1; }

// Set routines
flag = ARKStepSetUserData(arkstep_mem,
(void*)udata); // Pass udata to user functions
if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; }
flag = ARKStepSetNonlinConvCoef(arkstep_mem,
SUN_RCONST(1.e-7)); // Update solver convergence coeff.
if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1)) { return 1; }
flag = ARKStepSStolerances(arkstep_mem, rtol, atol); // Specify tolerances
if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; }
flag = ARKStepSetFixedStep(arkstep_mem, Tf / Nt); // Specify fixed time step size
if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; }
flag = ARKodeSetUserData(arkstep_mem,
(void*)udata); // Pass udata to user functions
if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; }
flag = ARKodeSetNonlinConvCoef(arkstep_mem,
SUN_RCONST(1.e-7)); // Update solver convergence coeff.
if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; }
flag = ARKodeSStolerances(arkstep_mem, rtol, atol); // Specify tolerances
if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; }
flag = ARKodeSetFixedStep(arkstep_mem, Tf / Nt); // Specify fixed time step size
if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; }
flag = ARKStepSetTables(arkstep_mem, 2, 0, B, NULL); // Specify Butcher table
if (check_flag(&flag, "ARKStepSetTables", 1)) { return 1; }
flag = ARKStepSetMaxNumSteps(arkstep_mem, 2 * Nt); // Increase num internal steps
if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; }

flag = MRIStepSetUserData(mristep_mem,
(void*)udata); // Pass udata to user functions
if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; }
flag = MRIStepSetNonlinConvCoef(mristep_mem,
SUN_RCONST(1.e-7)); // Update solver convergence coeff.
if (check_flag(&flag, "MRIStepSetNonlinConvCoef", 1)) { return 1; }
flag = MRIStepSStolerances(mristep_mem, rtol, atol); // Specify tolerances
if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; }
flag = MRIStepSetFixedStep(mristep_mem, Tf / Nt); // Specify fixed time step sizes
if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; }
flag = ARKStepSetFixedStep(inner_mem, Tf / Nt / 10);
if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; }
flag = MRIStepSetCoupling(mristep_mem, C); // Specify Butcher table
flag = ARKodeSetMaxNumSteps(arkstep_mem, 2 * Nt); // Increase num internal steps
if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; }

flag = ARKodeSetUserData(mristep_mem,
(void*)udata); // Pass udata to user functions
if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; }
flag = ARKodeSetNonlinConvCoef(mristep_mem,
SUN_RCONST(1.e-7)); // Update solver convergence coeff.
if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; }
flag = ARKodeSStolerances(mristep_mem, rtol, atol); // Specify tolerances
if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; }
flag = ARKodeSetFixedStep(mristep_mem, Tf / Nt); // Specify fixed time step sizes
if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; }
flag = ARKodeSetFixedStep(inner_mem, Tf / Nt / 10);
if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; }
flag = MRIStepSetCoupling(mristep_mem, C); // Specify coupling table
if (check_flag(&flag, "MRIStepSetCoupling", 1)) { return 1; }
flag = MRIStepSetMaxNumSteps(mristep_mem, 2 * Nt); // Increase num internal steps
if (check_flag(&flag, "MRIStepSetMaxNumSteps", 1)) { return 1; }
flag = ARKodeSetMaxNumSteps(mristep_mem, 2 * Nt); // Increase num internal steps
if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; }

// Linear solver interface
flag = ARKStepSetLinearSolver(arkstep_mem, LSa, NULL); // Attach linear solver
if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; }
flag = ARKStepSetPreconditioner(arkstep_mem, PSet,
PSol); // Specify the Preconditoner
if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; }

flag = MRIStepSetLinearSolver(mristep_mem, LSm, NULL); // Attach linear solver
if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; }
flag = MRIStepSetPreconditioner(mristep_mem, PSet,
PSol); // Specify the Preconditoner
if (check_flag(&flag, "MRIStepSetPreconditioner", 1)) { return 1; }
flag = ARKodeSetLinearSolver(arkstep_mem, LSa, NULL); // Attach linear solver
if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; }
flag = ARKodeSetPreconditioner(arkstep_mem, PSet,
PSol); // Specify the Preconditoner
if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; }

flag = ARKodeSetLinearSolver(mristep_mem, LSm, NULL); // Attach linear solver
if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; }
flag = ARKodeSetPreconditioner(mristep_mem, PSet,
PSol); // Specify the Preconditoner
if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; }

// Optionally specify linearly implicit RHS, with non-time-dependent preconditioner
if (linear)
{
flag = ARKStepSetLinear(arkstep_mem, 0);
if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; }
flag = ARKodeSetLinear(arkstep_mem, 0);
if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; }

flag = MRIStepSetLinear(mristep_mem, 0);
if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; }
flag = ARKodeSetLinear(mristep_mem, 0);
if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; }
}

// First call ARKStep to evolve the full problem, and print results
// First call ARKodeEvolve to evolve the full problem, and print results
t = T0;
N_VConst(ZERO, y);
flag = ARKStepEvolve(arkstep_mem, Tf, y, &t, ARK_NORMAL);
if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; }
flag = ARKStepGetNumSteps(arkstep_mem, &ark_nst);
if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return 1; }
flag = ARKodeEvolve(arkstep_mem, Tf, y, &t, ARK_NORMAL);
if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; }
flag = ARKodeGetNumSteps(arkstep_mem, &ark_nst);
if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; }
flag = ARKStepGetNumRhsEvals(arkstep_mem, &ark_nfe, &ark_nfi);
if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return 1; }
flag = ARKStepGetNumLinSolvSetups(arkstep_mem, &ark_nsetups);
if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return 1; }
flag = ARKStepGetNumNonlinSolvIters(arkstep_mem, &ark_nni);
if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return 1; }
flag = ARKStepGetNumNonlinSolvConvFails(arkstep_mem, &ark_ncfn);
if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return 1; }
flag = ARKStepGetNumLinIters(arkstep_mem, &ark_nli);
if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return 1; }
flag = ARKStepGetNumJtimesEvals(arkstep_mem, &ark_nJv);
if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return 1; }
flag = ARKStepGetNumLinConvFails(arkstep_mem, &ark_nlcf);
if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return 1; }
flag = ARKStepGetNumPrecEvals(arkstep_mem, &ark_npe);
if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return 1; }
flag = ARKStepGetNumPrecSolves(arkstep_mem, &ark_nps);
if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return 1; }
flag = ARKodeGetNumLinSolvSetups(arkstep_mem, &ark_nsetups);
if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; }
flag = ARKodeGetNumNonlinSolvIters(arkstep_mem, &ark_nni);
if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; }
flag = ARKodeGetNumNonlinSolvConvFails(arkstep_mem, &ark_ncfn);
if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; }
flag = ARKodeGetNumLinIters(arkstep_mem, &ark_nli);
if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return 1; }
flag = ARKodeGetNumJtimesEvals(arkstep_mem, &ark_nJv);
if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return 1; }
flag = ARKodeGetNumLinConvFails(arkstep_mem, &ark_nlcf);
if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return 1; }
flag = ARKodeGetNumPrecEvals(arkstep_mem, &ark_npe);
if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return 1; }
flag = ARKodeGetNumPrecSolves(arkstep_mem, &ark_nps);
if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return 1; }
if (outproc)
{
cout << "\nARKStep Solver Statistics:\n";
Expand All @@ -356,31 +356,31 @@ int main(int argc, char* argv[])
<< ark_ncfn << "\n";
}

// Second call MRIStep to evolve the full problem, and print results
// Second call ARKodeEvolve to evolve the full problem, and print results
t = T0;
N_VConst(ZERO, y);
flag = MRIStepEvolve(mristep_mem, Tf, y, &t, ARK_NORMAL);
if (check_flag(&flag, "MRIStepEvolve", 1)) { return 1; }
flag = MRIStepGetNumSteps(mristep_mem, &mri_nst);
if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return 1; }
flag = ARKodeEvolve(mristep_mem, Tf, y, &t, ARK_NORMAL);
if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; }
flag = ARKodeGetNumSteps(mristep_mem, &mri_nst);
if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; }
flag = MRIStepGetNumRhsEvals(mristep_mem, &mri_nfse, &mri_nfsi);
if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return 1; }
flag = MRIStepGetNumLinSolvSetups(mristep_mem, &mri_nsetups);
if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return 1; }
flag = MRIStepGetNumNonlinSolvIters(mristep_mem, &mri_nni);
if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return 1; }
flag = MRIStepGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn);
if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) { return 1; }
flag = MRIStepGetNumLinIters(mristep_mem, &mri_nli);
if (check_flag(&flag, "MRIStepGetNumLinIters", 1)) { return 1; }
flag = MRIStepGetNumJtimesEvals(mristep_mem, &mri_nJv);
if (check_flag(&flag, "MRIStepGetNumJtimesEvals", 1)) { return 1; }
flag = MRIStepGetNumLinConvFails(mristep_mem, &mri_nlcf);
if (check_flag(&flag, "MRIStepGetNumLinConvFails", 1)) { return 1; }
flag = MRIStepGetNumPrecEvals(mristep_mem, &mri_npe);
if (check_flag(&flag, "MRIStepGetNumPrecEvals", 1)) { return 1; }
flag = MRIStepGetNumPrecSolves(mristep_mem, &mri_nps);
if (check_flag(&flag, "MRIStepGetNumPrecSolves", 1)) { return 1; }
flag = ARKodeGetNumLinSolvSetups(mristep_mem, &mri_nsetups);
if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; }
flag = ARKodeGetNumNonlinSolvIters(mristep_mem, &mri_nni);
if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; }
flag = ARKodeGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn);
if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; }
flag = ARKodeGetNumLinIters(mristep_mem, &mri_nli);
if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return 1; }
flag = ARKodeGetNumJtimesEvals(mristep_mem, &mri_nJv);
if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return 1; }
flag = ARKodeGetNumLinConvFails(mristep_mem, &mri_nlcf);
if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return 1; }
flag = ARKodeGetNumPrecEvals(mristep_mem, &mri_npe);
if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return 1; }
flag = ARKodeGetNumPrecSolves(mristep_mem, &mri_nps);
if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return 1; }
if (outproc)
{
cout << "\nMRIStep Solver Statistics:\n";
Expand Down Expand Up @@ -491,9 +491,9 @@ int main(int argc, char* argv[])
ARKodeButcherTable_Free(B); // Free Butcher table
ARKodeButcherTable_Free(Bc); // Free Butcher table
MRIStepCoupling_Free(C); // Free MRI coupling table
ARKStepFree(&arkstep_mem); // Free integrator memory
MRIStepFree(&mristep_mem);
ARKStepFree(&inner_mem);
ARKodeFree(&arkstep_mem); // Free integrator memory
ARKodeFree(&mristep_mem);
ARKodeFree(&inner_mem);
MRIStepInnerStepper_Free(&inner_stepper);
SUNLinSolFree(LSa); // Free linear solver
SUNLinSolFree(LSm);
Expand Down
Loading

0 comments on commit f7b9e40

Please sign in to comment.