-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format source code based on ˋSciMLˋ style (4 spaces) (#1513)
* Format source code based on ˋSciMLˋ style (4 spaces) * Make JuliaFormatter consume the two-layer SWE files again * Remove files from ignore list * Format two-layer SWE files * Fix recursive_length formatting * Find accceptable formatting for SemiHypMeshBCSolver * Slightly improve semi_hyp_par formatting * Variant on TrixiODESolution type formatting * add FormatCheck CI job * Allow alignment in struct definitions * Fix formatting abomination * Remove useless spam * Sanitize type alias * Fix using statement * Update src/auxiliary/mpi.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Update src/callbacks_stage/positivity_zhang_shu.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Update src/callbacks_step/amr_dg2d.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Update src/callbacks_step/analysis.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Format the formatter * substituted non-ascii lambda (#1521) * rename format-check job name * fix bad formatting * improve some bad formatting * align some struct fields * align some struct fields * align some struct fields * begin end blocks for some at-trixi_timeit * Update src/visualization/utilities.jl * Update src/solvers/fdsbp_tree/fdsbp.jl * Update src/meshes/p4est_mesh.jl * Update src/meshes/p4est_mesh.jl * comments on pssing nothing as mortar * comment on passing nothing as mortar * formatting on/off blocks * Copy JuliaFormatter.toml from TrixiParticles.jl * Add info on automated source code formatting * Format `ext/` * Format `benchmark/` * Format `utils/` --------- Co-authored-by: Hendrik Ranocha <[email protected]> Co-authored-by: Joshua Lampert <[email protected]> Co-authored-by: Hendrik Ranocha <[email protected]> Co-authored-by: Jesse Chan <[email protected]>
- Loading branch information
1 parent
4357fe9
commit 2bc1cc6
Showing
207 changed files
with
46,607 additions
and
43,236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use SciML style: https://github.com/SciML/SciMLStyle | ||
style = "sciml" | ||
|
||
# Python style alignment. See https://github.com/domluna/JuliaFormatter.jl/pull/732. | ||
yas_style_nesting = true | ||
|
||
# Align struct fields for better readability of large struct definitions | ||
align_struct_field = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: format-check | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: '*' | ||
pull_request: | ||
|
||
jobs: | ||
check-format: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
julia-version: [1] | ||
julia-arch: [x86] | ||
os: [ubuntu-latest] | ||
steps: | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: ${{ matrix.julia-version }} | ||
|
||
- uses: actions/checkout@v3 | ||
- name: Install JuliaFormatter and format | ||
# This will use the latest version by default but you can set the version like so: | ||
# | ||
# julia -e 'using Pkg; Pkg.add(PackageSpec(name = "JuliaFormatter", version = "0.13.0"))' | ||
# | ||
# TODO: Change the call below to | ||
# format(".") | ||
run: | | ||
julia -e 'using Pkg; Pkg.add(PackageSpec(name = "JuliaFormatter"))' | ||
julia -e 'using JuliaFormatter; format(["benchmark", "ext", "src", "utils"])' | ||
- name: Format check | ||
run: | | ||
julia -e ' | ||
out = Cmd(`git diff --name-only`) |> read |> String | ||
if out == "" | ||
exit(0) | ||
else | ||
@error "Some files have not been formatted !!!" | ||
write(stdout, out) | ||
exit(1) | ||
end' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
using Printf, BenchmarkTools, Trixi | ||
|
||
function run_benchmarks(benchmark_run; levels=0:5, polydeg=3) | ||
runtimes = zeros(length(levels)) | ||
for (idx,initial_refinement_level) in enumerate(levels) | ||
result = benchmark_run(; initial_refinement_level, polydeg) | ||
display(result) | ||
runtimes[idx] = result |> median |> time # in nanoseconds | ||
end | ||
return (; levels, runtimes, polydeg) | ||
function run_benchmarks(benchmark_run; levels = 0:5, polydeg = 3) | ||
runtimes = zeros(length(levels)) | ||
for (idx, initial_refinement_level) in enumerate(levels) | ||
result = benchmark_run(; initial_refinement_level, polydeg) | ||
display(result) | ||
runtimes[idx] = result |> median |> time # in nanoseconds | ||
end | ||
return (; levels, runtimes, polydeg) | ||
end | ||
|
||
function tabulate_benchmarks(args...; kwargs...) | ||
result = run_benchmarks(args...; kwargs...) | ||
println("#Elements | Runtime in seconds") | ||
for (level,runtime) in zip(result.levels, result.runtimes) | ||
@printf("%9d | %.2e\n", 4^level, 1.0e-9 * runtime) | ||
end | ||
for (level,runtime) in zip(result.levels, result.runtimes) | ||
@printf("%.16e\n", 1.0e-9 * runtime) | ||
end | ||
result = run_benchmarks(args...; kwargs...) | ||
println("#Elements | Runtime in seconds") | ||
for (level, runtime) in zip(result.levels, result.runtimes) | ||
@printf("%9d | %.2e\n", 4^level, 1.0e-9*runtime) | ||
end | ||
for (level, runtime) in zip(result.levels, result.runtimes) | ||
@printf("%.16e\n", 1.0e-9*runtime) | ||
end | ||
end | ||
|
||
function benchmark_euler(; initial_refinement_level=1, polydeg=3) | ||
function benchmark_euler(; initial_refinement_level = 1, polydeg = 3) | ||
γ = 1.4 | ||
equations = CompressibleEulerEquations2D(γ) | ||
|
||
γ = 1.4 | ||
equations = CompressibleEulerEquations2D(γ) | ||
surface_flux = flux_ranocha | ||
volume_flux = flux_ranocha | ||
solver = DGSEM(polydeg, surface_flux, VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
surface_flux = flux_ranocha | ||
volume_flux = flux_ranocha | ||
solver = DGSEM(polydeg, surface_flux, VolumeIntegralFluxDifferencing(volume_flux)) | ||
coordinates_min = (-2.0, -2.0) | ||
coordinates_max = (2.0, 2.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = initial_refinement_level, | ||
n_cells_max = 100_000) | ||
|
||
coordinates_min = (-2.0, -2.0) | ||
coordinates_max = ( 2.0, 2.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level=initial_refinement_level, | ||
n_cells_max=100_000) | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_weak_blast_wave, | ||
solver) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_weak_blast_wave, solver) | ||
t0 = 0.0 | ||
u0 = compute_coefficients(t0, semi) | ||
du = similar(u0) | ||
|
||
t0 = 0.0 | ||
u0 = compute_coefficients(t0, semi) | ||
du = similar(u0) | ||
|
||
@benchmark Trixi.rhs!($du, $u0, $semi, $t0) | ||
@benchmark Trixi.rhs!($du, $u0, $semi, $t0) | ||
end | ||
|
||
# versioninfo(verbose=true) | ||
@show Threads.nthreads() | ||
tabulate_benchmarks(benchmark_euler, levels=0:8) | ||
tabulate_benchmarks(benchmark_euler, levels = 0:8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.