Skip to content

Commit 7d92aaf

Browse files
authored
Format documentation (trixi-framework#2111)
* Format * Fix * Add format * Add * Fix * Fix
1 parent 00ef308 commit 7d92aaf

34 files changed

+1538
-1258
lines changed

docs/literate/make.jl

+24-18
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ using Test: @testset
33
import Pkg
44

55
# Create markdown and notebook files for `file`
6-
function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder="")
6+
function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder = "")
77
notebook_filename = first(splitext(file)) * ".ipynb"
88
if !isempty(folder)
99
notebook_filename = joinpath(folder, notebook_filename)
1010
end
1111

12-
binder_logo = "https://mybinder.org/badge_logo.svg"
12+
binder_logo = "https://mybinder.org/badge_logo.svg"
1313
nbviewer_logo = "https://img.shields.io/badge/render-nbviewer-f37726"
1414
raw_notebook_logo = "https://img.shields.io/badge/raw-notebook-4cc61e"
1515

1616
notebook_path = "tutorials/notebooks/$notebook_filename"
17-
binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path"
17+
binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path"
1818
nbviewer_url = "https://nbviewer.jupyter.org/github/trixi-framework/Trixi.jl/blob/tutorial_notebooks/$notebook_path"
1919
raw_notebook_url = "https://raw.githubusercontent.com/trixi-framework/Trixi.jl/tutorial_notebooks/$notebook_path"
2020

21-
binder_badge = "# [![]($binder_logo)]($binder_url)"
21+
binder_badge = "# [![]($binder_logo)]($binder_url)"
2222
nbviewer_badge = "# [![]($nbviewer_logo)]($nbviewer_url)"
2323
raw_notebook_badge = "# [![]($raw_notebook_logo)]($raw_notebook_url)"
2424

@@ -28,25 +28,28 @@ function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder=""
2828
# available for the latest stable release of Trixi.jl at the time of caching.\n\n"
2929
return string("# # $title\n\n", warning, content)
3030
end
31-
Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder); execute=false, preprocess=preprocess_notebook, credit=false)
31+
Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder);
32+
execute = false, preprocess = preprocess_notebook, credit = false)
3233

3334
# Generate markdown file
3435
function preprocess_docs(content)
35-
return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $raw_notebook_badge\n\n", content)
36+
return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $raw_notebook_badge\n\n",
37+
content)
3638
end
37-
Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder); preprocess=preprocess_docs,)
39+
Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder);
40+
preprocess = preprocess_docs,)
3841
end
3942

4043
# Create tutorials with Literate.jl
4144
function create_tutorials(files)
42-
repo_src = joinpath(@__DIR__, "src", "files")
45+
repo_src = joinpath(@__DIR__, "src", "files")
4346

44-
pages_dir = joinpath(@__DIR__, "..", "src", "tutorials")
45-
notebooks_dir = joinpath(pages_dir, "notebooks")
47+
pages_dir = joinpath(@__DIR__, "..", "src", "tutorials")
48+
notebooks_dir = joinpath(pages_dir, "notebooks")
4649

47-
Sys.rm(pages_dir; recursive=true, force=true)
50+
Sys.rm(pages_dir; recursive = true, force = true)
4851

49-
Sys.rm("out"; recursive=true, force=true)
52+
Sys.rm("out"; recursive = true, force = true)
5053

5154
# Run tests on all tutorial files
5255
@testset "TrixiTutorials" begin
@@ -59,15 +62,16 @@ function create_tutorials(files)
5962
mod = gensym(filename[j][2][2])
6063
@testset "$(filename[j][2][2])" begin
6164
@eval module $mod
62-
include(joinpath($repo_src, $(filename[j][2][1]), $(filename[j][2][2])))
65+
include(joinpath($repo_src, $(filename[j][2][1]),
66+
$(filename[j][2][2])))
6367
end
6468
end
6569
end
6670
else # Single files
6771
mod = gensym(title)
6872
@testset "$title" begin
6973
@eval module $mod
70-
include(joinpath($repo_src, $filename))
74+
include(joinpath($repo_src, $filename))
7175
end
7276
end
7377
end
@@ -85,18 +89,20 @@ function create_tutorials(files)
8589
end
8690
return content
8791
end
88-
Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name="introduction", preprocess=preprocess_introduction)
92+
Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name = "introduction",
93+
preprocess = preprocess_introduction)
8994
# Navigation system for makedocs
90-
pages = Any["Introduction" => "tutorials/introduction.md",]
95+
pages = Any["Introduction" => "tutorials/introduction.md"]
9196

9297
# Create markdown and notebook files for tutorials
9398
for (i, (title, filename)) in enumerate(files)
9499
# Several files of one topic are created separately and pushed to `pages` together.
95100
if filename isa Vector
96101
vector = []
97102
for j in eachindex(filename)
98-
create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2], repo_src,
99-
pages_dir, notebooks_dir; folder=filename[j][2][1])
103+
create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2],
104+
repo_src,
105+
pages_dir, notebooks_dir; folder = filename[j][2][1])
100106

