Skip to content

Commit 3fea822

Browse files
const and immutable structs, non-breaking (#2659)
* `const` and immutable `struct`s, non-breaking * try cosnt boundary names * fmt * return * try t8code const * try const eqs * p4est mv * rt * clean up t8code * revert
1 parent 81b8662 commit 3fea822

29 files changed

+129
-123
lines changed

src/callbacks_stage/entropy_bounded_limiter.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@muladd begin
66
#! format: noindent
77

8-
mutable struct EntropyBoundedLimiter{RealT <: Real}
8+
struct EntropyBoundedLimiter{RealT <: Real}
99
exp_entropy_decrease_max::RealT # < 0
1010
end
1111

src/callbacks_step/alive.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ time steps. If `analysis_interval ≂̸ 0`, the output is omitted every
1515
"""
1616
mutable struct AliveCallback
1717
start_time::Float64
18-
alive_interval::Int
19-
analysis_interval::Int
18+
const alive_interval::Int
19+
const analysis_interval::Int
2020
end
2121

2222
function AliveCallback(; analysis_interval = 0,

src/callbacks_step/analysis.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ mutable struct AnalysisCallback{Analyzer, AnalysisIntegrals, InitialStateIntegra
4949
start_time_last_analysis::Float64
5050
ncalls_rhs_last_analysis::Int
5151
start_gc_time::Float64
52-
interval::Int
53-
save_analysis::Bool
54-
output_directory::String
55-
analysis_filename::String
56-
analyzer::Analyzer
57-
analysis_errors::Vector{Symbol}
58-
analysis_integrals::AnalysisIntegrals
52+
const interval::Int
53+
const save_analysis::Bool
54+
const output_directory::String
55+
const analysis_filename::String
56+
const analyzer::Analyzer
57+
const analysis_errors::Vector{Symbol}
58+
const analysis_integrals::AnalysisIntegrals
5959
initial_state_integrals::InitialStateIntegrals
60-
cache::Cache
60+
const cache::Cache
6161
end
6262

6363
# TODO: Taal bikeshedding, implement a method with less information and the signature

src/callbacks_step/save_restart.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
Save the current numerical solution in a restart file every `interval` time steps.
1414
"""
15-
mutable struct SaveRestartCallback
15+
struct SaveRestartCallback
1616
interval::Int
1717
save_final_restart::Bool
1818
output_directory::String

src/callbacks_step/steady_state.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Terminates the integration when the [`residual_steady_state(du, equations)`](@ref)
1212
falls below the threshold specified by `abstol, reltol`.
1313
"""
14-
mutable struct SteadyStateCallback{RealT <: Real}
14+
struct SteadyStateCallback{RealT <: Real}
1515
abstol::RealT
1616
reltol::RealT
1717
end

src/callbacks_step/stepsize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ diffusive CFL number, or a function of time `t` returning a `Real` number.
2727
By default, the timestep will be adjusted at every step.
2828
For different values of `interval`, the timestep will be adjusted every `interval` steps.
2929
"""
30-
mutable struct StepsizeCallback{CflAdvectiveType, CflDiffusiveType}
30+
struct StepsizeCallback{CflAdvectiveType, CflDiffusiveType}
3131
cfl_advective::CflAdvectiveType
3232
cfl_diffusive::CflDiffusiveType
3333
interval::Int

src/callbacks_step/time_series.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ Currently this callback is only implemented for [`TreeMesh`](@ref) and [`Unstruc
2727
"""
2828
mutable struct TimeSeriesCallback{RealT <: Real, uEltype <: Real, SolutionVariables,
2929
VariableNames, Cache}
30-
interval::Int
31-
solution_variables::SolutionVariables
32-
variable_names::VariableNames
33-
output_directory::String
34-
filename::String
35-
point_coordinates::Array{RealT, 2}
30+
const interval::Int
31+
const solution_variables::SolutionVariables
32+
const variable_names::VariableNames
33+
const output_directory::String
34+
const filename::String
35+
const point_coordinates::Array{RealT, 2}
3636
# Point data is stored as a vector of vectors of the solution data type:
3737
# * the "outer" `Vector` contains one vector for each point at which a time_series is recorded
3838
# * the "inner" `Vector` contains the actual time series for a single point,
@@ -42,7 +42,7 @@ mutable struct TimeSeriesCallback{RealT <: Real, uEltype <: Real, SolutionVariab
4242
point_data::Vector{Vector{uEltype}}
4343
time::Vector{RealT}
4444
step::Vector{Int}
45-
time_series_cache::Cache
45+
const time_series_cache::Cache
4646
end
4747

4848
function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:TimeSeriesCallback})

src/callbacks_step/visualization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
@muladd begin
66
#! format: noindent
77

8-
mutable struct VisualizationCallback{PlotDataCreator, SolutionVariables, VariableNames,
9-
PlotCreator}
8+
struct VisualizationCallback{PlotDataCreator, SolutionVariables, VariableNames,
9+
PlotCreator}
1010
plot_data_creator::PlotDataCreator
1111
interval::Int
1212
solution_variables::SolutionVariables

src/equations/ideal_glm_mhd_multiion_2d.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ References:
8282
In case of more than one ion species, the multi-ion GLM-MHD equations should ALWAYS be used
8383
with [`source_terms_lorentz`](@ref).
8484
"""
85-
mutable struct IdealGlmMhdMultiIonEquations2D{NVARS, NCOMP, RealT <: Real,
86-
ElectronPressure, ElectronTemperature} <:
87-
AbstractIdealGlmMhdMultiIonEquations{2, NVARS, NCOMP}
85+
struct IdealGlmMhdMultiIonEquations2D{NVARS, NCOMP, RealT <: Real,
86+
ElectronPressure, ElectronTemperature} <:
87+
AbstractIdealGlmMhdMultiIonEquations{2, NVARS, NCOMP}
8888
gammas::SVector{NCOMP, RealT} # Heat capacity ratios
8989
charge_to_mass::SVector{NCOMP, RealT} # Charge to mass ratios
9090
gas_constants::SVector{NCOMP, RealT} # Specific gas constants

src/equations/ideal_glm_mhd_multiion_3d.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ References:
3838
In case of more than one ion species, the multi-ion GLM-MHD equations should ALWAYS be used
3939
with [`source_terms_lorentz`](@ref).
4040
"""
41-
mutable struct IdealGlmMhdMultiIonEquations3D{NVARS, NCOMP, RealT <: Real,
42-
ElectronPressure} <:
43-
AbstractIdealGlmMhdMultiIonEquations{3, NVARS, NCOMP}
41+
struct IdealGlmMhdMultiIonEquations3D{NVARS, NCOMP, RealT <: Real,
42+
ElectronPressure} <:
43+
AbstractIdealGlmMhdMultiIonEquations{3, NVARS, NCOMP}
4444
gammas::SVector{NCOMP, RealT} # Heat capacity ratios
4545
charge_to_mass::SVector{NCOMP, RealT} # Charge to mass ratios
4646
electron_pressure::ElectronPressure # Function to compute the electron pressure

0 commit comments

Comments
 (0)