Skip to content

Commit 8af7785

Browse files
Merge pull request #57 from ChrisRackauckas/fix-formatting
Apply JuliaFormatter to fix code formatting
2 parents cae6c59 + 021b037 commit 8af7785

File tree

75 files changed

+2856
-2157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2856
-2157
lines changed

.JuliaFormatter.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
style = "sciml"
2+
format_markdown = true
3+
format_docstrings = true

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@
55
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://SciML.github.io/FiniteVolumeMethod.jl/stable)
66
[![Coverage](https://codecov.io/gh/SciML/FiniteVolumeMethod.jl/branch/main/graph/badge.svg?token=XPM5KN89R6)](https://codecov.io/gh/SciML/FiniteVolumeMethod.jl)
77

8-
This is a Julia package for solving partial differential equations (PDEs) of the form
8+
This is a Julia package for solving partial differential equations (PDEs) of the form
99

1010
$$
1111
\dfrac{\partial u(\boldsymbol x, t)}{\partial t} + \boldsymbol{\nabla} \boldsymbol{\cdot} \boldsymbol{q}(\boldsymbol x, t, u) = S(\boldsymbol x, t, u), \quad (x, y)^{\mkern-1.5mu\mathsf{T}} \in \Omega \subset \mathbb R^2,t>0,
1212
$$
1313

1414
in two dimensions using the finite volume method, with support also provided for steady-state problems and for systems of PDEs of the above form. In addition to this generic form above, we also provide support for specific problems that can be solved in a more efficient manner, namely:
1515

16-
1. `DiffusionEquation`s: $\partial_tu = \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u]$.
17-
2. `MeanExitTimeProblem`s: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla T(\boldsymbol x)] = -1$.
18-
3. `LinearReactionDiffusionEquation`s: $\partial_tu = \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] + f(\boldsymbol x)u$.
19-
4. `PoissonsEquation`: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] = f(\boldsymbol x)$.
20-
5. `LaplacesEquation`: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] = 0$.
16+
1. `DiffusionEquation`s: $\partial_tu = \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u]$.
17+
2. `MeanExitTimeProblem`s: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla T(\boldsymbol x)] = -1$.
18+
3. `LinearReactionDiffusionEquation`s: $\partial_tu = \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] + f(\boldsymbol x)u$.
19+
4. `PoissonsEquation`: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] = f(\boldsymbol x)$.
20+
5. `LaplacesEquation`: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] = 0$.
2121

2222
See the documentation for more information.
2323

2424
If this package doesn't suit what you need, you may like to review some of the other PDE packages shown [here](https://github.com/JuliaPDE/SurveyofPDEPackages).
2525

26-
As a very quick demonstration, here is how we could solve a diffusion equation with Dirichlet boundary conditions on a square domain using the standard `FVMProblem` formulation; please see the docs for more information.
26+
As a very quick demonstration, here is how we could solve a diffusion equation with Dirichlet boundary conditions on a square domain using the standard `FVMProblem` formulation; please see the docs for more information.
2727