101107
path = "$(filename[j][2][1])/$(splitext(filename[j][2][2])[1]).md"
102108
push!(vector, "$i.$j $(filename[j][1])" => "tutorials/$path")

docs/literate/src/files/DGMulti_1.jl

+33-37
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ dg = DGMulti(polydeg = 3,
3030
cells_per_dimension = (32, 32)
3131
mesh = DGMultiMesh(dg,
3232
cells_per_dimension, # initial_refinement_level = 5
33-
coordinates_min=(-2.0, -2.0),
34-
coordinates_max=( 2.0, 2.0),
35-
periodicity=true)
33+
coordinates_min = (-2.0, -2.0),
34+
coordinates_max = (2.0, 2.0),
35+
periodicity = true)
3636

3737
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
38-
boundary_conditions=boundary_condition_periodic)
38+
boundary_conditions = boundary_condition_periodic)
3939
tspan = (0.0, 0.4)
4040
ode = semidiscretize(semi, tspan)
4141

42-
alive_callback = AliveCallback(alive_interval=10)
43-
analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg))
42+
alive_callback = AliveCallback(alive_interval = 10)
43+
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
4444
callbacks = CallbackSet(analysis_callback, alive_callback);
4545

4646
# Run the simulation with the same time integration algorithm as before.
47-
sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-6, reltol=1.0e-6,
48-
callback=callbacks, save_everystep=false);
47+
sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-6, reltol = 1.0e-6,
48+
callback = callbacks, save_everystep = false);
4949
#-
5050
using Plots
5151
pd = PlotData2D(sol)
@@ -60,7 +60,6 @@ plot!(getmesh(pd))
6060
# (2021) provides a nice runtime comparison between the different mesh types. On the other hand,
6161
# the functions are more general and thus we have more option we can choose from.
6262

63-
6463
# ## Simulation with Gauss nodes
6564
# For instance, we can change the approximation type of our simulation.
6665
using Trixi, OrdinaryDiffEq
@@ -78,28 +77,27 @@ dg = DGMulti(polydeg = 3,
7877

7978
cells_per_dimension = (32, 32)
8079
mesh = DGMultiMesh(dg,
81-
cells_per_dimension, # initial_refinement_level = 5
82-
coordinates_min=(-2.0, -2.0),
83-
coordinates_max=( 2.0, 2.0),
84-
periodicity=true)
80+
cells_per_dimension, # initial_refinement_level = 5
81+
coordinates_min = (-2.0, -2.0),
82+
coordinates_max = (2.0, 2.0),
83+
periodicity = true)
8584

8685
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
87-
boundary_conditions=boundary_condition_periodic)
86+
boundary_conditions = boundary_condition_periodic)
8887
tspan = (0.0, 0.4)
8988
ode = semidiscretize(semi, tspan)
9089

91-
alive_callback = AliveCallback(alive_interval=10)
92-
analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg))
90+
alive_callback = AliveCallback(alive_interval = 10)
91+
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
9392
callbacks = CallbackSet(analysis_callback, alive_callback);
9493

95-
sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6,
96-
ode_default_options()..., callback=callbacks);
94+
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,
95+
ode_default_options()..., callback = callbacks);
9796
#-
9897
using Plots
9998
pd = PlotData2D(sol)
10099
plot(pd)
101100

102-
103101
# ## Simulation with triangular elements
104102
# Also, we can set another element type. We want to use triangles now.
105103
using Trixi, OrdinaryDiffEq
@@ -119,21 +117,21 @@ dg = DGMulti(polydeg = 3,
119117
cells_per_dimension = (32, 32)
120118
mesh = DGMultiMesh(dg,
121119
cells_per_dimension, # initial_refinement_level = 5
122-
coordinates_min=(-2.0, -2.0),
123-
coordinates_max=( 2.0, 2.0),
124-
periodicity=true)
120+
coordinates_min = (-2.0, -2.0),
121+
coordinates_max = (2.0, 2.0),
122+
periodicity = true)
125123

126124
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
127-
boundary_conditions=boundary_condition_periodic)
125+
boundary_conditions = boundary_condition_periodic)
128126
tspan = (0.0, 0.4)
129127
ode = semidiscretize(semi, tspan)
130128

131-
alive_callback = AliveCallback(alive_interval=10)
132-
analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg))
129+
alive_callback = AliveCallback(alive_interval = 10)
130+
analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg))
133131
callbacks = CallbackSet(analysis_callback, alive_callback);
134132

135-
sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6,
136-
ode_default_options()..., callback=callbacks);
133+
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,
134+
ode_default_options()..., callback = callbacks);
137135
#-
138136
using Plots
139137
pd = PlotData2D(sol)
@@ -142,7 +140,6 @@ plot(pd)
142140
plot(pd["rho"])
143141
plot!(getmesh(pd))
144142

145-
146143
# ## Triangular meshes on non-Cartesian domains
147144
# To use triangular meshes on a non-Cartesian domain, Trixi.jl uses the package [StartUpDG.jl](https://github.com/jlchan/StartUpDG.jl).
148145
# The following example is based on [`elixir_euler_triangulate_pkg_mesh.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl)
@@ -157,7 +154,7 @@ source_terms = source_terms_convergence_test
157154

