Skip to content

Commit

Permalink
Apply formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Roberts committed Nov 21, 2024
1 parent 81bb8e1 commit 9f645dc
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions test/unit_tests/arkode/CXX_serial/ark_test_splittingstep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ static int test_mixed_directions(const sundials::Context& ctx, const char* name)
ARKodeSetFixedStep(arkode_mem, dt);
ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE);
ARKodeSetMaxNumSteps(arkode_mem, -1);
auto coefficients =
SplittingStepCoefficients_LoadCoefficientsByName(name);
auto coefficients = SplittingStepCoefficients_LoadCoefficientsByName(name);
SplittingStepSetCoefficients(arkode_mem, coefficients);
SplittingStepCoefficients_Destroy(&coefficients);

Expand All @@ -176,7 +175,8 @@ static int test_mixed_directions(const sundials::Context& ctx, const char* name)
N_VLinearSum(SUN_RCONST(1.0), err, -SUN_RCONST(1.0), y, err);
auto max_err = N_VMaxNorm(err);

std::cout << "Mixed direction solution using " << name << " completed with an error of " << max_err << "\n";
std::cout << "Mixed direction solution using " << name
<< " completed with an error of " << max_err << "\n";
ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE);

sunbooleantype fail = max_err > global_tol;
Expand Down Expand Up @@ -389,7 +389,8 @@ static int test_custom_stepper(const sundials::Context& ctx, int order)
auto numerical_solution = N_VGetArrayPointer(y)[0];
auto err = numerical_solution - exact_solution;

std::cout << "Custom SUNStepper solution of order " << order << " completed with an error of " << err << "\n";
std::cout << "Custom SUNStepper solution of order " << order
<< " completed with an error of " << err << "\n";
ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE);

sunbooleantype fail = SUNRCompare(exact_solution, numerical_solution);
Expand Down Expand Up @@ -424,22 +425,21 @@ static int test_reinit(const sundials::Context& ctx)
auto y = N_VNew_Serial(1, ctx);
N_VConst(SUN_RCONST(1.0), y);

ARKRhsFn fns[] = {
[](sunrealtype t, N_Vector z, N_Vector zdot, void*)
{
N_VScale(SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t), z, zdot);
return 0;
},
[](sunrealtype t, N_Vector z, N_Vector zdot, void*)
{
N_VScale(-SUN_RCONST(1.0) / (SUN_RCONST(2.0) + t), z, zdot);
return 0;
},
[](sunrealtype t, N_Vector z, N_Vector zdot, void*)
{
N_VScale(SUN_RCONST(1.0) / (SUN_RCONST(3.0) + t), z, zdot);
return 0;
}};
ARKRhsFn fns[] = {[](sunrealtype t, N_Vector z, N_Vector zdot, void*)
{
N_VScale(SUN_RCONST(1.0) / (SUN_RCONST(1.0) + t), z, zdot);
return 0;
},
[](sunrealtype t, N_Vector z, N_Vector zdot, void*)
{
N_VScale(-SUN_RCONST(1.0) / (SUN_RCONST(2.0) + t), z, zdot);
return 0;
},
[](sunrealtype t, N_Vector z, N_Vector zdot, void*)
{
N_VScale(SUN_RCONST(1.0) / (SUN_RCONST(3.0) + t), z, zdot);
return 0;
}};

void* partition_mem[] = {nullptr, nullptr, nullptr};
SUNStepper steppers[] = {nullptr, nullptr, nullptr};
Expand All @@ -451,8 +451,7 @@ static int test_reinit(const sundials::Context& ctx)
ARKodeCreateSUNStepper(partition_mem[i], &steppers[i]);
}

auto arkode_mem = SplittingStepCreate(steppers, 3, t0, y,
ctx);
auto arkode_mem = SplittingStepCreate(steppers, 3, t0, y, ctx);
ARKodeSetFixedStep(arkode_mem, dt);
ARKodeSetOrder(arkode_mem, 2);
auto tret = t0;
Expand Down Expand Up @@ -508,20 +507,15 @@ int main()
{
constexpr auto min_order = 1;
constexpr auto max_order = 4;
for (auto order = min_order; order <= max_order; order ++) {
for (auto order = min_order; order <= max_order; order++)
{
errors += test_forward(ctx, order, p);
}
}

auto names = {
"ARKODE_SPLITTING_STRANG_2_2_2",
"ARKODE_SPLITTING_BEST_2_2_2",
"ARKODE_SPLITTING_SUZUKI_3_3_2",
"ARKODE_SPLITTING_RUTH_3_3_2"
};
for (auto name : names) {
errors += test_mixed_directions(ctx, name);
}
auto names = {"ARKODE_SPLITTING_STRANG_2_2_2", "ARKODE_SPLITTING_BEST_2_2_2",
"ARKODE_SPLITTING_SUZUKI_3_3_2", "ARKODE_SPLITTING_RUTH_3_3_2"};
for (auto name : names) { errors += test_mixed_directions(ctx, name); }

errors += test_resize(ctx);
errors += test_custom_stepper(ctx, 4);
Expand Down

0 comments on commit 9f645dc

Please sign in to comment.