From e1950ac92c683b054964458c3a61d18ebf627c57 Mon Sep 17 00:00:00 2001 From: Warisa Roongaraya <81345089+warisa-r@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:37:26 +0100 Subject: [PATCH] Minor modification on PairedExplicitRK3 to reduce redundant computation (#2152) * remove the redundant recalculation of c in the objective function * put verbose and max_iter on the same line as c --------- Co-authored-by: Hendrik Ranocha Co-authored-by: Daniel Doehring --- ext/TrixiNLsolveExt.jl | 12 +++++------- .../paired_explicit_runge_kutta/methods_PERK3.jl | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ext/TrixiNLsolveExt.jl b/ext/TrixiNLsolveExt.jl index 9247687fdc7..fa188d04c71 100644 --- a/ext/TrixiNLsolveExt.jl +++ b/ext/TrixiNLsolveExt.jl @@ -15,7 +15,7 @@ end using StableRNGs: StableRNG, rand # Use functions that are to be extended and additional symbols that are not exported -using Trixi: Trixi, compute_c_coeffs, @muladd +using Trixi: Trixi, @muladd # By default, Julia/LLVM does not use fused multiply-add operations (FMAs). # Since these FMAs can increase the performance of many numerical algorithms, @@ -29,9 +29,8 @@ using Trixi: Trixi, compute_c_coeffs, @muladd function PairedExplicitRK3_butcher_tableau_objective_function!(c_eq, a_unknown, num_stages, num_stage_evals, - monomial_coeffs, - cS2) - c_ts = compute_c_coeffs(num_stages, cS2) # ts = timestep + monomial_coeffs, c) + c_ts = c # ts = timestep # For explicit methods, a_{1,1} = 0 and a_{2,1} = c_2 (Butcher's condition) a_coeff = [0, c_ts[2], a_unknown...] # Equality constraint array that ensures that the stability polynomial computed from @@ -74,8 +73,7 @@ end # For details, see Proposition 3.2, Equation (3.3) from # Hairer, Wanner: Solving Ordinary Differential Equations 2 function Trixi.solve_a_butcher_coeffs_unknown!(a_unknown, num_stages, monomial_coeffs, - c_s2, c; - verbose, max_iter = 100000) + c; verbose, max_iter = 100000) # Define the objective_function function objective_function!(c_eq, x) @@ -83,7 +81,7 @@ function Trixi.solve_a_butcher_coeffs_unknown!(a_unknown, num_stages, monomial_c num_stages, num_stages, monomial_coeffs, - c_s2) + c) end # RealT is determined as the type of the first element in monomial_coeffs to ensure type consistency diff --git a/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl b/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl index 384f4b408ca..477748b28c5 100644 --- a/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl +++ b/src/time_integration/paired_explicit_runge_kutta/methods_PERK3.jl @@ -55,7 +55,7 @@ function compute_PairedExplicitRK3_butcher_tableau(num_stages, tspan, # Butcher array abscissae c to find Butcher matrix A # This function is extended in TrixiNLsolveExt.jl a_unknown = solve_a_butcher_coeffs_unknown!(a_unknown, num_stages, - monomial_coeffs, cS2, c; + monomial_coeffs, c; verbose) end # Fill A-matrix in P-ERK style