2828
```julia
2929
using FiniteVolumeMethod, DelaunayTriangulation, CairoMakie, OrdinaryDiffEq
3030
a, b, c, d = 0.0, 2.0, 0.0, 2.0
3131
nx, ny = 50, 50
32-
tri = triangulate_rectangle(a, b, c, d, nx, ny, single_boundary=true)
32+
tri = triangulate_rectangle(a, b, c, d, nx, ny, single_boundary = true)
3333
mesh = FVMGeometry(tri)
3434
bc = (x, y, t, u, p) -> zero(u)
3535
BCs = BoundaryConditions(mesh, bc, Dirichlet)
3636
f = (x, y) -> y 1.0 ? 50.0 : 0.0
3737
initial_condition = [f(x, y) for (x, y) in DelaunayTriangulation.each_point(tri)]
3838
D = (x, y, t, u, p) -> 1 / 9
3939
final_time = 0.5
40-
prob = FVMProblem(mesh, BCs; diffusion_function=D, initial_condition, final_time)
41-
sol = solve(prob, Tsit5(), saveat=0.001)
40+
prob = FVMProblem(mesh, BCs; diffusion_function = D, initial_condition, final_time)
41+
sol = solve(prob, Tsit5(), saveat = 0.001)
4242
u = Observable(sol.u[1])
43-
fig, ax, sc = tricontourf(tri, u, levels=0:5:50, colormap=:matter)
43+
fig, ax, sc = tricontourf(tri, u, levels = 0:5:50, colormap = :matter)
4444
tightlimits!(ax)
4545
record(fig, "anim.gif", eachindex(sol)) do i
4646
u[] = sol.u[i]
@@ -49,10 +49,10 @@ end
4949

5050
![Animation of a solution](https://github.com/SciML/FiniteVolumeMethod.jl/blob/main/anim.gif)
5151

52-
We could have equivalently used the `DiffusionEquation` template, so that `prob` could have also been defined by
52+
We could have equivalently used the `DiffusionEquation` template, so that `prob` could have also been defined by
5353

5454
```julia
55-
prob = DiffusionEquation(mesh, BCs; diffusion_function=D, initial_condition, final_time)
55+
prob = DiffusionEquation(mesh, BCs; diffusion_function = D, initial_condition, final_time)
5656
```
5757

5858
and be solved much more efficiently. See the documentation for more information.

docs/liveserver.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ Pkg.instantiate()
55
import LiveServer
66
withenv("LIVESERVER_ACTIVE" => "true") do
77
LiveServer.servedocs(;
8-
launch_browser=true,
9-
foldername=joinpath(repo_root, "docs"),
10-
include_dirs=[joinpath(repo_root, "src")],
11-
skip_dirs=[joinpath(repo_root, "docs/src/tutorials"),
8+
launch_browser = true,
9+
foldername = joinpath(repo_root, "docs"),
10+
include_dirs = [joinpath(repo_root, "src")],
11+
skip_dirs = [joinpath(repo_root, "docs/src/tutorials"),
1212
joinpath(repo_root, "docs/src/wyos"),
13-
joinpath(repo_root, "docs/src/figures"),
14-
],
13+
joinpath(repo_root, "docs/src/figures")
14+
]
1515
)
16-
end
16+
end

docs/make.jl

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,23 @@ if RUN_EXAMPLES
2222
function update_edit_url(content, file, folder)
2323
content = replace(content, "<unknown>" => "https://github.com/SciML/FiniteVolumeMethod.jl/tree/main")
2424
content = replace(content, "temp/" => "") # as of Literate 2.14.1
25-
content = replace(content, r"EditURL\s*=\s*\"[^\"]*\"" => "EditURL = \"https://github.com/SciML/FiniteVolumeMethod.jl/tree/main/docs/src/literate_$(folder)/$file\"")
25+
content = replace(content,
26+
r"EditURL\s*=\s*\"[^\"]*\"" => "EditURL = \"https://github.com/SciML/FiniteVolumeMethod.jl/tree/main/docs/src/literate_$(folder)/$file\"")
2627
return content
2728
end
2829
# We can add the code to the end of each file in its uncommented form programatically.
2930
function add_just_the_code_section(dir, file)
3031
file_name, file_ext = splitext(file)
3132
file_path = joinpath(dir, file)
3233
new_file_path = joinpath(session_tmp, file_name * "_just_the_code" * file_ext)
33-
cp(file_path, new_file_path, force=true)
34+
cp(file_path, new_file_path, force = true)
3435
folder = splitpath(dir)[end] # literate_tutorials or literate_applications
3536
open(new_file_path, "a") do io
3637
write(io, "\n")
3738
write(io, "# ## Just the code\n")
3839
write(io, "# An uncommented version of this example is given below.\n")
39-
write(io, "# You can view the source code for this file [here](<unknown>/docs/src/$folder/@__NAME__.jl).\n")
40+
write(io,
41+
"# You can view the source code for this file [here](<unknown>/docs/src/$folder/@__NAME__.jl).\n")
4042
write(io, "\n")
4143
write(io, "# ```julia\n")
4244
write(io, "# @__CODE__\n")
@@ -59,7 +61,7 @@ if RUN_EXAMPLES
5961
"tutorials/piecewise_linear_and_natural_neighbour_interpolation_for_an_advection_diffusion_equation.jl",
6062
"tutorials/helmholtz_equation_with_inhomogeneous_boundary_conditions.jl",
6163
"tutorials/laplaces_equation_with_internal_dirichlet_conditions.jl",
62-
"tutorials/diffusion_equation_on_an_annulus.jl",
64+
"tutorials/diffusion_equation_on_an_annulus.jl"
6365
]
6466
wyos_files = [
6567
"wyos/diffusion_equations.jl",
@@ -71,7 +73,6 @@ if RUN_EXAMPLES
7173
example_files = vcat(tutorial_files, wyos_files)
7274
session_tmp = mktempdir()
7375

74-
7576
map(1:length(example_files)) do n
7677
example = example_files[n]
7778
folder, file = splitpath(example)
@@ -80,7 +81,8 @@ if RUN_EXAMPLES
8081
file_path = joinpath(dir, file)
8182
# See also https://github.com/Ferrite-FEM/Ferrite.jl/blob/d474caf357c696cdb80d7c5e1edcbc7b4c91af6b/docs/generate.jl for some of this
8283
new_file_path = add_just_the_code_section(dir, file)
83-
script = Literate.script(file_path, session_tmp, name=splitext(file)[1] * "_just_the_code_cleaned")
84+
script = Literate.script(file_path, session_tmp, name = splitext(file)[1] *
85+
"_just_the_code_cleaned")
8486
code = strip(read(script, String))
8587
@info "[$(ct())] Processing $file: Converting markdown script"
8688
line_ending_symbol = occursin(code, "\r\n") ? "\r\n" : "\n"
@@ -93,12 +95,12 @@ if RUN_EXAMPLES
9395
Literate.markdown(
9496
new_file_path,
9597
outputdir;
96-
documenter=true,
97-
postprocess=editurl_update post_strip,
98-
credit=true,
99-
execute=!IS_LIVESERVER,
100-
flavor=Literate.DocumenterFlavor(),
101-
name=splitext(file)[1]
98+
documenter = true,
99+
postprocess = editurl_update post_strip,
100+
credit = true,
101+
execute = !IS_LIVESERVER,
102+
flavor = Literate.DocumenterFlavor(),
103+
name = splitext(file)[1]
102104
)
103105
end
104106
end
@@ -128,15 +130,15 @@ _PAGES = [
128130
"Diffusion Equation on an Annulus" => "tutorials/diffusion_equation_on_an_annulus.md",
129131
"Mean Exit Time" => "tutorials/mean_exit_time.md",
130132
"Solving Mazes with Laplace's Equation" => "tutorials/solving_mazes_with_laplaces_equation.md",
131-
"Keller-Segel Model of Chemotaxis" => "tutorials/keller_segel_chemotaxis.md",
133+
"Keller-Segel Model of Chemotaxis" => "tutorials/keller_segel_chemotaxis.md"
132134
],
133135
"Solvers for Specific Problems, and Writing Your Own" => [
134136
"Section Overview" => "wyos/overview.md",
135137
"Diffusion Equations" => "wyos/diffusion_equations.md",
136138
"Mean Exit Time Problems" => "wyos/mean_exit_time.md",
137139
"Linear Reaction-Diffusion Equations" => "wyos/linear_reaction_diffusion_equations.md",
138140
"Poisson's Equation" => "wyos/poissons_equation.md",
139-
"Laplace's Equation" => "wyos/laplaces_equation.md",
141+
"Laplace's Equation" => "wyos/laplaces_equation.md"
140142
],
141143
"Mathematical and Implementation Details" => "math.md"
142144
]
@@ -172,32 +174,32 @@ end
172174

