Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor modification on PairedExplicitRK3 to reduce redundant computation #2152

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions ext/TrixiNLsolveExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -74,7 +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;
c;
warisa-r marked this conversation as resolved.
Show resolved Hide resolved
verbose, max_iter = 100000)

# Define the objective_function
Expand All @@ -83,7 +82,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading