Skip to content

Commit

Permalink
use formatter version in format check
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmontoya committed Oct 3, 2024
1 parent ff5f16a commit 0753e35
Show file tree
Hide file tree
Showing 38 changed files with 1,804 additions and 1,767 deletions.
4 changes: 2 additions & 2 deletions src/.JuliaFormatter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
style = "sciml"

# Python style alignment. See https://github.com/domluna/JuliaFormatter.jl/pull/732.
yas_style_nesting = true
yas_style_nesting = false

# Align struct fields for better readability of large struct definitions
align_struct_field = true
align_struct_field = true
97 changes: 49 additions & 48 deletions src/Analysis/Analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@ module Analysis

using LinearMaps: LinearMap, UniformScalingMap
using LinearAlgebra:
Diagonal,
diag,
diagm,
mul!,
lmul!,
dot,
norm,
eigen,
inv,
svd,
qr,
pinv,
eigsortby,
I,
rank,
cond
Diagonal,
diag,
diagm,
mul!,
lmul!,
dot,
norm,
eigen,
inv,
svd,
qr,
pinv,
eigsortby,
I,
rank,
cond
using JLD2: save, load, save_object, load_object
using Plots:
plot,
savefig,
plot!,
scatter,
text,
annotate!,
vline!,
grid,
theme_palette,
twinx,
@layout
plot,
savefig,
plot!,
scatter,
text,
annotate!,
vline!,
grid,
theme_palette,
twinx,
@layout
using LaTeXStrings: LaTeXString, latexstring
using SparseArrays: sparse, blockdiag, kron!
using OrdinaryDiffEq:
OrdinaryDiffEqAlgorithm, ODESolution, ODEIntegrator, solve, RK4,
step!, reinit!
OrdinaryDiffEqAlgorithm,
ODESolution, ODEIntegrator, solve, RK4,
step!, reinit!
using StartUpDG: MeshData, vandermonde
using RecipesBase
using Printf
Expand All @@ -53,40 +54,40 @@ using ..File
using ..Visualize

export AbstractAnalysis,
AbstractAnalysisResults,
analyze,
analyze_new,
save_analysis,
tabulate_analysis,
tabulate_analysis_for_paper
AbstractAnalysisResults,
analyze,
analyze_new,
save_analysis,
tabulate_analysis,
tabulate_analysis_for_paper

abstract type AbstractAnalysis end
abstract type AbstractAnalysisResults end

function save_analysis(analysis::AbstractAnalysis, results::AbstractAnalysisResults)
save(string(analysis.analysis_path, "analysis.jld2"),
Dict("analysis" => analysis, "results" => results))
Dict("analysis" => analysis, "results" => results))
end

export ErrorAnalysis, AbstractNorm, QuadratureL2, QuadratureL2Normalized
include("error.jl")

export ConservationAnalysis,
PrimaryConservationAnalysis,
EnergyConservationAnalysis,
EntropyConservationAnalysis,
ConservationAnalysisResults,
ConservationAnalysisResultsWithDerivative,
evaluate_conservation,
evaluate_conservation_residual
PrimaryConservationAnalysis,
EnergyConservationAnalysis,
EntropyConservationAnalysis,
ConservationAnalysisResults,
ConservationAnalysisResultsWithDerivative,
evaluate_conservation,
evaluate_conservation_residual
include("conservation.jl")

export RefinementAnalysis,
RefinementErrorAnalysis,
RefinementAnalysisResults,
RefinementErrorAnalysisResults,
run_refinement,
get_tickslogscale
RefinementErrorAnalysis,
RefinementAnalysisResults,
RefinementErrorAnalysisResults,
run_refinement,
get_tickslogscale
include("refinement.jl")

export scaling_test_euler_2d
Expand Down
94 changes: 47 additions & 47 deletions src/Analysis/benchmark.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

"""This removes the threading and considers just one element. Note that this probably will not work with the Euler equations as the facet states at adjacent elements are left undefined and thus may lead to non-physical states when used to compute the fluxes"""
@views @timeit "semi-disc. residual" function rhs_benchmark!(dudt::AbstractArray{Float64,
3},
u::AbstractArray{Float64, 3},
solver::Solver{<:AbstractConservationLaw{d,
FirstOrder},
<:ReferenceOperators,
<:AbstractMassMatrixSolver,
<:StandardForm},
t::Float64 = 0.0) where {d}
3},
u::AbstractArray{Float64, 3},
solver::Solver{<:AbstractConservationLaw{d,
FirstOrder},
<:ReferenceOperators,
<:AbstractMassMatrixSolver,
<:StandardForm},
t::Float64 = 0.0) where {d}
@timeit "unpack" begin
(; conservation_law, connectivity, form) = solver
(; inviscid_numerical_flux) = form
Expand All @@ -25,11 +25,11 @@
@timeit "phys flux" physical_flux!(f_q[:, :, :, k], conservation_law, u_q[:, :, k])