173175
# Make and deploy
174176
DocMeta.setdocmeta!(FiniteVolumeMethod, :DocTestSetup, :(using FiniteVolumeMethod, Test);
175-
recursive=true)
177+
recursive = true)
176178
IS_LIVESERVER = get(ENV, "LIVESERVER_ACTIVE", "false") == "true"
177179
IS_CI = get(ENV, "CI", "false") == "true"
178180
makedocs(;
179-
modules=[FiniteVolumeMethod],
180-
authors="Daniel VandenHeuvel <danj.vandenheuvel@gmail.com>",
181-
sitename="FiniteVolumeMethod.jl",
182-
format=Documenter.HTML(;
183-
canonical="https://SciML.github.io/FiniteVolumeMethod.jl",
184-
edit_link="main",
185-
collapselevel=1,
186-
assets=String[],
187-
mathengine=MathJax3(Dict(
181+
modules = [FiniteVolumeMethod],
182+
authors = "Daniel VandenHeuvel <danj.vandenheuvel@gmail.com>",
183+
sitename = "FiniteVolumeMethod.jl",
184+
format = Documenter.HTML(;
185+
canonical = "https://SciML.github.io/FiniteVolumeMethod.jl",
186+
edit_link = "main",
187+
collapselevel = 1,
188+
assets = String[],
189+
mathengine = MathJax3(Dict(
188190
:loader => Dict("load" => ["[tex]/physics"]),
189191
:tex => Dict(
190192
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
191193
"tags" => "ams",
192-
"packages" => ["base", "ams", "autoload", "physics"],
193-
),
194+
"packages" => ["base", "ams", "autoload", "physics"]
195+
)
194196
))),
195-
draft=IS_LIVESERVER,
196-
pages=_PAGES,
197-
warnonly=true
197+
draft = IS_LIVESERVER,
198+
pages = _PAGES,
199+
warnonly = true
198200
)
199201

200202
deploydocs(;
201-
repo="github.com/SciML/FiniteVolumeMethod.jl",
202-
devbranch="main",
203-
push_preview=true)
203+
repo = "github.com/SciML/FiniteVolumeMethod.jl",
204+
devbranch = "main",
205+
push_preview = true)

docs/src/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CurrentModule = FiniteVolumeMethod
33
```
44

5-
# Introduction
5+
# Introduction
66

77
This is the documentation for FiniteVolumeMethod.jl. [Click here to go back to the GitHub repository](https://github.com/SciML/FiniteVolumeMethod.jl).
88

@@ -20,10 +20,10 @@ using the finite volume method, with additional support for steady-state problem
2020

2121
The [tutorials](tutorials/overview.md) in the sidebar demonstrate the many possibilities of this package. In addition to these two generic forms, we also provide support for specific problems that can be solved in a more efficient manner, namely:
2222

23-
1. `DiffusionEquation`s: $\partial_tu = \div[D(\vb x)\grad u]$.
24-
2. `MeanExitTimeProblem`s: $\div[D(\vb x)\grad T(\vb x)] = -1$.
25-
3. `LinearReactionDiffusionEquation`s: $\partial_tu = \div[D(\vb x)\grad u] + f(\vb x)u$.
26-
4. `PoissonsEquation`: $\div[D(\vb x)\grad u] = f(\vb x)$.
27-
5. `LaplacesEquation`: $\div[D(\vb x)\grad u] = 0$.
23+
1. `DiffusionEquation`s: $\partial_tu = \div[D(\vb x)\grad u]$.
24+
2. `MeanExitTimeProblem`s: $\div[D(\vb x)\grad T(\vb x)] = -1$.
25+
3. `LinearReactionDiffusionEquation`s: $\partial_tu = \div[D(\vb x)\grad u] + f(\vb x)u$.
26+
4. `PoissonsEquation`: $\div[D(\vb x)\grad u] = f(\vb x)$.
27+
5. `LaplacesEquation`: $\div[D(\vb x)\grad u] = 0$.
2828

29-
See the [Solvers for Specific Problems, and Writing Your Own](wyos/overview.md) section for more information on these templates.
29+
See the [Solvers for Specific Problems, and Writing Your Own](wyos/overview.md) section for more information on these templates.

docs/src/interface.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
CurrentModule = FiniteVolumeMethod
33
```
44

5-
# Interface
5+
# Interface
66

7-
```@contents
7+
```@contents
88
Pages = ["interface.md"]
99
```
1010

1111
In this section, we describe the basic interface for defining and solving PDEs using this package. This interface will also be made clearer in the tutorials. The basic summary of the discussion below is as follows:
1212

13-
1. Use `FVMGeometry` to define the problem's mesh.
14-
2. Provide boundary conditions using `BoundaryConditions`.
15-
3. (Optional) Provide internal conditions using `InternalConditions`.
16-
4. Convert the problem into an `FVMProblem`.
17-
5. If you want to make the problem steady, use `SteadyFVMProblem` on the `FVMProblem`.
18-
6. If you want a system of equations, construct an `FVMSystem` from multiple `FVMProblem`s; if you want this problem to be steady, skip step 5 and only now apply `SteadyFVMProblem`.
19-
7. Solve the problem using `solve`.
20-
8. For a discussion of custom constraints, see the tutorials.
21-
9. For interpolation, we provide `pl_interpolate` (but you might prefer [NaturalNeighbours.jl](https://github.com/DanielVandH/NaturalNeighbours.jl) - see [this tutorial for an example](tutorials/piecewise_linear_and_natural_neighbour_interpolation_for_an_advection_diffusion_equation.md)).
13+
1. Use `FVMGeometry` to define the problem's mesh.
14+
2. Provide boundary conditions using `BoundaryConditions`.
15+
3. (Optional) Provide internal conditions using `InternalConditions`.
16+
4. Convert the problem into an `FVMProblem`.
17+
5. If you want to make the problem steady, use `SteadyFVMProblem` on the `FVMProblem`.
18+
6. If you want a system of equations, construct an `FVMSystem` from multiple `FVMProblem`s; if you want this problem to be steady, skip step 5 and only now apply `SteadyFVMProblem`.
19+
7. Solve the problem using `solve`.
20+
8. For a discussion of custom constraints, see the tutorials.
21+
9. For interpolation, we provide `pl_interpolate` (but you might prefer [NaturalNeighbours.jl](https://github.com/DanielVandH/NaturalNeighbours.jl) - see [this tutorial for an example](tutorials/piecewise_linear_and_natural_neighbour_interpolation_for_an_advection_diffusion_equation.md)).
2222

23-
# `FVMGeometry`: Defining the mesh
23+
# `FVMGeometry`: Defining the mesh
2424

25-
The finite volume method (FVM) requires an underlying triangular mesh, as outlined in the [mathematical details section](math.md). This triangular mesh is to be defined from [DelaunayTriangulation.jl](https://github.com/JuliaGeometry/DelaunayTriangulation.jl). The `FVMGeometry` type wraps the resulting `Triangulation` and computes information about the geometry required for solving the PDEs. The docstring for `FVMGeometry` is below; the fields of `FVMGeometry` are public API.
25+
The finite volume method (FVM) requires an underlying triangular mesh, as outlined in the [mathematical details section](math.md). This triangular mesh is to be defined from [DelaunayTriangulation.jl](https://github.com/JuliaGeometry/DelaunayTriangulation.jl). The `FVMGeometry` type wraps the resulting `Triangulation` and computes information about the geometry required for solving the PDEs. The docstring for `FVMGeometry` is below; the fields of `FVMGeometry` are public API.
2626

2727
```@docs
2828
FVMGeometry
2929
```
3030

31-
The `FVMGeometry` struct uses `TriangleProperties` for storing properties of a control volume that intersects a given triangle, defined below. This struct is
32-
public API, although it is unlikely you would ever need it.
31+
The `FVMGeometry` struct uses `TriangleProperties` for storing properties of a control volume that intersects a given triangle, defined below. This struct is
32+
public API, although it is unlikely you would ever need it.
3333

3434
```@docs
3535
TriangleProperties
@@ -152,15 +152,14 @@ These `solve` functions rely on `fvm_eqs!` for evaluating the equations. You sho
152152
fvm_eqs!
153153
```
154154

155-
# Custom constraints
155+
# Custom constraints
156156

157157
You can also provide custom constraints. Rather than outlining this precisely here, it is best explained in the tutorials, namely [this tutorial](tutorials/solving_mazes_with_laplaces_equation.md). We note that one useful function for this is `compute_flux`, which allows you to compute the flux across a given edge. The docstring for `compute_flux` is below, and this function is public API.
158158

159159
```@docs
160160
compute_flux
161161
```
162162

163-
164163
# Piecewise linear interpolation
165164

166165
You can evaluate the piecewise linear interpolation corresponding to a solution using `pl_interpolate`, defined below; this function is public API.
@@ -169,4 +168,4 @@ You can evaluate the piecewise linear interpolation corresponding to a solution
169168
pl_interpolate
170169
```
171170

172-
Better interpolants are available from [NaturalNeighbours.jl](https://github.com/DanielVandH/NaturalNeighbours.jl) - see the [this tutorial](tutorials/piecewise_linear_and_natural_neighbour_interpolation_for_an_advection_diffusion_equation.md) for some examples.
171+
Better interpolants are available from [NaturalNeighbours.jl](https://github.com/DanielVandH/NaturalNeighbours.jl) - see the [this tutorial](tutorials/piecewise_linear_and_natural_neighbour_interpolation_for_an_advection_diffusion_equation.md) for some examples.

0 commit comments

Comments
 (0)