158155
# We create the solver `DGMulti` with triangular elements (`Tri()`) as before.
159156
dg = DGMulti(polydeg = 3, element_type = Tri(),
160-
approximation_type=Polynomial(),
157+
approximation_type = Polynomial(),
161158
surface_flux = flux_lax_friedrichs,
162159
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))
163160

@@ -168,11 +165,11 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole());
168165

169166
# The pre-defined Triangulate geometry in StartUpDG has integer boundary tags. With [`DGMultiMesh`](@ref)
170167
# we assign boundary faces based on these integer boundary tags and create a mesh compatible with Trixi.jl.
171-
mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary=>1, :inner_boundary=>2))
168+
mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary => 1, :inner_boundary => 2))
172169
#-
173170
boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
174171
boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test,
175-
:inner_boundary => boundary_condition_convergence_test)
172+
:inner_boundary => boundary_condition_convergence_test)
176173

177174
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
178175
source_terms = source_terms,
@@ -181,12 +178,12 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
181178
tspan = (0.0, 0.2)
182179
ode = semidiscretize(semi, tspan)
183180

184-
alive_callback = AliveCallback(alive_interval=20)
185-
analysis_callback = AnalysisCallback(semi, interval=200, uEltype=real(dg))
181+
alive_callback = AliveCallback(alive_interval = 20)
182+
analysis_callback = AnalysisCallback(semi, interval = 200, uEltype = real(dg))
186183
callbacks = CallbackSet(alive_callback, analysis_callback);
187184

188-
sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false),
189-
dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks);
185+
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
186+
dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks);
190187
#-
191188
using Plots
192189
pd = PlotData2D(sol)
@@ -195,7 +192,6 @@ plot!(getmesh(pd))
195192

196193
# For more information, please have a look in the [StartUpDG.jl documentation](https://jlchan.github.io/StartUpDG.jl/stable/).
197194

198-
199195
# ## Package versions
200196

201197
# These results were obtained using the following versions.
@@ -205,4 +201,4 @@ versioninfo()
205201

206202
using Pkg
207203
Pkg.status(["Trixi", "StartUpDG", "OrdinaryDiffEq", "Plots"],
208-
mode=PKGMODE_MANIFEST)
204+
mode = PKGMODE_MANIFEST)

docs/literate/src/files/DGMulti_2.jl

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# to the `DGMulti` constructor. For example, the classical second-order FD SBP operator
99
# can be created as
1010
using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly
11-
D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_order=2,
12-
xmin=0.0, xmax=1.0, N=11)
11+
D = derivative_operator(MattssonNordström2004(), derivative_order = 1, accuracy_order = 2,
12+
xmin = 0.0, xmax = 1.0, N = 11)
1313
# Here, the arguments `xmin` and `xmax` do not matter beyond setting the real type
1414
# used for the operator - they just set a reference element and are rescaled on the
1515
# physical elements. The parameter `N` determines the number of finite difference nodes.
@@ -20,8 +20,8 @@ D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_o
2020
#
2121
# You can also use fully periodic single-block FD methods by creating a periodic SBP
2222
# operator. For example, a fully periodic FD operator can be constructed as
23-
D = periodic_derivative_operator(derivative_order=1, accuracy_order=2,
24-
xmin=0.0, xmax=1.0, N=11)
23+
D = periodic_derivative_operator(derivative_order = 1, accuracy_order = 2,
24+
xmin = 0.0, xmax = 1.0, N = 11)
2525
# An example using such an FD method is implemented in
2626
# [`elixir_euler_fdsbp_periodic.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl).
2727
# For all parameters and other calling options, please have a look in the
@@ -31,15 +31,14 @@ D = periodic_derivative_operator(derivative_order=1, accuracy_order=2,
3131
# method with polynomial degree of `3` (`N=4` Legendre Lobatto nodes on `[0, 1]`) coupled continuously
3232
# on a uniform mesh with `Nx=10` elements by setting `approximation_type` to
3333
using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly
34-
D = couple_continuously(legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4),
35-
UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10))
34+
D = couple_continuously(legendre_derivative_operator(xmin = 0.0, xmax = 1.0, N = 4),
35+
UniformPeriodicMesh1D(xmin = -1.0, xmax = 1.0, Nx = 10))
3636

3737
# To choose a discontinuous coupling (DGSEM), use `couple_discontinuously()` instead of `couple_continuously()`.
3838

3939
# For more information and other SBP operators, see the documentations of [StartUpDG.jl](https://jlchan.github.io/StartUpDG.jl/dev/)
4040
# and [SummationByPartsOperators.jl](https://ranocha.de/SummationByPartsOperators.jl/stable/).
4141

42-
4342
# ## Package versions
4443

4544
# These results were obtained using the following versions.
@@ -49,4 +48,4 @@ versioninfo()
4948

5049
using Pkg
5150
Pkg.status(["Trixi", "StartUpDG", "SummationByPartsOperators"],
52-
mode=PKGMODE_MANIFEST)
51+
mode = PKGMODE_MANIFEST)

0 commit comments

Comments
 (0)