Skip to content

Commit

Permalink
runic format everything
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Dec 6, 2024
1 parent 6062449 commit 463af70
Show file tree
Hide file tree
Showing 55 changed files with 4,224 additions and 4,078 deletions.
96 changes: 51 additions & 45 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,63 @@ import Gmsh
import CairoMakie, Pluto, PlutoStaticHTML
CairoMakie.activate!(; type = "png", visible = false)
ExampleJuggler.verbose!(true)
ExtendableGridsGmshExt=Base.get_extension(ExtendableGrids, :ExtendableGridsGmshExt)
ExtendableGridsGmshExt = Base.get_extension(ExtendableGrids, :ExtendableGridsGmshExt)
function mkdocs()
cleanexamples()
exampledir=joinpath(@__DIR__, "..", "examples")
exampledir = joinpath(@__DIR__, "..", "examples")

generated_examples = @docscripts(exampledir,
["examples1d.jl", "examples2d.jl", "examples3d.jl", "gmsh.jl"],
Plotter=CairoMakie)
generated_examples = @docscripts(
exampledir,
["examples1d.jl", "examples2d.jl", "examples3d.jl", "gmsh.jl"],
Plotter = CairoMakie
)

notebooks = ["Partitioning" => "pluto-partitioning.jl"]
notebook_examples = @docplutonotebooks(exampledir, notebooks, iframe=false)
notebooks = ["Partitioning" => "pluto-partitioning.jl"]
notebook_examples = @docplutonotebooks(exampledir, notebooks, iframe = false)
size_threshold_ignore = last.(notebook_examples)

generated_examples=vcat(generated_examples, notebook_examples)

makedocs(; sitename = "ExtendableGrids.jl",
modules = [ExtendableGrids,ExtendableGridsGmshExt],
clean = false,
doctest = true,
authors = "J. Fuhrmann, Ch. Merdon, J. Taraz",
repo = "https://github.com/WIAS-PDELib/ExtendableGrids.jl",
format = Documenter.HTML(; size_threshold_ignore,
assets=String["assets/citations.css"],
mathengine = MathJax3()),
pages = [
"Home" => "index.md",
"Changes" => "changes.md",
"adjacency.md",
"vectorofconstants.md",
"typehierarchy.md",
"elementgeometry.md",
"shape_specs.md",
"coordinatesystem.md",
"extendablegrid.md",
"subgrid.md",
"more.md",
"voronoi.md",
"assembly.md",
"cellfinder.md",
"arraytools.md",
"gridconstructors.md",
"output.md",
"refinement.md",
"partitioning.md",
"regionedit.md",
"tokenstream.md",
"binnedpointlist.md",
"gmsh.md",
"allindex.md",
"Examples" => generated_examples,
])
generated_examples = vcat(generated_examples, notebook_examples)

return makedocs(;
sitename = "ExtendableGrids.jl",
modules = [ExtendableGrids, ExtendableGridsGmshExt],
clean = false,
doctest = true,
authors = "J. Fuhrmann, Ch. Merdon, J. Taraz",
repo = "https://github.com/WIAS-PDELib/ExtendableGrids.jl",
format = Documenter.HTML(;
size_threshold_ignore,
assets = String["assets/citations.css"],
mathengine = MathJax3()
),
pages = [
"Home" => "index.md",
"Changes" => "changes.md",
"adjacency.md",
"vectorofconstants.md",
"typehierarchy.md",
"elementgeometry.md",
"shape_specs.md",
"coordinatesystem.md",
"extendablegrid.md",
"subgrid.md",
"more.md",
"voronoi.md",
"assembly.md",
"cellfinder.md",
"arraytools.md",
"gridconstructors.md",
"output.md",
"refinement.md",
"partitioning.md",
"regionedit.md",
"tokenstream.md",
"binnedpointlist.md",
"gmsh.md",
"allindex.md",
"Examples" => generated_examples,
]
)
end

mkdocs()
Expand Down
16 changes: 9 additions & 7 deletions examples/examples1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ using ExtendableGrids
#
function interval_from_vector()
X = collect(0:0.05:1)
grid = simplexgrid(X)
return simplexgrid(X)
end
# ![](interval_from_vector.png)

#
#
# ## Interval with local refinement
#
#
function interval_localref()
XLeft = geomspace(0.0, 0.5, 0.1, 0.01)
XRight = geomspace(0.5, 1.0, 0.01, 0.1)
X = glue(XLeft, XRight)
grid = simplexgrid(X)
return simplexgrid(X)
end
# ![](interval_localref.png)

Expand All @@ -29,7 +29,7 @@ function interval_multiregion()
grid = simplexgrid(X)
cellmask!(grid, [0.0], [0.5], 3)
bfacemask!(grid, [0.5], [0.5], 4)
grid
return grid
end
# ![](interval_multiregion.png)
#
Expand All @@ -40,8 +40,8 @@ function interval_subgrid()
grid = simplexgrid(X)
bfacemask!(grid, [0.5], [0.5], 3)
cellmask!(grid, [0.0], [0.25], 2)
cellmask!(grid, [0.20], [0.5], 3)
subgrid(grid, [2, 3])
cellmask!(grid, [0.2], [0.5], 3)
return subgrid(grid, [2, 3])
end
# ![](interval_subgrid.png)
# ## CI callbacks for [ExampleJuggler.jl](https://github.com/j-fu/ExampleJuggler.jl)
Expand All @@ -53,6 +53,7 @@ function runtests()
@test numbers_match(interval_localref(), 27, 26, 2)
@test numbers_match(interval_multiregion(), 21, 20, 3)
@test numbers_match(interval_subgrid(), 51, 50, 2)
nothing
end

