Skip to content

Commit 1358f40

Browse files
authored
Merge pull request #63 from maltezfaria/runic-format
Runic format
2 parents baef4ee + 8e91ef7 commit 1358f40

17 files changed

+100
-128
lines changed

.JuliaFormatter.toml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/Lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
version: "1"
2727
- name: Use Julia cache
2828
uses: julia-actions/cache@v2
29-
- name: Install JuliaFormatter.jl
30-
run: julia -e 'using Pkg; pkg"add JuliaFormatter"'
29+
- name: Install Runic.jl
30+
run: julia -e 'using Pkg; pkg"add Runic"'
3131
- name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807
3232
run: touch requirements.txt
3333
- name: Setup Python

.pre-commit-config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ repos:
1414
- id: check-toml
1515
- id: check-yaml
1616
- id: end-of-file-fixer
17-
- id: file-contents-sorter
18-
files: .JuliaFormatter.toml
19-
args: [--unique]
2017
- id: mixed-line-ending
2118
args: [--fix=lf]
2219
# - id: no-commit-to-branch
@@ -43,7 +40,7 @@ repos:
4340
rev: v1.37.1
4441
hooks:
4542
- id: yamllint
46-
- repo: https://github.com/domluna/JuliaFormatter.jl
47-
rev: v2.1.6
43+
- repo: https://github.com/fredrikekre/runic-pre-commit
44+
rev: v2.0.1
4845
hooks:
49-
- id: julia-formatter
46+
- id: runic

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Build Status](https://github.com/maltezfaria/LevelSetMethods.jl/workflows/Test/badge.svg)](https://github.com/maltezfaria/LevelSetMethods.jl/actions)
66
[![Test workflow status](https://github.com/maltezfaria/LevelSetMethods.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/maltezfaria/LevelSetMethods.jl/actions/workflows/Test.yml?query=branch%3Amain)
77
[![Lint workflow Status](https://github.com/maltezfaria/LevelSetMethods.jl/actions/workflows/Lint.yml/badge.svg?branch=main)](https://github.com/maltezfaria/LevelSetMethods.jl/actions/workflows/Lint.yml?query=branch%3Amain)
8+
[![Runic Badge](https://img.shields.io/badge/Runic-formatting-brightgreen.svg)](https://github.com/fredrikekre/Runic.jl)
89
[![Docs workflow Status](https://github.com/maltezfaria/LevelSetMethods.jl/actions/workflows/Docs.yml/badge.svg?branch=main)](https://github.com/maltezfaria/LevelSetMethods.jl/actions/workflows/Docs.yml?query=branch%3Amain)
910
[![Coverage](https://codecov.io/gh/maltezfaria/LevelSetMethods.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/maltezfaria/LevelSetMethods.jl)
1011
[![BestieTemplate](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/JuliaBesties/BestieTemplate.jl/main/docs/src/assets/badge.json)](https://github.com/JuliaBesties/BestieTemplate.jl)

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DocMeta.setdocmeta!(
1919
const page_rename = Dict("developer.md" => "Developer docs") # Without the numbers
2020
const numbered_pages = [
2121
file for file in readdir(joinpath(@__DIR__, "src")) if
22-
file != "index.md" && splitext(file)[2] == ".md" && occursin(r"^\d", file)
22+
file != "index.md" && splitext(file)[2] == ".md" && occursin(r"^\d", file)
2323
]
2424

2525
modules = [LevelSetMethods]

ext/InterpolationsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Interpolations as Itp
44
import LevelSetMethods as LSM
55

66
function __init__()
7-
@info "Loading Interpolations extension for LevelSetMethods.jl"
7+
return @info "Loading Interpolations extension for LevelSetMethods.jl"
88
end
99

1010
Itp.interpolate::LSM.LevelSet) = Itp.interpolate(ϕ, Itp.BSpline(Itp.Cubic()))

ext/MMGSurfaceExt.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MarchingCubes
55
import LevelSetMethods as LSM
66

77
function __init__()
8-
@info "Loading MMGSurface extension for LevelSetMethods.jl"
8+
return @info "Loading MMGSurface extension for LevelSetMethods.jl"
99
end
1010

1111
"""
@@ -37,13 +37,13 @@ boundary and the reconstructed ideal boundary
3737
Only works for 3 dimensional level-set.
3838
"""
3939
function LSM.export_surface_mesh(
40-
ϕ::LSM.LevelSet,
41-
output::String;
42-
hgrad = nothing,
43-
hmin = nothing,
44-
hmax = nothing,
45-
hausd = nothing,
46-
)
40+
ϕ::LSM.LevelSet,
41+
output::String;
42+
hgrad = nothing,
43+
hmin = nothing,
44+
hmax = nothing,
45+
hausd = nothing,
46+
)
4747
N = LSM.dimension(ϕ)
4848
if N != 3
4949
throw(ArgumentError("export_mesh of $N dimensional level-set not supported."))
@@ -85,7 +85,7 @@ function LSM.export_surface_mesh(
8585
end
8686

8787
function _write_3D_triangular_mesh(path, vertices, triangles)
88-
open(path, "w") do file
88+
return open(path, "w") do file
8989
write(file, "MeshVersionFormatted 1\n")
9090
write(file, "Dimension 3\n")
9191

ext/MMGVolumeExt.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import LevelSetMethods as LSM
55
# using DelimitedFiles # using or import ? # faster with writedlm ?
66

77
function __init__()
8-
@info "Loading MMGVolume extension for LevelSetMethods.jl"
8+
return @info "Loading MMGVolume extension for LevelSetMethods.jl"
99
end
1010

1111
"""
@@ -39,13 +39,13 @@ For more information, see the official [MMG documentation](http://www.mmgtools.o
3939
Only works for 2 and 3 dimensional level-set.
4040
"""
4141
function LSM.export_volume_mesh(
42-
ϕ::LSM.LevelSet,
43-
output::String;
44-
hgrad = nothing,
45-
hmin = nothing,
46-
hmax = nothing,
47-
hausd = nothing,
48-
)
42+
ϕ::LSM.LevelSet,
43+
output::String;
44+
hgrad = nothing,
45+
hmin = nothing,
46+
hmax = nothing,
47+
hausd = nothing,
48+
)
4949
N = LSM.dimension(ϕ)
5050
if N != 2 && N != 3
5151
throw(ArgumentError("export_mesh of $N dimensional level-set not supported."))
@@ -78,7 +78,7 @@ function LSM.export_volume_mesh(
7878
num_triangles = 2(nx - 1) * (ny - 1)
7979
write(file, "\nTriangles\n")
8080
write(file, "$num_triangles\n")
81-
for x_id in 1:(nx-1), y_id in 1:(ny-1)
81+
for x_id in 1:(nx - 1), y_id in 1:(ny - 1)
8282
c00 = (y_id - 1) * nx + x_id
8383
c10 = c00 + 1
8484
c01 = c00 + nx
@@ -96,7 +96,7 @@ function LSM.export_volume_mesh(
9696
num_tetrahedrons = 6(nx - 1) * (ny - 1) * (nz - 1)
9797
write(file, "\nTetrahedra\n")
9898
write(file, "$num_tetrahedrons\n")
99-
for x_id in 1:(nx-1), y_id in 1:(ny-1), z_id in 1:(nz-1)
99+
for x_id in 1:(nx - 1), y_id in 1:(ny - 1), z_id in 1:(nz - 1)
100100
c000 = (z_id - 1) * nx * ny + (y_id - 1) * nx + x_id
101101
c100 = c000 + 1
102102
c010 = c000 + nx

ext/MakieExt.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Makie
44
import LevelSetMethods as LSM
55

66
function __init__()
7-
@info "Loading Makie extension for LevelSetMethods.jl"
7+
return @info "Loading Makie extension for LevelSetMethods.jl"
88
end
99

1010
# NOTE: Makie recipes currently can't modify the Axis (https://discourse.julialang.org/t/makie-plot-recipe-collections/86434)
@@ -37,7 +37,10 @@ end
3737
# end
3838
# end
3939

40-
function Makie.convert_arguments(::Union{Type{<:Contour},Type{<:Contourf}}, ϕ::LSM.LevelSet)
40+
function Makie.convert_arguments(
41+
::Union{Type{<:Contour}, Type{<:Contourf}, Type{<:Heatmap}},
42+
ϕ::LSM.LevelSet,
43+
)
4144
LSM.dimension(ϕ) == 2 ||
4245
throw(ArgumentError("Contour plot only supported for 2D level-sets."))
4346
return _contour_plot(ϕ)

src/derivatives.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Centered finite difference scheme for first order derivative at grid point `I`
1111
along dimension `dim`.
1212
"""
1313
function D⁰::CartesianMeshField, I, dim)
14-
h = meshsize(ϕ, dim)
14+
h = meshsize(ϕ, dim)
1515
Im = _decrement_index(I, dim)
1616
Ip = _increment_index(I, dim)
1717
return (ϕ[Ip] - ϕ[Im]) / (2h)
@@ -24,14 +24,14 @@ Forward finite difference scheme for first order derivative at grid point `I`
2424
along dimension `dim`.
2525
"""
2626
@inline function D⁺::CartesianMeshField, I, dim)
27-
h = meshsize(ϕ, dim)
27+
h = meshsize(ϕ, dim)
2828
Ip = _increment_index(I, dim)
2929
return (ϕ[Ip] - ϕ[I]) / h
3030
end
3131

3232
function D⁺⁺::CartesianMeshField, I, dim)
33-
h = meshsize(ϕ, dim)
34-
Ip = _increment_index(I, dim)
33+
h = meshsize(ϕ, dim)
34+
Ip = _increment_index(I, dim)
3535
Ipp = _increment_index(I, dim, 2)
3636
return (-1.5 * ϕ[I] + 2 * ϕ[Ip] - 1 / 2 * ϕ[Ipp]) / h
3737
end
@@ -43,7 +43,7 @@ Backward finite difference scheme for first order derivative at grid point `I`
4343
along dimension `dim`.
4444
"""
4545
function D⁻::CartesianMeshField, I, dim)
46-
h = meshsize(ϕ, dim)
46+
h = meshsize(ϕ, dim)
4747
Im = _decrement_index(I, dim)
4848
return (ϕ[I] - ϕ[Im]) / h
4949
end
@@ -57,9 +57,9 @@ end
5757

5858
function weno5⁻::CartesianMeshField, I, dim)
5959
# see section 3.4 of Osher-Fedwik
60-
Im = _decrement_index(I, dim)
60+
Im = _decrement_index(I, dim)
6161
Imm = _decrement_index(Im, dim)
62-
Ip = _increment_index(I, dim)
62+
Ip = _increment_index(I, dim)
6363
Ipp = _increment_index(Ip, dim)
6464
# finite differences
6565
v1 = D⁻(ϕ, Imm, dim)
@@ -76,7 +76,7 @@ function weno5⁻(ϕ::CartesianMeshField, I, dim)
7676
S2 = (13 / 12) * (v2 - 2 * v3 + v4)^2 + (1 / 4) * (v2 - v4)^2
7777
S3 = (13 / 12) * (v3 - 2 * v4 + v5)^2 + (1 / 4) * (3 * v3 - 4 * v4 + v5)^2
7878
# fudge factor
79-
ϵ = 1e-6 * max(v1^2, v2^2, v3^2, v4^2, v5^2) + 1e-99
79+
ϵ = 1.0e-6 * max(v1^2, v2^2, v3^2, v4^2, v5^2) + 1.0e-99
8080
# weights
8181
α1 = 0.1 / (S1 + ϵ)^2
8282
α2 = 0.6 / (S2 + ϵ)^2
@@ -90,9 +90,9 @@ end
9090

9191
function weno5⁺::CartesianMeshField, I, dim)
9292
# see section 3.4 of Osher-Fedwik
93-
Im = _decrement_index(I, dim)
93+
Im = _decrement_index(I, dim)
9494
Imm = _decrement_index(Im, dim)
95-
Ip = _increment_index(I, dim)
95+
Ip = _increment_index(I, dim)
9696
Ipp = _increment_index(Ip, dim)
9797
# finite differences
9898
v1 = D⁺(ϕ, Ipp, dim)
@@ -109,7 +109,7 @@ function weno5⁺(ϕ::CartesianMeshField, I, dim)
109109
S2 = (13 / 12) * (v2 - 2 * v3 + v4)^2 + (1 / 4) * (v2 - v4)^2
110110
S3 = (13 / 12) * (v3 - 2 * v4 + v5)^2 + (1 / 4) * (3 * v3 - 4 * v4 + v5)^2
111111
# fudge factor
112-
ϵ = 1e-6 * max(v1^2, v2^2, v3^2, v4^2, v5^2) + 1e-99
112+
ϵ = 1.0e-6 * max(v1^2, v2^2, v3^2, v4^2, v5^2) + 1.0e-99
113113
# weights
114114
α1 = 0.1 / (S1 + ϵ)^2
115115
α2 = 0.6 / (S2 + ϵ)^2
@@ -128,7 +128,7 @@ Centered finite difference scheme for second order derivative at grid point `I`
128128
along dimension `dim`. E.g. if `dim=1`, this approximates `∂ₓₓ`.
129129
"""
130130
function D2⁰::CartesianMeshField, I, dim)
131-
h = meshsize(ϕ, dim)
131+
h = meshsize(ϕ, dim)
132132
Im = _decrement_index(I, dim)
133133
Ip = _increment_index(I, dim)
134134
return (ϕ[Ip] - 2ϕ[I] + ϕ[Im]) / h^2
@@ -143,7 +143,7 @@ along the dimensions `dims`.
143143
If `dims[1] == dims[2]`, it is more efficient to call `D2⁰(ϕ,I,dims[1])`.
144144
"""
145145
function D2(ϕ, I, dims)
146-
h = meshsize(ϕ)
146+
h = meshsize(ϕ)
147147
Ip = _increment_index(I, dims[1])
148148
Im = _decrement_index(I, dims[1])
149149
return (D⁰(ϕ, Ip, dims[2]) - D⁰(ϕ, Im, dims[2])) / (2 * h[dims[1]])
@@ -156,8 +156,8 @@ Upward finite difference scheme for second order derivative at grid point `I`
156156
along dimension `dim`. E.g. if `dim=1`, this approximates `∂ₓₓ`.
157157
"""
158158
function D2⁺⁺::CartesianMeshField, I, dim)
159-
h = meshsize(ϕ, dim)
160-
Ip = _increment_index(I, dim, 1)
159+
h = meshsize(ϕ, dim)
160+
Ip = _increment_index(I, dim, 1)
161161
Ipp = _increment_index(I, dim, 2)
162162
return (ϕ[I] - 2ϕ[Ip] + ϕ[Ipp]) / h^2
163163
end
@@ -169,8 +169,8 @@ Backward finite difference scheme for second order derivative at grid point `I`
169169
along dimension `dim`. E.g. if `dim=1`, this approximates `∂ₓₓ`.
170170
"""
171171
function D2⁻⁻::CartesianMeshField, I, dim)
172-
h = meshsize(ϕ, dim)
173-
Im = _decrement_index(I, dim, 1)
172+
h = meshsize(ϕ, dim)
173+
Im = _decrement_index(I, dim, 1)
174174
Imm = _decrement_index(I, dim, 2)
175175
return (ϕ[Imm] - 2ϕ[Im] + ϕ[I]) / h^2
176176
end

0 commit comments

Comments
 (0)