@timeit "num flux" numerical_flux!(f_f[:, :, k],
conservation_law,
inviscid_numerical_flux,
u_f[:, k, :],
u_f[CI[connectivity[:, k]], :],
n_f[:, :, k])
conservation_law,
inviscid_numerical_flux,
u_f[:, k, :],
u_f[CI[connectivity[:, k]], :],
n_f[:, :, k])

@timeit "fill w zeros" fill!(r_q[:, :, k], 0.0)

Expand Down Expand Up @@ -61,21 +61,21 @@
# solve for time derivative
@timeit "trans. VDM" mul!(dudt[:, :, k], V', r_q[:, :, k])
@timeit "mass solve" mass_matrix_solve!(solver.mass_solver,
k,
dudt[:, :, k],
u_q[:, :, k])
k,
dudt[:, :, k],
u_q[:, :, k])
return dudt
end

@views @timeit "semi-disc. residual" function rhs_benchmark!(dudt::AbstractArray{Float64,
3},
u::AbstractArray{Float64, 3},
solver::Solver{<:AbstractConservationLaw{d,
FirstOrder},
<:PhysicalOperators,
<:AbstractMassMatrixSolver,
<:StandardForm},
t::Float64 = 0.0) where {d}
3},
u::AbstractArray{Float64, 3},
solver::Solver{<:AbstractConservationLaw{d,
FirstOrder},
<:PhysicalOperators,
<:AbstractMassMatrixSolver,
<:StandardForm},
t::Float64 = 0.0) where {d}
@timeit "unpack" begin
(; conservation_law, operators, connectivity, form) = solver
(; inviscid_numerical_flux) = form
Expand All @@ -90,11 +90,11 @@ end
@timeit "phys flux" physical_flux!(f_q[:, :, :, k], conservation_law, u_q[:, :, k])

@timeit "num flux" numerical_flux!(f_f[:, :, k],
conservation_law,
inviscid_numerical_flux,
u_f[:, k, :],
u_f[CI[connectivity[:, k]], :],
operators.n_f[k])
conservation_law,
inviscid_numerical_flux,
u_f[:, k, :],
u_f[CI[connectivity[:, k]], :],
operators.n_f[k])

@timeit "fill w zeros" fill!(view(dudt, :, :, k), 0.0)

Expand All @@ -112,9 +112,9 @@ end
end

function scaling_test_euler_2d(p::Int,
M::Int,
path = "./results/euler_benchmark/",
parallelism = Threaded())
M::Int,
path = "./results/euler_benchmark/",
parallelism = Threaded())
path = new_path(path, true, true)

mach_number = 0.4
Expand All @@ -126,38 +126,38 @@ function scaling_test_euler_2d(p::Int,

conservation_law = EulerEquations{2}(γ)
exact_solution = IsentropicVortex(conservation_law,
θ = angle,
Ma = mach_number,
β = strength,
R = 1.0 / 10.0,
x_0 = (L / 2, L / 2))
θ = angle,
Ma = mach_number,
β = strength,
R = 1.0 / 10.0,
x_0 = (L / 2, L / 2))

form = FluxDifferencingForm(inviscid_numerical_flux = LaxFriedrichsNumericalFlux())

println("building reference approximation...")
reference_approximation = ReferenceApproximation(ModalTensor(p), Tri(),
mapping_degree = p, N_plot = 25)
mapping_degree = p, N_plot = 25)

println("generating mesh...")
uniform_mesh = uniform_periodic_mesh(reference_approximation, ((0.0, L), (0.0, L)),
(M, M))
(M, M))

println("warping mesh...")
mesh = warp_mesh(uniform_mesh, reference_approximation, ChanWarping(1 / 16, (L, L)))

println("building global discretization...")
spatial_discretization = SpatialDiscretization(mesh, reference_approximation,
project_jacobian = true)
project_jacobian = true)

println("preprocessing...")
ode = semidiscretize(conservation_law,
spatial_discretization,
exact_solution,
form,
(0.0, T),
ReferenceOperator(),
GenericTensorProductAlgorithm(),
parallelism = parallelism)
spatial_discretization,
exact_solution,
form,
(0.0, T),
ReferenceOperator(),
GenericTensorProductAlgorithm(),
parallelism = parallelism)

dudt = similar(ode.u0)
println("solving...")
Expand Down
Loading

0 comments on commit 0753e35

Please sign in to comment.