# Plot generation
Expand All @@ -66,4 +67,5 @@ function generateplots(picdir; Plotter = nothing)
Plotter.save(joinpath(picdir, "interval_multiregion.png"), gridplot(interval_multiregion(); Plotter, size, legend))
Plotter.save(joinpath(picdir, "interval_subgrid.png"), gridplot(interval_subgrid(); Plotter, size, legend))
end
nothing
end
29 changes: 16 additions & 13 deletions examples/examples2d.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# 2D Grid examples
# ===============
#
#
using Triangulate, ExtendableGrids, SimplexGridFactory

# ## Rectangle
function rectangle()
X = collect(0:0.05:1)
Y = collect(0:0.05:1)
simplexgrid(X, X)
return simplexgrid(X, X)
end
# ![](rectangle.png)
#
#
# ## Rectangle with local refinement
#
#
function rectangle_localref()
hmin = 0.01
hmax = 0.1
XLeft = geomspace(0.0, 0.5, hmax, hmin)
XRight = geomspace(0.5, 1.0, hmin, hmax)
X = glue(XLeft, XRight)
simplexgrid(X, X)
return simplexgrid(X, X)
end
# ![](rectangle_localref.png)

#
#
# ## Rectangle with multiple regions
#
#
function rectangle_multiregion()
X = collect(0:0.05:1)
Y = collect(0:0.05:1)
Expand All @@ -34,22 +34,23 @@ function rectangle_multiregion()
bfacemask!(grid, [0.0, 0.0], [0.0, 0.5], 5)
bfacemask!(grid, [1.0, 0.0], [1.0, 0.5], 6)
bfacemask!(grid, [0.0, 0.5], [1.0, 0.5], 7)
grid
end
# ![](rectangle_multiregion.png)

#
#
# ## Subgrid from rectangle
#
#
function rectangle_subgrid()
X = collect(0:0.05:1)
Y = collect(0:0.05:1)
grid = simplexgrid(X, Y)
rect!(grid, [0.25, 0.25], [0.75, 0.75]; region = 2, bregion = 5)
subgrid(grid, [1])
return subgrid(grid, [1])
end
# ![](rectangle_subgrid.png)

#
#
# ## Rect2d with bregion function
#
# Here, we use function as bregion parameter - this allows to
Expand All @@ -62,7 +63,7 @@ function rect2d_bregion_function()

rect!(grid, [4, 2], [5, 8]; region = 2, bregion = cur -> cur == 5 ? 0 : 8)

subgrid(grid, [2])
return subgrid(grid, [2])
end
# ![](rect2d_bregion_function.png)

Expand Down Expand Up @@ -90,7 +91,7 @@ function sorted_subgrid(; maxvolume = 0.01)
sg = subgrid(g, [2]; boundary = true, transform = (a, b) -> a[1] = b[2])
f = map((x, y) -> sin(3x) * cos(3y), g)
sf = view(f, sg)
g, sg, sf
return g, sg, sf
end
# ![](sorted_subgrid.png)
# ## CI callbacks for [ExampleJuggler.jl](https://github.com/j-fu/ExampleJuggler.jl)
Expand All @@ -107,6 +108,7 @@ function runtests()
@test numbers_match(g, 187, 306, 66)
@test numbers_match(sg, 17, 16, 0)
@test issorted(view(sg[Coordinates], 1, :))
nothing
end

# Plot generation
Expand All @@ -128,4 +130,5 @@ function generateplots(picdir; Plotter = nothing)
fname = joinpath(picdir, "sorted_subgrid.png")
Plotter.save(fname, reveal(p))
end
nothing
end
12 changes: 7 additions & 5 deletions examples/examples3d.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# 3D Grid examples
# ===============
#
#
using ExtendableGrids

# ## Quadrilateral
function quadrilateral(; hx = 0.25, hy = 0.2, hz = 0.1)
X = collect(0:hx:1)
Y = collect(0:hy:1)
Z = collect(0:hz:1)
simplexgrid(X, Y, Z)
return simplexgrid(X, Y, Z)
end
# ![](quadrilateral.png)

Expand All @@ -23,7 +23,7 @@ function cross3d()

rect!(grid, (0.4, 0, 0.2), (0.6, 1, 0.4); region = 2, bregions = [4, 4, 4, 4, (cur) -> cur == 3 ? 0 : 5, 6])

subgrid(grid, [2])
return subgrid(grid, [2])
end
# ![](cross3d.png)
# ## CI callbacks for [ExampleJuggler.jl](https://github.com/j-fu/ExampleJuggler.jl)
Expand All @@ -38,7 +38,7 @@ function mask_bedges()
bedgemask!(grid, [0.0, 0.0, 1.0], [0.0, 1.0, 1.0], 4)
bedgemask!(grid, [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], 5)

true
return true
end

using Test
Expand All @@ -47,14 +47,16 @@ function runtests()
@test numbers_match(quadrilateral(), 330, 1200, 440)
@test mask_bedges()
@test numbers_match(cross3d(), 189, 480, 344)
nothing
end

# Plot generation
using GridVisualize
function generateplots(picdir; Plotter = nothing)
if isdefined(Plotter, :Makie)
if isdefined(Plotter, :Makie)
size = (400, 400)
Plotter.save(joinpath(picdir, "quadrilateral.png"), gridplot(quadrilateral(); Plotter, size))
Plotter.save(joinpath(picdir, "cross3d.png"), gridplot(cross3d(); Plotter, size))
end
nothing
end
Loading

0 comments on commit 463af70

Please sign in to comment.