Skip to content

Commit f586b0d

Browse files
PERK2 constructor consistence (#2184)
* Make `PairedExplicitRK2` constructors consistent * Make PERK2 constructor consistent * changes * Update NEWS.md * prevent readdlm error for S=2 * fix merge errors * fix errors --------- Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent 3ed2f3a commit f586b0d

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ for human readability.
1515
[RecursiveArrayTools.jl](https://github.com/SciML/RecursiveArrayTools.jl)
1616
for `DGMulti` solvers ([#2150]). You can use `Base.parent` to unwrap
1717
the original data.
18+
- The `PairedExplicitRK2` constructor with second argument `base_path_monomial_coeffs::AbstractString` requires
19+
now `dt_opt`, `bS`, `cS` to be given as keyword arguments ([#2184]).
20+
Previously, those where standard function parameters, in the same order as listed above.
1821
- The `AnalysisCallback` output generated with the `save_analysis = true` option now prints
1922
floating point numbers in their respective (full) precision.
2023
Previously, only the first 8 digits were printed to file.

src/time_integration/paired_explicit_runge_kutta/methods_PERK2.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function compute_PairedExplicitRK2_butcher_tableau(num_stages, eig_vals, tspan,
5050
dteps,
5151
eig_vals; verbose)
5252

53-
if num_stages != consistency_order
53+
if coeffs_max > 0
5454
monomial_coeffs = undo_normalization!(monomial_coeffs, consistency_order,
5555
num_stages)
5656
num_monomial_coeffs = length(monomial_coeffs)
@@ -81,24 +81,26 @@ function compute_PairedExplicitRK2_butcher_tableau(num_stages,
8181
a_matrix = zeros(2, coeffs_max)
8282
a_matrix[1, :] = c[3:end]
8383

84-
path_monomial_coeffs = joinpath(base_path_monomial_coeffs,
85-
"gamma_" * string(num_stages) * ".txt")
84+
if coeffs_max > 0
85+
path_monomial_coeffs = joinpath(base_path_monomial_coeffs,
86+
"gamma_" * string(num_stages) * ".txt")
8687

87-
@assert isfile(path_monomial_coeffs) "Couldn't find file"
88-
monomial_coeffs = readdlm(path_monomial_coeffs, Float64)
89-
num_monomial_coeffs = size(monomial_coeffs, 1)
88+
@assert isfile(path_monomial_coeffs) "Couldn't find file"
89+
monomial_coeffs = readdlm(path_monomial_coeffs, Float64)
90+
num_monomial_coeffs = size(monomial_coeffs, 1)
9091

91-
@assert num_monomial_coeffs == coeffs_max
92-
A = compute_a_coeffs(num_stages, stage_scaling_factors, monomial_coeffs)
92+
@assert num_monomial_coeffs == coeffs_max
93+
A = compute_a_coeffs(num_stages, stage_scaling_factors, monomial_coeffs)
9394

94-
a_matrix[1, :] -= A
95-
a_matrix[2, :] = A
95+
a_matrix[1, :] -= A
96+
a_matrix[2, :] = A
97+
end
9698

9799
return a_matrix, c
98100
end
99101

100102
@doc raw"""
101-
PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString, dt_opt = nothing,
103+
PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString; dt_opt = nothing,
102104
bS = 1.0, cS = 0.5)
103105
PairedExplicitRK2(num_stages, tspan, semi::AbstractSemidiscretization;
104106
verbose = false, bS = 1.0, cS = 0.5)
@@ -144,7 +146,7 @@ struct PairedExplicitRK2 <: AbstractPairedExplicitRKSingle
144146
end
145147

146148
# Constructor that reads the coefficients from a file
147-
function PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString,
149+
function PairedExplicitRK2(num_stages, base_path_monomial_coeffs::AbstractString;
148150
dt_opt = nothing,
149151
bS = 1.0, cS = 0.5)
150152
# If the user has the monomial coefficients, they also must have the optimal time step

0 commit comments

Comments
 (0)